Index.h revision 226633
1198092Srdivacky/*===-- clang-c/Index.h - Indexing Public C Interface -------------*- C -*-===*\
2198092Srdivacky|*                                                                            *|
3198092Srdivacky|*                     The LLVM Compiler Infrastructure                       *|
4198092Srdivacky|*                                                                            *|
5198092Srdivacky|* This file is distributed under the University of Illinois Open Source      *|
6198092Srdivacky|* License. See LICENSE.TXT for details.                                      *|
7198092Srdivacky|*                                                                            *|
8198092Srdivacky|*===----------------------------------------------------------------------===*|
9198092Srdivacky|*                                                                            *|
10198092Srdivacky|* This header provides a public inferface to a Clang library for extracting  *|
11198092Srdivacky|* high-level symbol information from source files without exposing the full  *|
12198092Srdivacky|* Clang C++ API.                                                             *|
13198092Srdivacky|*                                                                            *|
14198092Srdivacky\*===----------------------------------------------------------------------===*/
15198092Srdivacky
16198092Srdivacky#ifndef CLANG_C_INDEX_H
17198092Srdivacky#define CLANG_C_INDEX_H
18198092Srdivacky
19198893Srdivacky#include <sys/stat.h>
20201361Srdivacky#include <time.h>
21204643Srdivacky#include <stdio.h>
22198893Srdivacky
23198092Srdivacky#ifdef __cplusplus
24198092Srdivackyextern "C" {
25198092Srdivacky#endif
26198092Srdivacky
27198893Srdivacky/* MSVC DLL import/export. */
28198893Srdivacky#ifdef _MSC_VER
29198893Srdivacky  #ifdef _CINDEX_LIB_
30198893Srdivacky    #define CINDEX_LINKAGE __declspec(dllexport)
31198893Srdivacky  #else
32198893Srdivacky    #define CINDEX_LINKAGE __declspec(dllimport)
33198893Srdivacky  #endif
34198893Srdivacky#else
35198893Srdivacky  #define CINDEX_LINKAGE
36198893Srdivacky#endif
37198893Srdivacky
38219077Sdim/** \defgroup CINDEX libclang: C Interface to Clang
39202879Srdivacky *
40203955Srdivacky * The C Interface to Clang provides a relatively small API that exposes
41202879Srdivacky * facilities for parsing source code into an abstract syntax tree (AST),
42202879Srdivacky * loading already-parsed ASTs, traversing the AST, associating
43202879Srdivacky * physical source locations with elements within the AST, and other
44202879Srdivacky * facilities that support Clang-based development tools.
45202879Srdivacky *
46203955Srdivacky * This C interface to Clang will never provide all of the information
47202879Srdivacky * representation stored in Clang's C++ AST, nor should it: the intent is to
48202879Srdivacky * maintain an API that is relatively stable from one release to the next,
49202879Srdivacky * providing only the basic functionality needed to support development tools.
50203955Srdivacky *
51203955Srdivacky * To avoid namespace pollution, data types are prefixed with "CX" and
52202879Srdivacky * functions are prefixed with "clang_".
53202879Srdivacky *
54202879Srdivacky * @{
55202879Srdivacky */
56203955Srdivacky
57202879Srdivacky/**
58202879Srdivacky * \brief An "index" that consists of a set of translation units that would
59202879Srdivacky * typically be linked together into an executable or library.
60202879Srdivacky */
61202879Srdivackytypedef void *CXIndex;
62198092Srdivacky
63202879Srdivacky/**
64202879Srdivacky * \brief A single translation unit, which resides in an index.
65202879Srdivacky */
66218893Sdimtypedef struct CXTranslationUnitImpl *CXTranslationUnit;
67198092Srdivacky
68200583Srdivacky/**
69202879Srdivacky * \brief Opaque pointer representing client data that will be passed through
70202879Srdivacky * to various callbacks and visitors.
71202879Srdivacky */
72202879Srdivackytypedef void *CXClientData;
73203955Srdivacky
74202879Srdivacky/**
75200583Srdivacky * \brief Provides the contents of a file that has not yet been saved to disk.
76200583Srdivacky *
77200583Srdivacky * Each CXUnsavedFile instance provides the name of a file on the
78200583Srdivacky * system along with the current contents of that file that have not
79200583Srdivacky * yet been saved to disk.
80200583Srdivacky */
81200583Srdivackystruct CXUnsavedFile {
82203955Srdivacky  /**
83203955Srdivacky   * \brief The file whose contents have not yet been saved.
84200583Srdivacky   *
85200583Srdivacky   * This file must already exist in the file system.
86200583Srdivacky   */
87200583Srdivacky  const char *Filename;
88200583Srdivacky
89203955Srdivacky  /**
90204643Srdivacky   * \brief A buffer containing the unsaved contents of this file.
91200583Srdivacky   */
92200583Srdivacky  const char *Contents;
93200583Srdivacky
94200583Srdivacky  /**
95204643Srdivacky   * \brief The length of the unsaved contents of this buffer.
96200583Srdivacky   */
97200583Srdivacky  unsigned long Length;
98200583Srdivacky};
99200583Srdivacky
100199482Srdivacky/**
101212904Sdim * \brief Describes the availability of a particular entity, which indicates
102212904Sdim * whether the use of this entity will result in a warning or error due to
103212904Sdim * it being deprecated or unavailable.
104212904Sdim */
105212904Sdimenum CXAvailabilityKind {
106212904Sdim  /**
107212904Sdim   * \brief The entity is available.
108212904Sdim   */
109212904Sdim  CXAvailability_Available,
110212904Sdim  /**
111212904Sdim   * \brief The entity is available, but has been deprecated (and its use is
112212904Sdim   * not recommended).
113212904Sdim   */
114212904Sdim  CXAvailability_Deprecated,
115212904Sdim  /**
116212904Sdim   * \brief The entity is not available; any use of it will be an error.
117212904Sdim   */
118226633Sdim  CXAvailability_NotAvailable,
119226633Sdim  /**
120226633Sdim   * \brief The entity is available, but not accessible; any use of it will be
121226633Sdim   * an error.
122226633Sdim   */
123226633Sdim  CXAvailability_NotAccessible
124212904Sdim};
125212904Sdim
126212904Sdim/**
127202879Srdivacky * \defgroup CINDEX_STRING String manipulation routines
128202879Srdivacky *
129202879Srdivacky * @{
130199482Srdivacky */
131203955Srdivacky
132202879Srdivacky/**
133202879Srdivacky * \brief A character string.
134202879Srdivacky *
135202879Srdivacky * The \c CXString type is used to return strings from the interface when
136202879Srdivacky * the ownership of that string might different from one call to the next.
137202879Srdivacky * Use \c clang_getCString() to retrieve the string data and, once finished
138202879Srdivacky * with the string data, call \c clang_disposeString() to free the string.
139202879Srdivacky */
140199482Srdivackytypedef struct {
141218893Sdim  void *data;
142218893Sdim  unsigned private_flags;
143199482Srdivacky} CXString;
144199482Srdivacky
145202879Srdivacky/**
146202879Srdivacky * \brief Retrieve the character data associated with the given string.
147202879Srdivacky */
148199482SrdivackyCINDEX_LINKAGE const char *clang_getCString(CXString string);
149199482Srdivacky
150202879Srdivacky/**
151202879Srdivacky * \brief Free the given string,
152202879Srdivacky */
153199482SrdivackyCINDEX_LINKAGE void clang_disposeString(CXString string);
154199482Srdivacky
155202879Srdivacky/**
156202879Srdivacky * @}
157202879Srdivacky */
158203955Srdivacky
159203955Srdivacky/**
160198398Srdivacky * \brief clang_createIndex() provides a shared context for creating
161198398Srdivacky * translation units. It provides two options:
162198398Srdivacky *
163198398Srdivacky * - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local"
164198398Srdivacky * declarations (when loading any new translation units). A "local" declaration
165203955Srdivacky * is one that belongs in the translation unit itself and not in a precompiled
166198398Srdivacky * header that was used by the translation unit. If zero, all declarations
167198398Srdivacky * will be enumerated.
168198398Srdivacky *
169198398Srdivacky * Here is an example:
170198398Srdivacky *
171204643Srdivacky *   // excludeDeclsFromPCH = 1, displayDiagnostics=1
172204643Srdivacky *   Idx = clang_createIndex(1, 1);
173198398Srdivacky *
174198398Srdivacky *   // IndexTest.pch was produced with the following command:
175198398Srdivacky *   // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch"
176198398Srdivacky *   TU = clang_createTranslationUnit(Idx, "IndexTest.pch");
177198398Srdivacky *
178198398Srdivacky *   // This will load all the symbols from 'IndexTest.pch'
179203955Srdivacky *   clang_visitChildren(clang_getTranslationUnitCursor(TU),
180202879Srdivacky *                       TranslationUnitVisitor, 0);
181198398Srdivacky *   clang_disposeTranslationUnit(TU);
182198398Srdivacky *
183198398Srdivacky *   // This will load all the symbols from 'IndexTest.c', excluding symbols
184198398Srdivacky *   // from 'IndexTest.pch'.
185203955Srdivacky *   char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" };
186203955Srdivacky *   TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args,
187203955Srdivacky *                                                  0, 0);
188202879Srdivacky *   clang_visitChildren(clang_getTranslationUnitCursor(TU),
189202879Srdivacky *                       TranslationUnitVisitor, 0);
190198398Srdivacky *   clang_disposeTranslationUnit(TU);
191198398Srdivacky *
192198398Srdivacky * This process of creating the 'pch', loading it separately, and using it (via
193198398Srdivacky * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks
194198398Srdivacky * (which gives the indexer the same performance benefit as the compiler).
195198398Srdivacky */
196204643SrdivackyCINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH,
197204643Srdivacky                                         int displayDiagnostics);
198205219Srdivacky
199203955Srdivacky/**
200203955Srdivacky * \brief Destroy the given index.
201203955Srdivacky *
202203955Srdivacky * The index must not be destroyed until all of the translation units created
203203955Srdivacky * within that index have been destroyed.
204203955Srdivacky */
205200583SrdivackyCINDEX_LINKAGE void clang_disposeIndex(CXIndex index);
206198092Srdivacky
207202879Srdivacky/**
208202879Srdivacky * \defgroup CINDEX_FILES File manipulation routines
209202879Srdivacky *
210202879Srdivacky * @{
211202879Srdivacky */
212203955Srdivacky
213202879Srdivacky/**
214202879Srdivacky * \brief A particular source file that is part of a translation unit.
215202879Srdivacky */
216202879Srdivackytypedef void *CXFile;
217198092Srdivacky
218203955Srdivacky
219202879Srdivacky/**
220202879Srdivacky * \brief Retrieve the complete file and path name of the given file.
221202879Srdivacky */
222204643SrdivackyCINDEX_LINKAGE CXString clang_getFileName(CXFile SFile);
223203955Srdivacky
224202879Srdivacky/**
225202879Srdivacky * \brief Retrieve the last modification time of the given file.
226202879Srdivacky */
227202879SrdivackyCINDEX_LINKAGE time_t clang_getFileTime(CXFile SFile);
228198092Srdivacky
229202879Srdivacky/**
230223017Sdim * \brief Determine whether the given header is guarded against
231223017Sdim * multiple inclusions, either with the conventional
232223017Sdim * #ifndef/#define/#endif macro guards or with #pragma once.
233223017Sdim */
234223017SdimCINDEX_LINKAGE unsigned
235223017Sdimclang_isFileMultipleIncludeGuarded(CXTranslationUnit tu, CXFile file);
236223017Sdim
237223017Sdim/**
238202879Srdivacky * \brief Retrieve a file handle within the given translation unit.
239202879Srdivacky *
240202879Srdivacky * \param tu the translation unit
241203955Srdivacky *
242202879Srdivacky * \param file_name the name of the file.
243202879Srdivacky *
244202879Srdivacky * \returns the file handle for the named file in the translation unit \p tu,
245202879Srdivacky * or a NULL file handle if the file was not a part of this translation unit.
246202879Srdivacky */
247203955SrdivackyCINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu,
248202879Srdivacky                                    const char *file_name);
249203955Srdivacky
250202879Srdivacky/**
251202879Srdivacky * @}
252202879Srdivacky */
253198092Srdivacky
254202879Srdivacky/**
255202879Srdivacky * \defgroup CINDEX_LOCATIONS Physical source locations
256202879Srdivacky *
257202879Srdivacky * Clang represents physical source locations in its abstract syntax tree in
258202879Srdivacky * great detail, with file, line, and column information for the majority of
259202879Srdivacky * the tokens parsed in the source code. These data types and functions are
260202879Srdivacky * used to represent source location information, either for a particular
261202879Srdivacky * point in the program or for a range of points in the program, and extract
262202879Srdivacky * specific location information from those data types.
263202879Srdivacky *
264202879Srdivacky * @{
265202879Srdivacky */
266203955Srdivacky
267202879Srdivacky/**
268202879Srdivacky * \brief Identifies a specific source location within a translation
269202879Srdivacky * unit.
270202879Srdivacky *
271226633Sdim * Use clang_getExpansionLocation() or clang_getSpellingLocation()
272218893Sdim * to map a source location to a particular file, line, and column.
273202879Srdivacky */
274202879Srdivackytypedef struct {
275203955Srdivacky  void *ptr_data[2];
276202879Srdivacky  unsigned int_data;
277202879Srdivacky} CXSourceLocation;
278198092Srdivacky
279202879Srdivacky/**
280203955Srdivacky * \brief Identifies a half-open character range in the source code.
281202879Srdivacky *
282202879Srdivacky * Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the
283202879Srdivacky * starting and end locations from a source range, respectively.
284198893Srdivacky */
285202879Srdivackytypedef struct {
286203955Srdivacky  void *ptr_data[2];
287202879Srdivacky  unsigned begin_int_data;
288202879Srdivacky  unsigned end_int_data;
289202879Srdivacky} CXSourceRange;
290198893Srdivacky
291202879Srdivacky/**
292202879Srdivacky * \brief Retrieve a NULL (invalid) source location.
293198092Srdivacky */
294202879SrdivackyCINDEX_LINKAGE CXSourceLocation clang_getNullLocation();
295203955Srdivacky
296202879Srdivacky/**
297202879Srdivacky * \determine Determine whether two source locations, which must refer into
298203955Srdivacky * the same translation unit, refer to exactly the same point in the source
299202879Srdivacky * code.
300202879Srdivacky *
301202879Srdivacky * \returns non-zero if the source locations refer to the same location, zero
302202879Srdivacky * if they refer to different locations.
303202879Srdivacky */
304202879SrdivackyCINDEX_LINKAGE unsigned clang_equalLocations(CXSourceLocation loc1,
305202879Srdivacky                                             CXSourceLocation loc2);
306203955Srdivacky
307202879Srdivacky/**
308203955Srdivacky * \brief Retrieves the source location associated with a given file/line/column
309203955Srdivacky * in a particular translation unit.
310202879Srdivacky */
311202879SrdivackyCINDEX_LINKAGE CXSourceLocation clang_getLocation(CXTranslationUnit tu,
312202879Srdivacky                                                  CXFile file,
313202879Srdivacky                                                  unsigned line,
314202879Srdivacky                                                  unsigned column);
315218893Sdim/**
316218893Sdim * \brief Retrieves the source location associated with a given character offset
317218893Sdim * in a particular translation unit.
318218893Sdim */
319218893SdimCINDEX_LINKAGE CXSourceLocation clang_getLocationForOffset(CXTranslationUnit tu,
320218893Sdim                                                           CXFile file,
321218893Sdim                                                           unsigned offset);
322203955Srdivacky
323203955Srdivacky/**
324203955Srdivacky * \brief Retrieve a NULL (invalid) source range.
325203955Srdivacky */
326203955SrdivackyCINDEX_LINKAGE CXSourceRange clang_getNullRange();
327205219Srdivacky
328202879Srdivacky/**
329202879Srdivacky * \brief Retrieve a source range given the beginning and ending source
330202879Srdivacky * locations.
331202879Srdivacky */
332202879SrdivackyCINDEX_LINKAGE CXSourceRange clang_getRange(CXSourceLocation begin,
333202879Srdivacky                                            CXSourceLocation end);
334203955Srdivacky
335202879Srdivacky/**
336226633Sdim * \brief Determine whether two ranges are equivalent.
337226633Sdim *
338226633Sdim * \returns non-zero if the ranges are the same, zero if they differ.
339226633Sdim */
340226633SdimCINDEX_LINKAGE unsigned clang_equalRanges(CXSourceRange range1,
341226633Sdim                                          CXSourceRange range2);
342226633Sdim
343226633Sdim/**
344226633Sdim * \brief Returns non-zero if \arg range is null.
345226633Sdim */
346226633SdimCINDEX_LINKAGE int clang_Range_isNull(CXSourceRange range);
347226633Sdim
348226633Sdim/**
349203955Srdivacky * \brief Retrieve the file, line, column, and offset represented by
350203955Srdivacky * the given source location.
351202879Srdivacky *
352226633Sdim * If the location refers into a macro expansion, retrieves the
353226633Sdim * location of the macro expansion.
354218893Sdim *
355203955Srdivacky * \param location the location within a source file that will be decomposed
356203955Srdivacky * into its parts.
357202879Srdivacky *
358203955Srdivacky * \param file [out] if non-NULL, will be set to the file to which the given
359202879Srdivacky * source location points.
360202879Srdivacky *
361203955Srdivacky * \param line [out] if non-NULL, will be set to the line to which the given
362202879Srdivacky * source location points.
363202879Srdivacky *
364203955Srdivacky * \param column [out] if non-NULL, will be set to the column to which the given
365203955Srdivacky * source location points.
366203955Srdivacky *
367203955Srdivacky * \param offset [out] if non-NULL, will be set to the offset into the
368203955Srdivacky * buffer to which the given source location points.
369202879Srdivacky */
370226633SdimCINDEX_LINKAGE void clang_getExpansionLocation(CXSourceLocation location,
371226633Sdim                                               CXFile *file,
372226633Sdim                                               unsigned *line,
373226633Sdim                                               unsigned *column,
374226633Sdim                                               unsigned *offset);
375226633Sdim
376226633Sdim/**
377226633Sdim * \brief Retrieve the file, line, column, and offset represented by
378226633Sdim * the given source location, as specified in a # line directive.
379226633Sdim *
380226633Sdim * Example: given the following source code in a file somefile.c
381226633Sdim *
382226633Sdim * #123 "dummy.c" 1
383226633Sdim *
384226633Sdim * static int func(void)
385226633Sdim * {
386226633Sdim *     return 0;
387226633Sdim * }
388226633Sdim *
389226633Sdim * the location information returned by this function would be
390226633Sdim *
391226633Sdim * File: dummy.c Line: 124 Column: 12
392226633Sdim *
393226633Sdim * whereas clang_getExpansionLocation would have returned
394226633Sdim *
395226633Sdim * File: somefile.c Line: 3 Column: 12
396226633Sdim *
397226633Sdim * \param location the location within a source file that will be decomposed
398226633Sdim * into its parts.
399226633Sdim *
400226633Sdim * \param filename [out] if non-NULL, will be set to the filename of the
401226633Sdim * source location. Note that filenames returned will be for "virtual" files,
402226633Sdim * which don't necessarily exist on the machine running clang - e.g. when
403226633Sdim * parsing preprocessed output obtained from a different environment. If
404226633Sdim * a non-NULL value is passed in, remember to dispose of the returned value
405226633Sdim * using \c clang_disposeString() once you've finished with it. For an invalid
406226633Sdim * source location, an empty string is returned.
407226633Sdim *
408226633Sdim * \param line [out] if non-NULL, will be set to the line number of the
409226633Sdim * source location. For an invalid source location, zero is returned.
410226633Sdim *
411226633Sdim * \param column [out] if non-NULL, will be set to the column number of the
412226633Sdim * source location. For an invalid source location, zero is returned.
413226633Sdim */
414226633SdimCINDEX_LINKAGE void clang_getPresumedLocation(CXSourceLocation location,
415226633Sdim                                              CXString *filename,
416226633Sdim                                              unsigned *line,
417226633Sdim                                              unsigned *column);
418226633Sdim
419226633Sdim/**
420226633Sdim * \brief Legacy API to retrieve the file, line, column, and offset represented
421226633Sdim * by the given source location.
422226633Sdim *
423226633Sdim * This interface has been replaced by the newer interface
424226633Sdim * \see clang_getExpansionLocation(). See that interface's documentation for
425226633Sdim * details.
426226633Sdim */
427202879SrdivackyCINDEX_LINKAGE void clang_getInstantiationLocation(CXSourceLocation location,
428202879Srdivacky                                                   CXFile *file,
429202879Srdivacky                                                   unsigned *line,
430203955Srdivacky                                                   unsigned *column,
431203955Srdivacky                                                   unsigned *offset);
432202379Srdivacky
433202879Srdivacky/**
434218893Sdim * \brief Retrieve the file, line, column, and offset represented by
435218893Sdim * the given source location.
436218893Sdim *
437218893Sdim * If the location refers into a macro instantiation, return where the
438218893Sdim * location was originally spelled in the source file.
439218893Sdim *
440218893Sdim * \param location the location within a source file that will be decomposed
441218893Sdim * into its parts.
442218893Sdim *
443218893Sdim * \param file [out] if non-NULL, will be set to the file to which the given
444218893Sdim * source location points.
445218893Sdim *
446218893Sdim * \param line [out] if non-NULL, will be set to the line to which the given
447218893Sdim * source location points.
448218893Sdim *
449218893Sdim * \param column [out] if non-NULL, will be set to the column to which the given
450218893Sdim * source location points.
451218893Sdim *
452218893Sdim * \param offset [out] if non-NULL, will be set to the offset into the
453218893Sdim * buffer to which the given source location points.
454218893Sdim */
455218893SdimCINDEX_LINKAGE void clang_getSpellingLocation(CXSourceLocation location,
456218893Sdim                                              CXFile *file,
457218893Sdim                                              unsigned *line,
458218893Sdim                                              unsigned *column,
459218893Sdim                                              unsigned *offset);
460218893Sdim
461218893Sdim/**
462203955Srdivacky * \brief Retrieve a source location representing the first character within a
463203955Srdivacky * source range.
464198092Srdivacky */
465202879SrdivackyCINDEX_LINKAGE CXSourceLocation clang_getRangeStart(CXSourceRange range);
466198092Srdivacky
467202879Srdivacky/**
468203955Srdivacky * \brief Retrieve a source location representing the last character within a
469203955Srdivacky * source range.
470202879Srdivacky */
471202879SrdivackyCINDEX_LINKAGE CXSourceLocation clang_getRangeEnd(CXSourceRange range);
472202379Srdivacky
473202879Srdivacky/**
474202879Srdivacky * @}
475202879Srdivacky */
476202379Srdivacky
477202879Srdivacky/**
478203955Srdivacky * \defgroup CINDEX_DIAG Diagnostic reporting
479203955Srdivacky *
480203955Srdivacky * @{
481203955Srdivacky */
482203955Srdivacky
483203955Srdivacky/**
484203955Srdivacky * \brief Describes the severity of a particular diagnostic.
485203955Srdivacky */
486203955Srdivackyenum CXDiagnosticSeverity {
487203955Srdivacky  /**
488205219Srdivacky   * \brief A diagnostic that has been suppressed, e.g., by a command-line
489203955Srdivacky   * option.
490203955Srdivacky   */
491203955Srdivacky  CXDiagnostic_Ignored = 0,
492205219Srdivacky
493203955Srdivacky  /**
494203955Srdivacky   * \brief This diagnostic is a note that should be attached to the
495203955Srdivacky   * previous (non-note) diagnostic.
496203955Srdivacky   */
497203955Srdivacky  CXDiagnostic_Note    = 1,
498203955Srdivacky
499203955Srdivacky  /**
500203955Srdivacky   * \brief This diagnostic indicates suspicious code that may not be
501203955Srdivacky   * wrong.
502203955Srdivacky   */
503203955Srdivacky  CXDiagnostic_Warning = 2,
504203955Srdivacky
505203955Srdivacky  /**
506203955Srdivacky   * \brief This diagnostic indicates that the code is ill-formed.
507203955Srdivacky   */
508203955Srdivacky  CXDiagnostic_Error   = 3,
509203955Srdivacky
510203955Srdivacky  /**
511203955Srdivacky   * \brief This diagnostic indicates that the code is ill-formed such
512203955Srdivacky   * that future parser recovery is unlikely to produce useful
513203955Srdivacky   * results.
514203955Srdivacky   */
515203955Srdivacky  CXDiagnostic_Fatal   = 4
516203955Srdivacky};
517203955Srdivacky
518203955Srdivacky/**
519204643Srdivacky * \brief A single diagnostic, containing the diagnostic's severity,
520204643Srdivacky * location, text, source ranges, and fix-it hints.
521203955Srdivacky */
522204643Srdivackytypedef void *CXDiagnostic;
523204643Srdivacky
524204643Srdivacky/**
525204643Srdivacky * \brief Determine the number of diagnostics produced for the given
526204643Srdivacky * translation unit.
527204643Srdivacky */
528204643SrdivackyCINDEX_LINKAGE unsigned clang_getNumDiagnostics(CXTranslationUnit Unit);
529204643Srdivacky
530204643Srdivacky/**
531204643Srdivacky * \brief Retrieve a diagnostic associated with the given translation unit.
532204643Srdivacky *
533204643Srdivacky * \param Unit the translation unit to query.
534204643Srdivacky * \param Index the zero-based diagnostic number to retrieve.
535204643Srdivacky *
536204643Srdivacky * \returns the requested diagnostic. This diagnostic must be freed
537204643Srdivacky * via a call to \c clang_disposeDiagnostic().
538204643Srdivacky */
539204643SrdivackyCINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit,
540204643Srdivacky                                                unsigned Index);
541204643Srdivacky
542204643Srdivacky/**
543204643Srdivacky * \brief Destroy a diagnostic.
544204643Srdivacky */
545204643SrdivackyCINDEX_LINKAGE void clang_disposeDiagnostic(CXDiagnostic Diagnostic);
546204643Srdivacky
547204643Srdivacky/**
548204643Srdivacky * \brief Options to control the display of diagnostics.
549204643Srdivacky *
550204643Srdivacky * The values in this enum are meant to be combined to customize the
551204643Srdivacky * behavior of \c clang_displayDiagnostic().
552204643Srdivacky */
553204643Srdivackyenum CXDiagnosticDisplayOptions {
554203955Srdivacky  /**
555204643Srdivacky   * \brief Display the source-location information where the
556204643Srdivacky   * diagnostic was located.
557204643Srdivacky   *
558204643Srdivacky   * When set, diagnostics will be prefixed by the file, line, and
559204643Srdivacky   * (optionally) column to which the diagnostic refers. For example,
560204643Srdivacky   *
561204643Srdivacky   * \code
562204643Srdivacky   * test.c:28: warning: extra tokens at end of #endif directive
563204643Srdivacky   * \endcode
564204643Srdivacky   *
565204643Srdivacky   * This option corresponds to the clang flag \c -fshow-source-location.
566203955Srdivacky   */
567204643Srdivacky  CXDiagnostic_DisplaySourceLocation = 0x01,
568203955Srdivacky
569203955Srdivacky  /**
570204643Srdivacky   * \brief If displaying the source-location information of the
571204643Srdivacky   * diagnostic, also include the column number.
572204643Srdivacky   *
573204643Srdivacky   * This option corresponds to the clang flag \c -fshow-column.
574203955Srdivacky   */
575204643Srdivacky  CXDiagnostic_DisplayColumn = 0x02,
576203955Srdivacky
577203955Srdivacky  /**
578204643Srdivacky   * \brief If displaying the source-location information of the
579204643Srdivacky   * diagnostic, also include information about source ranges in a
580204643Srdivacky   * machine-parsable format.
581204643Srdivacky   *
582205219Srdivacky   * This option corresponds to the clang flag
583204643Srdivacky   * \c -fdiagnostics-print-source-range-info.
584203955Srdivacky   */
585218893Sdim  CXDiagnostic_DisplaySourceRanges = 0x04,
586218893Sdim
587218893Sdim  /**
588218893Sdim   * \brief Display the option name associated with this diagnostic, if any.
589218893Sdim   *
590218893Sdim   * The option name displayed (e.g., -Wconversion) will be placed in brackets
591218893Sdim   * after the diagnostic text. This option corresponds to the clang flag
592218893Sdim   * \c -fdiagnostics-show-option.
593218893Sdim   */
594218893Sdim  CXDiagnostic_DisplayOption = 0x08,
595218893Sdim
596218893Sdim  /**
597218893Sdim   * \brief Display the category number associated with this diagnostic, if any.
598218893Sdim   *
599218893Sdim   * The category number is displayed within brackets after the diagnostic text.
600218893Sdim   * This option corresponds to the clang flag
601218893Sdim   * \c -fdiagnostics-show-category=id.
602218893Sdim   */
603218893Sdim  CXDiagnostic_DisplayCategoryId = 0x10,
604218893Sdim
605218893Sdim  /**
606218893Sdim   * \brief Display the category name associated with this diagnostic, if any.
607218893Sdim   *
608218893Sdim   * The category name is displayed within brackets after the diagnostic text.
609218893Sdim   * This option corresponds to the clang flag
610218893Sdim   * \c -fdiagnostics-show-category=name.
611218893Sdim   */
612218893Sdim  CXDiagnostic_DisplayCategoryName = 0x20
613203955Srdivacky};
614203955Srdivacky
615203955Srdivacky/**
616204643Srdivacky * \brief Format the given diagnostic in a manner that is suitable for display.
617204643Srdivacky *
618204643Srdivacky * This routine will format the given diagnostic to a string, rendering
619205219Srdivacky * the diagnostic according to the various options given. The
620205219Srdivacky * \c clang_defaultDiagnosticDisplayOptions() function returns the set of
621204643Srdivacky * options that most closely mimics the behavior of the clang compiler.
622204643Srdivacky *
623204643Srdivacky * \param Diagnostic The diagnostic to print.
624204643Srdivacky *
625205219Srdivacky * \param Options A set of options that control the diagnostic display,
626204643Srdivacky * created by combining \c CXDiagnosticDisplayOptions values.
627204643Srdivacky *
628204643Srdivacky * \returns A new string containing for formatted diagnostic.
629203955Srdivacky */
630204643SrdivackyCINDEX_LINKAGE CXString clang_formatDiagnostic(CXDiagnostic Diagnostic,
631204643Srdivacky                                               unsigned Options);
632203955Srdivacky
633203955Srdivacky/**
634204643Srdivacky * \brief Retrieve the set of display options most similar to the
635204643Srdivacky * default behavior of the clang compiler.
636203955Srdivacky *
637204643Srdivacky * \returns A set of display options suitable for use with \c
638204643Srdivacky * clang_displayDiagnostic().
639203955Srdivacky */
640204643SrdivackyCINDEX_LINKAGE unsigned clang_defaultDiagnosticDisplayOptions(void);
641203955Srdivacky
642203955Srdivacky/**
643203955Srdivacky * \brief Determine the severity of the given diagnostic.
644203955Srdivacky */
645205219SrdivackyCINDEX_LINKAGE enum CXDiagnosticSeverity
646203955Srdivackyclang_getDiagnosticSeverity(CXDiagnostic);
647203955Srdivacky
648203955Srdivacky/**
649203955Srdivacky * \brief Retrieve the source location of the given diagnostic.
650203955Srdivacky *
651203955Srdivacky * This location is where Clang would print the caret ('^') when
652203955Srdivacky * displaying the diagnostic on the command line.
653203955Srdivacky */
654203955SrdivackyCINDEX_LINKAGE CXSourceLocation clang_getDiagnosticLocation(CXDiagnostic);
655203955Srdivacky
656203955Srdivacky/**
657203955Srdivacky * \brief Retrieve the text of the given diagnostic.
658203955Srdivacky */
659203955SrdivackyCINDEX_LINKAGE CXString clang_getDiagnosticSpelling(CXDiagnostic);
660203955Srdivacky
661203955Srdivacky/**
662218893Sdim * \brief Retrieve the name of the command-line option that enabled this
663218893Sdim * diagnostic.
664218893Sdim *
665218893Sdim * \param Diag The diagnostic to be queried.
666218893Sdim *
667218893Sdim * \param Disable If non-NULL, will be set to the option that disables this
668218893Sdim * diagnostic (if any).
669218893Sdim *
670218893Sdim * \returns A string that contains the command-line option used to enable this
671218893Sdim * warning, such as "-Wconversion" or "-pedantic".
672218893Sdim */
673218893SdimCINDEX_LINKAGE CXString clang_getDiagnosticOption(CXDiagnostic Diag,
674218893Sdim                                                  CXString *Disable);
675218893Sdim
676218893Sdim/**
677218893Sdim * \brief Retrieve the category number for this diagnostic.
678218893Sdim *
679218893Sdim * Diagnostics can be categorized into groups along with other, related
680218893Sdim * diagnostics (e.g., diagnostics under the same warning flag). This routine
681218893Sdim * retrieves the category number for the given diagnostic.
682218893Sdim *
683218893Sdim * \returns The number of the category that contains this diagnostic, or zero
684218893Sdim * if this diagnostic is uncategorized.
685218893Sdim */
686218893SdimCINDEX_LINKAGE unsigned clang_getDiagnosticCategory(CXDiagnostic);
687218893Sdim
688218893Sdim/**
689218893Sdim * \brief Retrieve the name of a particular diagnostic category.
690218893Sdim *
691218893Sdim * \param Category A diagnostic category number, as returned by
692218893Sdim * \c clang_getDiagnosticCategory().
693218893Sdim *
694218893Sdim * \returns The name of the given diagnostic category.
695218893Sdim */
696218893SdimCINDEX_LINKAGE CXString clang_getDiagnosticCategoryName(unsigned Category);
697218893Sdim
698218893Sdim/**
699203955Srdivacky * \brief Determine the number of source ranges associated with the given
700203955Srdivacky * diagnostic.
701203955Srdivacky */
702203955SrdivackyCINDEX_LINKAGE unsigned clang_getDiagnosticNumRanges(CXDiagnostic);
703205219Srdivacky
704203955Srdivacky/**
705203955Srdivacky * \brief Retrieve a source range associated with the diagnostic.
706203955Srdivacky *
707203955Srdivacky * A diagnostic's source ranges highlight important elements in the source
708203955Srdivacky * code. On the command line, Clang displays source ranges by
709205219Srdivacky * underlining them with '~' characters.
710203955Srdivacky *
711203955Srdivacky * \param Diagnostic the diagnostic whose range is being extracted.
712203955Srdivacky *
713205219Srdivacky * \param Range the zero-based index specifying which range to
714203955Srdivacky *
715203955Srdivacky * \returns the requested source range.
716203955Srdivacky */
717205219SrdivackyCINDEX_LINKAGE CXSourceRange clang_getDiagnosticRange(CXDiagnostic Diagnostic,
718203955Srdivacky                                                      unsigned Range);
719203955Srdivacky
720203955Srdivacky/**
721203955Srdivacky * \brief Determine the number of fix-it hints associated with the
722203955Srdivacky * given diagnostic.
723203955Srdivacky */
724203955SrdivackyCINDEX_LINKAGE unsigned clang_getDiagnosticNumFixIts(CXDiagnostic Diagnostic);
725203955Srdivacky
726203955Srdivacky/**
727204643Srdivacky * \brief Retrieve the replacement information for a given fix-it.
728203955Srdivacky *
729204643Srdivacky * Fix-its are described in terms of a source range whose contents
730204643Srdivacky * should be replaced by a string. This approach generalizes over
731204643Srdivacky * three kinds of operations: removal of source code (the range covers
732204643Srdivacky * the code to be removed and the replacement string is empty),
733204643Srdivacky * replacement of source code (the range covers the code to be
734204643Srdivacky * replaced and the replacement string provides the new code), and
735204643Srdivacky * insertion (both the start and end of the range point at the
736204643Srdivacky * insertion location, and the replacement string provides the text to
737204643Srdivacky * insert).
738203955Srdivacky *
739204643Srdivacky * \param Diagnostic The diagnostic whose fix-its are being queried.
740203955Srdivacky *
741204643Srdivacky * \param FixIt The zero-based index of the fix-it.
742203955Srdivacky *
743204643Srdivacky * \param ReplacementRange The source range whose contents will be
744204643Srdivacky * replaced with the returned replacement string. Note that source
745204643Srdivacky * ranges are half-open ranges [a, b), so the source code should be
746204643Srdivacky * replaced from a and up to (but not including) b.
747203955Srdivacky *
748204643Srdivacky * \returns A string containing text that should be replace the source
749204643Srdivacky * code indicated by the \c ReplacementRange.
750203955Srdivacky */
751205219SrdivackyCINDEX_LINKAGE CXString clang_getDiagnosticFixIt(CXDiagnostic Diagnostic,
752204643Srdivacky                                                 unsigned FixIt,
753204643Srdivacky                                               CXSourceRange *ReplacementRange);
754203955Srdivacky
755203955Srdivacky/**
756203955Srdivacky * @}
757203955Srdivacky */
758203955Srdivacky
759203955Srdivacky/**
760203955Srdivacky * \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation
761203955Srdivacky *
762203955Srdivacky * The routines in this group provide the ability to create and destroy
763203955Srdivacky * translation units from files, either by parsing the contents of the files or
764203955Srdivacky * by reading in a serialized representation of a translation unit.
765203955Srdivacky *
766203955Srdivacky * @{
767203955Srdivacky */
768205219Srdivacky
769203955Srdivacky/**
770203955Srdivacky * \brief Get the original translation unit source file name.
771203955Srdivacky */
772203955SrdivackyCINDEX_LINKAGE CXString
773203955Srdivackyclang_getTranslationUnitSpelling(CXTranslationUnit CTUnit);
774203955Srdivacky
775203955Srdivacky/**
776203955Srdivacky * \brief Return the CXTranslationUnit for a given source file and the provided
777203955Srdivacky * command line arguments one would pass to the compiler.
778203955Srdivacky *
779203955Srdivacky * Note: The 'source_filename' argument is optional.  If the caller provides a
780203955Srdivacky * NULL pointer, the name of the source file is expected to reside in the
781203955Srdivacky * specified command line arguments.
782203955Srdivacky *
783203955Srdivacky * Note: When encountered in 'clang_command_line_args', the following options
784203955Srdivacky * are ignored:
785203955Srdivacky *
786203955Srdivacky *   '-c'
787203955Srdivacky *   '-emit-ast'
788203955Srdivacky *   '-fsyntax-only'
789203955Srdivacky *   '-o <output file>'  (both '-o' and '<output file>' are ignored)
790203955Srdivacky *
791218893Sdim * \param CIdx The index object with which the translation unit will be
792218893Sdim * associated.
793203955Srdivacky *
794203955Srdivacky * \param source_filename - The name of the source file to load, or NULL if the
795218893Sdim * source file is included in \p clang_command_line_args.
796203955Srdivacky *
797218893Sdim * \param num_clang_command_line_args The number of command-line arguments in
798218893Sdim * \p clang_command_line_args.
799218893Sdim *
800218893Sdim * \param clang_command_line_args The command-line arguments that would be
801218893Sdim * passed to the \c clang executable if it were being invoked out-of-process.
802218893Sdim * These command-line options will be parsed and will affect how the translation
803218893Sdim * unit is parsed. Note that the following options are ignored: '-c',
804218893Sdim * '-emit-ast', '-fsyntex-only' (which is the default), and '-o <output file>'.
805218893Sdim *
806203955Srdivacky * \param num_unsaved_files the number of unsaved file entries in \p
807203955Srdivacky * unsaved_files.
808203955Srdivacky *
809203955Srdivacky * \param unsaved_files the files that have not yet been saved to disk
810203955Srdivacky * but may be required for code completion, including the contents of
811207619Srdivacky * those files.  The contents and name of these files (as specified by
812207619Srdivacky * CXUnsavedFile) are copied when necessary, so the client only needs to
813207619Srdivacky * guarantee their validity until the call to this function returns.
814203955Srdivacky */
815203955SrdivackyCINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnitFromSourceFile(
816203955Srdivacky                                         CXIndex CIdx,
817203955Srdivacky                                         const char *source_filename,
818203955Srdivacky                                         int num_clang_command_line_args,
819212904Sdim                                   const char * const *clang_command_line_args,
820203955Srdivacky                                         unsigned num_unsaved_files,
821204643Srdivacky                                         struct CXUnsavedFile *unsaved_files);
822205219Srdivacky
823203955Srdivacky/**
824203955Srdivacky * \brief Create a translation unit from an AST file (-emit-ast).
825203955Srdivacky */
826205219SrdivackyCINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnit(CXIndex,
827204643Srdivacky                                             const char *ast_filename);
828203955Srdivacky
829203955Srdivacky/**
830212904Sdim * \brief Flags that control the creation of translation units.
831212904Sdim *
832212904Sdim * The enumerators in this enumeration type are meant to be bitwise
833212904Sdim * ORed together to specify which options should be used when
834212904Sdim * constructing the translation unit.
835212904Sdim */
836212904Sdimenum CXTranslationUnit_Flags {
837212904Sdim  /**
838212904Sdim   * \brief Used to indicate that no special translation-unit options are
839212904Sdim   * needed.
840212904Sdim   */
841212904Sdim  CXTranslationUnit_None = 0x0,
842212904Sdim
843212904Sdim  /**
844212904Sdim   * \brief Used to indicate that the parser should construct a "detailed"
845212904Sdim   * preprocessing record, including all macro definitions and instantiations.
846212904Sdim   *
847212904Sdim   * Constructing a detailed preprocessing record requires more memory
848212904Sdim   * and time to parse, since the information contained in the record
849212904Sdim   * is usually not retained. However, it can be useful for
850212904Sdim   * applications that require more detailed information about the
851212904Sdim   * behavior of the preprocessor.
852212904Sdim   */
853212904Sdim  CXTranslationUnit_DetailedPreprocessingRecord = 0x01,
854212904Sdim
855212904Sdim  /**
856212904Sdim   * \brief Used to indicate that the translation unit is incomplete.
857212904Sdim   *
858212904Sdim   * When a translation unit is considered "incomplete", semantic
859212904Sdim   * analysis that is typically performed at the end of the
860212904Sdim   * translation unit will be suppressed. For example, this suppresses
861212904Sdim   * the completion of tentative declarations in C and of
862212904Sdim   * instantiation of implicitly-instantiation function templates in
863212904Sdim   * C++. This option is typically used when parsing a header with the
864212904Sdim   * intent of producing a precompiled header.
865212904Sdim   */
866212904Sdim  CXTranslationUnit_Incomplete = 0x02,
867212904Sdim
868212904Sdim  /**
869212904Sdim   * \brief Used to indicate that the translation unit should be built with an
870212904Sdim   * implicit precompiled header for the preamble.
871212904Sdim   *
872212904Sdim   * An implicit precompiled header is used as an optimization when a
873212904Sdim   * particular translation unit is likely to be reparsed many times
874212904Sdim   * when the sources aren't changing that often. In this case, an
875212904Sdim   * implicit precompiled header will be built containing all of the
876212904Sdim   * initial includes at the top of the main file (what we refer to as
877212904Sdim   * the "preamble" of the file). In subsequent parses, if the
878212904Sdim   * preamble or the files in it have not changed, \c
879212904Sdim   * clang_reparseTranslationUnit() will re-use the implicit
880212904Sdim   * precompiled header to improve parsing performance.
881212904Sdim   */
882212904Sdim  CXTranslationUnit_PrecompiledPreamble = 0x04,
883212904Sdim
884212904Sdim  /**
885212904Sdim   * \brief Used to indicate that the translation unit should cache some
886212904Sdim   * code-completion results with each reparse of the source file.
887212904Sdim   *
888212904Sdim   * Caching of code-completion results is a performance optimization that
889212904Sdim   * introduces some overhead to reparsing but improves the performance of
890212904Sdim   * code-completion operations.
891212904Sdim   */
892218893Sdim  CXTranslationUnit_CacheCompletionResults = 0x08,
893218893Sdim  /**
894226633Sdim   * \brief DEPRECATED: Enable precompiled preambles in C++.
895218893Sdim   *
896218893Sdim   * Note: this is a *temporary* option that is available only while
897226633Sdim   * we are testing C++ precompiled preamble support. It is deprecated.
898218893Sdim   */
899218893Sdim  CXTranslationUnit_CXXPrecompiledPreamble = 0x10,
900218893Sdim
901218893Sdim  /**
902226633Sdim   * \brief DEPRECATED: Enabled chained precompiled preambles in C++.
903218893Sdim   *
904218893Sdim   * Note: this is a *temporary* option that is available only while
905226633Sdim   * we are testing C++ precompiled preamble support. It is deprecated.
906218893Sdim   */
907223017Sdim  CXTranslationUnit_CXXChainedPCH = 0x20,
908223017Sdim
909223017Sdim  /**
910223017Sdim   * \brief Used to indicate that the "detailed" preprocessing record,
911224145Sdim   * if requested, should also contain nested macro expansions.
912223017Sdim   *
913224145Sdim   * Nested macro expansions (i.e., macro expansions that occur
914224145Sdim   * inside another macro expansion) can, in some code bases, require
915223017Sdim   * a large amount of storage to due preprocessor metaprogramming. Moreover,
916223017Sdim   * its fairly rare that this information is useful for libclang clients.
917223017Sdim   */
918224145Sdim  CXTranslationUnit_NestedMacroExpansions = 0x40,
919224145Sdim
920224145Sdim  /**
921224145Sdim   * \brief Legacy name to indicate that the "detailed" preprocessing record,
922224145Sdim   * if requested, should contain nested macro expansions.
923224145Sdim   *
924224145Sdim   * \see CXTranslationUnit_NestedMacroExpansions for the current name for this
925224145Sdim   * value, and its semantics. This is just an alias.
926224145Sdim   */
927224145Sdim  CXTranslationUnit_NestedMacroInstantiations =
928224145Sdim    CXTranslationUnit_NestedMacroExpansions
929212904Sdim};
930212904Sdim
931212904Sdim/**
932212904Sdim * \brief Returns the set of flags that is suitable for parsing a translation
933212904Sdim * unit that is being edited.
934212904Sdim *
935212904Sdim * The set of flags returned provide options for \c clang_parseTranslationUnit()
936212904Sdim * to indicate that the translation unit is likely to be reparsed many times,
937212904Sdim * either explicitly (via \c clang_reparseTranslationUnit()) or implicitly
938212904Sdim * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag
939212904Sdim * set contains an unspecified set of optimizations (e.g., the precompiled
940212904Sdim * preamble) geared toward improving the performance of these routines. The
941212904Sdim * set of optimizations enabled may change from one version to the next.
942212904Sdim */
943212904SdimCINDEX_LINKAGE unsigned clang_defaultEditingTranslationUnitOptions(void);
944212904Sdim
945212904Sdim/**
946212904Sdim * \brief Parse the given source file and the translation unit corresponding
947212904Sdim * to that file.
948212904Sdim *
949212904Sdim * This routine is the main entry point for the Clang C API, providing the
950212904Sdim * ability to parse a source file into a translation unit that can then be
951212904Sdim * queried by other functions in the API. This routine accepts a set of
952212904Sdim * command-line arguments so that the compilation can be configured in the same
953212904Sdim * way that the compiler is configured on the command line.
954212904Sdim *
955212904Sdim * \param CIdx The index object with which the translation unit will be
956212904Sdim * associated.
957212904Sdim *
958212904Sdim * \param source_filename The name of the source file to load, or NULL if the
959218893Sdim * source file is included in \p command_line_args.
960212904Sdim *
961212904Sdim * \param command_line_args The command-line arguments that would be
962212904Sdim * passed to the \c clang executable if it were being invoked out-of-process.
963212904Sdim * These command-line options will be parsed and will affect how the translation
964212904Sdim * unit is parsed. Note that the following options are ignored: '-c',
965212904Sdim * '-emit-ast', '-fsyntex-only' (which is the default), and '-o <output file>'.
966212904Sdim *
967212904Sdim * \param num_command_line_args The number of command-line arguments in
968212904Sdim * \p command_line_args.
969212904Sdim *
970212904Sdim * \param unsaved_files the files that have not yet been saved to disk
971212904Sdim * but may be required for parsing, including the contents of
972212904Sdim * those files.  The contents and name of these files (as specified by
973212904Sdim * CXUnsavedFile) are copied when necessary, so the client only needs to
974212904Sdim * guarantee their validity until the call to this function returns.
975212904Sdim *
976212904Sdim * \param num_unsaved_files the number of unsaved file entries in \p
977212904Sdim * unsaved_files.
978212904Sdim *
979212904Sdim * \param options A bitmask of options that affects how the translation unit
980212904Sdim * is managed but not its compilation. This should be a bitwise OR of the
981212904Sdim * CXTranslationUnit_XXX flags.
982212904Sdim *
983212904Sdim * \returns A new translation unit describing the parsed code and containing
984212904Sdim * any diagnostics produced by the compiler. If there is a failure from which
985212904Sdim * the compiler cannot recover, returns NULL.
986212904Sdim */
987212904SdimCINDEX_LINKAGE CXTranslationUnit clang_parseTranslationUnit(CXIndex CIdx,
988212904Sdim                                                    const char *source_filename,
989212904Sdim                                         const char * const *command_line_args,
990212904Sdim                                                      int num_command_line_args,
991212904Sdim                                            struct CXUnsavedFile *unsaved_files,
992212904Sdim                                                     unsigned num_unsaved_files,
993212904Sdim                                                            unsigned options);
994212904Sdim
995212904Sdim/**
996212904Sdim * \brief Flags that control how translation units are saved.
997212904Sdim *
998212904Sdim * The enumerators in this enumeration type are meant to be bitwise
999212904Sdim * ORed together to specify which options should be used when
1000212904Sdim * saving the translation unit.
1001212904Sdim */
1002212904Sdimenum CXSaveTranslationUnit_Flags {
1003212904Sdim  /**
1004212904Sdim   * \brief Used to indicate that no special saving options are needed.
1005212904Sdim   */
1006212904Sdim  CXSaveTranslationUnit_None = 0x0
1007212904Sdim};
1008212904Sdim
1009212904Sdim/**
1010212904Sdim * \brief Returns the set of flags that is suitable for saving a translation
1011212904Sdim * unit.
1012212904Sdim *
1013212904Sdim * The set of flags returned provide options for
1014212904Sdim * \c clang_saveTranslationUnit() by default. The returned flag
1015212904Sdim * set contains an unspecified set of options that save translation units with
1016212904Sdim * the most commonly-requested data.
1017212904Sdim */
1018212904SdimCINDEX_LINKAGE unsigned clang_defaultSaveOptions(CXTranslationUnit TU);
1019212904Sdim
1020212904Sdim/**
1021224145Sdim * \brief Describes the kind of error that occurred (if any) in a call to
1022224145Sdim * \c clang_saveTranslationUnit().
1023224145Sdim */
1024224145Sdimenum CXSaveError {
1025224145Sdim  /**
1026224145Sdim   * \brief Indicates that no error occurred while saving a translation unit.
1027224145Sdim   */
1028224145Sdim  CXSaveError_None = 0,
1029224145Sdim
1030224145Sdim  /**
1031224145Sdim   * \brief Indicates that an unknown error occurred while attempting to save
1032224145Sdim   * the file.
1033224145Sdim   *
1034224145Sdim   * This error typically indicates that file I/O failed when attempting to
1035224145Sdim   * write the file.
1036224145Sdim   */
1037224145Sdim  CXSaveError_Unknown = 1,
1038224145Sdim
1039224145Sdim  /**
1040224145Sdim   * \brief Indicates that errors during translation prevented this attempt
1041224145Sdim   * to save the translation unit.
1042224145Sdim   *
1043224145Sdim   * Errors that prevent the translation unit from being saved can be
1044224145Sdim   * extracted using \c clang_getNumDiagnostics() and \c clang_getDiagnostic().
1045224145Sdim   */
1046224145Sdim  CXSaveError_TranslationErrors = 2,
1047224145Sdim
1048224145Sdim  /**
1049224145Sdim   * \brief Indicates that the translation unit to be saved was somehow
1050224145Sdim   * invalid (e.g., NULL).
1051224145Sdim   */
1052224145Sdim  CXSaveError_InvalidTU = 3
1053224145Sdim};
1054224145Sdim
1055224145Sdim/**
1056212904Sdim * \brief Saves a translation unit into a serialized representation of
1057212904Sdim * that translation unit on disk.
1058212904Sdim *
1059212904Sdim * Any translation unit that was parsed without error can be saved
1060212904Sdim * into a file. The translation unit can then be deserialized into a
1061212904Sdim * new \c CXTranslationUnit with \c clang_createTranslationUnit() or,
1062212904Sdim * if it is an incomplete translation unit that corresponds to a
1063212904Sdim * header, used as a precompiled header when parsing other translation
1064212904Sdim * units.
1065212904Sdim *
1066212904Sdim * \param TU The translation unit to save.
1067212904Sdim *
1068212904Sdim * \param FileName The file to which the translation unit will be saved.
1069212904Sdim *
1070212904Sdim * \param options A bitmask of options that affects how the translation unit
1071212904Sdim * is saved. This should be a bitwise OR of the
1072212904Sdim * CXSaveTranslationUnit_XXX flags.
1073212904Sdim *
1074224145Sdim * \returns A value that will match one of the enumerators of the CXSaveError
1075224145Sdim * enumeration. Zero (CXSaveError_None) indicates that the translation unit was
1076224145Sdim * saved successfully, while a non-zero value indicates that a problem occurred.
1077212904Sdim */
1078212904SdimCINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU,
1079212904Sdim                                             const char *FileName,
1080212904Sdim                                             unsigned options);
1081212904Sdim
1082212904Sdim/**
1083203955Srdivacky * \brief Destroy the specified CXTranslationUnit object.
1084203955Srdivacky */
1085203955SrdivackyCINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit);
1086205219Srdivacky
1087203955Srdivacky/**
1088212904Sdim * \brief Flags that control the reparsing of translation units.
1089212904Sdim *
1090212904Sdim * The enumerators in this enumeration type are meant to be bitwise
1091212904Sdim * ORed together to specify which options should be used when
1092212904Sdim * reparsing the translation unit.
1093212904Sdim */
1094212904Sdimenum CXReparse_Flags {
1095212904Sdim  /**
1096212904Sdim   * \brief Used to indicate that no special reparsing options are needed.
1097212904Sdim   */
1098212904Sdim  CXReparse_None = 0x0
1099212904Sdim};
1100212904Sdim
1101212904Sdim/**
1102212904Sdim * \brief Returns the set of flags that is suitable for reparsing a translation
1103212904Sdim * unit.
1104212904Sdim *
1105212904Sdim * The set of flags returned provide options for
1106212904Sdim * \c clang_reparseTranslationUnit() by default. The returned flag
1107212904Sdim * set contains an unspecified set of optimizations geared toward common uses
1108212904Sdim * of reparsing. The set of optimizations enabled may change from one version
1109212904Sdim * to the next.
1110212904Sdim */
1111212904SdimCINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU);
1112212904Sdim
1113212904Sdim/**
1114212904Sdim * \brief Reparse the source files that produced this translation unit.
1115212904Sdim *
1116212904Sdim * This routine can be used to re-parse the source files that originally
1117212904Sdim * created the given translation unit, for example because those source files
1118212904Sdim * have changed (either on disk or as passed via \p unsaved_files). The
1119212904Sdim * source code will be reparsed with the same command-line options as it
1120212904Sdim * was originally parsed.
1121212904Sdim *
1122212904Sdim * Reparsing a translation unit invalidates all cursors and source locations
1123212904Sdim * that refer into that translation unit. This makes reparsing a translation
1124212904Sdim * unit semantically equivalent to destroying the translation unit and then
1125212904Sdim * creating a new translation unit with the same command-line arguments.
1126212904Sdim * However, it may be more efficient to reparse a translation
1127212904Sdim * unit using this routine.
1128212904Sdim *
1129212904Sdim * \param TU The translation unit whose contents will be re-parsed. The
1130212904Sdim * translation unit must originally have been built with
1131212904Sdim * \c clang_createTranslationUnitFromSourceFile().
1132212904Sdim *
1133212904Sdim * \param num_unsaved_files The number of unsaved file entries in \p
1134212904Sdim * unsaved_files.
1135212904Sdim *
1136212904Sdim * \param unsaved_files The files that have not yet been saved to disk
1137212904Sdim * but may be required for parsing, including the contents of
1138212904Sdim * those files.  The contents and name of these files (as specified by
1139212904Sdim * CXUnsavedFile) are copied when necessary, so the client only needs to
1140212904Sdim * guarantee their validity until the call to this function returns.
1141212904Sdim *
1142212904Sdim * \param options A bitset of options composed of the flags in CXReparse_Flags.
1143212904Sdim * The function \c clang_defaultReparseOptions() produces a default set of
1144212904Sdim * options recommended for most uses, based on the translation unit.
1145212904Sdim *
1146212904Sdim * \returns 0 if the sources could be reparsed. A non-zero value will be
1147212904Sdim * returned if reparsing was impossible, such that the translation unit is
1148212904Sdim * invalid. In such cases, the only valid call for \p TU is
1149212904Sdim * \c clang_disposeTranslationUnit(TU).
1150212904Sdim */
1151212904SdimCINDEX_LINKAGE int clang_reparseTranslationUnit(CXTranslationUnit TU,
1152212904Sdim                                                unsigned num_unsaved_files,
1153212904Sdim                                          struct CXUnsavedFile *unsaved_files,
1154212904Sdim                                                unsigned options);
1155221345Sdim
1156212904Sdim/**
1157221345Sdim  * \brief Categorizes how memory is being used by a translation unit.
1158221345Sdim  */
1159221345Sdimenum CXTUResourceUsageKind {
1160221345Sdim  CXTUResourceUsage_AST = 1,
1161221345Sdim  CXTUResourceUsage_Identifiers = 2,
1162221345Sdim  CXTUResourceUsage_Selectors = 3,
1163221345Sdim  CXTUResourceUsage_GlobalCompletionResults = 4,
1164221345Sdim  CXTUResourceUsage_SourceManagerContentCache = 5,
1165221345Sdim  CXTUResourceUsage_AST_SideTables = 6,
1166221345Sdim  CXTUResourceUsage_SourceManager_Membuffer_Malloc = 7,
1167221345Sdim  CXTUResourceUsage_SourceManager_Membuffer_MMap = 8,
1168221345Sdim  CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc = 9,
1169221345Sdim  CXTUResourceUsage_ExternalASTSource_Membuffer_MMap = 10,
1170223017Sdim  CXTUResourceUsage_Preprocessor = 11,
1171223017Sdim  CXTUResourceUsage_PreprocessingRecord = 12,
1172226633Sdim  CXTUResourceUsage_SourceManager_DataStructures = 13,
1173226633Sdim  CXTUResourceUsage_Preprocessor_HeaderSearch = 14,
1174221345Sdim  CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST,
1175221345Sdim  CXTUResourceUsage_MEMORY_IN_BYTES_END =
1176226633Sdim    CXTUResourceUsage_Preprocessor_HeaderSearch,
1177221345Sdim
1178221345Sdim  CXTUResourceUsage_First = CXTUResourceUsage_AST,
1179226633Sdim  CXTUResourceUsage_Last = CXTUResourceUsage_Preprocessor_HeaderSearch
1180221345Sdim};
1181221345Sdim
1182221345Sdim/**
1183221345Sdim  * \brief Returns the human-readable null-terminated C string that represents
1184221345Sdim  *  the name of the memory category.  This string should never be freed.
1185221345Sdim  */
1186221345SdimCINDEX_LINKAGE
1187221345Sdimconst char *clang_getTUResourceUsageName(enum CXTUResourceUsageKind kind);
1188221345Sdim
1189221345Sdimtypedef struct CXTUResourceUsageEntry {
1190221345Sdim  /* \brief The memory usage category. */
1191221345Sdim  enum CXTUResourceUsageKind kind;
1192221345Sdim  /* \brief Amount of resources used.
1193221345Sdim      The units will depend on the resource kind. */
1194221345Sdim  unsigned long amount;
1195221345Sdim} CXTUResourceUsageEntry;
1196221345Sdim
1197221345Sdim/**
1198221345Sdim  * \brief The memory usage of a CXTranslationUnit, broken into categories.
1199221345Sdim  */
1200221345Sdimtypedef struct CXTUResourceUsage {
1201221345Sdim  /* \brief Private data member, used for queries. */
1202221345Sdim  void *data;
1203221345Sdim
1204221345Sdim  /* \brief The number of entries in the 'entries' array. */
1205221345Sdim  unsigned numEntries;
1206221345Sdim
1207221345Sdim  /* \brief An array of key-value pairs, representing the breakdown of memory
1208221345Sdim            usage. */
1209221345Sdim  CXTUResourceUsageEntry *entries;
1210221345Sdim
1211221345Sdim} CXTUResourceUsage;
1212221345Sdim
1213221345Sdim/**
1214221345Sdim  * \brief Return the memory usage of a translation unit.  This object
1215221345Sdim  *  should be released with clang_disposeCXTUResourceUsage().
1216221345Sdim  */
1217221345SdimCINDEX_LINKAGE CXTUResourceUsage clang_getCXTUResourceUsage(CXTranslationUnit TU);
1218221345Sdim
1219221345SdimCINDEX_LINKAGE void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage);
1220221345Sdim
1221221345Sdim/**
1222203955Srdivacky * @}
1223203955Srdivacky */
1224205219Srdivacky
1225203955Srdivacky/**
1226202879Srdivacky * \brief Describes the kind of entity that a cursor refers to.
1227202379Srdivacky */
1228202879Srdivackyenum CXCursorKind {
1229202879Srdivacky  /* Declarations */
1230203955Srdivacky  /**
1231202879Srdivacky   * \brief A declaration whose specific kind is not exposed via this
1232203955Srdivacky   * interface.
1233202879Srdivacky   *
1234202879Srdivacky   * Unexposed declarations have the same operations as any other kind
1235202879Srdivacky   * of declaration; one can extract their location information,
1236202879Srdivacky   * spelling, find their definitions, etc. However, the specific kind
1237202879Srdivacky   * of the declaration is not reported.
1238202879Srdivacky   */
1239202879Srdivacky  CXCursor_UnexposedDecl                 = 1,
1240202879Srdivacky  /** \brief A C or C++ struct. */
1241203955Srdivacky  CXCursor_StructDecl                    = 2,
1242202879Srdivacky  /** \brief A C or C++ union. */
1243202879Srdivacky  CXCursor_UnionDecl                     = 3,
1244202879Srdivacky  /** \brief A C++ class. */
1245202879Srdivacky  CXCursor_ClassDecl                     = 4,
1246202879Srdivacky  /** \brief An enumeration. */
1247202879Srdivacky  CXCursor_EnumDecl                      = 5,
1248203955Srdivacky  /**
1249202879Srdivacky   * \brief A field (in C) or non-static data member (in C++) in a
1250202879Srdivacky   * struct, union, or C++ class.
1251202879Srdivacky   */
1252202879Srdivacky  CXCursor_FieldDecl                     = 6,
1253202879Srdivacky  /** \brief An enumerator constant. */
1254202879Srdivacky  CXCursor_EnumConstantDecl              = 7,
1255202879Srdivacky  /** \brief A function. */
1256202879Srdivacky  CXCursor_FunctionDecl                  = 8,
1257202879Srdivacky  /** \brief A variable. */
1258202879Srdivacky  CXCursor_VarDecl                       = 9,
1259202879Srdivacky  /** \brief A function or method parameter. */
1260202879Srdivacky  CXCursor_ParmDecl                      = 10,
1261202879Srdivacky  /** \brief An Objective-C @interface. */
1262202879Srdivacky  CXCursor_ObjCInterfaceDecl             = 11,
1263202879Srdivacky  /** \brief An Objective-C @interface for a category. */
1264202879Srdivacky  CXCursor_ObjCCategoryDecl              = 12,
1265202879Srdivacky  /** \brief An Objective-C @protocol declaration. */
1266202879Srdivacky  CXCursor_ObjCProtocolDecl              = 13,
1267202879Srdivacky  /** \brief An Objective-C @property declaration. */
1268202879Srdivacky  CXCursor_ObjCPropertyDecl              = 14,
1269202879Srdivacky  /** \brief An Objective-C instance variable. */
1270202879Srdivacky  CXCursor_ObjCIvarDecl                  = 15,
1271202879Srdivacky  /** \brief An Objective-C instance method. */
1272202879Srdivacky  CXCursor_ObjCInstanceMethodDecl        = 16,
1273202879Srdivacky  /** \brief An Objective-C class method. */
1274202879Srdivacky  CXCursor_ObjCClassMethodDecl           = 17,
1275202879Srdivacky  /** \brief An Objective-C @implementation. */
1276202879Srdivacky  CXCursor_ObjCImplementationDecl        = 18,
1277202879Srdivacky  /** \brief An Objective-C @implementation for a category. */
1278202879Srdivacky  CXCursor_ObjCCategoryImplDecl          = 19,
1279202879Srdivacky  /** \brief A typedef */
1280202879Srdivacky  CXCursor_TypedefDecl                   = 20,
1281207619Srdivacky  /** \brief A C++ class method. */
1282207619Srdivacky  CXCursor_CXXMethod                     = 21,
1283208600Srdivacky  /** \brief A C++ namespace. */
1284208600Srdivacky  CXCursor_Namespace                     = 22,
1285208600Srdivacky  /** \brief A linkage specification, e.g. 'extern "C"'. */
1286208600Srdivacky  CXCursor_LinkageSpec                   = 23,
1287212904Sdim  /** \brief A C++ constructor. */
1288212904Sdim  CXCursor_Constructor                   = 24,
1289212904Sdim  /** \brief A C++ destructor. */
1290212904Sdim  CXCursor_Destructor                    = 25,
1291212904Sdim  /** \brief A C++ conversion function. */
1292212904Sdim  CXCursor_ConversionFunction            = 26,
1293212904Sdim  /** \brief A C++ template type parameter. */
1294212904Sdim  CXCursor_TemplateTypeParameter         = 27,
1295212904Sdim  /** \brief A C++ non-type template parameter. */
1296212904Sdim  CXCursor_NonTypeTemplateParameter      = 28,
1297212904Sdim  /** \brief A C++ template template parameter. */
1298212904Sdim  CXCursor_TemplateTemplateParameter     = 29,
1299212904Sdim  /** \brief A C++ function template. */
1300212904Sdim  CXCursor_FunctionTemplate              = 30,
1301212904Sdim  /** \brief A C++ class template. */
1302212904Sdim  CXCursor_ClassTemplate                 = 31,
1303212904Sdim  /** \brief A C++ class template partial specialization. */
1304212904Sdim  CXCursor_ClassTemplatePartialSpecialization = 32,
1305212904Sdim  /** \brief A C++ namespace alias declaration. */
1306212904Sdim  CXCursor_NamespaceAlias                = 33,
1307212904Sdim  /** \brief A C++ using directive. */
1308212904Sdim  CXCursor_UsingDirective                = 34,
1309221345Sdim  /** \brief A C++ using declaration. */
1310212904Sdim  CXCursor_UsingDeclaration              = 35,
1311221345Sdim  /** \brief A C++ alias declaration */
1312221345Sdim  CXCursor_TypeAliasDecl                 = 36,
1313223017Sdim  /** \brief An Objective-C @synthesize definition. */
1314223017Sdim  CXCursor_ObjCSynthesizeDecl            = 37,
1315223017Sdim  /** \brief An Objective-C @dynamic definition. */
1316223017Sdim  CXCursor_ObjCDynamicDecl               = 38,
1317226633Sdim  /** \brief An access specifier. */
1318226633Sdim  CXCursor_CXXAccessSpecifier            = 39,
1319226633Sdim
1320208600Srdivacky  CXCursor_FirstDecl                     = CXCursor_UnexposedDecl,
1321226633Sdim  CXCursor_LastDecl                      = CXCursor_CXXAccessSpecifier,
1322207619Srdivacky
1323202879Srdivacky  /* References */
1324202879Srdivacky  CXCursor_FirstRef                      = 40, /* Decl references */
1325203955Srdivacky  CXCursor_ObjCSuperClassRef             = 40,
1326202879Srdivacky  CXCursor_ObjCProtocolRef               = 41,
1327202879Srdivacky  CXCursor_ObjCClassRef                  = 42,
1328202879Srdivacky  /**
1329202879Srdivacky   * \brief A reference to a type declaration.
1330202879Srdivacky   *
1331202879Srdivacky   * A type reference occurs anywhere where a type is named but not
1332202879Srdivacky   * declared. For example, given:
1333202879Srdivacky   *
1334202879Srdivacky   * \code
1335202879Srdivacky   * typedef unsigned size_type;
1336202879Srdivacky   * size_type size;
1337202879Srdivacky   * \endcode
1338202879Srdivacky   *
1339202879Srdivacky   * The typedef is a declaration of size_type (CXCursor_TypedefDecl),
1340202879Srdivacky   * while the type of the variable "size" is referenced. The cursor
1341202879Srdivacky   * referenced by the type of size is the typedef for size_type.
1342202879Srdivacky   */
1343202879Srdivacky  CXCursor_TypeRef                       = 43,
1344212904Sdim  CXCursor_CXXBaseSpecifier              = 44,
1345212904Sdim  /**
1346218893Sdim   * \brief A reference to a class template, function template, template
1347218893Sdim   * template parameter, or class template partial specialization.
1348212904Sdim   */
1349212904Sdim  CXCursor_TemplateRef                   = 45,
1350212904Sdim  /**
1351212904Sdim   * \brief A reference to a namespace or namespace alias.
1352212904Sdim   */
1353212904Sdim  CXCursor_NamespaceRef                  = 46,
1354218893Sdim  /**
1355218893Sdim   * \brief A reference to a member of a struct, union, or class that occurs in
1356218893Sdim   * some non-expression context, e.g., a designated initializer.
1357218893Sdim   */
1358218893Sdim  CXCursor_MemberRef                     = 47,
1359218893Sdim  /**
1360218893Sdim   * \brief A reference to a labeled statement.
1361218893Sdim   *
1362218893Sdim   * This cursor kind is used to describe the jump to "start_over" in the
1363218893Sdim   * goto statement in the following example:
1364218893Sdim   *
1365218893Sdim   * \code
1366218893Sdim   *   start_over:
1367218893Sdim   *     ++counter;
1368218893Sdim   *
1369218893Sdim   *     goto start_over;
1370218893Sdim   * \endcode
1371218893Sdim   *
1372218893Sdim   * A label reference cursor refers to a label statement.
1373218893Sdim   */
1374218893Sdim  CXCursor_LabelRef                      = 48,
1375218893Sdim
1376218893Sdim  /**
1377218893Sdim   * \brief A reference to a set of overloaded functions or function templates
1378218893Sdim   * that has not yet been resolved to a specific function or function template.
1379218893Sdim   *
1380218893Sdim   * An overloaded declaration reference cursor occurs in C++ templates where
1381218893Sdim   * a dependent name refers to a function. For example:
1382218893Sdim   *
1383218893Sdim   * \code
1384218893Sdim   * template<typename T> void swap(T&, T&);
1385218893Sdim   *
1386218893Sdim   * struct X { ... };
1387218893Sdim   * void swap(X&, X&);
1388218893Sdim   *
1389218893Sdim   * template<typename T>
1390218893Sdim   * void reverse(T* first, T* last) {
1391218893Sdim   *   while (first < last - 1) {
1392218893Sdim   *     swap(*first, *--last);
1393218893Sdim   *     ++first;
1394218893Sdim   *   }
1395218893Sdim   * }
1396218893Sdim   *
1397218893Sdim   * struct Y { };
1398218893Sdim   * void swap(Y&, Y&);
1399218893Sdim   * \endcode
1400218893Sdim   *
1401218893Sdim   * Here, the identifier "swap" is associated with an overloaded declaration
1402218893Sdim   * reference. In the template definition, "swap" refers to either of the two
1403218893Sdim   * "swap" functions declared above, so both results will be available. At
1404218893Sdim   * instantiation time, "swap" may also refer to other functions found via
1405218893Sdim   * argument-dependent lookup (e.g., the "swap" function at the end of the
1406218893Sdim   * example).
1407218893Sdim   *
1408218893Sdim   * The functions \c clang_getNumOverloadedDecls() and
1409218893Sdim   * \c clang_getOverloadedDecl() can be used to retrieve the definitions
1410218893Sdim   * referenced by this cursor.
1411218893Sdim   */
1412218893Sdim  CXCursor_OverloadedDeclRef             = 49,
1413218893Sdim
1414218893Sdim  CXCursor_LastRef                       = CXCursor_OverloadedDeclRef,
1415203955Srdivacky
1416202879Srdivacky  /* Error conditions */
1417202879Srdivacky  CXCursor_FirstInvalid                  = 70,
1418202879Srdivacky  CXCursor_InvalidFile                   = 70,
1419202879Srdivacky  CXCursor_NoDeclFound                   = 71,
1420202879Srdivacky  CXCursor_NotImplemented                = 72,
1421205408Srdivacky  CXCursor_InvalidCode                   = 73,
1422205408Srdivacky  CXCursor_LastInvalid                   = CXCursor_InvalidCode,
1423203955Srdivacky
1424202879Srdivacky  /* Expressions */
1425202879Srdivacky  CXCursor_FirstExpr                     = 100,
1426203955Srdivacky
1427202879Srdivacky  /**
1428202879Srdivacky   * \brief An expression whose specific kind is not exposed via this
1429203955Srdivacky   * interface.
1430202879Srdivacky   *
1431202879Srdivacky   * Unexposed expressions have the same operations as any other kind
1432202879Srdivacky   * of expression; one can extract their location information,
1433202879Srdivacky   * spelling, children, etc. However, the specific kind of the
1434202879Srdivacky   * expression is not reported.
1435202879Srdivacky   */
1436202879Srdivacky  CXCursor_UnexposedExpr                 = 100,
1437203955Srdivacky
1438202879Srdivacky  /**
1439202879Srdivacky   * \brief An expression that refers to some value declaration, such
1440202879Srdivacky   * as a function, varible, or enumerator.
1441202879Srdivacky   */
1442202879Srdivacky  CXCursor_DeclRefExpr                   = 101,
1443203955Srdivacky
1444202879Srdivacky  /**
1445202879Srdivacky   * \brief An expression that refers to a member of a struct, union,
1446202879Srdivacky   * class, Objective-C class, etc.
1447202879Srdivacky   */
1448202879Srdivacky  CXCursor_MemberRefExpr                 = 102,
1449203955Srdivacky
1450202879Srdivacky  /** \brief An expression that calls a function. */
1451202879Srdivacky  CXCursor_CallExpr                      = 103,
1452203955Srdivacky
1453202879Srdivacky  /** \brief An expression that sends a message to an Objective-C
1454202879Srdivacky   object or class. */
1455202879Srdivacky  CXCursor_ObjCMessageExpr               = 104,
1456203955Srdivacky
1457207619Srdivacky  /** \brief An expression that represents a block literal. */
1458207619Srdivacky  CXCursor_BlockExpr                     = 105,
1459207619Srdivacky
1460226633Sdim  /** \brief An integer literal.
1461226633Sdim   */
1462226633Sdim  CXCursor_IntegerLiteral                = 106,
1463207619Srdivacky
1464226633Sdim  /** \brief A floating point number literal.
1465226633Sdim   */
1466226633Sdim  CXCursor_FloatingLiteral               = 107,
1467226633Sdim
1468226633Sdim  /** \brief An imaginary number literal.
1469226633Sdim   */
1470226633Sdim  CXCursor_ImaginaryLiteral              = 108,
1471226633Sdim
1472226633Sdim  /** \brief A string literal.
1473226633Sdim   */
1474226633Sdim  CXCursor_StringLiteral                 = 109,
1475226633Sdim
1476226633Sdim  /** \brief A character literal.
1477226633Sdim   */
1478226633Sdim  CXCursor_CharacterLiteral              = 110,
1479226633Sdim
1480226633Sdim  /** \brief A parenthesized expression, e.g. "(1)".
1481226633Sdim   *
1482226633Sdim   * This AST node is only formed if full location information is requested.
1483226633Sdim   */
1484226633Sdim  CXCursor_ParenExpr                     = 111,
1485226633Sdim
1486226633Sdim  /** \brief This represents the unary-expression's (except sizeof and
1487226633Sdim   * alignof).
1488226633Sdim   */
1489226633Sdim  CXCursor_UnaryOperator                 = 112,
1490226633Sdim
1491226633Sdim  /** \brief [C99 6.5.2.1] Array Subscripting.
1492226633Sdim   */
1493226633Sdim  CXCursor_ArraySubscriptExpr            = 113,
1494226633Sdim
1495226633Sdim  /** \brief A builtin binary operation expression such as "x + y" or
1496226633Sdim   * "x <= y".
1497226633Sdim   */
1498226633Sdim  CXCursor_BinaryOperator                = 114,
1499226633Sdim
1500226633Sdim  /** \brief Compound assignment such as "+=".
1501226633Sdim   */
1502226633Sdim  CXCursor_CompoundAssignOperator        = 115,
1503226633Sdim
1504226633Sdim  /** \brief The ?: ternary operator.
1505226633Sdim   */
1506226633Sdim  CXCursor_ConditionalOperator           = 116,
1507226633Sdim
1508226633Sdim  /** \brief An explicit cast in C (C99 6.5.4) or a C-style cast in C++
1509226633Sdim   * (C++ [expr.cast]), which uses the syntax (Type)expr.
1510226633Sdim   *
1511226633Sdim   * For example: (int)f.
1512226633Sdim   */
1513226633Sdim  CXCursor_CStyleCastExpr                = 117,
1514226633Sdim
1515226633Sdim  /** \brief [C99 6.5.2.5]
1516226633Sdim   */
1517226633Sdim  CXCursor_CompoundLiteralExpr           = 118,
1518226633Sdim
1519226633Sdim  /** \brief Describes an C or C++ initializer list.
1520226633Sdim   */
1521226633Sdim  CXCursor_InitListExpr                  = 119,
1522226633Sdim
1523226633Sdim  /** \brief The GNU address of label extension, representing &&label.
1524226633Sdim   */
1525226633Sdim  CXCursor_AddrLabelExpr                 = 120,
1526226633Sdim
1527226633Sdim  /** \brief This is the GNU Statement Expression extension: ({int X=4; X;})
1528226633Sdim   */
1529226633Sdim  CXCursor_StmtExpr                      = 121,
1530226633Sdim
1531226633Sdim  /** \brief Represents a C1X generic selection.
1532226633Sdim   */
1533226633Sdim  CXCursor_GenericSelectionExpr          = 122,
1534226633Sdim
1535226633Sdim  /** \brief Implements the GNU __null extension, which is a name for a null
1536226633Sdim   * pointer constant that has integral type (e.g., int or long) and is the same
1537226633Sdim   * size and alignment as a pointer.
1538226633Sdim   *
1539226633Sdim   * The __null extension is typically only used by system headers, which define
1540226633Sdim   * NULL as __null in C++ rather than using 0 (which is an integer that may not
1541226633Sdim   * match the size of a pointer).
1542226633Sdim   */
1543226633Sdim  CXCursor_GNUNullExpr                   = 123,
1544226633Sdim
1545226633Sdim  /** \brief C++'s static_cast<> expression.
1546226633Sdim   */
1547226633Sdim  CXCursor_CXXStaticCastExpr             = 124,
1548226633Sdim
1549226633Sdim  /** \brief C++'s dynamic_cast<> expression.
1550226633Sdim   */
1551226633Sdim  CXCursor_CXXDynamicCastExpr            = 125,
1552226633Sdim
1553226633Sdim  /** \brief C++'s reinterpret_cast<> expression.
1554226633Sdim   */
1555226633Sdim  CXCursor_CXXReinterpretCastExpr        = 126,
1556226633Sdim
1557226633Sdim  /** \brief C++'s const_cast<> expression.
1558226633Sdim   */
1559226633Sdim  CXCursor_CXXConstCastExpr              = 127,
1560226633Sdim
1561226633Sdim  /** \brief Represents an explicit C++ type conversion that uses "functional"
1562226633Sdim   * notion (C++ [expr.type.conv]).
1563226633Sdim   *
1564226633Sdim   * Example:
1565226633Sdim   * \code
1566226633Sdim   *   x = int(0.5);
1567226633Sdim   * \endcode
1568226633Sdim   */
1569226633Sdim  CXCursor_CXXFunctionalCastExpr         = 128,
1570226633Sdim
1571226633Sdim  /** \brief A C++ typeid expression (C++ [expr.typeid]).
1572226633Sdim   */
1573226633Sdim  CXCursor_CXXTypeidExpr                 = 129,
1574226633Sdim
1575226633Sdim  /** \brief [C++ 2.13.5] C++ Boolean Literal.
1576226633Sdim   */
1577226633Sdim  CXCursor_CXXBoolLiteralExpr            = 130,
1578226633Sdim
1579226633Sdim  /** \brief [C++0x 2.14.7] C++ Pointer Literal.
1580226633Sdim   */
1581226633Sdim  CXCursor_CXXNullPtrLiteralExpr         = 131,
1582226633Sdim
1583226633Sdim  /** \brief Represents the "this" expression in C++
1584226633Sdim   */
1585226633Sdim  CXCursor_CXXThisExpr                   = 132,
1586226633Sdim
1587226633Sdim  /** \brief [C++ 15] C++ Throw Expression.
1588226633Sdim   *
1589226633Sdim   * This handles 'throw' and 'throw' assignment-expression. When
1590226633Sdim   * assignment-expression isn't present, Op will be null.
1591226633Sdim   */
1592226633Sdim  CXCursor_CXXThrowExpr                  = 133,
1593226633Sdim
1594226633Sdim  /** \brief A new expression for memory allocation and constructor calls, e.g:
1595226633Sdim   * "new CXXNewExpr(foo)".
1596226633Sdim   */
1597226633Sdim  CXCursor_CXXNewExpr                    = 134,
1598226633Sdim
1599226633Sdim  /** \brief A delete expression for memory deallocation and destructor calls,
1600226633Sdim   * e.g. "delete[] pArray".
1601226633Sdim   */
1602226633Sdim  CXCursor_CXXDeleteExpr                 = 135,
1603226633Sdim
1604226633Sdim  /** \brief A unary expression.
1605226633Sdim   */
1606226633Sdim  CXCursor_UnaryExpr                     = 136,
1607226633Sdim
1608226633Sdim  /** \brief ObjCStringLiteral, used for Objective-C string literals i.e. "foo".
1609226633Sdim   */
1610226633Sdim  CXCursor_ObjCStringLiteral             = 137,
1611226633Sdim
1612226633Sdim  /** \brief ObjCEncodeExpr, used for in Objective-C.
1613226633Sdim   */
1614226633Sdim  CXCursor_ObjCEncodeExpr                = 138,
1615226633Sdim
1616226633Sdim  /** \brief ObjCSelectorExpr used for in Objective-C.
1617226633Sdim   */
1618226633Sdim  CXCursor_ObjCSelectorExpr              = 139,
1619226633Sdim
1620226633Sdim  /** \brief Objective-C's protocol expression.
1621226633Sdim   */
1622226633Sdim  CXCursor_ObjCProtocolExpr              = 140,
1623226633Sdim
1624226633Sdim  /** \brief An Objective-C "bridged" cast expression, which casts between
1625226633Sdim   * Objective-C pointers and C pointers, transferring ownership in the process.
1626226633Sdim   *
1627226633Sdim   * \code
1628226633Sdim   *   NSString *str = (__bridge_transfer NSString *)CFCreateString();
1629226633Sdim   * \endcode
1630226633Sdim   */
1631226633Sdim  CXCursor_ObjCBridgedCastExpr           = 141,
1632226633Sdim
1633226633Sdim  /** \brief Represents a C++0x pack expansion that produces a sequence of
1634226633Sdim   * expressions.
1635226633Sdim   *
1636226633Sdim   * A pack expansion expression contains a pattern (which itself is an
1637226633Sdim   * expression) followed by an ellipsis. For example:
1638226633Sdim   *
1639226633Sdim   * \code
1640226633Sdim   * template<typename F, typename ...Types>
1641226633Sdim   * void forward(F f, Types &&...args) {
1642226633Sdim   *  f(static_cast<Types&&>(args)...);
1643226633Sdim   * }
1644226633Sdim   * \endcode
1645226633Sdim   */
1646226633Sdim  CXCursor_PackExpansionExpr             = 142,
1647226633Sdim
1648226633Sdim  /** \brief Represents an expression that computes the length of a parameter
1649226633Sdim   * pack.
1650226633Sdim   *
1651226633Sdim   * \code
1652226633Sdim   * template<typename ...Types>
1653226633Sdim   * struct count {
1654226633Sdim   *   static const unsigned value = sizeof...(Types);
1655226633Sdim   * };
1656226633Sdim   * \endcode
1657226633Sdim   */
1658226633Sdim  CXCursor_SizeOfPackExpr                = 143,
1659226633Sdim
1660226633Sdim  CXCursor_LastExpr                      = CXCursor_SizeOfPackExpr,
1661226633Sdim
1662202879Srdivacky  /* Statements */
1663202879Srdivacky  CXCursor_FirstStmt                     = 200,
1664202879Srdivacky  /**
1665202879Srdivacky   * \brief A statement whose specific kind is not exposed via this
1666202879Srdivacky   * interface.
1667202879Srdivacky   *
1668202879Srdivacky   * Unexposed statements have the same operations as any other kind of
1669202879Srdivacky   * statement; one can extract their location information, spelling,
1670202879Srdivacky   * children, etc. However, the specific kind of the statement is not
1671202879Srdivacky   * reported.
1672202879Srdivacky   */
1673202879Srdivacky  CXCursor_UnexposedStmt                 = 200,
1674218893Sdim
1675218893Sdim  /** \brief A labelled statement in a function.
1676218893Sdim   *
1677218893Sdim   * This cursor kind is used to describe the "start_over:" label statement in
1678218893Sdim   * the following example:
1679218893Sdim   *
1680218893Sdim   * \code
1681218893Sdim   *   start_over:
1682218893Sdim   *     ++counter;
1683218893Sdim   * \endcode
1684218893Sdim   *
1685218893Sdim   */
1686218893Sdim  CXCursor_LabelStmt                     = 201,
1687203955Srdivacky
1688226633Sdim  /** \brief A group of statements like { stmt stmt }.
1689226633Sdim   *
1690226633Sdim   * This cursor kind is used to describe compound statements, e.g. function
1691226633Sdim   * bodies.
1692226633Sdim   */
1693226633Sdim  CXCursor_CompoundStmt                  = 202,
1694226633Sdim
1695226633Sdim  /** \brief A case statment.
1696226633Sdim   */
1697226633Sdim  CXCursor_CaseStmt                      = 203,
1698226633Sdim
1699226633Sdim  /** \brief A default statement.
1700226633Sdim   */
1701226633Sdim  CXCursor_DefaultStmt                   = 204,
1702226633Sdim
1703226633Sdim  /** \brief An if statement
1704226633Sdim   */
1705226633Sdim  CXCursor_IfStmt                        = 205,
1706226633Sdim
1707226633Sdim  /** \brief A switch statement.
1708226633Sdim   */
1709226633Sdim  CXCursor_SwitchStmt                    = 206,
1710226633Sdim
1711226633Sdim  /** \brief A while statement.
1712226633Sdim   */
1713226633Sdim  CXCursor_WhileStmt                     = 207,
1714226633Sdim
1715226633Sdim  /** \brief A do statement.
1716226633Sdim   */
1717226633Sdim  CXCursor_DoStmt                        = 208,
1718226633Sdim
1719226633Sdim  /** \brief A for statement.
1720226633Sdim   */
1721226633Sdim  CXCursor_ForStmt                       = 209,
1722226633Sdim
1723226633Sdim  /** \brief A goto statement.
1724226633Sdim   */
1725226633Sdim  CXCursor_GotoStmt                      = 210,
1726226633Sdim
1727226633Sdim  /** \brief An indirect goto statement.
1728226633Sdim   */
1729226633Sdim  CXCursor_IndirectGotoStmt              = 211,
1730226633Sdim
1731226633Sdim  /** \brief A continue statement.
1732226633Sdim   */
1733226633Sdim  CXCursor_ContinueStmt                  = 212,
1734226633Sdim
1735226633Sdim  /** \brief A break statement.
1736226633Sdim   */
1737226633Sdim  CXCursor_BreakStmt                     = 213,
1738226633Sdim
1739226633Sdim  /** \brief A return statement.
1740226633Sdim   */
1741226633Sdim  CXCursor_ReturnStmt                    = 214,
1742226633Sdim
1743226633Sdim  /** \brief A GNU inline assembly statement extension.
1744226633Sdim   */
1745226633Sdim  CXCursor_AsmStmt                       = 215,
1746226633Sdim
1747226633Sdim  /** \brief Objective-C's overall @try-@catc-@finall statement.
1748226633Sdim   */
1749226633Sdim  CXCursor_ObjCAtTryStmt                 = 216,
1750226633Sdim
1751226633Sdim  /** \brief Objective-C's @catch statement.
1752226633Sdim   */
1753226633Sdim  CXCursor_ObjCAtCatchStmt               = 217,
1754226633Sdim
1755226633Sdim  /** \brief Objective-C's @finally statement.
1756226633Sdim   */
1757226633Sdim  CXCursor_ObjCAtFinallyStmt             = 218,
1758226633Sdim
1759226633Sdim  /** \brief Objective-C's @throw statement.
1760226633Sdim   */
1761226633Sdim  CXCursor_ObjCAtThrowStmt               = 219,
1762226633Sdim
1763226633Sdim  /** \brief Objective-C's @synchronized statement.
1764226633Sdim   */
1765226633Sdim  CXCursor_ObjCAtSynchronizedStmt        = 220,
1766226633Sdim
1767226633Sdim  /** \brief Objective-C's autorelease pool statement.
1768226633Sdim   */
1769226633Sdim  CXCursor_ObjCAutoreleasePoolStmt       = 221,
1770226633Sdim
1771226633Sdim  /** \brief Objective-C's collection statement.
1772226633Sdim   */
1773226633Sdim  CXCursor_ObjCForCollectionStmt         = 222,
1774226633Sdim
1775226633Sdim  /** \brief C++'s catch statement.
1776226633Sdim   */
1777226633Sdim  CXCursor_CXXCatchStmt                  = 223,
1778226633Sdim
1779226633Sdim  /** \brief C++'s try statement.
1780226633Sdim   */
1781226633Sdim  CXCursor_CXXTryStmt                    = 224,
1782226633Sdim
1783226633Sdim  /** \brief C++'s for (* : *) statement.
1784226633Sdim   */
1785226633Sdim  CXCursor_CXXForRangeStmt               = 225,
1786226633Sdim
1787226633Sdim  /** \brief Windows Structured Exception Handling's try statement.
1788226633Sdim   */
1789226633Sdim  CXCursor_SEHTryStmt                    = 226,
1790226633Sdim
1791226633Sdim  /** \brief Windows Structured Exception Handling's except statement.
1792226633Sdim   */
1793226633Sdim  CXCursor_SEHExceptStmt                 = 227,
1794226633Sdim
1795226633Sdim  /** \brief Windows Structured Exception Handling's finally statement.
1796226633Sdim   */
1797226633Sdim  CXCursor_SEHFinallyStmt                = 228,
1798226633Sdim
1799226633Sdim  /** \brief The null satement ";": C99 6.8.3p3.
1800226633Sdim   *
1801226633Sdim   * This cursor kind is used to describe the null statement.
1802226633Sdim   */
1803226633Sdim  CXCursor_NullStmt                      = 230,
1804226633Sdim
1805226633Sdim  /** \brief Adaptor class for mixing declarations with statements and
1806226633Sdim   * expressions.
1807226633Sdim   */
1808226633Sdim  CXCursor_DeclStmt                      = 231,
1809226633Sdim
1810226633Sdim  CXCursor_LastStmt                      = CXCursor_DeclStmt,
1811226633Sdim
1812202879Srdivacky  /**
1813202879Srdivacky   * \brief Cursor that represents the translation unit itself.
1814202879Srdivacky   *
1815202879Srdivacky   * The translation unit cursor exists primarily to act as the root
1816202879Srdivacky   * cursor for traversing the contents of a translation unit.
1817202879Srdivacky   */
1818204643Srdivacky  CXCursor_TranslationUnit               = 300,
1819204643Srdivacky
1820204643Srdivacky  /* Attributes */
1821204643Srdivacky  CXCursor_FirstAttr                     = 400,
1822204643Srdivacky  /**
1823204643Srdivacky   * \brief An attribute whose specific kind is not exposed via this
1824204643Srdivacky   * interface.
1825204643Srdivacky   */
1826204643Srdivacky  CXCursor_UnexposedAttr                 = 400,
1827204643Srdivacky
1828204643Srdivacky  CXCursor_IBActionAttr                  = 401,
1829204643Srdivacky  CXCursor_IBOutletAttr                  = 402,
1830208600Srdivacky  CXCursor_IBOutletCollectionAttr        = 403,
1831226633Sdim  CXCursor_CXXFinalAttr                  = 404,
1832226633Sdim  CXCursor_CXXOverrideAttr               = 405,
1833226633Sdim  CXCursor_AnnotateAttr                  = 406,
1834226633Sdim  CXCursor_LastAttr                      = CXCursor_AnnotateAttr,
1835205408Srdivacky
1836205408Srdivacky  /* Preprocessing */
1837205408Srdivacky  CXCursor_PreprocessingDirective        = 500,
1838205408Srdivacky  CXCursor_MacroDefinition               = 501,
1839224145Sdim  CXCursor_MacroExpansion                = 502,
1840224145Sdim  CXCursor_MacroInstantiation            = CXCursor_MacroExpansion,
1841218893Sdim  CXCursor_InclusionDirective            = 503,
1842205408Srdivacky  CXCursor_FirstPreprocessing            = CXCursor_PreprocessingDirective,
1843218893Sdim  CXCursor_LastPreprocessing             = CXCursor_InclusionDirective
1844202879Srdivacky};
1845202379Srdivacky
1846202879Srdivacky/**
1847202879Srdivacky * \brief A cursor representing some element in the abstract syntax tree for
1848202879Srdivacky * a translation unit.
1849202879Srdivacky *
1850203955Srdivacky * The cursor abstraction unifies the different kinds of entities in a
1851202879Srdivacky * program--declaration, statements, expressions, references to declarations,
1852202879Srdivacky * etc.--under a single "cursor" abstraction with a common set of operations.
1853202879Srdivacky * Common operation for a cursor include: getting the physical location in
1854202879Srdivacky * a source file where the cursor points, getting the name associated with a
1855202879Srdivacky * cursor, and retrieving cursors for any child nodes of a particular cursor.
1856202879Srdivacky *
1857202879Srdivacky * Cursors can be produced in two specific ways.
1858202879Srdivacky * clang_getTranslationUnitCursor() produces a cursor for a translation unit,
1859202879Srdivacky * from which one can use clang_visitChildren() to explore the rest of the
1860202879Srdivacky * translation unit. clang_getCursor() maps from a physical source location
1861202879Srdivacky * to the entity that resides at that location, allowing one to map from the
1862202879Srdivacky * source code into the AST.
1863198092Srdivacky */
1864202879Srdivackytypedef struct {
1865202879Srdivacky  enum CXCursorKind kind;
1866226633Sdim  int xdata;
1867202879Srdivacky  void *data[3];
1868203955Srdivacky} CXCursor;
1869202879Srdivacky
1870198398Srdivacky/**
1871202879Srdivacky * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations
1872202879Srdivacky *
1873202879Srdivacky * @{
1874198398Srdivacky */
1875203955Srdivacky
1876202879Srdivacky/**
1877202879Srdivacky * \brief Retrieve the NULL cursor, which represents no entity.
1878202879Srdivacky */
1879199482SrdivackyCINDEX_LINKAGE CXCursor clang_getNullCursor(void);
1880203955Srdivacky
1881202879Srdivacky/**
1882202879Srdivacky * \brief Retrieve the cursor that represents the given translation unit.
1883202879Srdivacky *
1884202879Srdivacky * The translation unit cursor can be used to start traversing the
1885202879Srdivacky * various declarations within the given translation unit.
1886202879Srdivacky */
1887202879SrdivackyCINDEX_LINKAGE CXCursor clang_getTranslationUnitCursor(CXTranslationUnit);
1888198092Srdivacky
1889202879Srdivacky/**
1890202879Srdivacky * \brief Determine whether two cursors are equivalent.
1891202879Srdivacky */
1892202879SrdivackyCINDEX_LINKAGE unsigned clang_equalCursors(CXCursor, CXCursor);
1893203955Srdivacky
1894202879Srdivacky/**
1895226633Sdim * \brief Returns non-zero if \arg cursor is null.
1896226633Sdim */
1897226633Sdimint clang_Cursor_isNull(CXCursor);
1898226633Sdim
1899226633Sdim/**
1900218893Sdim * \brief Compute a hash value for the given cursor.
1901218893Sdim */
1902218893SdimCINDEX_LINKAGE unsigned clang_hashCursor(CXCursor);
1903218893Sdim
1904218893Sdim/**
1905202879Srdivacky * \brief Retrieve the kind of the given cursor.
1906202879Srdivacky */
1907198893SrdivackyCINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor);
1908202879Srdivacky
1909202879Srdivacky/**
1910202879Srdivacky * \brief Determine whether the given cursor kind represents a declaration.
1911202879Srdivacky */
1912198893SrdivackyCINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind);
1913202879Srdivacky
1914202879Srdivacky/**
1915202879Srdivacky * \brief Determine whether the given cursor kind represents a simple
1916202879Srdivacky * reference.
1917202879Srdivacky *
1918202879Srdivacky * Note that other kinds of cursors (such as expressions) can also refer to
1919202879Srdivacky * other cursors. Use clang_getCursorReferenced() to determine whether a
1920202879Srdivacky * particular cursor refers to another entity.
1921202879Srdivacky */
1922198893SrdivackyCINDEX_LINKAGE unsigned clang_isReference(enum CXCursorKind);
1923202879Srdivacky
1924202879Srdivacky/**
1925202879Srdivacky * \brief Determine whether the given cursor kind represents an expression.
1926202879Srdivacky */
1927202879SrdivackyCINDEX_LINKAGE unsigned clang_isExpression(enum CXCursorKind);
1928202879Srdivacky
1929202879Srdivacky/**
1930202879Srdivacky * \brief Determine whether the given cursor kind represents a statement.
1931202879Srdivacky */
1932202879SrdivackyCINDEX_LINKAGE unsigned clang_isStatement(enum CXCursorKind);
1933202879Srdivacky
1934202879Srdivacky/**
1935224145Sdim * \brief Determine whether the given cursor kind represents an attribute.
1936224145Sdim */
1937224145SdimCINDEX_LINKAGE unsigned clang_isAttribute(enum CXCursorKind);
1938224145Sdim
1939224145Sdim/**
1940203955Srdivacky * \brief Determine whether the given cursor kind represents an invalid
1941202879Srdivacky * cursor.
1942203955Srdivacky */
1943198893SrdivackyCINDEX_LINKAGE unsigned clang_isInvalid(enum CXCursorKind);
1944198398Srdivacky
1945202879Srdivacky/**
1946203955Srdivacky * \brief Determine whether the given cursor kind represents a translation
1947203955Srdivacky * unit.
1948202879Srdivacky */
1949202879SrdivackyCINDEX_LINKAGE unsigned clang_isTranslationUnit(enum CXCursorKind);
1950203955Srdivacky
1951204962Srdivacky/***
1952205408Srdivacky * \brief Determine whether the given cursor represents a preprocessing
1953205408Srdivacky * element, such as a preprocessor directive or macro instantiation.
1954205408Srdivacky */
1955205408SrdivackyCINDEX_LINKAGE unsigned clang_isPreprocessing(enum CXCursorKind);
1956205408Srdivacky
1957205408Srdivacky/***
1958204962Srdivacky * \brief Determine whether the given cursor represents a currently
1959204962Srdivacky *  unexposed piece of the AST (e.g., CXCursor_UnexposedStmt).
1960204962Srdivacky */
1961204962SrdivackyCINDEX_LINKAGE unsigned clang_isUnexposed(enum CXCursorKind);
1962204962Srdivacky
1963202879Srdivacky/**
1964204643Srdivacky * \brief Describe the linkage of the entity referred to by a cursor.
1965204643Srdivacky */
1966204643Srdivackyenum CXLinkageKind {
1967204643Srdivacky  /** \brief This value indicates that no linkage information is available
1968204643Srdivacky   * for a provided CXCursor. */
1969204643Srdivacky  CXLinkage_Invalid,
1970204643Srdivacky  /**
1971204643Srdivacky   * \brief This is the linkage for variables, parameters, and so on that
1972204643Srdivacky   *  have automatic storage.  This covers normal (non-extern) local variables.
1973204643Srdivacky   */
1974204643Srdivacky  CXLinkage_NoLinkage,
1975204643Srdivacky  /** \brief This is the linkage for static variables and static functions. */
1976204643Srdivacky  CXLinkage_Internal,
1977204643Srdivacky  /** \brief This is the linkage for entities with external linkage that live
1978204643Srdivacky   * in C++ anonymous namespaces.*/
1979204643Srdivacky  CXLinkage_UniqueExternal,
1980204643Srdivacky  /** \brief This is the linkage for entities with true, external linkage. */
1981204643Srdivacky  CXLinkage_External
1982204643Srdivacky};
1983204643Srdivacky
1984204643Srdivacky/**
1985207619Srdivacky * \brief Determine the linkage of the entity referred to by a given cursor.
1986204643Srdivacky */
1987204643SrdivackyCINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor);
1988204643Srdivacky
1989204643Srdivacky/**
1990212904Sdim * \brief Determine the availability of the entity that this cursor refers to.
1991212904Sdim *
1992212904Sdim * \param cursor The cursor to query.
1993212904Sdim *
1994212904Sdim * \returns The availability of the cursor.
1995212904Sdim */
1996212904SdimCINDEX_LINKAGE enum CXAvailabilityKind
1997212904Sdimclang_getCursorAvailability(CXCursor cursor);
1998212904Sdim
1999212904Sdim/**
2000207619Srdivacky * \brief Describe the "language" of the entity referred to by a cursor.
2001207619Srdivacky */
2002207619SrdivackyCINDEX_LINKAGE enum CXLanguageKind {
2003207619Srdivacky  CXLanguage_Invalid = 0,
2004207619Srdivacky  CXLanguage_C,
2005207619Srdivacky  CXLanguage_ObjC,
2006207619Srdivacky  CXLanguage_CPlusPlus
2007207619Srdivacky};
2008207619Srdivacky
2009207619Srdivacky/**
2010207619Srdivacky * \brief Determine the "language" of the entity referred to by a given cursor.
2011207619Srdivacky */
2012207619SrdivackyCINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor);
2013207619Srdivacky
2014226633Sdim/**
2015226633Sdim * \brief Returns the translation unit that a cursor originated from.
2016226633Sdim */
2017226633SdimCINDEX_LINKAGE CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor);
2018218893Sdim
2019226633Sdim
2020207619Srdivacky/**
2021218893Sdim * \brief A fast container representing a set of CXCursors.
2022218893Sdim */
2023218893Sdimtypedef struct CXCursorSetImpl *CXCursorSet;
2024218893Sdim
2025218893Sdim/**
2026218893Sdim * \brief Creates an empty CXCursorSet.
2027218893Sdim */
2028218893SdimCINDEX_LINKAGE CXCursorSet clang_createCXCursorSet();
2029218893Sdim
2030218893Sdim/**
2031218893Sdim * \brief Disposes a CXCursorSet and releases its associated memory.
2032218893Sdim */
2033218893SdimCINDEX_LINKAGE void clang_disposeCXCursorSet(CXCursorSet cset);
2034218893Sdim
2035218893Sdim/**
2036218893Sdim * \brief Queries a CXCursorSet to see if it contains a specific CXCursor.
2037218893Sdim *
2038218893Sdim * \returns non-zero if the set contains the specified cursor.
2039218893Sdim*/
2040218893SdimCINDEX_LINKAGE unsigned clang_CXCursorSet_contains(CXCursorSet cset,
2041218893Sdim                                                   CXCursor cursor);
2042218893Sdim
2043218893Sdim/**
2044218893Sdim * \brief Inserts a CXCursor into a CXCursorSet.
2045218893Sdim *
2046218893Sdim * \returns zero if the CXCursor was already in the set, and non-zero otherwise.
2047218893Sdim*/
2048218893SdimCINDEX_LINKAGE unsigned clang_CXCursorSet_insert(CXCursorSet cset,
2049218893Sdim                                                 CXCursor cursor);
2050218893Sdim
2051218893Sdim/**
2052218893Sdim * \brief Determine the semantic parent of the given cursor.
2053218893Sdim *
2054218893Sdim * The semantic parent of a cursor is the cursor that semantically contains
2055218893Sdim * the given \p cursor. For many declarations, the lexical and semantic parents
2056218893Sdim * are equivalent (the lexical parent is returned by
2057218893Sdim * \c clang_getCursorLexicalParent()). They diverge when declarations or
2058218893Sdim * definitions are provided out-of-line. For example:
2059218893Sdim *
2060218893Sdim * \code
2061218893Sdim * class C {
2062218893Sdim *  void f();
2063218893Sdim * };
2064218893Sdim *
2065218893Sdim * void C::f() { }
2066218893Sdim * \endcode
2067218893Sdim *
2068218893Sdim * In the out-of-line definition of \c C::f, the semantic parent is the
2069218893Sdim * the class \c C, of which this function is a member. The lexical parent is
2070218893Sdim * the place where the declaration actually occurs in the source code; in this
2071218893Sdim * case, the definition occurs in the translation unit. In general, the
2072218893Sdim * lexical parent for a given entity can change without affecting the semantics
2073218893Sdim * of the program, and the lexical parent of different declarations of the
2074218893Sdim * same entity may be different. Changing the semantic parent of a declaration,
2075218893Sdim * on the other hand, can have a major impact on semantics, and redeclarations
2076218893Sdim * of a particular entity should all have the same semantic context.
2077218893Sdim *
2078218893Sdim * In the example above, both declarations of \c C::f have \c C as their
2079218893Sdim * semantic context, while the lexical context of the first \c C::f is \c C
2080218893Sdim * and the lexical context of the second \c C::f is the translation unit.
2081218893Sdim *
2082218893Sdim * For global declarations, the semantic parent is the translation unit.
2083218893Sdim */
2084218893SdimCINDEX_LINKAGE CXCursor clang_getCursorSemanticParent(CXCursor cursor);
2085218893Sdim
2086218893Sdim/**
2087218893Sdim * \brief Determine the lexical parent of the given cursor.
2088218893Sdim *
2089218893Sdim * The lexical parent of a cursor is the cursor in which the given \p cursor
2090218893Sdim * was actually written. For many declarations, the lexical and semantic parents
2091218893Sdim * are equivalent (the semantic parent is returned by
2092218893Sdim * \c clang_getCursorSemanticParent()). They diverge when declarations or
2093218893Sdim * definitions are provided out-of-line. For example:
2094218893Sdim *
2095218893Sdim * \code
2096218893Sdim * class C {
2097218893Sdim *  void f();
2098218893Sdim * };
2099218893Sdim *
2100218893Sdim * void C::f() { }
2101218893Sdim * \endcode
2102218893Sdim *
2103218893Sdim * In the out-of-line definition of \c C::f, the semantic parent is the
2104218893Sdim * the class \c C, of which this function is a member. The lexical parent is
2105218893Sdim * the place where the declaration actually occurs in the source code; in this
2106218893Sdim * case, the definition occurs in the translation unit. In general, the
2107218893Sdim * lexical parent for a given entity can change without affecting the semantics
2108218893Sdim * of the program, and the lexical parent of different declarations of the
2109218893Sdim * same entity may be different. Changing the semantic parent of a declaration,
2110218893Sdim * on the other hand, can have a major impact on semantics, and redeclarations
2111218893Sdim * of a particular entity should all have the same semantic context.
2112218893Sdim *
2113218893Sdim * In the example above, both declarations of \c C::f have \c C as their
2114218893Sdim * semantic context, while the lexical context of the first \c C::f is \c C
2115218893Sdim * and the lexical context of the second \c C::f is the translation unit.
2116218893Sdim *
2117218893Sdim * For declarations written in the global scope, the lexical parent is
2118218893Sdim * the translation unit.
2119218893Sdim */
2120218893SdimCINDEX_LINKAGE CXCursor clang_getCursorLexicalParent(CXCursor cursor);
2121218893Sdim
2122218893Sdim/**
2123218893Sdim * \brief Determine the set of methods that are overridden by the given
2124218893Sdim * method.
2125218893Sdim *
2126218893Sdim * In both Objective-C and C++, a method (aka virtual member function,
2127218893Sdim * in C++) can override a virtual method in a base class. For
2128218893Sdim * Objective-C, a method is said to override any method in the class's
2129218893Sdim * interface (if we're coming from an implementation), its protocols,
2130218893Sdim * or its categories, that has the same selector and is of the same
2131218893Sdim * kind (class or instance). If no such method exists, the search
2132218893Sdim * continues to the class's superclass, its protocols, and its
2133218893Sdim * categories, and so on.
2134218893Sdim *
2135218893Sdim * For C++, a virtual member function overrides any virtual member
2136218893Sdim * function with the same signature that occurs in its base
2137218893Sdim * classes. With multiple inheritance, a virtual member function can
2138218893Sdim * override several virtual member functions coming from different
2139218893Sdim * base classes.
2140218893Sdim *
2141218893Sdim * In all cases, this function determines the immediate overridden
2142218893Sdim * method, rather than all of the overridden methods. For example, if
2143218893Sdim * a method is originally declared in a class A, then overridden in B
2144218893Sdim * (which in inherits from A) and also in C (which inherited from B),
2145218893Sdim * then the only overridden method returned from this function when
2146218893Sdim * invoked on C's method will be B's method. The client may then
2147218893Sdim * invoke this function again, given the previously-found overridden
2148218893Sdim * methods, to map out the complete method-override set.
2149218893Sdim *
2150218893Sdim * \param cursor A cursor representing an Objective-C or C++
2151218893Sdim * method. This routine will compute the set of methods that this
2152218893Sdim * method overrides.
2153218893Sdim *
2154218893Sdim * \param overridden A pointer whose pointee will be replaced with a
2155218893Sdim * pointer to an array of cursors, representing the set of overridden
2156218893Sdim * methods. If there are no overridden methods, the pointee will be
2157218893Sdim * set to NULL. The pointee must be freed via a call to
2158218893Sdim * \c clang_disposeOverriddenCursors().
2159218893Sdim *
2160218893Sdim * \param num_overridden A pointer to the number of overridden
2161218893Sdim * functions, will be set to the number of overridden functions in the
2162218893Sdim * array pointed to by \p overridden.
2163218893Sdim */
2164218893SdimCINDEX_LINKAGE void clang_getOverriddenCursors(CXCursor cursor,
2165218893Sdim                                               CXCursor **overridden,
2166218893Sdim                                               unsigned *num_overridden);
2167218893Sdim
2168218893Sdim/**
2169218893Sdim * \brief Free the set of overridden cursors returned by \c
2170218893Sdim * clang_getOverriddenCursors().
2171218893Sdim */
2172218893SdimCINDEX_LINKAGE void clang_disposeOverriddenCursors(CXCursor *overridden);
2173218893Sdim
2174218893Sdim/**
2175218893Sdim * \brief Retrieve the file that is included by the given inclusion directive
2176218893Sdim * cursor.
2177218893Sdim */
2178218893SdimCINDEX_LINKAGE CXFile clang_getIncludedFile(CXCursor cursor);
2179218893Sdim
2180218893Sdim/**
2181202879Srdivacky * @}
2182202879Srdivacky */
2183203955Srdivacky
2184202879Srdivacky/**
2185202879Srdivacky * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code
2186202879Srdivacky *
2187202879Srdivacky * Cursors represent a location within the Abstract Syntax Tree (AST). These
2188202879Srdivacky * routines help map between cursors and the physical locations where the
2189202879Srdivacky * described entities occur in the source code. The mapping is provided in
2190202879Srdivacky * both directions, so one can map from source code to the AST and back.
2191202879Srdivacky *
2192202879Srdivacky * @{
2193202879Srdivacky */
2194203955Srdivacky
2195202879Srdivacky/**
2196202879Srdivacky * \brief Map a source location to the cursor that describes the entity at that
2197202879Srdivacky * location in the source code.
2198202879Srdivacky *
2199202879Srdivacky * clang_getCursor() maps an arbitrary source location within a translation
2200202879Srdivacky * unit down to the most specific cursor that describes the entity at that
2201203955Srdivacky * location. For example, given an expression \c x + y, invoking
2202202879Srdivacky * clang_getCursor() with a source location pointing to "x" will return the
2203203955Srdivacky * cursor for "x"; similarly for "y". If the cursor points anywhere between
2204202879Srdivacky * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor()
2205202879Srdivacky * will return a cursor referring to the "+" expression.
2206202879Srdivacky *
2207202879Srdivacky * \returns a cursor representing the entity at the given source location, or
2208202879Srdivacky * a NULL cursor if no such entity can be found.
2209202879Srdivacky */
2210202879SrdivackyCINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, CXSourceLocation);
2211203955Srdivacky
2212202879Srdivacky/**
2213202879Srdivacky * \brief Retrieve the physical location of the source constructor referenced
2214202879Srdivacky * by the given cursor.
2215202879Srdivacky *
2216202879Srdivacky * The location of a declaration is typically the location of the name of that
2217203955Srdivacky * declaration, where the name of that declaration would occur if it is
2218203955Srdivacky * unnamed, or some keyword that introduces that particular declaration.
2219203955Srdivacky * The location of a reference is where that reference occurs within the
2220202879Srdivacky * source code.
2221202879Srdivacky */
2222202879SrdivackyCINDEX_LINKAGE CXSourceLocation clang_getCursorLocation(CXCursor);
2223199482Srdivacky
2224202879Srdivacky/**
2225202879Srdivacky * \brief Retrieve the physical extent of the source construct referenced by
2226202879Srdivacky * the given cursor.
2227202879Srdivacky *
2228202879Srdivacky * The extent of a cursor starts with the file/line/column pointing at the
2229202879Srdivacky * first character within the source construct that the cursor refers to and
2230203955Srdivacky * ends with the last character withinin that source construct. For a
2231202879Srdivacky * declaration, the extent covers the declaration itself. For a reference,
2232202879Srdivacky * the extent covers the location of the reference (e.g., where the referenced
2233202879Srdivacky * entity was actually used).
2234202879Srdivacky */
2235202879SrdivackyCINDEX_LINKAGE CXSourceRange clang_getCursorExtent(CXCursor);
2236202879Srdivacky
2237202879Srdivacky/**
2238202879Srdivacky * @}
2239202879Srdivacky */
2240212904Sdim
2241202879Srdivacky/**
2242208600Srdivacky * \defgroup CINDEX_TYPES Type information for CXCursors
2243208600Srdivacky *
2244208600Srdivacky * @{
2245208600Srdivacky */
2246208600Srdivacky
2247208600Srdivacky/**
2248208600Srdivacky * \brief Describes the kind of type
2249208600Srdivacky */
2250208600Srdivackyenum CXTypeKind {
2251208600Srdivacky  /**
2252208600Srdivacky   * \brief Reprents an invalid type (e.g., where no type is available).
2253208600Srdivacky   */
2254208600Srdivacky  CXType_Invalid = 0,
2255208600Srdivacky
2256208600Srdivacky  /**
2257208600Srdivacky   * \brief A type whose specific kind is not exposed via this
2258208600Srdivacky   * interface.
2259208600Srdivacky   */
2260208600Srdivacky  CXType_Unexposed = 1,
2261208600Srdivacky
2262208600Srdivacky  /* Builtin types */
2263208600Srdivacky  CXType_Void = 2,
2264208600Srdivacky  CXType_Bool = 3,
2265208600Srdivacky  CXType_Char_U = 4,
2266208600Srdivacky  CXType_UChar = 5,
2267208600Srdivacky  CXType_Char16 = 6,
2268208600Srdivacky  CXType_Char32 = 7,
2269208600Srdivacky  CXType_UShort = 8,
2270208600Srdivacky  CXType_UInt = 9,
2271208600Srdivacky  CXType_ULong = 10,
2272208600Srdivacky  CXType_ULongLong = 11,
2273208600Srdivacky  CXType_UInt128 = 12,
2274208600Srdivacky  CXType_Char_S = 13,
2275208600Srdivacky  CXType_SChar = 14,
2276208600Srdivacky  CXType_WChar = 15,
2277208600Srdivacky  CXType_Short = 16,
2278208600Srdivacky  CXType_Int = 17,
2279208600Srdivacky  CXType_Long = 18,
2280208600Srdivacky  CXType_LongLong = 19,
2281208600Srdivacky  CXType_Int128 = 20,
2282208600Srdivacky  CXType_Float = 21,
2283208600Srdivacky  CXType_Double = 22,
2284208600Srdivacky  CXType_LongDouble = 23,
2285208600Srdivacky  CXType_NullPtr = 24,
2286208600Srdivacky  CXType_Overload = 25,
2287208600Srdivacky  CXType_Dependent = 26,
2288208600Srdivacky  CXType_ObjCId = 27,
2289208600Srdivacky  CXType_ObjCClass = 28,
2290208600Srdivacky  CXType_ObjCSel = 29,
2291208600Srdivacky  CXType_FirstBuiltin = CXType_Void,
2292208600Srdivacky  CXType_LastBuiltin  = CXType_ObjCSel,
2293208600Srdivacky
2294208600Srdivacky  CXType_Complex = 100,
2295208600Srdivacky  CXType_Pointer = 101,
2296208600Srdivacky  CXType_BlockPointer = 102,
2297208600Srdivacky  CXType_LValueReference = 103,
2298208600Srdivacky  CXType_RValueReference = 104,
2299208600Srdivacky  CXType_Record = 105,
2300208600Srdivacky  CXType_Enum = 106,
2301208600Srdivacky  CXType_Typedef = 107,
2302208600Srdivacky  CXType_ObjCInterface = 108,
2303210299Sed  CXType_ObjCObjectPointer = 109,
2304210299Sed  CXType_FunctionNoProto = 110,
2305226633Sdim  CXType_FunctionProto = 111,
2306226633Sdim  CXType_ConstantArray = 112
2307208600Srdivacky};
2308208600Srdivacky
2309208600Srdivacky/**
2310208600Srdivacky * \brief The type of an element in the abstract syntax tree.
2311208600Srdivacky *
2312208600Srdivacky */
2313208600Srdivackytypedef struct {
2314208600Srdivacky  enum CXTypeKind kind;
2315208600Srdivacky  void *data[2];
2316208600Srdivacky} CXType;
2317208600Srdivacky
2318208600Srdivacky/**
2319208600Srdivacky * \brief Retrieve the type of a CXCursor (if any).
2320208600Srdivacky */
2321208600SrdivackyCINDEX_LINKAGE CXType clang_getCursorType(CXCursor C);
2322208600Srdivacky
2323208600Srdivacky/**
2324208600Srdivacky * \determine Determine whether two CXTypes represent the same type.
2325208600Srdivacky *
2326208600Srdivacky * \returns non-zero if the CXTypes represent the same type and
2327208600Srdivacky            zero otherwise.
2328208600Srdivacky */
2329208600SrdivackyCINDEX_LINKAGE unsigned clang_equalTypes(CXType A, CXType B);
2330208600Srdivacky
2331208600Srdivacky/**
2332208600Srdivacky * \brief Return the canonical type for a CXType.
2333208600Srdivacky *
2334208600Srdivacky * Clang's type system explicitly models typedefs and all the ways
2335208600Srdivacky * a specific type can be represented.  The canonical type is the underlying
2336208600Srdivacky * type with all the "sugar" removed.  For example, if 'T' is a typedef
2337208600Srdivacky * for 'int', the canonical type for 'T' would be 'int'.
2338208600Srdivacky */
2339208600SrdivackyCINDEX_LINKAGE CXType clang_getCanonicalType(CXType T);
2340208600Srdivacky
2341208600Srdivacky/**
2342218893Sdim *  \determine Determine whether a CXType has the "const" qualifier set,
2343218893Sdim *  without looking through typedefs that may have added "const" at a different level.
2344218893Sdim */
2345218893SdimCINDEX_LINKAGE unsigned clang_isConstQualifiedType(CXType T);
2346218893Sdim
2347218893Sdim/**
2348218893Sdim *  \determine Determine whether a CXType has the "volatile" qualifier set,
2349218893Sdim *  without looking through typedefs that may have added "volatile" at a different level.
2350218893Sdim */
2351218893SdimCINDEX_LINKAGE unsigned clang_isVolatileQualifiedType(CXType T);
2352218893Sdim
2353218893Sdim/**
2354218893Sdim *  \determine Determine whether a CXType has the "restrict" qualifier set,
2355218893Sdim *  without looking through typedefs that may have added "restrict" at a different level.
2356218893Sdim */
2357218893SdimCINDEX_LINKAGE unsigned clang_isRestrictQualifiedType(CXType T);
2358218893Sdim
2359218893Sdim/**
2360208600Srdivacky * \brief For pointer types, returns the type of the pointee.
2361208600Srdivacky *
2362208600Srdivacky */
2363208600SrdivackyCINDEX_LINKAGE CXType clang_getPointeeType(CXType T);
2364208600Srdivacky
2365208600Srdivacky/**
2366208600Srdivacky * \brief Return the cursor for the declaration of the given type.
2367208600Srdivacky */
2368208600SrdivackyCINDEX_LINKAGE CXCursor clang_getTypeDeclaration(CXType T);
2369208600Srdivacky
2370218893Sdim/**
2371218893Sdim * Returns the Objective-C type encoding for the specified declaration.
2372218893Sdim */
2373218893SdimCINDEX_LINKAGE CXString clang_getDeclObjCTypeEncoding(CXCursor C);
2374208600Srdivacky
2375208600Srdivacky/**
2376208600Srdivacky * \brief Retrieve the spelling of a given CXTypeKind.
2377208600Srdivacky */
2378208600SrdivackyCINDEX_LINKAGE CXString clang_getTypeKindSpelling(enum CXTypeKind K);
2379208600Srdivacky
2380208600Srdivacky/**
2381210299Sed * \brief Retrieve the result type associated with a function type.
2382210299Sed */
2383210299SedCINDEX_LINKAGE CXType clang_getResultType(CXType T);
2384210299Sed
2385210299Sed/**
2386210299Sed * \brief Retrieve the result type associated with a given cursor.  This only
2387210299Sed *  returns a valid type of the cursor refers to a function or method.
2388210299Sed */
2389210299SedCINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C);
2390210299Sed
2391210299Sed/**
2392212904Sdim * \brief Return 1 if the CXType is a POD (plain old data) type, and 0
2393212904Sdim *  otherwise.
2394212904Sdim */
2395212904SdimCINDEX_LINKAGE unsigned clang_isPODType(CXType T);
2396212904Sdim
2397212904Sdim/**
2398226633Sdim * \brief Return the element type of an array type.
2399226633Sdim *
2400226633Sdim * If a non-array type is passed in, an invalid type is returned.
2401226633Sdim */
2402226633SdimCINDEX_LINKAGE CXType clang_getArrayElementType(CXType T);
2403226633Sdim
2404226633Sdim/**
2405226633Sdim * \brief Return the the array size of a constant array.
2406226633Sdim *
2407226633Sdim * If a non-array type is passed in, -1 is returned.
2408226633Sdim */
2409226633SdimCINDEX_LINKAGE long long clang_getArraySize(CXType T);
2410226633Sdim
2411226633Sdim/**
2412212904Sdim * \brief Returns 1 if the base class specified by the cursor with kind
2413212904Sdim *   CX_CXXBaseSpecifier is virtual.
2414212904Sdim */
2415212904SdimCINDEX_LINKAGE unsigned clang_isVirtualBase(CXCursor);
2416212904Sdim
2417212904Sdim/**
2418212904Sdim * \brief Represents the C++ access control level to a base class for a
2419212904Sdim * cursor with kind CX_CXXBaseSpecifier.
2420212904Sdim */
2421212904Sdimenum CX_CXXAccessSpecifier {
2422212904Sdim  CX_CXXInvalidAccessSpecifier,
2423212904Sdim  CX_CXXPublic,
2424212904Sdim  CX_CXXProtected,
2425212904Sdim  CX_CXXPrivate
2426212904Sdim};
2427212904Sdim
2428212904Sdim/**
2429212904Sdim * \brief Returns the access control level for the C++ base specifier
2430226633Sdim * represented by a cursor with kind CXCursor_CXXBaseSpecifier or
2431226633Sdim * CXCursor_AccessSpecifier.
2432212904Sdim */
2433212904SdimCINDEX_LINKAGE enum CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor);
2434212904Sdim
2435212904Sdim/**
2436218893Sdim * \brief Determine the number of overloaded declarations referenced by a
2437218893Sdim * \c CXCursor_OverloadedDeclRef cursor.
2438218893Sdim *
2439218893Sdim * \param cursor The cursor whose overloaded declarations are being queried.
2440218893Sdim *
2441218893Sdim * \returns The number of overloaded declarations referenced by \c cursor. If it
2442218893Sdim * is not a \c CXCursor_OverloadedDeclRef cursor, returns 0.
2443218893Sdim */
2444218893SdimCINDEX_LINKAGE unsigned clang_getNumOverloadedDecls(CXCursor cursor);
2445218893Sdim
2446218893Sdim/**
2447218893Sdim * \brief Retrieve a cursor for one of the overloaded declarations referenced
2448218893Sdim * by a \c CXCursor_OverloadedDeclRef cursor.
2449218893Sdim *
2450218893Sdim * \param cursor The cursor whose overloaded declarations are being queried.
2451218893Sdim *
2452218893Sdim * \param index The zero-based index into the set of overloaded declarations in
2453218893Sdim * the cursor.
2454218893Sdim *
2455218893Sdim * \returns A cursor representing the declaration referenced by the given
2456218893Sdim * \c cursor at the specified \c index. If the cursor does not have an
2457218893Sdim * associated set of overloaded declarations, or if the index is out of bounds,
2458218893Sdim * returns \c clang_getNullCursor();
2459218893Sdim */
2460218893SdimCINDEX_LINKAGE CXCursor clang_getOverloadedDecl(CXCursor cursor,
2461218893Sdim                                                unsigned index);
2462218893Sdim
2463218893Sdim/**
2464208600Srdivacky * @}
2465208600Srdivacky */
2466212904Sdim
2467212904Sdim/**
2468212904Sdim * \defgroup CINDEX_ATTRIBUTES Information for attributes
2469212904Sdim *
2470212904Sdim * @{
2471212904Sdim */
2472208600Srdivacky
2473212904Sdim
2474208600Srdivacky/**
2475212904Sdim * \brief For cursors representing an iboutletcollection attribute,
2476212904Sdim *  this function returns the collection element type.
2477212904Sdim *
2478212904Sdim */
2479212904SdimCINDEX_LINKAGE CXType clang_getIBOutletCollectionType(CXCursor);
2480212904Sdim
2481212904Sdim/**
2482212904Sdim * @}
2483212904Sdim */
2484212904Sdim
2485212904Sdim/**
2486202879Srdivacky * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors
2487202879Srdivacky *
2488202879Srdivacky * These routines provide the ability to traverse the abstract syntax tree
2489202879Srdivacky * using cursors.
2490202879Srdivacky *
2491202879Srdivacky * @{
2492202879Srdivacky */
2493203955Srdivacky
2494202879Srdivacky/**
2495202879Srdivacky * \brief Describes how the traversal of the children of a particular
2496202879Srdivacky * cursor should proceed after visiting a particular child cursor.
2497202879Srdivacky *
2498202879Srdivacky * A value of this enumeration type should be returned by each
2499202879Srdivacky * \c CXCursorVisitor to indicate how clang_visitChildren() proceed.
2500202879Srdivacky */
2501202879Srdivackyenum CXChildVisitResult {
2502202879Srdivacky  /**
2503203955Srdivacky   * \brief Terminates the cursor traversal.
2504202879Srdivacky   */
2505202879Srdivacky  CXChildVisit_Break,
2506203955Srdivacky  /**
2507202879Srdivacky   * \brief Continues the cursor traversal with the next sibling of
2508202879Srdivacky   * the cursor just visited, without visiting its children.
2509202879Srdivacky   */
2510202879Srdivacky  CXChildVisit_Continue,
2511202879Srdivacky  /**
2512202879Srdivacky   * \brief Recursively traverse the children of this cursor, using
2513202879Srdivacky   * the same visitor and client data.
2514202879Srdivacky   */
2515202879Srdivacky  CXChildVisit_Recurse
2516202879Srdivacky};
2517202879Srdivacky
2518202879Srdivacky/**
2519202879Srdivacky * \brief Visitor invoked for each cursor found by a traversal.
2520202879Srdivacky *
2521202879Srdivacky * This visitor function will be invoked for each cursor found by
2522202879Srdivacky * clang_visitCursorChildren(). Its first argument is the cursor being
2523202879Srdivacky * visited, its second argument is the parent visitor for that cursor,
2524202879Srdivacky * and its third argument is the client data provided to
2525202879Srdivacky * clang_visitCursorChildren().
2526202879Srdivacky *
2527202879Srdivacky * The visitor should return one of the \c CXChildVisitResult values
2528202879Srdivacky * to direct clang_visitCursorChildren().
2529202879Srdivacky */
2530203955Srdivackytypedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor,
2531203955Srdivacky                                                   CXCursor parent,
2532202879Srdivacky                                                   CXClientData client_data);
2533202879Srdivacky
2534202879Srdivacky/**
2535202879Srdivacky * \brief Visit the children of a particular cursor.
2536202879Srdivacky *
2537202879Srdivacky * This function visits all the direct children of the given cursor,
2538202879Srdivacky * invoking the given \p visitor function with the cursors of each
2539202879Srdivacky * visited child. The traversal may be recursive, if the visitor returns
2540202879Srdivacky * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if
2541202879Srdivacky * the visitor returns \c CXChildVisit_Break.
2542202879Srdivacky *
2543202879Srdivacky * \param parent the cursor whose child may be visited. All kinds of
2544203955Srdivacky * cursors can be visited, including invalid cursors (which, by
2545202879Srdivacky * definition, have no children).
2546202879Srdivacky *
2547202879Srdivacky * \param visitor the visitor function that will be invoked for each
2548202879Srdivacky * child of \p parent.
2549202879Srdivacky *
2550202879Srdivacky * \param client_data pointer data supplied by the client, which will
2551202879Srdivacky * be passed to the visitor each time it is invoked.
2552202879Srdivacky *
2553202879Srdivacky * \returns a non-zero value if the traversal was terminated
2554202879Srdivacky * prematurely by the visitor returning \c CXChildVisit_Break.
2555202879Srdivacky */
2556203955SrdivackyCINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent,
2557202879Srdivacky                                            CXCursorVisitor visitor,
2558202879Srdivacky                                            CXClientData client_data);
2559218893Sdim#ifdef __has_feature
2560218893Sdim#  if __has_feature(blocks)
2561218893Sdim/**
2562218893Sdim * \brief Visitor invoked for each cursor found by a traversal.
2563218893Sdim *
2564218893Sdim * This visitor block will be invoked for each cursor found by
2565218893Sdim * clang_visitChildrenWithBlock(). Its first argument is the cursor being
2566218893Sdim * visited, its second argument is the parent visitor for that cursor.
2567218893Sdim *
2568218893Sdim * The visitor should return one of the \c CXChildVisitResult values
2569218893Sdim * to direct clang_visitChildrenWithBlock().
2570218893Sdim */
2571218893Sdimtypedef enum CXChildVisitResult
2572218893Sdim     (^CXCursorVisitorBlock)(CXCursor cursor, CXCursor parent);
2573203955Srdivacky
2574202879Srdivacky/**
2575218893Sdim * Visits the children of a cursor using the specified block.  Behaves
2576218893Sdim * identically to clang_visitChildren() in all other respects.
2577218893Sdim */
2578218893Sdimunsigned clang_visitChildrenWithBlock(CXCursor parent,
2579218893Sdim                                      CXCursorVisitorBlock block);
2580218893Sdim#  endif
2581218893Sdim#endif
2582218893Sdim
2583218893Sdim/**
2584202879Srdivacky * @}
2585202879Srdivacky */
2586203955Srdivacky
2587202879Srdivacky/**
2588202879Srdivacky * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST
2589202879Srdivacky *
2590203955Srdivacky * These routines provide the ability to determine references within and
2591202879Srdivacky * across translation units, by providing the names of the entities referenced
2592202879Srdivacky * by cursors, follow reference cursors to the declarations they reference,
2593202879Srdivacky * and associate declarations with their definitions.
2594202879Srdivacky *
2595202879Srdivacky * @{
2596202879Srdivacky */
2597203955Srdivacky
2598202879Srdivacky/**
2599202879Srdivacky * \brief Retrieve a Unified Symbol Resolution (USR) for the entity referenced
2600202879Srdivacky * by the given cursor.
2601202879Srdivacky *
2602202879Srdivacky * A Unified Symbol Resolution (USR) is a string that identifies a particular
2603202879Srdivacky * entity (function, class, variable, etc.) within a program. USRs can be
2604202879Srdivacky * compared across translation units to determine, e.g., when references in
2605202879Srdivacky * one translation refer to an entity defined in another translation unit.
2606202879Srdivacky */
2607202879SrdivackyCINDEX_LINKAGE CXString clang_getCursorUSR(CXCursor);
2608202879Srdivacky
2609202879Srdivacky/**
2610205219Srdivacky * \brief Construct a USR for a specified Objective-C class.
2611205219Srdivacky */
2612205219SrdivackyCINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name);
2613205219Srdivacky
2614205219Srdivacky/**
2615205219Srdivacky * \brief Construct a USR for a specified Objective-C category.
2616205219Srdivacky */
2617205219SrdivackyCINDEX_LINKAGE CXString
2618205219Srdivacky  clang_constructUSR_ObjCCategory(const char *class_name,
2619205219Srdivacky                                 const char *category_name);
2620205219Srdivacky
2621205219Srdivacky/**
2622205219Srdivacky * \brief Construct a USR for a specified Objective-C protocol.
2623205219Srdivacky */
2624205219SrdivackyCINDEX_LINKAGE CXString
2625205219Srdivacky  clang_constructUSR_ObjCProtocol(const char *protocol_name);
2626205219Srdivacky
2627205219Srdivacky
2628205219Srdivacky/**
2629205219Srdivacky * \brief Construct a USR for a specified Objective-C instance variable and
2630205219Srdivacky *   the USR for its containing class.
2631205219Srdivacky */
2632205219SrdivackyCINDEX_LINKAGE CXString clang_constructUSR_ObjCIvar(const char *name,
2633205219Srdivacky                                                    CXString classUSR);
2634205219Srdivacky
2635205219Srdivacky/**
2636205219Srdivacky * \brief Construct a USR for a specified Objective-C method and
2637205219Srdivacky *   the USR for its containing class.
2638205219Srdivacky */
2639205219SrdivackyCINDEX_LINKAGE CXString clang_constructUSR_ObjCMethod(const char *name,
2640205219Srdivacky                                                      unsigned isInstanceMethod,
2641205219Srdivacky                                                      CXString classUSR);
2642205219Srdivacky
2643205219Srdivacky/**
2644205219Srdivacky * \brief Construct a USR for a specified Objective-C property and the USR
2645205219Srdivacky *  for its containing class.
2646205219Srdivacky */
2647205219SrdivackyCINDEX_LINKAGE CXString clang_constructUSR_ObjCProperty(const char *property,
2648205219Srdivacky                                                        CXString classUSR);
2649205219Srdivacky
2650205219Srdivacky/**
2651202879Srdivacky * \brief Retrieve a name for the entity referenced by this cursor.
2652202879Srdivacky */
2653199482SrdivackyCINDEX_LINKAGE CXString clang_getCursorSpelling(CXCursor);
2654198398Srdivacky
2655218893Sdim/**
2656218893Sdim * \brief Retrieve the display name for the entity referenced by this cursor.
2657218893Sdim *
2658218893Sdim * The display name contains extra information that helps identify the cursor,
2659218893Sdim * such as the parameters of a function or template or the arguments of a
2660218893Sdim * class template specialization.
2661218893Sdim */
2662218893SdimCINDEX_LINKAGE CXString clang_getCursorDisplayName(CXCursor);
2663218893Sdim
2664202879Srdivacky/** \brief For a cursor that is a reference, retrieve a cursor representing the
2665202879Srdivacky * entity that it references.
2666202879Srdivacky *
2667202879Srdivacky * Reference cursors refer to other entities in the AST. For example, an
2668202879Srdivacky * Objective-C superclass reference cursor refers to an Objective-C class.
2669203955Srdivacky * This function produces the cursor for the Objective-C class from the
2670202879Srdivacky * cursor for the superclass reference. If the input cursor is a declaration or
2671202879Srdivacky * definition, it returns that declaration or definition unchanged.
2672203955Srdivacky * Otherwise, returns the NULL cursor.
2673202879Srdivacky */
2674202879SrdivackyCINDEX_LINKAGE CXCursor clang_getCursorReferenced(CXCursor);
2675202879Srdivacky
2676203955Srdivacky/**
2677202879Srdivacky *  \brief For a cursor that is either a reference to or a declaration
2678202879Srdivacky *  of some entity, retrieve a cursor that describes the definition of
2679202879Srdivacky *  that entity.
2680202879Srdivacky *
2681202879Srdivacky *  Some entities can be declared multiple times within a translation
2682202879Srdivacky *  unit, but only one of those declarations can also be a
2683202879Srdivacky *  definition. For example, given:
2684202879Srdivacky *
2685202879Srdivacky *  \code
2686202879Srdivacky *  int f(int, int);
2687202879Srdivacky *  int g(int x, int y) { return f(x, y); }
2688202879Srdivacky *  int f(int a, int b) { return a + b; }
2689202879Srdivacky *  int f(int, int);
2690202879Srdivacky *  \endcode
2691202879Srdivacky *
2692202879Srdivacky *  there are three declarations of the function "f", but only the
2693202879Srdivacky *  second one is a definition. The clang_getCursorDefinition()
2694202879Srdivacky *  function will take any cursor pointing to a declaration of "f"
2695202879Srdivacky *  (the first or fourth lines of the example) or a cursor referenced
2696202879Srdivacky *  that uses "f" (the call to "f' inside "g") and will return a
2697202879Srdivacky *  declaration cursor pointing to the definition (the second "f"
2698202879Srdivacky *  declaration).
2699202879Srdivacky *
2700202879Srdivacky *  If given a cursor for which there is no corresponding definition,
2701202879Srdivacky *  e.g., because there is no definition of that entity within this
2702202879Srdivacky *  translation unit, returns a NULL cursor.
2703202879Srdivacky */
2704202879SrdivackyCINDEX_LINKAGE CXCursor clang_getCursorDefinition(CXCursor);
2705202879Srdivacky
2706203955Srdivacky/**
2707202879Srdivacky * \brief Determine whether the declaration pointed to by this cursor
2708202879Srdivacky * is also a definition of that entity.
2709202879Srdivacky */
2710202879SrdivackyCINDEX_LINKAGE unsigned clang_isCursorDefinition(CXCursor);
2711202879Srdivacky
2712202879Srdivacky/**
2713218893Sdim * \brief Retrieve the canonical cursor corresponding to the given cursor.
2714218893Sdim *
2715218893Sdim * In the C family of languages, many kinds of entities can be declared several
2716218893Sdim * times within a single translation unit. For example, a structure type can
2717218893Sdim * be forward-declared (possibly multiple times) and later defined:
2718218893Sdim *
2719218893Sdim * \code
2720218893Sdim * struct X;
2721218893Sdim * struct X;
2722218893Sdim * struct X {
2723218893Sdim *   int member;
2724218893Sdim * };
2725218893Sdim * \endcode
2726218893Sdim *
2727218893Sdim * The declarations and the definition of \c X are represented by three
2728218893Sdim * different cursors, all of which are declarations of the same underlying
2729218893Sdim * entity. One of these cursor is considered the "canonical" cursor, which
2730218893Sdim * is effectively the representative for the underlying entity. One can
2731218893Sdim * determine if two cursors are declarations of the same underlying entity by
2732218893Sdim * comparing their canonical cursors.
2733218893Sdim *
2734218893Sdim * \returns The canonical cursor for the entity referred to by the given cursor.
2735218893Sdim */
2736218893SdimCINDEX_LINKAGE CXCursor clang_getCanonicalCursor(CXCursor);
2737218893Sdim
2738218893Sdim/**
2739202879Srdivacky * @}
2740202879Srdivacky */
2741203955Srdivacky
2742203955Srdivacky/**
2743208600Srdivacky * \defgroup CINDEX_CPP C++ AST introspection
2744208600Srdivacky *
2745208600Srdivacky * The routines in this group provide access information in the ASTs specific
2746208600Srdivacky * to C++ language features.
2747208600Srdivacky *
2748208600Srdivacky * @{
2749208600Srdivacky */
2750208600Srdivacky
2751208600Srdivacky/**
2752212904Sdim * \brief Determine if a C++ member function or member function template is
2753212904Sdim * declared 'static'.
2754208600Srdivacky */
2755208600SrdivackyCINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C);
2756208600Srdivacky
2757208600Srdivacky/**
2758223017Sdim * \brief Determine if a C++ member function or member function template is
2759223017Sdim * explicitly declared 'virtual' or if it overrides a virtual method from
2760223017Sdim * one of the base classes.
2761223017Sdim */
2762223017SdimCINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual(CXCursor C);
2763223017Sdim
2764223017Sdim/**
2765212904Sdim * \brief Given a cursor that represents a template, determine
2766212904Sdim * the cursor kind of the specializations would be generated by instantiating
2767212904Sdim * the template.
2768212904Sdim *
2769212904Sdim * This routine can be used to determine what flavor of function template,
2770212904Sdim * class template, or class template partial specialization is stored in the
2771212904Sdim * cursor. For example, it can describe whether a class template cursor is
2772212904Sdim * declared with "struct", "class" or "union".
2773212904Sdim *
2774212904Sdim * \param C The cursor to query. This cursor should represent a template
2775212904Sdim * declaration.
2776212904Sdim *
2777212904Sdim * \returns The cursor kind of the specializations that would be generated
2778212904Sdim * by instantiating the template \p C. If \p C is not a template, returns
2779212904Sdim * \c CXCursor_NoDeclFound.
2780212904Sdim */
2781212904SdimCINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind(CXCursor C);
2782212904Sdim
2783212904Sdim/**
2784212904Sdim * \brief Given a cursor that may represent a specialization or instantiation
2785212904Sdim * of a template, retrieve the cursor that represents the template that it
2786212904Sdim * specializes or from which it was instantiated.
2787212904Sdim *
2788212904Sdim * This routine determines the template involved both for explicit
2789212904Sdim * specializations of templates and for implicit instantiations of the template,
2790212904Sdim * both of which are referred to as "specializations". For a class template
2791212904Sdim * specialization (e.g., \c std::vector<bool>), this routine will return
2792212904Sdim * either the primary template (\c std::vector) or, if the specialization was
2793212904Sdim * instantiated from a class template partial specialization, the class template
2794212904Sdim * partial specialization. For a class template partial specialization and a
2795212904Sdim * function template specialization (including instantiations), this
2796212904Sdim * this routine will return the specialized template.
2797212904Sdim *
2798212904Sdim * For members of a class template (e.g., member functions, member classes, or
2799212904Sdim * static data members), returns the specialized or instantiated member.
2800212904Sdim * Although not strictly "templates" in the C++ language, members of class
2801212904Sdim * templates have the same notions of specializations and instantiations that
2802212904Sdim * templates do, so this routine treats them similarly.
2803212904Sdim *
2804212904Sdim * \param C A cursor that may be a specialization of a template or a member
2805212904Sdim * of a template.
2806212904Sdim *
2807212904Sdim * \returns If the given cursor is a specialization or instantiation of a
2808212904Sdim * template or a member thereof, the template or member that it specializes or
2809212904Sdim * from which it was instantiated. Otherwise, returns a NULL cursor.
2810212904Sdim */
2811212904SdimCINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate(CXCursor C);
2812226633Sdim
2813226633Sdim/**
2814226633Sdim * \brief Given a cursor that references something else, return the source range
2815226633Sdim * covering that reference.
2816226633Sdim *
2817226633Sdim * \param C A cursor pointing to a member reference, a declaration reference, or
2818226633Sdim * an operator call.
2819226633Sdim * \param NameFlags A bitset with three independent flags:
2820226633Sdim * CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and
2821226633Sdim * CXNameRange_WantSinglePiece.
2822226633Sdim * \param PieceIndex For contiguous names or when passing the flag
2823226633Sdim * CXNameRange_WantSinglePiece, only one piece with index 0 is
2824226633Sdim * available. When the CXNameRange_WantSinglePiece flag is not passed for a
2825226633Sdim * non-contiguous names, this index can be used to retreive the individual
2826226633Sdim * pieces of the name. See also CXNameRange_WantSinglePiece.
2827226633Sdim *
2828226633Sdim * \returns The piece of the name pointed to by the given cursor. If there is no
2829226633Sdim * name, or if the PieceIndex is out-of-range, a null-cursor will be returned.
2830226633Sdim */
2831226633SdimCINDEX_LINKAGE CXSourceRange clang_getCursorReferenceNameRange(CXCursor C,
2832226633Sdim                                                unsigned NameFlags,
2833226633Sdim                                                unsigned PieceIndex);
2834226633Sdim
2835226633Sdimenum CXNameRefFlags {
2836226633Sdim  /**
2837226633Sdim   * \brief Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the
2838226633Sdim   * range.
2839226633Sdim   */
2840226633Sdim  CXNameRange_WantQualifier = 0x1,
2841212904Sdim
2842226633Sdim  /**
2843226633Sdim   * \brief Include the explicit template arguments, e.g. <int> in x.f<int>, in
2844226633Sdim   * the range.
2845226633Sdim   */
2846226633Sdim  CXNameRange_WantTemplateArgs = 0x2,
2847226633Sdim
2848226633Sdim  /**
2849226633Sdim   * \brief If the name is non-contiguous, return the full spanning range.
2850226633Sdim   *
2851226633Sdim   * Non-contiguous names occur in Objective-C when a selector with two or more
2852226633Sdim   * parameters is used, or in C++ when using an operator:
2853226633Sdim   * \code
2854226633Sdim   * [object doSomething:here withValue:there]; // ObjC
2855226633Sdim   * return some_vector[1]; // C++
2856226633Sdim   * \endcode
2857226633Sdim   */
2858226633Sdim  CXNameRange_WantSinglePiece = 0x4
2859226633Sdim};
2860226633Sdim
2861212904Sdim/**
2862208600Srdivacky * @}
2863208600Srdivacky */
2864208600Srdivacky
2865208600Srdivacky/**
2866203955Srdivacky * \defgroup CINDEX_LEX Token extraction and manipulation
2867203955Srdivacky *
2868203955Srdivacky * The routines in this group provide access to the tokens within a
2869203955Srdivacky * translation unit, along with a semantic mapping of those tokens to
2870203955Srdivacky * their corresponding cursors.
2871203955Srdivacky *
2872203955Srdivacky * @{
2873203955Srdivacky */
2874203955Srdivacky
2875203955Srdivacky/**
2876203955Srdivacky * \brief Describes a kind of token.
2877203955Srdivacky */
2878203955Srdivackytypedef enum CXTokenKind {
2879203955Srdivacky  /**
2880203955Srdivacky   * \brief A token that contains some kind of punctuation.
2881203955Srdivacky   */
2882203955Srdivacky  CXToken_Punctuation,
2883205219Srdivacky
2884203955Srdivacky  /**
2885203955Srdivacky   * \brief A language keyword.
2886203955Srdivacky   */
2887203955Srdivacky  CXToken_Keyword,
2888205219Srdivacky
2889203955Srdivacky  /**
2890203955Srdivacky   * \brief An identifier (that is not a keyword).
2891203955Srdivacky   */
2892203955Srdivacky  CXToken_Identifier,
2893205219Srdivacky
2894203955Srdivacky  /**
2895203955Srdivacky   * \brief A numeric, string, or character literal.
2896203955Srdivacky   */
2897203955Srdivacky  CXToken_Literal,
2898205219Srdivacky
2899203955Srdivacky  /**
2900203955Srdivacky   * \brief A comment.
2901203955Srdivacky   */
2902203955Srdivacky  CXToken_Comment
2903203955Srdivacky} CXTokenKind;
2904203955Srdivacky
2905202879Srdivacky/**
2906203955Srdivacky * \brief Describes a single preprocessing token.
2907203955Srdivacky */
2908203955Srdivackytypedef struct {
2909203955Srdivacky  unsigned int_data[4];
2910203955Srdivacky  void *ptr_data;
2911203955Srdivacky} CXToken;
2912203955Srdivacky
2913203955Srdivacky/**
2914203955Srdivacky * \brief Determine the kind of the given token.
2915203955Srdivacky */
2916203955SrdivackyCINDEX_LINKAGE CXTokenKind clang_getTokenKind(CXToken);
2917205219Srdivacky
2918203955Srdivacky/**
2919203955Srdivacky * \brief Determine the spelling of the given token.
2920203955Srdivacky *
2921203955Srdivacky * The spelling of a token is the textual representation of that token, e.g.,
2922203955Srdivacky * the text of an identifier or keyword.
2923203955Srdivacky */
2924203955SrdivackyCINDEX_LINKAGE CXString clang_getTokenSpelling(CXTranslationUnit, CXToken);
2925205219Srdivacky
2926203955Srdivacky/**
2927203955Srdivacky * \brief Retrieve the source location of the given token.
2928203955Srdivacky */
2929205219SrdivackyCINDEX_LINKAGE CXSourceLocation clang_getTokenLocation(CXTranslationUnit,
2930203955Srdivacky                                                       CXToken);
2931205219Srdivacky
2932203955Srdivacky/**
2933203955Srdivacky * \brief Retrieve a source range that covers the given token.
2934203955Srdivacky */
2935203955SrdivackyCINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken);
2936203955Srdivacky
2937203955Srdivacky/**
2938203955Srdivacky * \brief Tokenize the source code described by the given range into raw
2939203955Srdivacky * lexical tokens.
2940203955Srdivacky *
2941203955Srdivacky * \param TU the translation unit whose text is being tokenized.
2942203955Srdivacky *
2943203955Srdivacky * \param Range the source range in which text should be tokenized. All of the
2944203955Srdivacky * tokens produced by tokenization will fall within this source range,
2945203955Srdivacky *
2946203955Srdivacky * \param Tokens this pointer will be set to point to the array of tokens
2947203955Srdivacky * that occur within the given source range. The returned pointer must be
2948203955Srdivacky * freed with clang_disposeTokens() before the translation unit is destroyed.
2949203955Srdivacky *
2950203955Srdivacky * \param NumTokens will be set to the number of tokens in the \c *Tokens
2951203955Srdivacky * array.
2952203955Srdivacky *
2953203955Srdivacky */
2954203955SrdivackyCINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
2955203955Srdivacky                                   CXToken **Tokens, unsigned *NumTokens);
2956205219Srdivacky
2957203955Srdivacky/**
2958203955Srdivacky * \brief Annotate the given set of tokens by providing cursors for each token
2959203955Srdivacky * that can be mapped to a specific entity within the abstract syntax tree.
2960203955Srdivacky *
2961203955Srdivacky * This token-annotation routine is equivalent to invoking
2962203955Srdivacky * clang_getCursor() for the source locations of each of the
2963203955Srdivacky * tokens. The cursors provided are filtered, so that only those
2964203955Srdivacky * cursors that have a direct correspondence to the token are
2965203955Srdivacky * accepted. For example, given a function call \c f(x),
2966203955Srdivacky * clang_getCursor() would provide the following cursors:
2967203955Srdivacky *
2968203955Srdivacky *   * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'.
2969203955Srdivacky *   * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'.
2970203955Srdivacky *   * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'.
2971203955Srdivacky *
2972203955Srdivacky * Only the first and last of these cursors will occur within the
2973203955Srdivacky * annotate, since the tokens "f" and "x' directly refer to a function
2974203955Srdivacky * and a variable, respectively, but the parentheses are just a small
2975203955Srdivacky * part of the full syntax of the function call expression, which is
2976203955Srdivacky * not provided as an annotation.
2977203955Srdivacky *
2978203955Srdivacky * \param TU the translation unit that owns the given tokens.
2979203955Srdivacky *
2980203955Srdivacky * \param Tokens the set of tokens to annotate.
2981203955Srdivacky *
2982203955Srdivacky * \param NumTokens the number of tokens in \p Tokens.
2983203955Srdivacky *
2984203955Srdivacky * \param Cursors an array of \p NumTokens cursors, whose contents will be
2985203955Srdivacky * replaced with the cursors corresponding to each token.
2986203955Srdivacky */
2987203955SrdivackyCINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU,
2988203955Srdivacky                                         CXToken *Tokens, unsigned NumTokens,
2989203955Srdivacky                                         CXCursor *Cursors);
2990205219Srdivacky
2991203955Srdivacky/**
2992203955Srdivacky * \brief Free the given set of tokens.
2993203955Srdivacky */
2994205219SrdivackyCINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU,
2995203955Srdivacky                                        CXToken *Tokens, unsigned NumTokens);
2996205219Srdivacky
2997203955Srdivacky/**
2998203955Srdivacky * @}
2999203955Srdivacky */
3000205219Srdivacky
3001203955Srdivacky/**
3002202879Srdivacky * \defgroup CINDEX_DEBUG Debugging facilities
3003202879Srdivacky *
3004202879Srdivacky * These routines are used for testing and debugging, only, and should not
3005202879Srdivacky * be relied upon.
3006202879Srdivacky *
3007202879Srdivacky * @{
3008202879Srdivacky */
3009203955Srdivacky
3010198092Srdivacky/* for debug/testing */
3011204643SrdivackyCINDEX_LINKAGE CXString clang_getCursorKindSpelling(enum CXCursorKind Kind);
3012203955SrdivackyCINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(CXCursor,
3013203955Srdivacky                                          const char **startBuf,
3014198092Srdivacky                                          const char **endBuf,
3015198092Srdivacky                                          unsigned *startLine,
3016198092Srdivacky                                          unsigned *startColumn,
3017198092Srdivacky                                          unsigned *endLine,
3018198092Srdivacky                                          unsigned *endColumn);
3019204643SrdivackyCINDEX_LINKAGE void clang_enableStackTraces(void);
3020218893SdimCINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void*), void *user_data,
3021218893Sdim                                          unsigned stack_size);
3022218893Sdim
3023202879Srdivacky/**
3024202879Srdivacky * @}
3025198092Srdivacky */
3026203955Srdivacky
3027199482Srdivacky/**
3028202879Srdivacky * \defgroup CINDEX_CODE_COMPLET Code completion
3029202879Srdivacky *
3030202879Srdivacky * Code completion involves taking an (incomplete) source file, along with
3031202879Srdivacky * knowledge of where the user is actively editing that file, and suggesting
3032202879Srdivacky * syntactically- and semantically-valid constructs that the user might want to
3033202879Srdivacky * use at that particular point in the source code. These data structures and
3034202879Srdivacky * routines provide support for code completion.
3035202879Srdivacky *
3036202879Srdivacky * @{
3037202879Srdivacky */
3038203955Srdivacky
3039202879Srdivacky/**
3040199482Srdivacky * \brief A semantic string that describes a code-completion result.
3041199482Srdivacky *
3042199482Srdivacky * A semantic string that describes the formatting of a code-completion
3043199482Srdivacky * result as a single "template" of text that should be inserted into the
3044199482Srdivacky * source buffer when a particular code-completion result is selected.
3045199482Srdivacky * Each semantic string is made up of some number of "chunks", each of which
3046199482Srdivacky * contains some text along with a description of what that text means, e.g.,
3047199482Srdivacky * the name of the entity being referenced, whether the text chunk is part of
3048199482Srdivacky * the template, or whether it is a "placeholder" that the user should replace
3049199482Srdivacky * with actual code,of a specific kind. See \c CXCompletionChunkKind for a
3050203955Srdivacky * description of the different kinds of chunks.
3051199482Srdivacky */
3052199482Srdivackytypedef void *CXCompletionString;
3053203955Srdivacky
3054199482Srdivacky/**
3055199482Srdivacky * \brief A single result of code completion.
3056199482Srdivacky */
3057199482Srdivackytypedef struct {
3058199482Srdivacky  /**
3059203955Srdivacky   * \brief The kind of entity that this completion refers to.
3060199482Srdivacky   *
3061203955Srdivacky   * The cursor kind will be a macro, keyword, or a declaration (one of the
3062199482Srdivacky   * *Decl cursor kinds), describing the entity that the completion is
3063199482Srdivacky   * referring to.
3064199482Srdivacky   *
3065199482Srdivacky   * \todo In the future, we would like to provide a full cursor, to allow
3066199482Srdivacky   * the client to extract additional information from declaration.
3067199482Srdivacky   */
3068199482Srdivacky  enum CXCursorKind CursorKind;
3069203955Srdivacky
3070203955Srdivacky  /**
3071199482Srdivacky   * \brief The code-completion string that describes how to insert this
3072199482Srdivacky   * code-completion result into the editing buffer.
3073199482Srdivacky   */
3074199482Srdivacky  CXCompletionString CompletionString;
3075199482Srdivacky} CXCompletionResult;
3076199482Srdivacky
3077199482Srdivacky/**
3078199482Srdivacky * \brief Describes a single piece of text within a code-completion string.
3079199482Srdivacky *
3080203955Srdivacky * Each "chunk" within a code-completion string (\c CXCompletionString) is
3081203955Srdivacky * either a piece of text with a specific "kind" that describes how that text
3082199482Srdivacky * should be interpreted by the client or is another completion string.
3083199482Srdivacky */
3084199482Srdivackyenum CXCompletionChunkKind {
3085199482Srdivacky  /**
3086199482Srdivacky   * \brief A code-completion string that describes "optional" text that
3087199482Srdivacky   * could be a part of the template (but is not required).
3088199482Srdivacky   *
3089199482Srdivacky   * The Optional chunk is the only kind of chunk that has a code-completion
3090203955Srdivacky   * string for its representation, which is accessible via
3091199482Srdivacky   * \c clang_getCompletionChunkCompletionString(). The code-completion string
3092199482Srdivacky   * describes an additional part of the template that is completely optional.
3093199482Srdivacky   * For example, optional chunks can be used to describe the placeholders for
3094199482Srdivacky   * arguments that match up with defaulted function parameters, e.g. given:
3095199482Srdivacky   *
3096199482Srdivacky   * \code
3097199482Srdivacky   * void f(int x, float y = 3.14, double z = 2.71828);
3098199482Srdivacky   * \endcode
3099199482Srdivacky   *
3100199482Srdivacky   * The code-completion string for this function would contain:
3101199482Srdivacky   *   - a TypedText chunk for "f".
3102199482Srdivacky   *   - a LeftParen chunk for "(".
3103199482Srdivacky   *   - a Placeholder chunk for "int x"
3104199482Srdivacky   *   - an Optional chunk containing the remaining defaulted arguments, e.g.,
3105199482Srdivacky   *       - a Comma chunk for ","
3106204643Srdivacky   *       - a Placeholder chunk for "float y"
3107199482Srdivacky   *       - an Optional chunk containing the last defaulted argument:
3108199482Srdivacky   *           - a Comma chunk for ","
3109199482Srdivacky   *           - a Placeholder chunk for "double z"
3110199482Srdivacky   *   - a RightParen chunk for ")"
3111199482Srdivacky   *
3112204643Srdivacky   * There are many ways to handle Optional chunks. Two simple approaches are:
3113199482Srdivacky   *   - Completely ignore optional chunks, in which case the template for the
3114199482Srdivacky   *     function "f" would only include the first parameter ("int x").
3115199482Srdivacky   *   - Fully expand all optional chunks, in which case the template for the
3116199482Srdivacky   *     function "f" would have all of the parameters.
3117199482Srdivacky   */
3118199482Srdivacky  CXCompletionChunk_Optional,
3119199482Srdivacky  /**
3120199482Srdivacky   * \brief Text that a user would be expected to type to get this
3121203955Srdivacky   * code-completion result.
3122199482Srdivacky   *
3123203955Srdivacky   * There will be exactly one "typed text" chunk in a semantic string, which
3124203955Srdivacky   * will typically provide the spelling of a keyword or the name of a
3125199482Srdivacky   * declaration that could be used at the current code point. Clients are
3126199482Srdivacky   * expected to filter the code-completion results based on the text in this
3127199482Srdivacky   * chunk.
3128199482Srdivacky   */
3129199482Srdivacky  CXCompletionChunk_TypedText,
3130199482Srdivacky  /**
3131199482Srdivacky   * \brief Text that should be inserted as part of a code-completion result.
3132199482Srdivacky   *
3133199482Srdivacky   * A "text" chunk represents text that is part of the template to be
3134199482Srdivacky   * inserted into user code should this particular code-completion result
3135199482Srdivacky   * be selected.
3136199482Srdivacky   */
3137199482Srdivacky  CXCompletionChunk_Text,
3138199482Srdivacky  /**
3139199482Srdivacky   * \brief Placeholder text that should be replaced by the user.
3140199482Srdivacky   *
3141199482Srdivacky   * A "placeholder" chunk marks a place where the user should insert text
3142199482Srdivacky   * into the code-completion template. For example, placeholders might mark
3143199482Srdivacky   * the function parameters for a function declaration, to indicate that the
3144199482Srdivacky   * user should provide arguments for each of those parameters. The actual
3145199482Srdivacky   * text in a placeholder is a suggestion for the text to display before
3146199482Srdivacky   * the user replaces the placeholder with real code.
3147199482Srdivacky   */
3148199482Srdivacky  CXCompletionChunk_Placeholder,
3149199482Srdivacky  /**
3150199482Srdivacky   * \brief Informative text that should be displayed but never inserted as
3151199482Srdivacky   * part of the template.
3152203955Srdivacky   *
3153199482Srdivacky   * An "informative" chunk contains annotations that can be displayed to
3154199482Srdivacky   * help the user decide whether a particular code-completion result is the
3155199482Srdivacky   * right option, but which is not part of the actual template to be inserted
3156199482Srdivacky   * by code completion.
3157199482Srdivacky   */
3158199482Srdivacky  CXCompletionChunk_Informative,
3159199482Srdivacky  /**
3160199482Srdivacky   * \brief Text that describes the current parameter when code-completion is
3161199482Srdivacky   * referring to function call, message send, or template specialization.
3162199482Srdivacky   *
3163199482Srdivacky   * A "current parameter" chunk occurs when code-completion is providing
3164199482Srdivacky   * information about a parameter corresponding to the argument at the
3165199482Srdivacky   * code-completion point. For example, given a function
3166199482Srdivacky   *
3167199482Srdivacky   * \code
3168199482Srdivacky   * int add(int x, int y);
3169199482Srdivacky   * \endcode
3170199482Srdivacky   *
3171199482Srdivacky   * and the source code \c add(, where the code-completion point is after the
3172199482Srdivacky   * "(", the code-completion string will contain a "current parameter" chunk
3173199482Srdivacky   * for "int x", indicating that the current argument will initialize that
3174199482Srdivacky   * parameter. After typing further, to \c add(17, (where the code-completion
3175203955Srdivacky   * point is after the ","), the code-completion string will contain a
3176199482Srdivacky   * "current paremeter" chunk to "int y".
3177199482Srdivacky   */
3178199482Srdivacky  CXCompletionChunk_CurrentParameter,
3179199482Srdivacky  /**
3180199482Srdivacky   * \brief A left parenthesis ('('), used to initiate a function call or
3181199482Srdivacky   * signal the beginning of a function parameter list.
3182199482Srdivacky   */
3183199482Srdivacky  CXCompletionChunk_LeftParen,
3184199482Srdivacky  /**
3185199482Srdivacky   * \brief A right parenthesis (')'), used to finish a function call or
3186199482Srdivacky   * signal the end of a function parameter list.
3187199482Srdivacky   */
3188199482Srdivacky  CXCompletionChunk_RightParen,
3189199482Srdivacky  /**
3190199482Srdivacky   * \brief A left bracket ('[').
3191199482Srdivacky   */
3192199482Srdivacky  CXCompletionChunk_LeftBracket,
3193199482Srdivacky  /**
3194199482Srdivacky   * \brief A right bracket (']').
3195199482Srdivacky   */
3196199482Srdivacky  CXCompletionChunk_RightBracket,
3197199482Srdivacky  /**
3198199482Srdivacky   * \brief A left brace ('{').
3199199482Srdivacky   */
3200199482Srdivacky  CXCompletionChunk_LeftBrace,
3201199482Srdivacky  /**
3202199482Srdivacky   * \brief A right brace ('}').
3203199482Srdivacky   */
3204199482Srdivacky  CXCompletionChunk_RightBrace,
3205199482Srdivacky  /**
3206199482Srdivacky   * \brief A left angle bracket ('<').
3207199482Srdivacky   */
3208199482Srdivacky  CXCompletionChunk_LeftAngle,
3209199482Srdivacky  /**
3210199482Srdivacky   * \brief A right angle bracket ('>').
3211199482Srdivacky   */
3212199482Srdivacky  CXCompletionChunk_RightAngle,
3213199482Srdivacky  /**
3214199482Srdivacky   * \brief A comma separator (',').
3215199482Srdivacky   */
3216201361Srdivacky  CXCompletionChunk_Comma,
3217201361Srdivacky  /**
3218203955Srdivacky   * \brief Text that specifies the result type of a given result.
3219201361Srdivacky   *
3220201361Srdivacky   * This special kind of informative chunk is not meant to be inserted into
3221203955Srdivacky   * the text buffer. Rather, it is meant to illustrate the type that an
3222201361Srdivacky   * expression using the given completion string would have.
3223201361Srdivacky   */
3224202379Srdivacky  CXCompletionChunk_ResultType,
3225202379Srdivacky  /**
3226202379Srdivacky   * \brief A colon (':').
3227202379Srdivacky   */
3228202379Srdivacky  CXCompletionChunk_Colon,
3229202379Srdivacky  /**
3230202379Srdivacky   * \brief A semicolon (';').
3231202379Srdivacky   */
3232202379Srdivacky  CXCompletionChunk_SemiColon,
3233202379Srdivacky  /**
3234202379Srdivacky   * \brief An '=' sign.
3235202379Srdivacky   */
3236202379Srdivacky  CXCompletionChunk_Equal,
3237202379Srdivacky  /**
3238202379Srdivacky   * Horizontal space (' ').
3239202379Srdivacky   */
3240202379Srdivacky  CXCompletionChunk_HorizontalSpace,
3241202379Srdivacky  /**
3242202379Srdivacky   * Vertical space ('\n'), after which it is generally a good idea to
3243202379Srdivacky   * perform indentation.
3244202379Srdivacky   */
3245202379Srdivacky  CXCompletionChunk_VerticalSpace
3246199482Srdivacky};
3247203955Srdivacky
3248199482Srdivacky/**
3249199482Srdivacky * \brief Determine the kind of a particular chunk within a completion string.
3250199482Srdivacky *
3251199482Srdivacky * \param completion_string the completion string to query.
3252199482Srdivacky *
3253199482Srdivacky * \param chunk_number the 0-based index of the chunk in the completion string.
3254199482Srdivacky *
3255199482Srdivacky * \returns the kind of the chunk at the index \c chunk_number.
3256199482Srdivacky */
3257203955SrdivackyCINDEX_LINKAGE enum CXCompletionChunkKind
3258199482Srdivackyclang_getCompletionChunkKind(CXCompletionString completion_string,
3259199482Srdivacky                             unsigned chunk_number);
3260203955Srdivacky
3261199482Srdivacky/**
3262203955Srdivacky * \brief Retrieve the text associated with a particular chunk within a
3263199482Srdivacky * completion string.
3264199482Srdivacky *
3265199482Srdivacky * \param completion_string the completion string to query.
3266199482Srdivacky *
3267199482Srdivacky * \param chunk_number the 0-based index of the chunk in the completion string.
3268199482Srdivacky *
3269199482Srdivacky * \returns the text associated with the chunk at index \c chunk_number.
3270199482Srdivacky */
3271204643SrdivackyCINDEX_LINKAGE CXString
3272199482Srdivackyclang_getCompletionChunkText(CXCompletionString completion_string,
3273199482Srdivacky                             unsigned chunk_number);
3274199482Srdivacky
3275199482Srdivacky/**
3276203955Srdivacky * \brief Retrieve the completion string associated with a particular chunk
3277199482Srdivacky * within a completion string.
3278199482Srdivacky *
3279199482Srdivacky * \param completion_string the completion string to query.
3280199482Srdivacky *
3281199482Srdivacky * \param chunk_number the 0-based index of the chunk in the completion string.
3282199482Srdivacky *
3283199482Srdivacky * \returns the completion string associated with the chunk at index
3284226633Sdim * \c chunk_number.
3285199482Srdivacky */
3286199482SrdivackyCINDEX_LINKAGE CXCompletionString
3287199482Srdivackyclang_getCompletionChunkCompletionString(CXCompletionString completion_string,
3288199482Srdivacky                                         unsigned chunk_number);
3289203955Srdivacky
3290199482Srdivacky/**
3291199482Srdivacky * \brief Retrieve the number of chunks in the given code-completion string.
3292199482Srdivacky */
3293199482SrdivackyCINDEX_LINKAGE unsigned
3294199482Srdivackyclang_getNumCompletionChunks(CXCompletionString completion_string);
3295199482Srdivacky
3296199482Srdivacky/**
3297208600Srdivacky * \brief Determine the priority of this code completion.
3298208600Srdivacky *
3299208600Srdivacky * The priority of a code completion indicates how likely it is that this
3300208600Srdivacky * particular completion is the completion that the user will select. The
3301208600Srdivacky * priority is selected by various internal heuristics.
3302208600Srdivacky *
3303208600Srdivacky * \param completion_string The completion string to query.
3304208600Srdivacky *
3305208600Srdivacky * \returns The priority of this completion string. Smaller values indicate
3306208600Srdivacky * higher-priority (more likely) completions.
3307208600Srdivacky */
3308208600SrdivackyCINDEX_LINKAGE unsigned
3309208600Srdivackyclang_getCompletionPriority(CXCompletionString completion_string);
3310208600Srdivacky
3311208600Srdivacky/**
3312212904Sdim * \brief Determine the availability of the entity that this code-completion
3313212904Sdim * string refers to.
3314212904Sdim *
3315212904Sdim * \param completion_string The completion string to query.
3316212904Sdim *
3317212904Sdim * \returns The availability of the completion string.
3318212904Sdim */
3319212904SdimCINDEX_LINKAGE enum CXAvailabilityKind
3320212904Sdimclang_getCompletionAvailability(CXCompletionString completion_string);
3321212904Sdim
3322212904Sdim/**
3323226633Sdim * \brief Retrieve the number of annotations associated with the given
3324226633Sdim * completion string.
3325226633Sdim *
3326226633Sdim * \param completion_string the completion string to query.
3327226633Sdim *
3328226633Sdim * \returns the number of annotations associated with the given completion
3329226633Sdim * string.
3330226633Sdim */
3331226633SdimCINDEX_LINKAGE unsigned
3332226633Sdimclang_getCompletionNumAnnotations(CXCompletionString completion_string);
3333226633Sdim
3334226633Sdim/**
3335226633Sdim * \brief Retrieve the annotation associated with the given completion string.
3336226633Sdim *
3337226633Sdim * \param completion_string the completion string to query.
3338226633Sdim *
3339226633Sdim * \param annotation_number the 0-based index of the annotation of the
3340226633Sdim * completion string.
3341226633Sdim *
3342226633Sdim * \returns annotation string associated with the completion at index
3343226633Sdim * \c annotation_number, or a NULL string if that annotation is not available.
3344226633Sdim */
3345226633SdimCINDEX_LINKAGE CXString
3346226633Sdimclang_getCompletionAnnotation(CXCompletionString completion_string,
3347226633Sdim                              unsigned annotation_number);
3348226633Sdim
3349226633Sdim/**
3350226633Sdim * \brief Retrieve a completion string for an arbitrary declaration or macro
3351226633Sdim * definition cursor.
3352226633Sdim *
3353226633Sdim * \param cursor The cursor to query.
3354226633Sdim *
3355226633Sdim * \returns A non-context-sensitive completion string for declaration and macro
3356226633Sdim * definition cursors, or NULL for other kinds of cursors.
3357226633Sdim */
3358226633SdimCINDEX_LINKAGE CXCompletionString
3359226633Sdimclang_getCursorCompletionString(CXCursor cursor);
3360226633Sdim
3361226633Sdim/**
3362201361Srdivacky * \brief Contains the results of code-completion.
3363201361Srdivacky *
3364201361Srdivacky * This data structure contains the results of code completion, as
3365218893Sdim * produced by \c clang_codeCompleteAt(). Its contents must be freed by
3366201361Srdivacky * \c clang_disposeCodeCompleteResults.
3367201361Srdivacky */
3368201361Srdivackytypedef struct {
3369201361Srdivacky  /**
3370201361Srdivacky   * \brief The code-completion results.
3371201361Srdivacky   */
3372201361Srdivacky  CXCompletionResult *Results;
3373201361Srdivacky
3374201361Srdivacky  /**
3375201361Srdivacky   * \brief The number of code-completion results stored in the
3376201361Srdivacky   * \c Results array.
3377201361Srdivacky   */
3378201361Srdivacky  unsigned NumResults;
3379201361Srdivacky} CXCodeCompleteResults;
3380201361Srdivacky
3381201361Srdivacky/**
3382212904Sdim * \brief Flags that can be passed to \c clang_codeCompleteAt() to
3383212904Sdim * modify its behavior.
3384212904Sdim *
3385212904Sdim * The enumerators in this enumeration can be bitwise-OR'd together to
3386212904Sdim * provide multiple options to \c clang_codeCompleteAt().
3387212904Sdim */
3388212904Sdimenum CXCodeComplete_Flags {
3389212904Sdim  /**
3390212904Sdim   * \brief Whether to include macros within the set of code
3391212904Sdim   * completions returned.
3392212904Sdim   */
3393212904Sdim  CXCodeComplete_IncludeMacros = 0x01,
3394212904Sdim
3395212904Sdim  /**
3396212904Sdim   * \brief Whether to include code patterns for language constructs
3397212904Sdim   * within the set of code completions, e.g., for loops.
3398212904Sdim   */
3399212904Sdim  CXCodeComplete_IncludeCodePatterns = 0x02
3400212904Sdim};
3401212904Sdim
3402212904Sdim/**
3403224145Sdim * \brief Bits that represent the context under which completion is occurring.
3404224145Sdim *
3405224145Sdim * The enumerators in this enumeration may be bitwise-OR'd together if multiple
3406224145Sdim * contexts are occurring simultaneously.
3407224145Sdim */
3408224145Sdimenum CXCompletionContext {
3409224145Sdim  /**
3410224145Sdim   * \brief The context for completions is unexposed, as only Clang results
3411224145Sdim   * should be included. (This is equivalent to having no context bits set.)
3412224145Sdim   */
3413224145Sdim  CXCompletionContext_Unexposed = 0,
3414224145Sdim
3415224145Sdim  /**
3416224145Sdim   * \brief Completions for any possible type should be included in the results.
3417224145Sdim   */
3418224145Sdim  CXCompletionContext_AnyType = 1 << 0,
3419224145Sdim
3420224145Sdim  /**
3421224145Sdim   * \brief Completions for any possible value (variables, function calls, etc.)
3422224145Sdim   * should be included in the results.
3423224145Sdim   */
3424224145Sdim  CXCompletionContext_AnyValue = 1 << 1,
3425224145Sdim  /**
3426224145Sdim   * \brief Completions for values that resolve to an Objective-C object should
3427224145Sdim   * be included in the results.
3428224145Sdim   */
3429224145Sdim  CXCompletionContext_ObjCObjectValue = 1 << 2,
3430224145Sdim  /**
3431224145Sdim   * \brief Completions for values that resolve to an Objective-C selector
3432224145Sdim   * should be included in the results.
3433224145Sdim   */
3434224145Sdim  CXCompletionContext_ObjCSelectorValue = 1 << 3,
3435224145Sdim  /**
3436224145Sdim   * \brief Completions for values that resolve to a C++ class type should be
3437224145Sdim   * included in the results.
3438224145Sdim   */
3439224145Sdim  CXCompletionContext_CXXClassTypeValue = 1 << 4,
3440224145Sdim
3441224145Sdim  /**
3442224145Sdim   * \brief Completions for fields of the member being accessed using the dot
3443224145Sdim   * operator should be included in the results.
3444224145Sdim   */
3445224145Sdim  CXCompletionContext_DotMemberAccess = 1 << 5,
3446224145Sdim  /**
3447224145Sdim   * \brief Completions for fields of the member being accessed using the arrow
3448224145Sdim   * operator should be included in the results.
3449224145Sdim   */
3450224145Sdim  CXCompletionContext_ArrowMemberAccess = 1 << 6,
3451224145Sdim  /**
3452224145Sdim   * \brief Completions for properties of the Objective-C object being accessed
3453224145Sdim   * using the dot operator should be included in the results.
3454224145Sdim   */
3455224145Sdim  CXCompletionContext_ObjCPropertyAccess = 1 << 7,
3456224145Sdim
3457224145Sdim  /**
3458224145Sdim   * \brief Completions for enum tags should be included in the results.
3459224145Sdim   */
3460224145Sdim  CXCompletionContext_EnumTag = 1 << 8,
3461224145Sdim  /**
3462224145Sdim   * \brief Completions for union tags should be included in the results.
3463224145Sdim   */
3464224145Sdim  CXCompletionContext_UnionTag = 1 << 9,
3465224145Sdim  /**
3466224145Sdim   * \brief Completions for struct tags should be included in the results.
3467224145Sdim   */
3468224145Sdim  CXCompletionContext_StructTag = 1 << 10,
3469224145Sdim
3470224145Sdim  /**
3471224145Sdim   * \brief Completions for C++ class names should be included in the results.
3472224145Sdim   */
3473224145Sdim  CXCompletionContext_ClassTag = 1 << 11,
3474224145Sdim  /**
3475224145Sdim   * \brief Completions for C++ namespaces and namespace aliases should be
3476224145Sdim   * included in the results.
3477224145Sdim   */
3478224145Sdim  CXCompletionContext_Namespace = 1 << 12,
3479224145Sdim  /**
3480224145Sdim   * \brief Completions for C++ nested name specifiers should be included in
3481224145Sdim   * the results.
3482224145Sdim   */
3483224145Sdim  CXCompletionContext_NestedNameSpecifier = 1 << 13,
3484224145Sdim
3485224145Sdim  /**
3486224145Sdim   * \brief Completions for Objective-C interfaces (classes) should be included
3487224145Sdim   * in the results.
3488224145Sdim   */
3489224145Sdim  CXCompletionContext_ObjCInterface = 1 << 14,
3490224145Sdim  /**
3491224145Sdim   * \brief Completions for Objective-C protocols should be included in
3492224145Sdim   * the results.
3493224145Sdim   */
3494224145Sdim  CXCompletionContext_ObjCProtocol = 1 << 15,
3495224145Sdim  /**
3496224145Sdim   * \brief Completions for Objective-C categories should be included in
3497224145Sdim   * the results.
3498224145Sdim   */
3499224145Sdim  CXCompletionContext_ObjCCategory = 1 << 16,
3500224145Sdim  /**
3501224145Sdim   * \brief Completions for Objective-C instance messages should be included
3502224145Sdim   * in the results.
3503224145Sdim   */
3504224145Sdim  CXCompletionContext_ObjCInstanceMessage = 1 << 17,
3505224145Sdim  /**
3506224145Sdim   * \brief Completions for Objective-C class messages should be included in
3507224145Sdim   * the results.
3508224145Sdim   */
3509224145Sdim  CXCompletionContext_ObjCClassMessage = 1 << 18,
3510224145Sdim  /**
3511224145Sdim   * \brief Completions for Objective-C selector names should be included in
3512224145Sdim   * the results.
3513224145Sdim   */
3514224145Sdim  CXCompletionContext_ObjCSelectorName = 1 << 19,
3515224145Sdim
3516224145Sdim  /**
3517224145Sdim   * \brief Completions for preprocessor macro names should be included in
3518224145Sdim   * the results.
3519224145Sdim   */
3520224145Sdim  CXCompletionContext_MacroName = 1 << 20,
3521224145Sdim
3522224145Sdim  /**
3523224145Sdim   * \brief Natural language completions should be included in the results.
3524224145Sdim   */
3525224145Sdim  CXCompletionContext_NaturalLanguage = 1 << 21,
3526224145Sdim
3527224145Sdim  /**
3528224145Sdim   * \brief The current context is unknown, so set all contexts.
3529224145Sdim   */
3530224145Sdim  CXCompletionContext_Unknown = ((1 << 22) - 1)
3531224145Sdim};
3532224145Sdim
3533224145Sdim/**
3534212904Sdim * \brief Returns a default set of code-completion options that can be
3535212904Sdim * passed to\c clang_codeCompleteAt().
3536212904Sdim */
3537212904SdimCINDEX_LINKAGE unsigned clang_defaultCodeCompleteOptions(void);
3538212904Sdim
3539212904Sdim/**
3540212904Sdim * \brief Perform code completion at a given location in a translation unit.
3541212904Sdim *
3542212904Sdim * This function performs code completion at a particular file, line, and
3543212904Sdim * column within source code, providing results that suggest potential
3544212904Sdim * code snippets based on the context of the completion. The basic model
3545212904Sdim * for code completion is that Clang will parse a complete source file,
3546212904Sdim * performing syntax checking up to the location where code-completion has
3547212904Sdim * been requested. At that point, a special code-completion token is passed
3548212904Sdim * to the parser, which recognizes this token and determines, based on the
3549212904Sdim * current location in the C/Objective-C/C++ grammar and the state of
3550212904Sdim * semantic analysis, what completions to provide. These completions are
3551212904Sdim * returned via a new \c CXCodeCompleteResults structure.
3552212904Sdim *
3553212904Sdim * Code completion itself is meant to be triggered by the client when the
3554212904Sdim * user types punctuation characters or whitespace, at which point the
3555212904Sdim * code-completion location will coincide with the cursor. For example, if \c p
3556212904Sdim * is a pointer, code-completion might be triggered after the "-" and then
3557212904Sdim * after the ">" in \c p->. When the code-completion location is afer the ">",
3558212904Sdim * the completion results will provide, e.g., the members of the struct that
3559212904Sdim * "p" points to. The client is responsible for placing the cursor at the
3560212904Sdim * beginning of the token currently being typed, then filtering the results
3561212904Sdim * based on the contents of the token. For example, when code-completing for
3562212904Sdim * the expression \c p->get, the client should provide the location just after
3563212904Sdim * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the
3564212904Sdim * client can filter the results based on the current token text ("get"), only
3565212904Sdim * showing those results that start with "get". The intent of this interface
3566212904Sdim * is to separate the relatively high-latency acquisition of code-completion
3567212904Sdim * results from the filtering of results on a per-character basis, which must
3568212904Sdim * have a lower latency.
3569212904Sdim *
3570212904Sdim * \param TU The translation unit in which code-completion should
3571212904Sdim * occur. The source files for this translation unit need not be
3572212904Sdim * completely up-to-date (and the contents of those source files may
3573212904Sdim * be overridden via \p unsaved_files). Cursors referring into the
3574212904Sdim * translation unit may be invalidated by this invocation.
3575212904Sdim *
3576212904Sdim * \param complete_filename The name of the source file where code
3577212904Sdim * completion should be performed. This filename may be any file
3578212904Sdim * included in the translation unit.
3579212904Sdim *
3580212904Sdim * \param complete_line The line at which code-completion should occur.
3581212904Sdim *
3582212904Sdim * \param complete_column The column at which code-completion should occur.
3583212904Sdim * Note that the column should point just after the syntactic construct that
3584212904Sdim * initiated code completion, and not in the middle of a lexical token.
3585212904Sdim *
3586212904Sdim * \param unsaved_files the Tiles that have not yet been saved to disk
3587212904Sdim * but may be required for parsing or code completion, including the
3588212904Sdim * contents of those files.  The contents and name of these files (as
3589212904Sdim * specified by CXUnsavedFile) are copied when necessary, so the
3590212904Sdim * client only needs to guarantee their validity until the call to
3591212904Sdim * this function returns.
3592212904Sdim *
3593212904Sdim * \param num_unsaved_files The number of unsaved file entries in \p
3594212904Sdim * unsaved_files.
3595212904Sdim *
3596212904Sdim * \param options Extra options that control the behavior of code
3597212904Sdim * completion, expressed as a bitwise OR of the enumerators of the
3598212904Sdim * CXCodeComplete_Flags enumeration. The
3599212904Sdim * \c clang_defaultCodeCompleteOptions() function returns a default set
3600212904Sdim * of code-completion options.
3601212904Sdim *
3602212904Sdim * \returns If successful, a new \c CXCodeCompleteResults structure
3603212904Sdim * containing code-completion results, which should eventually be
3604212904Sdim * freed with \c clang_disposeCodeCompleteResults(). If code
3605212904Sdim * completion fails, returns NULL.
3606212904Sdim */
3607212904SdimCINDEX_LINKAGE
3608212904SdimCXCodeCompleteResults *clang_codeCompleteAt(CXTranslationUnit TU,
3609212904Sdim                                            const char *complete_filename,
3610212904Sdim                                            unsigned complete_line,
3611212904Sdim                                            unsigned complete_column,
3612212904Sdim                                            struct CXUnsavedFile *unsaved_files,
3613212904Sdim                                            unsigned num_unsaved_files,
3614212904Sdim                                            unsigned options);
3615212904Sdim
3616212904Sdim/**
3617212904Sdim * \brief Sort the code-completion results in case-insensitive alphabetical
3618212904Sdim * order.
3619212904Sdim *
3620212904Sdim * \param Results The set of results to sort.
3621212904Sdim * \param NumResults The number of results in \p Results.
3622212904Sdim */
3623212904SdimCINDEX_LINKAGE
3624212904Sdimvoid clang_sortCodeCompletionResults(CXCompletionResult *Results,
3625212904Sdim                                     unsigned NumResults);
3626212904Sdim
3627212904Sdim/**
3628201361Srdivacky * \brief Free the given set of code-completion results.
3629201361Srdivacky */
3630203955SrdivackyCINDEX_LINKAGE
3631201361Srdivackyvoid clang_disposeCodeCompleteResults(CXCodeCompleteResults *Results);
3632212904Sdim
3633202879Srdivacky/**
3634204643Srdivacky * \brief Determine the number of diagnostics produced prior to the
3635204643Srdivacky * location where code completion was performed.
3636204643Srdivacky */
3637205219SrdivackyCINDEX_LINKAGE
3638204643Srdivackyunsigned clang_codeCompleteGetNumDiagnostics(CXCodeCompleteResults *Results);
3639204643Srdivacky
3640204643Srdivacky/**
3641204643Srdivacky * \brief Retrieve a diagnostic associated with the given code completion.
3642204643Srdivacky *
3643204643Srdivacky * \param Result the code completion results to query.
3644204643Srdivacky * \param Index the zero-based diagnostic number to retrieve.
3645204643Srdivacky *
3646204643Srdivacky * \returns the requested diagnostic. This diagnostic must be freed
3647204643Srdivacky * via a call to \c clang_disposeDiagnostic().
3648204643Srdivacky */
3649205219SrdivackyCINDEX_LINKAGE
3650204643SrdivackyCXDiagnostic clang_codeCompleteGetDiagnostic(CXCodeCompleteResults *Results,
3651204643Srdivacky                                             unsigned Index);
3652204643Srdivacky
3653204643Srdivacky/**
3654224145Sdim * \brief Determines what compeltions are appropriate for the context
3655224145Sdim * the given code completion.
3656224145Sdim *
3657224145Sdim * \param Results the code completion results to query
3658224145Sdim *
3659224145Sdim * \returns the kinds of completions that are appropriate for use
3660224145Sdim * along with the given code completion results.
3661224145Sdim */
3662224145SdimCINDEX_LINKAGE
3663224145Sdimunsigned long long clang_codeCompleteGetContexts(
3664224145Sdim                                                CXCodeCompleteResults *Results);
3665226633Sdim
3666226633Sdim/**
3667226633Sdim * \brief Returns the cursor kind for the container for the current code
3668226633Sdim * completion context. The container is only guaranteed to be set for
3669226633Sdim * contexts where a container exists (i.e. member accesses or Objective-C
3670226633Sdim * message sends); if there is not a container, this function will return
3671226633Sdim * CXCursor_InvalidCode.
3672226633Sdim *
3673226633Sdim * \param Results the code completion results to query
3674226633Sdim *
3675226633Sdim * \param IsIncomplete on return, this value will be false if Clang has complete
3676226633Sdim * information about the container. If Clang does not have complete
3677226633Sdim * information, this value will be true.
3678226633Sdim *
3679226633Sdim * \returns the container kind, or CXCursor_InvalidCode if there is not a
3680226633Sdim * container
3681226633Sdim */
3682226633SdimCINDEX_LINKAGE
3683226633Sdimenum CXCursorKind clang_codeCompleteGetContainerKind(
3684226633Sdim                                                 CXCodeCompleteResults *Results,
3685226633Sdim                                                     unsigned *IsIncomplete);
3686226633Sdim
3687226633Sdim/**
3688226633Sdim * \brief Returns the USR for the container for the current code completion
3689226633Sdim * context. If there is not a container for the current context, this
3690226633Sdim * function will return the empty string.
3691226633Sdim *
3692226633Sdim * \param Results the code completion results to query
3693226633Sdim *
3694226633Sdim * \returns the USR for the container
3695226633Sdim */
3696226633SdimCINDEX_LINKAGE
3697226633SdimCXString clang_codeCompleteGetContainerUSR(CXCodeCompleteResults *Results);
3698224145Sdim
3699226633Sdim
3700224145Sdim/**
3701226633Sdim * \brief Returns the currently-entered selector for an Objective-C message
3702226633Sdim * send, formatted like "initWithFoo:bar:". Only guaranteed to return a
3703226633Sdim * non-empty string for CXCompletionContext_ObjCInstanceMessage and
3704226633Sdim * CXCompletionContext_ObjCClassMessage.
3705226633Sdim *
3706226633Sdim * \param Results the code completion results to query
3707226633Sdim *
3708226633Sdim * \returns the selector (or partial selector) that has been entered thus far
3709226633Sdim * for an Objective-C message send.
3710226633Sdim */
3711226633SdimCINDEX_LINKAGE
3712226633SdimCXString clang_codeCompleteGetObjCSelector(CXCodeCompleteResults *Results);
3713226633Sdim
3714226633Sdim/**
3715202879Srdivacky * @}
3716202879Srdivacky */
3717203955Srdivacky
3718203955Srdivacky
3719202879Srdivacky/**
3720202879Srdivacky * \defgroup CINDEX_MISC Miscellaneous utility functions
3721202879Srdivacky *
3722202879Srdivacky * @{
3723202879Srdivacky */
3724202879Srdivacky
3725202879Srdivacky/**
3726203955Srdivacky * \brief Return a version string, suitable for showing to a user, but not
3727203955Srdivacky *        intended to be parsed (the format is not guaranteed to be stable).
3728203955Srdivacky */
3729203955SrdivackyCINDEX_LINKAGE CXString clang_getClangVersion();
3730203955Srdivacky
3731221345Sdim
3732221345Sdim/**
3733221345Sdim * \brief Enable/disable crash recovery.
3734221345Sdim *
3735221345Sdim * \param Flag to indicate if crash recovery is enabled.  A non-zero value
3736221345Sdim *        enables crash recovery, while 0 disables it.
3737221345Sdim */
3738221345SdimCINDEX_LINKAGE void clang_toggleCrashRecovery(unsigned isEnabled);
3739221345Sdim
3740203955Srdivacky /**
3741205219Srdivacky  * \brief Visitor invoked for each file in a translation unit
3742203955Srdivacky  *        (used with clang_getInclusions()).
3743203955Srdivacky  *
3744203955Srdivacky  * This visitor function will be invoked by clang_getInclusions() for each
3745203955Srdivacky  * file included (either at the top-level or by #include directives) within
3746203955Srdivacky  * a translation unit.  The first argument is the file being included, and
3747203955Srdivacky  * the second and third arguments provide the inclusion stack.  The
3748203955Srdivacky  * array is sorted in order of immediate inclusion.  For example,
3749203955Srdivacky  * the first element refers to the location that included 'included_file'.
3750203955Srdivacky  */
3751203955Srdivackytypedef void (*CXInclusionVisitor)(CXFile included_file,
3752203955Srdivacky                                   CXSourceLocation* inclusion_stack,
3753203955Srdivacky                                   unsigned include_len,
3754203955Srdivacky                                   CXClientData client_data);
3755203955Srdivacky
3756203955Srdivacky/**
3757203955Srdivacky * \brief Visit the set of preprocessor inclusions in a translation unit.
3758203955Srdivacky *   The visitor function is called with the provided data for every included
3759203955Srdivacky *   file.  This does not include headers included by the PCH file (unless one
3760203955Srdivacky *   is inspecting the inclusions in the PCH file itself).
3761203955Srdivacky */
3762203955SrdivackyCINDEX_LINKAGE void clang_getInclusions(CXTranslationUnit tu,
3763203955Srdivacky                                        CXInclusionVisitor visitor,
3764203955Srdivacky                                        CXClientData client_data);
3765203955Srdivacky
3766203955Srdivacky/**
3767202879Srdivacky * @}
3768202879Srdivacky */
3769203955Srdivacky
3770224145Sdim/** \defgroup CINDEX_REMAPPING Remapping functions
3771224145Sdim *
3772224145Sdim * @{
3773224145Sdim */
3774224145Sdim
3775202879Srdivacky/**
3776224145Sdim * \brief A remapping of original source files and their translated files.
3777224145Sdim */
3778224145Sdimtypedef void *CXRemapping;
3779224145Sdim
3780224145Sdim/**
3781224145Sdim * \brief Retrieve a remapping.
3782224145Sdim *
3783224145Sdim * \param path the path that contains metadata about remappings.
3784224145Sdim *
3785224145Sdim * \returns the requested remapping. This remapping must be freed
3786224145Sdim * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
3787224145Sdim */
3788224145SdimCINDEX_LINKAGE CXRemapping clang_getRemappings(const char *path);
3789224145Sdim
3790224145Sdim/**
3791224145Sdim * \brief Determine the number of remappings.
3792224145Sdim */
3793224145SdimCINDEX_LINKAGE unsigned clang_remap_getNumFiles(CXRemapping);
3794224145Sdim
3795224145Sdim/**
3796224145Sdim * \brief Get the original and the associated filename from the remapping.
3797224145Sdim *
3798224145Sdim * \param original If non-NULL, will be set to the original filename.
3799224145Sdim *
3800224145Sdim * \param transformed If non-NULL, will be set to the filename that the original
3801224145Sdim * is associated with.
3802224145Sdim */
3803224145SdimCINDEX_LINKAGE void clang_remap_getFilenames(CXRemapping, unsigned index,
3804224145Sdim                                     CXString *original, CXString *transformed);
3805224145Sdim
3806224145Sdim/**
3807224145Sdim * \brief Dispose the remapping.
3808224145Sdim */
3809224145SdimCINDEX_LINKAGE void clang_remap_dispose(CXRemapping);
3810224145Sdim
3811224145Sdim/**
3812202879Srdivacky * @}
3813202879Srdivacky */
3814203955Srdivacky
3815226633Sdim/** \defgroup CINDEX_HIGH Higher level API functions
3816226633Sdim *
3817226633Sdim * @{
3818226633Sdim */
3819226633Sdim
3820226633Sdimenum CXVisitorResult {
3821226633Sdim  CXVisit_Break,
3822226633Sdim  CXVisit_Continue
3823226633Sdim};
3824226633Sdim
3825226633Sdimtypedef struct {
3826226633Sdim  void *context;
3827226633Sdim  enum CXVisitorResult (*visit)(void *context, CXCursor, CXSourceRange);
3828226633Sdim} CXCursorAndRangeVisitor;
3829226633Sdim
3830224145Sdim/**
3831226633Sdim * \brief Find references of a declaration in a specific file.
3832226633Sdim *
3833226633Sdim * \param cursor pointing to a declaration or a reference of one.
3834226633Sdim *
3835226633Sdim * \param file to search for references.
3836226633Sdim *
3837226633Sdim * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
3838226633Sdim * each reference found.
3839226633Sdim * The CXSourceRange will point inside the file; if the reference is inside
3840226633Sdim * a macro (and not a macro argument) the CXSourceRange will be invalid.
3841226633Sdim */
3842226633SdimCINDEX_LINKAGE void clang_findReferencesInFile(CXCursor cursor, CXFile file,
3843226633Sdim                                               CXCursorAndRangeVisitor visitor);
3844226633Sdim
3845226633Sdim#ifdef __has_feature
3846226633Sdim#  if __has_feature(blocks)
3847226633Sdim
3848226633Sdimtypedef enum CXVisitorResult
3849226633Sdim    (^CXCursorAndRangeVisitorBlock)(CXCursor, CXSourceRange);
3850226633Sdim
3851226633SdimCINDEX_LINKAGE
3852226633Sdimvoid clang_findReferencesInFileWithBlock(CXCursor, CXFile,
3853226633Sdim                                         CXCursorAndRangeVisitorBlock);
3854226633Sdim
3855226633Sdim#  endif
3856226633Sdim#endif
3857226633Sdim
3858226633Sdim/**
3859224145Sdim * @}
3860224145Sdim */
3861224145Sdim
3862226633Sdim/**
3863226633Sdim * @}
3864226633Sdim */
3865226633Sdim
3866198092Srdivacky#ifdef __cplusplus
3867198092Srdivacky}
3868198092Srdivacky#endif
3869198092Srdivacky#endif
3870198092Srdivacky
3871