• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*===-- clang-c/Index.h - Indexing Public C Interface -------------*- C -*-===*\
2 |*                                                                            *|
3 |*                     The LLVM Compiler Infrastructure                       *|
4 |*                                                                            *|
5 |* This file is distributed under the University of Illinois Open Source      *|
6 |* License. See LICENSE.TXT for details.                                      *|
7 |*                                                                            *|
8 |*===----------------------------------------------------------------------===*|
9 |*                                                                            *|
10 |* This header provides a public inferface to a Clang library for extracting  *|
11 |* high-level symbol information from source files without exposing the full  *|
12 |* Clang C++ API.                                                             *|
13 |*                                                                            *|
14 \*===----------------------------------------------------------------------===*/
15 
16 #ifndef CLANG_C_INDEX_H
17 #define CLANG_C_INDEX_H
18 
19 #include <sys/stat.h>
20 #include <time.h>
21 #include <stdio.h>
22 
23 #include "clang-c/Platform.h"
24 #include "clang-c/CXString.h"
25 
26 /**
27  * \brief The version constants for the libclang API.
28  * CINDEX_VERSION_MINOR should increase when there are API additions.
29  * CINDEX_VERSION_MAJOR is intended for "major" source/ABI breaking changes.
30  *
31  * The policy about the libclang API was always to keep it source and ABI
32  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
33  */
34 #define CINDEX_VERSION_MAJOR 0
35 #define CINDEX_VERSION_MINOR 15
36 
37 #define CINDEX_VERSION_ENCODE(major, minor) ( \
38       ((major) * 10000)                       \
39     + ((minor) *     1))
40 
41 #define CINDEX_VERSION CINDEX_VERSION_ENCODE( \
42     CINDEX_VERSION_MAJOR,                     \
43     CINDEX_VERSION_MINOR )
44 
45 #define CINDEX_VERSION_STRINGIZE_(major, minor)   \
46     #major"."#minor
47 #define CINDEX_VERSION_STRINGIZE(major, minor)    \
48     CINDEX_VERSION_STRINGIZE_(major, minor)
49 
50 #define CINDEX_VERSION_STRING CINDEX_VERSION_STRINGIZE( \
51     CINDEX_VERSION_MAJOR,                               \
52     CINDEX_VERSION_MINOR)
53 
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57 
58 /** \defgroup CINDEX libclang: C Interface to Clang
59  *
60  * The C Interface to Clang provides a relatively small API that exposes
61  * facilities for parsing source code into an abstract syntax tree (AST),
62  * loading already-parsed ASTs, traversing the AST, associating
63  * physical source locations with elements within the AST, and other
64  * facilities that support Clang-based development tools.
65  *
66  * This C interface to Clang will never provide all of the information
67  * representation stored in Clang's C++ AST, nor should it: the intent is to
68  * maintain an API that is relatively stable from one release to the next,
69  * providing only the basic functionality needed to support development tools.
70  *
71  * To avoid namespace pollution, data types are prefixed with "CX" and
72  * functions are prefixed with "clang_".
73  *
74  * @{
75  */
76 
77 /**
78  * \brief An "index" that consists of a set of translation units that would
79  * typically be linked together into an executable or library.
80  */
81 typedef void *CXIndex;
82 
83 /**
84  * \brief A single translation unit, which resides in an index.
85  */
86 typedef struct CXTranslationUnitImpl *CXTranslationUnit;
87 
88 /**
89  * \brief Opaque pointer representing client data that will be passed through
90  * to various callbacks and visitors.
91  */
92 typedef void *CXClientData;
93 
94 /**
95  * \brief Provides the contents of a file that has not yet been saved to disk.
96  *
97  * Each CXUnsavedFile instance provides the name of a file on the
98  * system along with the current contents of that file that have not
99  * yet been saved to disk.
100  */
101 struct CXUnsavedFile {
102   /**
103    * \brief The file whose contents have not yet been saved.
104    *
105    * This file must already exist in the file system.
106    */
107   const char *Filename;
108 
109   /**
110    * \brief A buffer containing the unsaved contents of this file.
111    */
112   const char *Contents;
113 
114   /**
115    * \brief The length of the unsaved contents of this buffer.
116    */
117   unsigned long Length;
118 };
119 
120 /**
121  * \brief Describes the availability of a particular entity, which indicates
122  * whether the use of this entity will result in a warning or error due to
123  * it being deprecated or unavailable.
124  */
125 enum CXAvailabilityKind {
126   /**
127    * \brief The entity is available.
128    */
129   CXAvailability_Available,
130   /**
131    * \brief The entity is available, but has been deprecated (and its use is
132    * not recommended).
133    */
134   CXAvailability_Deprecated,
135   /**
136    * \brief The entity is not available; any use of it will be an error.
137    */
138   CXAvailability_NotAvailable,
139   /**
140    * \brief The entity is available, but not accessible; any use of it will be
141    * an error.
142    */
143   CXAvailability_NotAccessible
144 };
145 
146 /**
147  * \brief Describes a version number of the form major.minor.subminor.
148  */
149 typedef struct CXVersion {
150   /**
151    * \brief The major version number, e.g., the '10' in '10.7.3'. A negative
152    * value indicates that there is no version number at all.
153    */
154   int Major;
155   /**
156    * \brief The minor version number, e.g., the '7' in '10.7.3'. This value
157    * will be negative if no minor version number was provided, e.g., for
158    * version '10'.
159    */
160   int Minor;
161   /**
162    * \brief The subminor version number, e.g., the '3' in '10.7.3'. This value
163    * will be negative if no minor or subminor version number was provided,
164    * e.g., in version '10' or '10.7'.
165    */
166   int Subminor;
167 } CXVersion;
168 
169 /**
170  * \brief Provides a shared context for creating translation units.
171  *
172  * It provides two options:
173  *
174  * - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local"
175  * declarations (when loading any new translation units). A "local" declaration
176  * is one that belongs in the translation unit itself and not in a precompiled
177  * header that was used by the translation unit. If zero, all declarations
178  * will be enumerated.
179  *
180  * Here is an example:
181  *
182  * \code
183  *   // excludeDeclsFromPCH = 1, displayDiagnostics=1
184  *   Idx = clang_createIndex(1, 1);
185  *
186  *   // IndexTest.pch was produced with the following command:
187  *   // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch"
188  *   TU = clang_createTranslationUnit(Idx, "IndexTest.pch");
189  *
190  *   // This will load all the symbols from 'IndexTest.pch'
191  *   clang_visitChildren(clang_getTranslationUnitCursor(TU),
192  *                       TranslationUnitVisitor, 0);
193  *   clang_disposeTranslationUnit(TU);
194  *
195  *   // This will load all the symbols from 'IndexTest.c', excluding symbols
196  *   // from 'IndexTest.pch'.
197  *   char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" };
198  *   TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args,
199  *                                                  0, 0);
200  *   clang_visitChildren(clang_getTranslationUnitCursor(TU),
201  *                       TranslationUnitVisitor, 0);
202  *   clang_disposeTranslationUnit(TU);
203  * \endcode
204  *
205  * This process of creating the 'pch', loading it separately, and using it (via
206  * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks
207  * (which gives the indexer the same performance benefit as the compiler).
208  */
209 CINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH,
210                                          int displayDiagnostics);
211 
212 /**
213  * \brief Destroy the given index.
214  *
215  * The index must not be destroyed until all of the translation units created
216  * within that index have been destroyed.
217  */
218 CINDEX_LINKAGE void clang_disposeIndex(CXIndex index);
219 
220 typedef enum {
221   /**
222    * \brief Used to indicate that no special CXIndex options are needed.
223    */
224   CXGlobalOpt_None = 0x0,
225 
226   /**
227    * \brief Used to indicate that threads that libclang creates for indexing
228    * purposes should use background priority.
229    *
230    * Affects #clang_indexSourceFile, #clang_indexTranslationUnit,
231    * #clang_parseTranslationUnit, #clang_saveTranslationUnit.
232    */
233   CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1,
234 
235   /**
236    * \brief Used to indicate that threads that libclang creates for editing
237    * purposes should use background priority.
238    *
239    * Affects #clang_reparseTranslationUnit, #clang_codeCompleteAt,
240    * #clang_annotateTokens
241    */
242   CXGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2,
243 
244   /**
245    * \brief Used to indicate that all threads that libclang creates should use
246    * background priority.
247    */
248   CXGlobalOpt_ThreadBackgroundPriorityForAll =
249       CXGlobalOpt_ThreadBackgroundPriorityForIndexing |
250       CXGlobalOpt_ThreadBackgroundPriorityForEditing
251 
252 } CXGlobalOptFlags;
253 
254 /**
255  * \brief Sets general options associated with a CXIndex.
256  *
257  * For example:
258  * \code
259  * CXIndex idx = ...;
260  * clang_CXIndex_setGlobalOptions(idx,
261  *     clang_CXIndex_getGlobalOptions(idx) |
262  *     CXGlobalOpt_ThreadBackgroundPriorityForIndexing);
263  * \endcode
264  *
265  * \param options A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags.
266  */
267 CINDEX_LINKAGE void clang_CXIndex_setGlobalOptions(CXIndex, unsigned options);
268 
269 /**
270  * \brief Gets the general options associated with a CXIndex.
271  *
272  * \returns A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags that
273  * are associated with the given CXIndex object.
274  */
275 CINDEX_LINKAGE unsigned clang_CXIndex_getGlobalOptions(CXIndex);
276 
277 /**
278  * \defgroup CINDEX_FILES File manipulation routines
279  *
280  * @{
281  */
282 
283 /**
284  * \brief A particular source file that is part of a translation unit.
285  */
286 typedef void *CXFile;
287 
288 
289 /**
290  * \brief Retrieve the complete file and path name of the given file.
291  */
292 CINDEX_LINKAGE CXString clang_getFileName(CXFile SFile);
293 
294 /**
295  * \brief Retrieve the last modification time of the given file.
296  */
297 CINDEX_LINKAGE time_t clang_getFileTime(CXFile SFile);
298 
299 /**
300  * \brief Uniquely identifies a CXFile, that refers to the same underlying file,
301  * across an indexing session.
302  */
303 typedef struct {
304   unsigned long long data[3];
305 } CXFileUniqueID;
306 
307 /**
308  * \brief Retrieve the unique ID for the given \c file.
309  *
310  * \param file the file to get the ID for.
311  * \param outID stores the returned CXFileUniqueID.
312  * \returns If there was a failure getting the unique ID, returns non-zero,
313  * otherwise returns 0.
314 */
315 CINDEX_LINKAGE int clang_getFileUniqueID(CXFile file, CXFileUniqueID *outID);
316 
317 /**
318  * \brief Determine whether the given header is guarded against
319  * multiple inclusions, either with the conventional
320  * \#ifndef/\#define/\#endif macro guards or with \#pragma once.
321  */
322 CINDEX_LINKAGE unsigned
323 clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu, CXFile file);
324 
325 /**
326  * \brief Retrieve a file handle within the given translation unit.
327  *
328  * \param tu the translation unit
329  *
330  * \param file_name the name of the file.
331  *
332  * \returns the file handle for the named file in the translation unit \p tu,
333  * or a NULL file handle if the file was not a part of this translation unit.
334  */
335 CINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu,
336                                     const char *file_name);
337 
338 /**
339  * @}
340  */
341 
342 /**
343  * \defgroup CINDEX_LOCATIONS Physical source locations
344  *
345  * Clang represents physical source locations in its abstract syntax tree in
346  * great detail, with file, line, and column information for the majority of
347  * the tokens parsed in the source code. These data types and functions are
348  * used to represent source location information, either for a particular
349  * point in the program or for a range of points in the program, and extract
350  * specific location information from those data types.
351  *
352  * @{
353  */
354 
355 /**
356  * \brief Identifies a specific source location within a translation
357  * unit.
358  *
359  * Use clang_getExpansionLocation() or clang_getSpellingLocation()
360  * to map a source location to a particular file, line, and column.
361  */
362 typedef struct {
363   const void *ptr_data[2];
364   unsigned int_data;
365 } CXSourceLocation;
366 
367 /**
368  * \brief Identifies a half-open character range in the source code.
369  *
370  * Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the
371  * starting and end locations from a source range, respectively.
372  */
373 typedef struct {
374   const void *ptr_data[2];
375   unsigned begin_int_data;
376   unsigned end_int_data;
377 } CXSourceRange;
378 
379 /**
380  * \brief Retrieve a NULL (invalid) source location.
381  */
382 CINDEX_LINKAGE CXSourceLocation clang_getNullLocation(void);
383 
384 /**
385  * \brief Determine whether two source locations, which must refer into
386  * the same translation unit, refer to exactly the same point in the source
387  * code.
388  *
389  * \returns non-zero if the source locations refer to the same location, zero
390  * if they refer to different locations.
391  */
392 CINDEX_LINKAGE unsigned clang_equalLocations(CXSourceLocation loc1,
393                                              CXSourceLocation loc2);
394 
395 /**
396  * \brief Retrieves the source location associated with a given file/line/column
397  * in a particular translation unit.
398  */
399 CINDEX_LINKAGE CXSourceLocation clang_getLocation(CXTranslationUnit tu,
400                                                   CXFile file,
401                                                   unsigned line,
402                                                   unsigned column);
403 /**
404  * \brief Retrieves the source location associated with a given character offset
405  * in a particular translation unit.
406  */
407 CINDEX_LINKAGE CXSourceLocation clang_getLocationForOffset(CXTranslationUnit tu,
408                                                            CXFile file,
409                                                            unsigned offset);
410 
411 /**
412  * \brief Retrieve a NULL (invalid) source range.
413  */
414 CINDEX_LINKAGE CXSourceRange clang_getNullRange(void);
415 
416 /**
417  * \brief Retrieve a source range given the beginning and ending source
418  * locations.
419  */
420 CINDEX_LINKAGE CXSourceRange clang_getRange(CXSourceLocation begin,
421                                             CXSourceLocation end);
422 
423 /**
424  * \brief Determine whether two ranges are equivalent.
425  *
426  * \returns non-zero if the ranges are the same, zero if they differ.
427  */
428 CINDEX_LINKAGE unsigned clang_equalRanges(CXSourceRange range1,
429                                           CXSourceRange range2);
430 
431 /**
432  * \brief Returns non-zero if \p range is null.
433  */
434 CINDEX_LINKAGE int clang_Range_isNull(CXSourceRange range);
435 
436 /**
437  * \brief Retrieve the file, line, column, and offset represented by
438  * the given source location.
439  *
440  * If the location refers into a macro expansion, retrieves the
441  * location of the macro expansion.
442  *
443  * \param location the location within a source file that will be decomposed
444  * into its parts.
445  *
446  * \param file [out] if non-NULL, will be set to the file to which the given
447  * source location points.
448  *
449  * \param line [out] if non-NULL, will be set to the line to which the given
450  * source location points.
451  *
452  * \param column [out] if non-NULL, will be set to the column to which the given
453  * source location points.
454  *
455  * \param offset [out] if non-NULL, will be set to the offset into the
456  * buffer to which the given source location points.
457  */
458 CINDEX_LINKAGE void clang_getExpansionLocation(CXSourceLocation location,
459                                                CXFile *file,
460                                                unsigned *line,
461                                                unsigned *column,
462                                                unsigned *offset);
463 
464 /**
465  * \brief Retrieve the file, line, column, and offset represented by
466  * the given source location, as specified in a # line directive.
467  *
468  * Example: given the following source code in a file somefile.c
469  *
470  * \code
471  * #123 "dummy.c" 1
472  *
473  * static int func(void)
474  * {
475  *     return 0;
476  * }
477  * \endcode
478  *
479  * the location information returned by this function would be
480  *
481  * File: dummy.c Line: 124 Column: 12
482  *
483  * whereas clang_getExpansionLocation would have returned
484  *
485  * File: somefile.c Line: 3 Column: 12
486  *
487  * \param location the location within a source file that will be decomposed
488  * into its parts.
489  *
490  * \param filename [out] if non-NULL, will be set to the filename of the
491  * source location. Note that filenames returned will be for "virtual" files,
492  * which don't necessarily exist on the machine running clang - e.g. when
493  * parsing preprocessed output obtained from a different environment. If
494  * a non-NULL value is passed in, remember to dispose of the returned value
495  * using \c clang_disposeString() once you've finished with it. For an invalid
496  * source location, an empty string is returned.
497  *
498  * \param line [out] if non-NULL, will be set to the line number of the
499  * source location. For an invalid source location, zero is returned.
500  *
501  * \param column [out] if non-NULL, will be set to the column number of the
502  * source location. For an invalid source location, zero is returned.
503  */
504 CINDEX_LINKAGE void clang_getPresumedLocation(CXSourceLocation location,
505                                               CXString *filename,
506                                               unsigned *line,
507                                               unsigned *column);
508 
509 /**
510  * \brief Legacy API to retrieve the file, line, column, and offset represented
511  * by the given source location.
512  *
513  * This interface has been replaced by the newer interface
514  * #clang_getExpansionLocation(). See that interface's documentation for
515  * details.
516  */
517 CINDEX_LINKAGE void clang_getInstantiationLocation(CXSourceLocation location,
518                                                    CXFile *file,
519                                                    unsigned *line,
520                                                    unsigned *column,
521                                                    unsigned *offset);
522 
523 /**
524  * \brief Retrieve the file, line, column, and offset represented by
525  * the given source location.
526  *
527  * If the location refers into a macro instantiation, return where the
528  * location was originally spelled in the source file.
529  *
530  * \param location the location within a source file that will be decomposed
531  * into its parts.
532  *
533  * \param file [out] if non-NULL, will be set to the file to which the given
534  * source location points.
535  *
536  * \param line [out] if non-NULL, will be set to the line to which the given
537  * source location points.
538  *
539  * \param column [out] if non-NULL, will be set to the column to which the given
540  * source location points.
541  *
542  * \param offset [out] if non-NULL, will be set to the offset into the
543  * buffer to which the given source location points.
544  */
545 CINDEX_LINKAGE void clang_getSpellingLocation(CXSourceLocation location,
546                                               CXFile *file,
547                                               unsigned *line,
548                                               unsigned *column,
549                                               unsigned *offset);
550 
551 /**
552  * \brief Retrieve the file, line, column, and offset represented by
553  * the given source location.
554  *
555  * If the location refers into a macro expansion, return where the macro was
556  * expanded or where the macro argument was written, if the location points at
557  * a macro argument.
558  *
559  * \param location the location within a source file that will be decomposed
560  * into its parts.
561  *
562  * \param file [out] if non-NULL, will be set to the file to which the given
563  * source location points.
564  *
565  * \param line [out] if non-NULL, will be set to the line to which the given
566  * source location points.
567  *
568  * \param column [out] if non-NULL, will be set to the column to which the given
569  * source location points.
570  *
571  * \param offset [out] if non-NULL, will be set to the offset into the
572  * buffer to which the given source location points.
573  */
574 CINDEX_LINKAGE void clang_getFileLocation(CXSourceLocation location,
575                                           CXFile *file,
576                                           unsigned *line,
577                                           unsigned *column,
578                                           unsigned *offset);
579 
580 /**
581  * \brief Retrieve a source location representing the first character within a
582  * source range.
583  */
584 CINDEX_LINKAGE CXSourceLocation clang_getRangeStart(CXSourceRange range);
585 
586 /**
587  * \brief Retrieve a source location representing the last character within a
588  * source range.
589  */
590 CINDEX_LINKAGE CXSourceLocation clang_getRangeEnd(CXSourceRange range);
591 
592 /**
593  * @}
594  */
595 
596 /**
597  * \defgroup CINDEX_DIAG Diagnostic reporting
598  *
599  * @{
600  */
601 
602 /**
603  * \brief Describes the severity of a particular diagnostic.
604  */
605 enum CXDiagnosticSeverity {
606   /**
607    * \brief A diagnostic that has been suppressed, e.g., by a command-line
608    * option.
609    */
610   CXDiagnostic_Ignored = 0,
611 
612   /**
613    * \brief This diagnostic is a note that should be attached to the
614    * previous (non-note) diagnostic.
615    */
616   CXDiagnostic_Note    = 1,
617 
618   /**
619    * \brief This diagnostic indicates suspicious code that may not be
620    * wrong.
621    */
622   CXDiagnostic_Warning = 2,
623 
624   /**
625    * \brief This diagnostic indicates that the code is ill-formed.
626    */
627   CXDiagnostic_Error   = 3,
628 
629   /**
630    * \brief This diagnostic indicates that the code is ill-formed such
631    * that future parser recovery is unlikely to produce useful
632    * results.
633    */
634   CXDiagnostic_Fatal   = 4
635 };
636 
637 /**
638  * \brief A single diagnostic, containing the diagnostic's severity,
639  * location, text, source ranges, and fix-it hints.
640  */
641 typedef void *CXDiagnostic;
642 
643 /**
644  * \brief A group of CXDiagnostics.
645  */
646 typedef void *CXDiagnosticSet;
647 
648 /**
649  * \brief Determine the number of diagnostics in a CXDiagnosticSet.
650  */
651 CINDEX_LINKAGE unsigned clang_getNumDiagnosticsInSet(CXDiagnosticSet Diags);
652 
653 /**
654  * \brief Retrieve a diagnostic associated with the given CXDiagnosticSet.
655  *
656  * \param Diags the CXDiagnosticSet to query.
657  * \param Index the zero-based diagnostic number to retrieve.
658  *
659  * \returns the requested diagnostic. This diagnostic must be freed
660  * via a call to \c clang_disposeDiagnostic().
661  */
662 CINDEX_LINKAGE CXDiagnostic clang_getDiagnosticInSet(CXDiagnosticSet Diags,
663                                                      unsigned Index);
664 
665 
666 /**
667  * \brief Describes the kind of error that occurred (if any) in a call to
668  * \c clang_loadDiagnostics.
669  */
670 enum CXLoadDiag_Error {
671   /**
672    * \brief Indicates that no error occurred.
673    */
674   CXLoadDiag_None = 0,
675 
676   /**
677    * \brief Indicates that an unknown error occurred while attempting to
678    * deserialize diagnostics.
679    */
680   CXLoadDiag_Unknown = 1,
681 
682   /**
683    * \brief Indicates that the file containing the serialized diagnostics
684    * could not be opened.
685    */
686   CXLoadDiag_CannotLoad = 2,
687 
688   /**
689    * \brief Indicates that the serialized diagnostics file is invalid or
690    * corrupt.
691    */
692   CXLoadDiag_InvalidFile = 3
693 };
694 
695 /**
696  * \brief Deserialize a set of diagnostics from a Clang diagnostics bitcode
697  * file.
698  *
699  * \param file The name of the file to deserialize.
700  * \param error A pointer to a enum value recording if there was a problem
701  *        deserializing the diagnostics.
702  * \param errorString A pointer to a CXString for recording the error string
703  *        if the file was not successfully loaded.
704  *
705  * \returns A loaded CXDiagnosticSet if successful, and NULL otherwise.  These
706  * diagnostics should be released using clang_disposeDiagnosticSet().
707  */
708 CINDEX_LINKAGE CXDiagnosticSet clang_loadDiagnostics(const char *file,
709                                                   enum CXLoadDiag_Error *error,
710                                                   CXString *errorString);
711 
712 /**
713  * \brief Release a CXDiagnosticSet and all of its contained diagnostics.
714  */
715 CINDEX_LINKAGE void clang_disposeDiagnosticSet(CXDiagnosticSet Diags);
716 
717 /**
718  * \brief Retrieve the child diagnostics of a CXDiagnostic.
719  *
720  * This CXDiagnosticSet does not need to be released by
721  * clang_diposeDiagnosticSet.
722  */
723 CINDEX_LINKAGE CXDiagnosticSet clang_getChildDiagnostics(CXDiagnostic D);
724 
725 /**
726  * \brief Determine the number of diagnostics produced for the given
727  * translation unit.
728  */
729 CINDEX_LINKAGE unsigned clang_getNumDiagnostics(CXTranslationUnit Unit);
730 
731 /**
732  * \brief Retrieve a diagnostic associated with the given translation unit.
733  *
734  * \param Unit the translation unit to query.
735  * \param Index the zero-based diagnostic number to retrieve.
736  *
737  * \returns the requested diagnostic. This diagnostic must be freed
738  * via a call to \c clang_disposeDiagnostic().
739  */
740 CINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit,
741                                                 unsigned Index);
742 
743 /**
744  * \brief Retrieve the complete set of diagnostics associated with a
745  *        translation unit.
746  *
747  * \param Unit the translation unit to query.
748  */
749 CINDEX_LINKAGE CXDiagnosticSet
750   clang_getDiagnosticSetFromTU(CXTranslationUnit Unit);
751 
752 /**
753  * \brief Destroy a diagnostic.
754  */
755 CINDEX_LINKAGE void clang_disposeDiagnostic(CXDiagnostic Diagnostic);
756 
757 /**
758  * \brief Options to control the display of diagnostics.
759  *
760  * The values in this enum are meant to be combined to customize the
761  * behavior of \c clang_displayDiagnostic().
762  */
763 enum CXDiagnosticDisplayOptions {
764   /**
765    * \brief Display the source-location information where the
766    * diagnostic was located.
767    *
768    * When set, diagnostics will be prefixed by the file, line, and
769    * (optionally) column to which the diagnostic refers. For example,
770    *
771    * \code
772    * test.c:28: warning: extra tokens at end of #endif directive
773    * \endcode
774    *
775    * This option corresponds to the clang flag \c -fshow-source-location.
776    */
777   CXDiagnostic_DisplaySourceLocation = 0x01,
778 
779   /**
780    * \brief If displaying the source-location information of the
781    * diagnostic, also include the column number.
782    *
783    * This option corresponds to the clang flag \c -fshow-column.
784    */
785   CXDiagnostic_DisplayColumn = 0x02,
786 
787   /**
788    * \brief If displaying the source-location information of the
789    * diagnostic, also include information about source ranges in a
790    * machine-parsable format.
791    *
792    * This option corresponds to the clang flag
793    * \c -fdiagnostics-print-source-range-info.
794    */
795   CXDiagnostic_DisplaySourceRanges = 0x04,
796 
797   /**
798    * \brief Display the option name associated with this diagnostic, if any.
799    *
800    * The option name displayed (e.g., -Wconversion) will be placed in brackets
801    * after the diagnostic text. This option corresponds to the clang flag
802    * \c -fdiagnostics-show-option.
803    */
804   CXDiagnostic_DisplayOption = 0x08,
805 
806   /**
807    * \brief Display the category number associated with this diagnostic, if any.
808    *
809    * The category number is displayed within brackets after the diagnostic text.
810    * This option corresponds to the clang flag
811    * \c -fdiagnostics-show-category=id.
812    */
813   CXDiagnostic_DisplayCategoryId = 0x10,
814 
815   /**
816    * \brief Display the category name associated with this diagnostic, if any.
817    *
818    * The category name is displayed within brackets after the diagnostic text.
819    * This option corresponds to the clang flag
820    * \c -fdiagnostics-show-category=name.
821    */
822   CXDiagnostic_DisplayCategoryName = 0x20
823 };
824 
825 /**
826  * \brief Format the given diagnostic in a manner that is suitable for display.
827  *
828  * This routine will format the given diagnostic to a string, rendering
829  * the diagnostic according to the various options given. The
830  * \c clang_defaultDiagnosticDisplayOptions() function returns the set of
831  * options that most closely mimics the behavior of the clang compiler.
832  *
833  * \param Diagnostic The diagnostic to print.
834  *
835  * \param Options A set of options that control the diagnostic display,
836  * created by combining \c CXDiagnosticDisplayOptions values.
837  *
838  * \returns A new string containing for formatted diagnostic.
839  */
840 CINDEX_LINKAGE CXString clang_formatDiagnostic(CXDiagnostic Diagnostic,
841                                                unsigned Options);
842 
843 /**
844  * \brief Retrieve the set of display options most similar to the
845  * default behavior of the clang compiler.
846  *
847  * \returns A set of display options suitable for use with \c
848  * clang_displayDiagnostic().
849  */
850 CINDEX_LINKAGE unsigned clang_defaultDiagnosticDisplayOptions(void);
851 
852 /**
853  * \brief Determine the severity of the given diagnostic.
854  */
855 CINDEX_LINKAGE enum CXDiagnosticSeverity
856 clang_getDiagnosticSeverity(CXDiagnostic);
857 
858 /**
859  * \brief Retrieve the source location of the given diagnostic.
860  *
861  * This location is where Clang would print the caret ('^') when
862  * displaying the diagnostic on the command line.
863  */
864 CINDEX_LINKAGE CXSourceLocation clang_getDiagnosticLocation(CXDiagnostic);
865 
866 /**
867  * \brief Retrieve the text of the given diagnostic.
868  */
869 CINDEX_LINKAGE CXString clang_getDiagnosticSpelling(CXDiagnostic);
870 
871 /**
872  * \brief Retrieve the name of the command-line option that enabled this
873  * diagnostic.
874  *
875  * \param Diag The diagnostic to be queried.
876  *
877  * \param Disable If non-NULL, will be set to the option that disables this
878  * diagnostic (if any).
879  *
880  * \returns A string that contains the command-line option used to enable this
881  * warning, such as "-Wconversion" or "-pedantic".
882  */
883 CINDEX_LINKAGE CXString clang_getDiagnosticOption(CXDiagnostic Diag,
884                                                   CXString *Disable);
885 
886 /**
887  * \brief Retrieve the category number for this diagnostic.
888  *
889  * Diagnostics can be categorized into groups along with other, related
890  * diagnostics (e.g., diagnostics under the same warning flag). This routine
891  * retrieves the category number for the given diagnostic.
892  *
893  * \returns The number of the category that contains this diagnostic, or zero
894  * if this diagnostic is uncategorized.
895  */
896 CINDEX_LINKAGE unsigned clang_getDiagnosticCategory(CXDiagnostic);
897 
898 /**
899  * \brief Retrieve the name of a particular diagnostic category.  This
900  *  is now deprecated.  Use clang_getDiagnosticCategoryText()
901  *  instead.
902  *
903  * \param Category A diagnostic category number, as returned by
904  * \c clang_getDiagnosticCategory().
905  *
906  * \returns The name of the given diagnostic category.
907  */
908 CINDEX_DEPRECATED CINDEX_LINKAGE
909 CXString clang_getDiagnosticCategoryName(unsigned Category);
910 
911 /**
912  * \brief Retrieve the diagnostic category text for a given diagnostic.
913  *
914  * \returns The text of the given diagnostic category.
915  */
916 CINDEX_LINKAGE CXString clang_getDiagnosticCategoryText(CXDiagnostic);
917 
918 /**
919  * \brief Determine the number of source ranges associated with the given
920  * diagnostic.
921  */
922 CINDEX_LINKAGE unsigned clang_getDiagnosticNumRanges(CXDiagnostic);
923 
924 /**
925  * \brief Retrieve a source range associated with the diagnostic.
926  *
927  * A diagnostic's source ranges highlight important elements in the source
928  * code. On the command line, Clang displays source ranges by
929  * underlining them with '~' characters.
930  *
931  * \param Diagnostic the diagnostic whose range is being extracted.
932  *
933  * \param Range the zero-based index specifying which range to
934  *
935  * \returns the requested source range.
936  */
937 CINDEX_LINKAGE CXSourceRange clang_getDiagnosticRange(CXDiagnostic Diagnostic,
938                                                       unsigned Range);
939 
940 /**
941  * \brief Determine the number of fix-it hints associated with the
942  * given diagnostic.
943  */
944 CINDEX_LINKAGE unsigned clang_getDiagnosticNumFixIts(CXDiagnostic Diagnostic);
945 
946 /**
947  * \brief Retrieve the replacement information for a given fix-it.
948  *
949  * Fix-its are described in terms of a source range whose contents
950  * should be replaced by a string. This approach generalizes over
951  * three kinds of operations: removal of source code (the range covers
952  * the code to be removed and the replacement string is empty),
953  * replacement of source code (the range covers the code to be
954  * replaced and the replacement string provides the new code), and
955  * insertion (both the start and end of the range point at the
956  * insertion location, and the replacement string provides the text to
957  * insert).
958  *
959  * \param Diagnostic The diagnostic whose fix-its are being queried.
960  *
961  * \param FixIt The zero-based index of the fix-it.
962  *
963  * \param ReplacementRange The source range whose contents will be
964  * replaced with the returned replacement string. Note that source
965  * ranges are half-open ranges [a, b), so the source code should be
966  * replaced from a and up to (but not including) b.
967  *
968  * \returns A string containing text that should be replace the source
969  * code indicated by the \c ReplacementRange.
970  */
971 CINDEX_LINKAGE CXString clang_getDiagnosticFixIt(CXDiagnostic Diagnostic,
972                                                  unsigned FixIt,
973                                                CXSourceRange *ReplacementRange);
974 
975 /**
976  * @}
977  */
978 
979 /**
980  * \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation
981  *
982  * The routines in this group provide the ability to create and destroy
983  * translation units from files, either by parsing the contents of the files or
984  * by reading in a serialized representation of a translation unit.
985  *
986  * @{
987  */
988 
989 /**
990  * \brief Get the original translation unit source file name.
991  */
992 CINDEX_LINKAGE CXString
993 clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit);
994 
995 /**
996  * \brief Return the CXTranslationUnit for a given source file and the provided
997  * command line arguments one would pass to the compiler.
998  *
999  * Note: The 'source_filename' argument is optional.  If the caller provides a
1000  * NULL pointer, the name of the source file is expected to reside in the
1001  * specified command line arguments.
1002  *
1003  * Note: When encountered in 'clang_command_line_args', the following options
1004  * are ignored:
1005  *
1006  *   '-c'
1007  *   '-emit-ast'
1008  *   '-fsyntax-only'
1009  *   '-o \<output file>'  (both '-o' and '\<output file>' are ignored)
1010  *
1011  * \param CIdx The index object with which the translation unit will be
1012  * associated.
1013  *
1014  * \param source_filename The name of the source file to load, or NULL if the
1015  * source file is included in \p clang_command_line_args.
1016  *
1017  * \param num_clang_command_line_args The number of command-line arguments in
1018  * \p clang_command_line_args.
1019  *
1020  * \param clang_command_line_args The command-line arguments that would be
1021  * passed to the \c clang executable if it were being invoked out-of-process.
1022  * These command-line options will be parsed and will affect how the translation
1023  * unit is parsed. Note that the following options are ignored: '-c',
1024  * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
1025  *
1026  * \param num_unsaved_files the number of unsaved file entries in \p
1027  * unsaved_files.
1028  *
1029  * \param unsaved_files the files that have not yet been saved to disk
1030  * but may be required for code completion, including the contents of
1031  * those files.  The contents and name of these files (as specified by
1032  * CXUnsavedFile) are copied when necessary, so the client only needs to
1033  * guarantee their validity until the call to this function returns.
1034  */
1035 CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnitFromSourceFile(
1036                                          CXIndex CIdx,
1037                                          const char *source_filename,
1038                                          int num_clang_command_line_args,
1039                                    const char * const *clang_command_line_args,
1040                                          unsigned num_unsaved_files,
1041                                          struct CXUnsavedFile *unsaved_files);
1042 
1043 /**
1044  * \brief Create a translation unit from an AST file (-emit-ast).
1045  */
1046 CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnit(CXIndex,
1047                                              const char *ast_filename);
1048 
1049 /**
1050  * \brief Flags that control the creation of translation units.
1051  *
1052  * The enumerators in this enumeration type are meant to be bitwise
1053  * ORed together to specify which options should be used when
1054  * constructing the translation unit.
1055  */
1056 enum CXTranslationUnit_Flags {
1057   /**
1058    * \brief Used to indicate that no special translation-unit options are
1059    * needed.
1060    */
1061   CXTranslationUnit_None = 0x0,
1062 
1063   /**
1064    * \brief Used to indicate that the parser should construct a "detailed"
1065    * preprocessing record, including all macro definitions and instantiations.
1066    *
1067    * Constructing a detailed preprocessing record requires more memory
1068    * and time to parse, since the information contained in the record
1069    * is usually not retained. However, it can be useful for
1070    * applications that require more detailed information about the
1071    * behavior of the preprocessor.
1072    */
1073   CXTranslationUnit_DetailedPreprocessingRecord = 0x01,
1074 
1075   /**
1076    * \brief Used to indicate that the translation unit is incomplete.
1077    *
1078    * When a translation unit is considered "incomplete", semantic
1079    * analysis that is typically performed at the end of the
1080    * translation unit will be suppressed. For example, this suppresses
1081    * the completion of tentative declarations in C and of
1082    * instantiation of implicitly-instantiation function templates in
1083    * C++. This option is typically used when parsing a header with the
1084    * intent of producing a precompiled header.
1085    */
1086   CXTranslationUnit_Incomplete = 0x02,
1087 
1088   /**
1089    * \brief Used to indicate that the translation unit should be built with an
1090    * implicit precompiled header for the preamble.
1091    *
1092    * An implicit precompiled header is used as an optimization when a
1093    * particular translation unit is likely to be reparsed many times
1094    * when the sources aren't changing that often. In this case, an
1095    * implicit precompiled header will be built containing all of the
1096    * initial includes at the top of the main file (what we refer to as
1097    * the "preamble" of the file). In subsequent parses, if the
1098    * preamble or the files in it have not changed, \c
1099    * clang_reparseTranslationUnit() will re-use the implicit
1100    * precompiled header to improve parsing performance.
1101    */
1102   CXTranslationUnit_PrecompiledPreamble = 0x04,
1103 
1104   /**
1105    * \brief Used to indicate that the translation unit should cache some
1106    * code-completion results with each reparse of the source file.
1107    *
1108    * Caching of code-completion results is a performance optimization that
1109    * introduces some overhead to reparsing but improves the performance of
1110    * code-completion operations.
1111    */
1112   CXTranslationUnit_CacheCompletionResults = 0x08,
1113 
1114   /**
1115    * \brief Used to indicate that the translation unit will be serialized with
1116    * \c clang_saveTranslationUnit.
1117    *
1118    * This option is typically used when parsing a header with the intent of
1119    * producing a precompiled header.
1120    */
1121   CXTranslationUnit_ForSerialization = 0x10,
1122 
1123   /**
1124    * \brief DEPRECATED: Enabled chained precompiled preambles in C++.
1125    *
1126    * Note: this is a *temporary* option that is available only while
1127    * we are testing C++ precompiled preamble support. It is deprecated.
1128    */
1129   CXTranslationUnit_CXXChainedPCH = 0x20,
1130 
1131   /**
1132    * \brief Used to indicate that function/method bodies should be skipped while
1133    * parsing.
1134    *
1135    * This option can be used to search for declarations/definitions while
1136    * ignoring the usages.
1137    */
1138   CXTranslationUnit_SkipFunctionBodies = 0x40,
1139 
1140   /**
1141    * \brief Used to indicate that brief documentation comments should be
1142    * included into the set of code completions returned from this translation
1143    * unit.
1144    */
1145   CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 0x80
1146 };
1147 
1148 /**
1149  * \brief Returns the set of flags that is suitable for parsing a translation
1150  * unit that is being edited.
1151  *
1152  * The set of flags returned provide options for \c clang_parseTranslationUnit()
1153  * to indicate that the translation unit is likely to be reparsed many times,
1154  * either explicitly (via \c clang_reparseTranslationUnit()) or implicitly
1155  * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag
1156  * set contains an unspecified set of optimizations (e.g., the precompiled
1157  * preamble) geared toward improving the performance of these routines. The
1158  * set of optimizations enabled may change from one version to the next.
1159  */
1160 CINDEX_LINKAGE unsigned clang_defaultEditingTranslationUnitOptions(void);
1161 
1162 /**
1163  * \brief Parse the given source file and the translation unit corresponding
1164  * to that file.
1165  *
1166  * This routine is the main entry point for the Clang C API, providing the
1167  * ability to parse a source file into a translation unit that can then be
1168  * queried by other functions in the API. This routine accepts a set of
1169  * command-line arguments so that the compilation can be configured in the same
1170  * way that the compiler is configured on the command line.
1171  *
1172  * \param CIdx The index object with which the translation unit will be
1173  * associated.
1174  *
1175  * \param source_filename The name of the source file to load, or NULL if the
1176  * source file is included in \p command_line_args.
1177  *
1178  * \param command_line_args The command-line arguments that would be
1179  * passed to the \c clang executable if it were being invoked out-of-process.
1180  * These command-line options will be parsed and will affect how the translation
1181  * unit is parsed. Note that the following options are ignored: '-c',
1182  * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
1183  *
1184  * \param num_command_line_args The number of command-line arguments in
1185  * \p command_line_args.
1186  *
1187  * \param unsaved_files the files that have not yet been saved to disk
1188  * but may be required for parsing, including the contents of
1189  * those files.  The contents and name of these files (as specified by
1190  * CXUnsavedFile) are copied when necessary, so the client only needs to
1191  * guarantee their validity until the call to this function returns.
1192  *
1193  * \param num_unsaved_files the number of unsaved file entries in \p
1194  * unsaved_files.
1195  *
1196  * \param options A bitmask of options that affects how the translation unit
1197  * is managed but not its compilation. This should be a bitwise OR of the
1198  * CXTranslationUnit_XXX flags.
1199  *
1200  * \returns A new translation unit describing the parsed code and containing
1201  * any diagnostics produced by the compiler. If there is a failure from which
1202  * the compiler cannot recover, returns NULL.
1203  */
1204 CINDEX_LINKAGE CXTranslationUnit clang_parseTranslationUnit(CXIndex CIdx,
1205                                                     const char *source_filename,
1206                                          const char * const *command_line_args,
1207                                                       int num_command_line_args,
1208                                             struct CXUnsavedFile *unsaved_files,
1209                                                      unsigned num_unsaved_files,
1210                                                             unsigned options);
1211 
1212 /**
1213  * \brief Flags that control how translation units are saved.
1214  *
1215  * The enumerators in this enumeration type are meant to be bitwise
1216  * ORed together to specify which options should be used when
1217  * saving the translation unit.
1218  */
1219 enum CXSaveTranslationUnit_Flags {
1220   /**
1221    * \brief Used to indicate that no special saving options are needed.
1222    */
1223   CXSaveTranslationUnit_None = 0x0
1224 };
1225 
1226 /**
1227  * \brief Returns the set of flags that is suitable for saving a translation
1228  * unit.
1229  *
1230  * The set of flags returned provide options for
1231  * \c clang_saveTranslationUnit() by default. The returned flag
1232  * set contains an unspecified set of options that save translation units with
1233  * the most commonly-requested data.
1234  */
1235 CINDEX_LINKAGE unsigned clang_defaultSaveOptions(CXTranslationUnit TU);
1236 
1237 /**
1238  * \brief Describes the kind of error that occurred (if any) in a call to
1239  * \c clang_saveTranslationUnit().
1240  */
1241 enum CXSaveError {
1242   /**
1243    * \brief Indicates that no error occurred while saving a translation unit.
1244    */
1245   CXSaveError_None = 0,
1246 
1247   /**
1248    * \brief Indicates that an unknown error occurred while attempting to save
1249    * the file.
1250    *
1251    * This error typically indicates that file I/O failed when attempting to
1252    * write the file.
1253    */
1254   CXSaveError_Unknown = 1,
1255 
1256   /**
1257    * \brief Indicates that errors during translation prevented this attempt
1258    * to save the translation unit.
1259    *
1260    * Errors that prevent the translation unit from being saved can be
1261    * extracted using \c clang_getNumDiagnostics() and \c clang_getDiagnostic().
1262    */
1263   CXSaveError_TranslationErrors = 2,
1264 
1265   /**
1266    * \brief Indicates that the translation unit to be saved was somehow
1267    * invalid (e.g., NULL).
1268    */
1269   CXSaveError_InvalidTU = 3
1270 };
1271 
1272 /**
1273  * \brief Saves a translation unit into a serialized representation of
1274  * that translation unit on disk.
1275  *
1276  * Any translation unit that was parsed without error can be saved
1277  * into a file. The translation unit can then be deserialized into a
1278  * new \c CXTranslationUnit with \c clang_createTranslationUnit() or,
1279  * if it is an incomplete translation unit that corresponds to a
1280  * header, used as a precompiled header when parsing other translation
1281  * units.
1282  *
1283  * \param TU The translation unit to save.
1284  *
1285  * \param FileName The file to which the translation unit will be saved.
1286  *
1287  * \param options A bitmask of options that affects how the translation unit
1288  * is saved. This should be a bitwise OR of the
1289  * CXSaveTranslationUnit_XXX flags.
1290  *
1291  * \returns A value that will match one of the enumerators of the CXSaveError
1292  * enumeration. Zero (CXSaveError_None) indicates that the translation unit was
1293  * saved successfully, while a non-zero value indicates that a problem occurred.
1294  */
1295 CINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU,
1296                                              const char *FileName,
1297                                              unsigned options);
1298 
1299 /**
1300  * \brief Destroy the specified CXTranslationUnit object.
1301  */
1302 CINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit);
1303 
1304 /**
1305  * \brief Flags that control the reparsing of translation units.
1306  *
1307  * The enumerators in this enumeration type are meant to be bitwise
1308  * ORed together to specify which options should be used when
1309  * reparsing the translation unit.
1310  */
1311 enum CXReparse_Flags {
1312   /**
1313    * \brief Used to indicate that no special reparsing options are needed.
1314    */
1315   CXReparse_None = 0x0
1316 };
1317 
1318 /**
1319  * \brief Returns the set of flags that is suitable for reparsing a translation
1320  * unit.
1321  *
1322  * The set of flags returned provide options for
1323  * \c clang_reparseTranslationUnit() by default. The returned flag
1324  * set contains an unspecified set of optimizations geared toward common uses
1325  * of reparsing. The set of optimizations enabled may change from one version
1326  * to the next.
1327  */
1328 CINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU);
1329 
1330 /**
1331  * \brief Reparse the source files that produced this translation unit.
1332  *
1333  * This routine can be used to re-parse the source files that originally
1334  * created the given translation unit, for example because those source files
1335  * have changed (either on disk or as passed via \p unsaved_files). The
1336  * source code will be reparsed with the same command-line options as it
1337  * was originally parsed.
1338  *
1339  * Reparsing a translation unit invalidates all cursors and source locations
1340  * that refer into that translation unit. This makes reparsing a translation
1341  * unit semantically equivalent to destroying the translation unit and then
1342  * creating a new translation unit with the same command-line arguments.
1343  * However, it may be more efficient to reparse a translation
1344  * unit using this routine.
1345  *
1346  * \param TU The translation unit whose contents will be re-parsed. The
1347  * translation unit must originally have been built with
1348  * \c clang_createTranslationUnitFromSourceFile().
1349  *
1350  * \param num_unsaved_files The number of unsaved file entries in \p
1351  * unsaved_files.
1352  *
1353  * \param unsaved_files The files that have not yet been saved to disk
1354  * but may be required for parsing, including the contents of
1355  * those files.  The contents and name of these files (as specified by
1356  * CXUnsavedFile) are copied when necessary, so the client only needs to
1357  * guarantee their validity until the call to this function returns.
1358  *
1359  * \param options A bitset of options composed of the flags in CXReparse_Flags.
1360  * The function \c clang_defaultReparseOptions() produces a default set of
1361  * options recommended for most uses, based on the translation unit.
1362  *
1363  * \returns 0 if the sources could be reparsed. A non-zero value will be
1364  * returned if reparsing was impossible, such that the translation unit is
1365  * invalid. In such cases, the only valid call for \p TU is
1366  * \c clang_disposeTranslationUnit(TU).
1367  */
1368 CINDEX_LINKAGE int clang_reparseTranslationUnit(CXTranslationUnit TU,
1369                                                 unsigned num_unsaved_files,
1370                                           struct CXUnsavedFile *unsaved_files,
1371                                                 unsigned options);
1372 
1373 /**
1374   * \brief Categorizes how memory is being used by a translation unit.
1375   */
1376 enum CXTUResourceUsageKind {
1377   CXTUResourceUsage_AST = 1,
1378   CXTUResourceUsage_Identifiers = 2,
1379   CXTUResourceUsage_Selectors = 3,
1380   CXTUResourceUsage_GlobalCompletionResults = 4,
1381   CXTUResourceUsage_SourceManagerContentCache = 5,
1382   CXTUResourceUsage_AST_SideTables = 6,
1383   CXTUResourceUsage_SourceManager_Membuffer_Malloc = 7,
1384   CXTUResourceUsage_SourceManager_Membuffer_MMap = 8,
1385   CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc = 9,
1386   CXTUResourceUsage_ExternalASTSource_Membuffer_MMap = 10,
1387   CXTUResourceUsage_Preprocessor = 11,
1388   CXTUResourceUsage_PreprocessingRecord = 12,
1389   CXTUResourceUsage_SourceManager_DataStructures = 13,
1390   CXTUResourceUsage_Preprocessor_HeaderSearch = 14,
1391   CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST,
1392   CXTUResourceUsage_MEMORY_IN_BYTES_END =
1393     CXTUResourceUsage_Preprocessor_HeaderSearch,
1394 
1395   CXTUResourceUsage_First = CXTUResourceUsage_AST,
1396   CXTUResourceUsage_Last = CXTUResourceUsage_Preprocessor_HeaderSearch
1397 };
1398 
1399 /**
1400   * \brief Returns the human-readable null-terminated C string that represents
1401   *  the name of the memory category.  This string should never be freed.
1402   */
1403 CINDEX_LINKAGE
1404 const char *clang_getTUResourceUsageName(enum CXTUResourceUsageKind kind);
1405 
1406 typedef struct CXTUResourceUsageEntry {
1407   /* \brief The memory usage category. */
1408   enum CXTUResourceUsageKind kind;
1409   /* \brief Amount of resources used.
1410       The units will depend on the resource kind. */
1411   unsigned long amount;
1412 } CXTUResourceUsageEntry;
1413 
1414 /**
1415   * \brief The memory usage of a CXTranslationUnit, broken into categories.
1416   */
1417 typedef struct CXTUResourceUsage {
1418   /* \brief Private data member, used for queries. */
1419   void *data;
1420 
1421   /* \brief The number of entries in the 'entries' array. */
1422   unsigned numEntries;
1423 
1424   /* \brief An array of key-value pairs, representing the breakdown of memory
1425             usage. */
1426   CXTUResourceUsageEntry *entries;
1427 
1428 } CXTUResourceUsage;
1429 
1430 /**
1431   * \brief Return the memory usage of a translation unit.  This object
1432   *  should be released with clang_disposeCXTUResourceUsage().
1433   */
1434 CINDEX_LINKAGE CXTUResourceUsage clang_getCXTUResourceUsage(CXTranslationUnit TU);
1435 
1436 CINDEX_LINKAGE void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage);
1437 
1438 /**
1439  * @}
1440  */
1441 
1442 /**
1443  * \brief Describes the kind of entity that a cursor refers to.
1444  */
1445 enum CXCursorKind {
1446   /* Declarations */
1447   /**
1448    * \brief A declaration whose specific kind is not exposed via this
1449    * interface.
1450    *
1451    * Unexposed declarations have the same operations as any other kind
1452    * of declaration; one can extract their location information,
1453    * spelling, find their definitions, etc. However, the specific kind
1454    * of the declaration is not reported.
1455    */
1456   CXCursor_UnexposedDecl                 = 1,
1457   /** \brief A C or C++ struct. */
1458   CXCursor_StructDecl                    = 2,
1459   /** \brief A C or C++ union. */
1460   CXCursor_UnionDecl                     = 3,
1461   /** \brief A C++ class. */
1462   CXCursor_ClassDecl                     = 4,
1463   /** \brief An enumeration. */
1464   CXCursor_EnumDecl                      = 5,
1465   /**
1466    * \brief A field (in C) or non-static data member (in C++) in a
1467    * struct, union, or C++ class.
1468    */
1469   CXCursor_FieldDecl                     = 6,
1470   /** \brief An enumerator constant. */
1471   CXCursor_EnumConstantDecl              = 7,
1472   /** \brief A function. */
1473   CXCursor_FunctionDecl                  = 8,
1474   /** \brief A variable. */
1475   CXCursor_VarDecl                       = 9,
1476   /** \brief A function or method parameter. */
1477   CXCursor_ParmDecl                      = 10,
1478   /** \brief An Objective-C \@interface. */
1479   CXCursor_ObjCInterfaceDecl             = 11,
1480   /** \brief An Objective-C \@interface for a category. */
1481   CXCursor_ObjCCategoryDecl              = 12,
1482   /** \brief An Objective-C \@protocol declaration. */
1483   CXCursor_ObjCProtocolDecl              = 13,
1484   /** \brief An Objective-C \@property declaration. */
1485   CXCursor_ObjCPropertyDecl              = 14,
1486   /** \brief An Objective-C instance variable. */
1487   CXCursor_ObjCIvarDecl                  = 15,
1488   /** \brief An Objective-C instance method. */
1489   CXCursor_ObjCInstanceMethodDecl        = 16,
1490   /** \brief An Objective-C class method. */
1491   CXCursor_ObjCClassMethodDecl           = 17,
1492   /** \brief An Objective-C \@implementation. */
1493   CXCursor_ObjCImplementationDecl        = 18,
1494   /** \brief An Objective-C \@implementation for a category. */
1495   CXCursor_ObjCCategoryImplDecl          = 19,
1496   /** \brief A typedef */
1497   CXCursor_TypedefDecl                   = 20,
1498   /** \brief A C++ class method. */
1499   CXCursor_CXXMethod                     = 21,
1500   /** \brief A C++ namespace. */
1501   CXCursor_Namespace                     = 22,
1502   /** \brief A linkage specification, e.g. 'extern "C"'. */
1503   CXCursor_LinkageSpec                   = 23,
1504   /** \brief A C++ constructor. */
1505   CXCursor_Constructor                   = 24,
1506   /** \brief A C++ destructor. */
1507   CXCursor_Destructor                    = 25,
1508   /** \brief A C++ conversion function. */
1509   CXCursor_ConversionFunction            = 26,
1510   /** \brief A C++ template type parameter. */
1511   CXCursor_TemplateTypeParameter         = 27,
1512   /** \brief A C++ non-type template parameter. */
1513   CXCursor_NonTypeTemplateParameter      = 28,
1514   /** \brief A C++ template template parameter. */
1515   CXCursor_TemplateTemplateParameter     = 29,
1516   /** \brief A C++ function template. */
1517   CXCursor_FunctionTemplate              = 30,
1518   /** \brief A C++ class template. */
1519   CXCursor_ClassTemplate                 = 31,
1520   /** \brief A C++ class template partial specialization. */
1521   CXCursor_ClassTemplatePartialSpecialization = 32,
1522   /** \brief A C++ namespace alias declaration. */
1523   CXCursor_NamespaceAlias                = 33,
1524   /** \brief A C++ using directive. */
1525   CXCursor_UsingDirective                = 34,
1526   /** \brief A C++ using declaration. */
1527   CXCursor_UsingDeclaration              = 35,
1528   /** \brief A C++ alias declaration */
1529   CXCursor_TypeAliasDecl                 = 36,
1530   /** \brief An Objective-C \@synthesize definition. */
1531   CXCursor_ObjCSynthesizeDecl            = 37,
1532   /** \brief An Objective-C \@dynamic definition. */
1533   CXCursor_ObjCDynamicDecl               = 38,
1534   /** \brief An access specifier. */
1535   CXCursor_CXXAccessSpecifier            = 39,
1536 
1537   CXCursor_FirstDecl                     = CXCursor_UnexposedDecl,
1538   CXCursor_LastDecl                      = CXCursor_CXXAccessSpecifier,
1539 
1540   /* References */
1541   CXCursor_FirstRef                      = 40, /* Decl references */
1542   CXCursor_ObjCSuperClassRef             = 40,
1543   CXCursor_ObjCProtocolRef               = 41,
1544   CXCursor_ObjCClassRef                  = 42,
1545   /**
1546    * \brief A reference to a type declaration.
1547    *
1548    * A type reference occurs anywhere where a type is named but not
1549    * declared. For example, given:
1550    *
1551    * \code
1552    * typedef unsigned size_type;
1553    * size_type size;
1554    * \endcode
1555    *
1556    * The typedef is a declaration of size_type (CXCursor_TypedefDecl),
1557    * while the type of the variable "size" is referenced. The cursor
1558    * referenced by the type of size is the typedef for size_type.
1559    */
1560   CXCursor_TypeRef                       = 43,
1561   CXCursor_CXXBaseSpecifier              = 44,
1562   /**
1563    * \brief A reference to a class template, function template, template
1564    * template parameter, or class template partial specialization.
1565    */
1566   CXCursor_TemplateRef                   = 45,
1567   /**
1568    * \brief A reference to a namespace or namespace alias.
1569    */
1570   CXCursor_NamespaceRef                  = 46,
1571   /**
1572    * \brief A reference to a member of a struct, union, or class that occurs in
1573    * some non-expression context, e.g., a designated initializer.
1574    */
1575   CXCursor_MemberRef                     = 47,
1576   /**
1577    * \brief A reference to a labeled statement.
1578    *
1579    * This cursor kind is used to describe the jump to "start_over" in the
1580    * goto statement in the following example:
1581    *
1582    * \code
1583    *   start_over:
1584    *     ++counter;
1585    *
1586    *     goto start_over;
1587    * \endcode
1588    *
1589    * A label reference cursor refers to a label statement.
1590    */
1591   CXCursor_LabelRef                      = 48,
1592 
1593   /**
1594    * \brief A reference to a set of overloaded functions or function templates
1595    * that has not yet been resolved to a specific function or function template.
1596    *
1597    * An overloaded declaration reference cursor occurs in C++ templates where
1598    * a dependent name refers to a function. For example:
1599    *
1600    * \code
1601    * template<typename T> void swap(T&, T&);
1602    *
1603    * struct X { ... };
1604    * void swap(X&, X&);
1605    *
1606    * template<typename T>
1607    * void reverse(T* first, T* last) {
1608    *   while (first < last - 1) {
1609    *     swap(*first, *--last);
1610    *     ++first;
1611    *   }
1612    * }
1613    *
1614    * struct Y { };
1615    * void swap(Y&, Y&);
1616    * \endcode
1617    *
1618    * Here, the identifier "swap" is associated with an overloaded declaration
1619    * reference. In the template definition, "swap" refers to either of the two
1620    * "swap" functions declared above, so both results will be available. At
1621    * instantiation time, "swap" may also refer to other functions found via
1622    * argument-dependent lookup (e.g., the "swap" function at the end of the
1623    * example).
1624    *
1625    * The functions \c clang_getNumOverloadedDecls() and
1626    * \c clang_getOverloadedDecl() can be used to retrieve the definitions
1627    * referenced by this cursor.
1628    */
1629   CXCursor_OverloadedDeclRef             = 49,
1630 
1631   /**
1632    * \brief A reference to a variable that occurs in some non-expression
1633    * context, e.g., a C++ lambda capture list.
1634    */
1635   CXCursor_VariableRef                   = 50,
1636 
1637   CXCursor_LastRef                       = CXCursor_VariableRef,
1638 
1639   /* Error conditions */
1640   CXCursor_FirstInvalid                  = 70,
1641   CXCursor_InvalidFile                   = 70,
1642   CXCursor_NoDeclFound                   = 71,
1643   CXCursor_NotImplemented                = 72,
1644   CXCursor_InvalidCode                   = 73,
1645   CXCursor_LastInvalid                   = CXCursor_InvalidCode,
1646 
1647   /* Expressions */
1648   CXCursor_FirstExpr                     = 100,
1649 
1650   /**
1651    * \brief An expression whose specific kind is not exposed via this
1652    * interface.
1653    *
1654    * Unexposed expressions have the same operations as any other kind
1655    * of expression; one can extract their location information,
1656    * spelling, children, etc. However, the specific kind of the
1657    * expression is not reported.
1658    */
1659   CXCursor_UnexposedExpr                 = 100,
1660 
1661   /**
1662    * \brief An expression that refers to some value declaration, such
1663    * as a function, varible, or enumerator.
1664    */
1665   CXCursor_DeclRefExpr                   = 101,
1666 
1667   /**
1668    * \brief An expression that refers to a member of a struct, union,
1669    * class, Objective-C class, etc.
1670    */
1671   CXCursor_MemberRefExpr                 = 102,
1672 
1673   /** \brief An expression that calls a function. */
1674   CXCursor_CallExpr                      = 103,
1675 
1676   /** \brief An expression that sends a message to an Objective-C
1677    object or class. */
1678   CXCursor_ObjCMessageExpr               = 104,
1679 
1680   /** \brief An expression that represents a block literal. */
1681   CXCursor_BlockExpr                     = 105,
1682 
1683   /** \brief An integer literal.
1684    */
1685   CXCursor_IntegerLiteral                = 106,
1686 
1687   /** \brief A floating point number literal.
1688    */
1689   CXCursor_FloatingLiteral               = 107,
1690 
1691   /** \brief An imaginary number literal.
1692    */
1693   CXCursor_ImaginaryLiteral              = 108,
1694 
1695   /** \brief A string literal.
1696    */
1697   CXCursor_StringLiteral                 = 109,
1698 
1699   /** \brief A character literal.
1700    */
1701   CXCursor_CharacterLiteral              = 110,
1702 
1703   /** \brief A parenthesized expression, e.g. "(1)".
1704    *
1705    * This AST node is only formed if full location information is requested.
1706    */
1707   CXCursor_ParenExpr                     = 111,
1708 
1709   /** \brief This represents the unary-expression's (except sizeof and
1710    * alignof).
1711    */
1712   CXCursor_UnaryOperator                 = 112,
1713 
1714   /** \brief [C99 6.5.2.1] Array Subscripting.
1715    */
1716   CXCursor_ArraySubscriptExpr            = 113,
1717 
1718   /** \brief A builtin binary operation expression such as "x + y" or
1719    * "x <= y".
1720    */
1721   CXCursor_BinaryOperator                = 114,
1722 
1723   /** \brief Compound assignment such as "+=".
1724    */
1725   CXCursor_CompoundAssignOperator        = 115,
1726 
1727   /** \brief The ?: ternary operator.
1728    */
1729   CXCursor_ConditionalOperator           = 116,
1730 
1731   /** \brief An explicit cast in C (C99 6.5.4) or a C-style cast in C++
1732    * (C++ [expr.cast]), which uses the syntax (Type)expr.
1733    *
1734    * For example: (int)f.
1735    */
1736   CXCursor_CStyleCastExpr                = 117,
1737 
1738   /** \brief [C99 6.5.2.5]
1739    */
1740   CXCursor_CompoundLiteralExpr           = 118,
1741 
1742   /** \brief Describes an C or C++ initializer list.
1743    */
1744   CXCursor_InitListExpr                  = 119,
1745 
1746   /** \brief The GNU address of label extension, representing &&label.
1747    */
1748   CXCursor_AddrLabelExpr                 = 120,
1749 
1750   /** \brief This is the GNU Statement Expression extension: ({int X=4; X;})
1751    */
1752   CXCursor_StmtExpr                      = 121,
1753 
1754   /** \brief Represents a C11 generic selection.
1755    */
1756   CXCursor_GenericSelectionExpr          = 122,
1757 
1758   /** \brief Implements the GNU __null extension, which is a name for a null
1759    * pointer constant that has integral type (e.g., int or long) and is the same
1760    * size and alignment as a pointer.
1761    *
1762    * The __null extension is typically only used by system headers, which define
1763    * NULL as __null in C++ rather than using 0 (which is an integer that may not
1764    * match the size of a pointer).
1765    */
1766   CXCursor_GNUNullExpr                   = 123,
1767 
1768   /** \brief C++'s static_cast<> expression.
1769    */
1770   CXCursor_CXXStaticCastExpr             = 124,
1771 
1772   /** \brief C++'s dynamic_cast<> expression.
1773    */
1774   CXCursor_CXXDynamicCastExpr            = 125,
1775 
1776   /** \brief C++'s reinterpret_cast<> expression.
1777    */
1778   CXCursor_CXXReinterpretCastExpr        = 126,
1779 
1780   /** \brief C++'s const_cast<> expression.
1781    */
1782   CXCursor_CXXConstCastExpr              = 127,
1783 
1784   /** \brief Represents an explicit C++ type conversion that uses "functional"
1785    * notion (C++ [expr.type.conv]).
1786    *
1787    * Example:
1788    * \code
1789    *   x = int(0.5);
1790    * \endcode
1791    */
1792   CXCursor_CXXFunctionalCastExpr         = 128,
1793 
1794   /** \brief A C++ typeid expression (C++ [expr.typeid]).
1795    */
1796   CXCursor_CXXTypeidExpr                 = 129,
1797 
1798   /** \brief [C++ 2.13.5] C++ Boolean Literal.
1799    */
1800   CXCursor_CXXBoolLiteralExpr            = 130,
1801 
1802   /** \brief [C++0x 2.14.7] C++ Pointer Literal.
1803    */
1804   CXCursor_CXXNullPtrLiteralExpr         = 131,
1805 
1806   /** \brief Represents the "this" expression in C++
1807    */
1808   CXCursor_CXXThisExpr                   = 132,
1809 
1810   /** \brief [C++ 15] C++ Throw Expression.
1811    *
1812    * This handles 'throw' and 'throw' assignment-expression. When
1813    * assignment-expression isn't present, Op will be null.
1814    */
1815   CXCursor_CXXThrowExpr                  = 133,
1816 
1817   /** \brief A new expression for memory allocation and constructor calls, e.g:
1818    * "new CXXNewExpr(foo)".
1819    */
1820   CXCursor_CXXNewExpr                    = 134,
1821 
1822   /** \brief A delete expression for memory deallocation and destructor calls,
1823    * e.g. "delete[] pArray".
1824    */
1825   CXCursor_CXXDeleteExpr                 = 135,
1826 
1827   /** \brief A unary expression.
1828    */
1829   CXCursor_UnaryExpr                     = 136,
1830 
1831   /** \brief An Objective-C string literal i.e. @"foo".
1832    */
1833   CXCursor_ObjCStringLiteral             = 137,
1834 
1835   /** \brief An Objective-C \@encode expression.
1836    */
1837   CXCursor_ObjCEncodeExpr                = 138,
1838 
1839   /** \brief An Objective-C \@selector expression.
1840    */
1841   CXCursor_ObjCSelectorExpr              = 139,
1842 
1843   /** \brief An Objective-C \@protocol expression.
1844    */
1845   CXCursor_ObjCProtocolExpr              = 140,
1846 
1847   /** \brief An Objective-C "bridged" cast expression, which casts between
1848    * Objective-C pointers and C pointers, transferring ownership in the process.
1849    *
1850    * \code
1851    *   NSString *str = (__bridge_transfer NSString *)CFCreateString();
1852    * \endcode
1853    */
1854   CXCursor_ObjCBridgedCastExpr           = 141,
1855 
1856   /** \brief Represents a C++0x pack expansion that produces a sequence of
1857    * expressions.
1858    *
1859    * A pack expansion expression contains a pattern (which itself is an
1860    * expression) followed by an ellipsis. For example:
1861    *
1862    * \code
1863    * template<typename F, typename ...Types>
1864    * void forward(F f, Types &&...args) {
1865    *  f(static_cast<Types&&>(args)...);
1866    * }
1867    * \endcode
1868    */
1869   CXCursor_PackExpansionExpr             = 142,
1870 
1871   /** \brief Represents an expression that computes the length of a parameter
1872    * pack.
1873    *
1874    * \code
1875    * template<typename ...Types>
1876    * struct count {
1877    *   static const unsigned value = sizeof...(Types);
1878    * };
1879    * \endcode
1880    */
1881   CXCursor_SizeOfPackExpr                = 143,
1882 
1883   /* \brief Represents a C++ lambda expression that produces a local function
1884    * object.
1885    *
1886    * \code
1887    * void abssort(float *x, unsigned N) {
1888    *   std::sort(x, x + N,
1889    *             [](float a, float b) {
1890    *               return std::abs(a) < std::abs(b);
1891    *             });
1892    * }
1893    * \endcode
1894    */
1895   CXCursor_LambdaExpr                    = 144,
1896 
1897   /** \brief Objective-c Boolean Literal.
1898    */
1899   CXCursor_ObjCBoolLiteralExpr           = 145,
1900 
1901   CXCursor_LastExpr                      = CXCursor_ObjCBoolLiteralExpr,
1902 
1903   /* Statements */
1904   CXCursor_FirstStmt                     = 200,
1905   /**
1906    * \brief A statement whose specific kind is not exposed via this
1907    * interface.
1908    *
1909    * Unexposed statements have the same operations as any other kind of
1910    * statement; one can extract their location information, spelling,
1911    * children, etc. However, the specific kind of the statement is not
1912    * reported.
1913    */
1914   CXCursor_UnexposedStmt                 = 200,
1915 
1916   /** \brief A labelled statement in a function.
1917    *
1918    * This cursor kind is used to describe the "start_over:" label statement in
1919    * the following example:
1920    *
1921    * \code
1922    *   start_over:
1923    *     ++counter;
1924    * \endcode
1925    *
1926    */
1927   CXCursor_LabelStmt                     = 201,
1928 
1929   /** \brief A group of statements like { stmt stmt }.
1930    *
1931    * This cursor kind is used to describe compound statements, e.g. function
1932    * bodies.
1933    */
1934   CXCursor_CompoundStmt                  = 202,
1935 
1936   /** \brief A case statment.
1937    */
1938   CXCursor_CaseStmt                      = 203,
1939 
1940   /** \brief A default statement.
1941    */
1942   CXCursor_DefaultStmt                   = 204,
1943 
1944   /** \brief An if statement
1945    */
1946   CXCursor_IfStmt                        = 205,
1947 
1948   /** \brief A switch statement.
1949    */
1950   CXCursor_SwitchStmt                    = 206,
1951 
1952   /** \brief A while statement.
1953    */
1954   CXCursor_WhileStmt                     = 207,
1955 
1956   /** \brief A do statement.
1957    */
1958   CXCursor_DoStmt                        = 208,
1959 
1960   /** \brief A for statement.
1961    */
1962   CXCursor_ForStmt                       = 209,
1963 
1964   /** \brief A goto statement.
1965    */
1966   CXCursor_GotoStmt                      = 210,
1967 
1968   /** \brief An indirect goto statement.
1969    */
1970   CXCursor_IndirectGotoStmt              = 211,
1971 
1972   /** \brief A continue statement.
1973    */
1974   CXCursor_ContinueStmt                  = 212,
1975 
1976   /** \brief A break statement.
1977    */
1978   CXCursor_BreakStmt                     = 213,
1979 
1980   /** \brief A return statement.
1981    */
1982   CXCursor_ReturnStmt                    = 214,
1983 
1984   /** \brief A GCC inline assembly statement extension.
1985    */
1986   CXCursor_GCCAsmStmt                    = 215,
1987   CXCursor_AsmStmt                       = CXCursor_GCCAsmStmt,
1988 
1989   /** \brief Objective-C's overall \@try-\@catch-\@finally statement.
1990    */
1991   CXCursor_ObjCAtTryStmt                 = 216,
1992 
1993   /** \brief Objective-C's \@catch statement.
1994    */
1995   CXCursor_ObjCAtCatchStmt               = 217,
1996 
1997   /** \brief Objective-C's \@finally statement.
1998    */
1999   CXCursor_ObjCAtFinallyStmt             = 218,
2000 
2001   /** \brief Objective-C's \@throw statement.
2002    */
2003   CXCursor_ObjCAtThrowStmt               = 219,
2004 
2005   /** \brief Objective-C's \@synchronized statement.
2006    */
2007   CXCursor_ObjCAtSynchronizedStmt        = 220,
2008 
2009   /** \brief Objective-C's autorelease pool statement.
2010    */
2011   CXCursor_ObjCAutoreleasePoolStmt       = 221,
2012 
2013   /** \brief Objective-C's collection statement.
2014    */
2015   CXCursor_ObjCForCollectionStmt         = 222,
2016 
2017   /** \brief C++'s catch statement.
2018    */
2019   CXCursor_CXXCatchStmt                  = 223,
2020 
2021   /** \brief C++'s try statement.
2022    */
2023   CXCursor_CXXTryStmt                    = 224,
2024 
2025   /** \brief C++'s for (* : *) statement.
2026    */
2027   CXCursor_CXXForRangeStmt               = 225,
2028 
2029   /** \brief Windows Structured Exception Handling's try statement.
2030    */
2031   CXCursor_SEHTryStmt                    = 226,
2032 
2033   /** \brief Windows Structured Exception Handling's except statement.
2034    */
2035   CXCursor_SEHExceptStmt                 = 227,
2036 
2037   /** \brief Windows Structured Exception Handling's finally statement.
2038    */
2039   CXCursor_SEHFinallyStmt                = 228,
2040 
2041   /** \brief A MS inline assembly statement extension.
2042    */
2043   CXCursor_MSAsmStmt                     = 229,
2044 
2045   /** \brief The null satement ";": C99 6.8.3p3.
2046    *
2047    * This cursor kind is used to describe the null statement.
2048    */
2049   CXCursor_NullStmt                      = 230,
2050 
2051   /** \brief Adaptor class for mixing declarations with statements and
2052    * expressions.
2053    */
2054   CXCursor_DeclStmt                      = 231,
2055 
2056   CXCursor_LastStmt                      = CXCursor_DeclStmt,
2057 
2058   /**
2059    * \brief Cursor that represents the translation unit itself.
2060    *
2061    * The translation unit cursor exists primarily to act as the root
2062    * cursor for traversing the contents of a translation unit.
2063    */
2064   CXCursor_TranslationUnit               = 300,
2065 
2066   /* Attributes */
2067   CXCursor_FirstAttr                     = 400,
2068   /**
2069    * \brief An attribute whose specific kind is not exposed via this
2070    * interface.
2071    */
2072   CXCursor_UnexposedAttr                 = 400,
2073 
2074   CXCursor_IBActionAttr                  = 401,
2075   CXCursor_IBOutletAttr                  = 402,
2076   CXCursor_IBOutletCollectionAttr        = 403,
2077   CXCursor_CXXFinalAttr                  = 404,
2078   CXCursor_CXXOverrideAttr               = 405,
2079   CXCursor_AnnotateAttr                  = 406,
2080   CXCursor_AsmLabelAttr                  = 407,
2081   CXCursor_LastAttr                      = CXCursor_AsmLabelAttr,
2082 
2083   /* Preprocessing */
2084   CXCursor_PreprocessingDirective        = 500,
2085   CXCursor_MacroDefinition               = 501,
2086   CXCursor_MacroExpansion                = 502,
2087   CXCursor_MacroInstantiation            = CXCursor_MacroExpansion,
2088   CXCursor_InclusionDirective            = 503,
2089   CXCursor_FirstPreprocessing            = CXCursor_PreprocessingDirective,
2090   CXCursor_LastPreprocessing             = CXCursor_InclusionDirective,
2091 
2092   /* Extra Declarations */
2093   /**
2094    * \brief A module import declaration.
2095    */
2096   CXCursor_ModuleImportDecl              = 600,
2097   CXCursor_FirstExtraDecl                = CXCursor_ModuleImportDecl,
2098   CXCursor_LastExtraDecl                 = CXCursor_ModuleImportDecl
2099 };
2100 
2101 /**
2102  * \brief A cursor representing some element in the abstract syntax tree for
2103  * a translation unit.
2104  *
2105  * The cursor abstraction unifies the different kinds of entities in a
2106  * program--declaration, statements, expressions, references to declarations,
2107  * etc.--under a single "cursor" abstraction with a common set of operations.
2108  * Common operation for a cursor include: getting the physical location in
2109  * a source file where the cursor points, getting the name associated with a
2110  * cursor, and retrieving cursors for any child nodes of a particular cursor.
2111  *
2112  * Cursors can be produced in two specific ways.
2113  * clang_getTranslationUnitCursor() produces a cursor for a translation unit,
2114  * from which one can use clang_visitChildren() to explore the rest of the
2115  * translation unit. clang_getCursor() maps from a physical source location
2116  * to the entity that resides at that location, allowing one to map from the
2117  * source code into the AST.
2118  */
2119 typedef struct {
2120   enum CXCursorKind kind;
2121   int xdata;
2122   const void *data[3];
2123 } CXCursor;
2124 
2125 /**
2126  * \brief A comment AST node.
2127  */
2128 typedef struct {
2129   const void *ASTNode;
2130   CXTranslationUnit TranslationUnit;
2131 } CXComment;
2132 
2133 /**
2134  * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations
2135  *
2136  * @{
2137  */
2138 
2139 /**
2140  * \brief Retrieve the NULL cursor, which represents no entity.
2141  */
2142 CINDEX_LINKAGE CXCursor clang_getNullCursor(void);
2143 
2144 /**
2145  * \brief Retrieve the cursor that represents the given translation unit.
2146  *
2147  * The translation unit cursor can be used to start traversing the
2148  * various declarations within the given translation unit.
2149  */
2150 CINDEX_LINKAGE CXCursor clang_getTranslationUnitCursor(CXTranslationUnit);
2151 
2152 /**
2153  * \brief Determine whether two cursors are equivalent.
2154  */
2155 CINDEX_LINKAGE unsigned clang_equalCursors(CXCursor, CXCursor);
2156 
2157 /**
2158  * \brief Returns non-zero if \p cursor is null.
2159  */
2160 CINDEX_LINKAGE int clang_Cursor_isNull(CXCursor cursor);
2161 
2162 /**
2163  * \brief Compute a hash value for the given cursor.
2164  */
2165 CINDEX_LINKAGE unsigned clang_hashCursor(CXCursor);
2166 
2167 /**
2168  * \brief Retrieve the kind of the given cursor.
2169  */
2170 CINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor);
2171 
2172 /**
2173  * \brief Determine whether the given cursor kind represents a declaration.
2174  */
2175 CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind);
2176 
2177 /**
2178  * \brief Determine whether the given cursor kind represents a simple
2179  * reference.
2180  *
2181  * Note that other kinds of cursors (such as expressions) can also refer to
2182  * other cursors. Use clang_getCursorReferenced() to determine whether a
2183  * particular cursor refers to another entity.
2184  */
2185 CINDEX_LINKAGE unsigned clang_isReference(enum CXCursorKind);
2186 
2187 /**
2188  * \brief Determine whether the given cursor kind represents an expression.
2189  */
2190 CINDEX_LINKAGE unsigned clang_isExpression(enum CXCursorKind);
2191 
2192 /**
2193  * \brief Determine whether the given cursor kind represents a statement.
2194  */
2195 CINDEX_LINKAGE unsigned clang_isStatement(enum CXCursorKind);
2196 
2197 /**
2198  * \brief Determine whether the given cursor kind represents an attribute.
2199  */
2200 CINDEX_LINKAGE unsigned clang_isAttribute(enum CXCursorKind);
2201 
2202 /**
2203  * \brief Determine whether the given cursor kind represents an invalid
2204  * cursor.
2205  */
2206 CINDEX_LINKAGE unsigned clang_isInvalid(enum CXCursorKind);
2207 
2208 /**
2209  * \brief Determine whether the given cursor kind represents a translation
2210  * unit.
2211  */
2212 CINDEX_LINKAGE unsigned clang_isTranslationUnit(enum CXCursorKind);
2213 
2214 /***
2215  * \brief Determine whether the given cursor represents a preprocessing
2216  * element, such as a preprocessor directive or macro instantiation.
2217  */
2218 CINDEX_LINKAGE unsigned clang_isPreprocessing(enum CXCursorKind);
2219 
2220 /***
2221  * \brief Determine whether the given cursor represents a currently
2222  *  unexposed piece of the AST (e.g., CXCursor_UnexposedStmt).
2223  */
2224 CINDEX_LINKAGE unsigned clang_isUnexposed(enum CXCursorKind);
2225 
2226 /**
2227  * \brief Describe the linkage of the entity referred to by a cursor.
2228  */
2229 enum CXLinkageKind {
2230   /** \brief This value indicates that no linkage information is available
2231    * for a provided CXCursor. */
2232   CXLinkage_Invalid,
2233   /**
2234    * \brief This is the linkage for variables, parameters, and so on that
2235    *  have automatic storage.  This covers normal (non-extern) local variables.
2236    */
2237   CXLinkage_NoLinkage,
2238   /** \brief This is the linkage for static variables and static functions. */
2239   CXLinkage_Internal,
2240   /** \brief This is the linkage for entities with external linkage that live
2241    * in C++ anonymous namespaces.*/
2242   CXLinkage_UniqueExternal,
2243   /** \brief This is the linkage for entities with true, external linkage. */
2244   CXLinkage_External
2245 };
2246 
2247 /**
2248  * \brief Determine the linkage of the entity referred to by a given cursor.
2249  */
2250 CINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor);
2251 
2252 /**
2253  * \brief Determine the availability of the entity that this cursor refers to,
2254  * taking the current target platform into account.
2255  *
2256  * \param cursor The cursor to query.
2257  *
2258  * \returns The availability of the cursor.
2259  */
2260 CINDEX_LINKAGE enum CXAvailabilityKind
2261 clang_getCursorAvailability(CXCursor cursor);
2262 
2263 /**
2264  * Describes the availability of a given entity on a particular platform, e.g.,
2265  * a particular class might only be available on Mac OS 10.7 or newer.
2266  */
2267 typedef struct CXPlatformAvailability {
2268   /**
2269    * \brief A string that describes the platform for which this structure
2270    * provides availability information.
2271    *
2272    * Possible values are "ios" or "macosx".
2273    */
2274   CXString Platform;
2275   /**
2276    * \brief The version number in which this entity was introduced.
2277    */
2278   CXVersion Introduced;
2279   /**
2280    * \brief The version number in which this entity was deprecated (but is
2281    * still available).
2282    */
2283   CXVersion Deprecated;
2284   /**
2285    * \brief The version number in which this entity was obsoleted, and therefore
2286    * is no longer available.
2287    */
2288   CXVersion Obsoleted;
2289   /**
2290    * \brief Whether the entity is unconditionally unavailable on this platform.
2291    */
2292   int Unavailable;
2293   /**
2294    * \brief An optional message to provide to a user of this API, e.g., to
2295    * suggest replacement APIs.
2296    */
2297   CXString Message;
2298 } CXPlatformAvailability;
2299 
2300 /**
2301  * \brief Determine the availability of the entity that this cursor refers to
2302  * on any platforms for which availability information is known.
2303  *
2304  * \param cursor The cursor to query.
2305  *
2306  * \param always_deprecated If non-NULL, will be set to indicate whether the
2307  * entity is deprecated on all platforms.
2308  *
2309  * \param deprecated_message If non-NULL, will be set to the message text
2310  * provided along with the unconditional deprecation of this entity. The client
2311  * is responsible for deallocating this string.
2312  *
2313  * \param always_unavailable If non-NULL, will be set to indicate whether the
2314  * entity is unavailable on all platforms.
2315  *
2316  * \param unavailable_message If non-NULL, will be set to the message text
2317  * provided along with the unconditional unavailability of this entity. The
2318  * client is responsible for deallocating this string.
2319  *
2320  * \param availability If non-NULL, an array of CXPlatformAvailability instances
2321  * that will be populated with platform availability information, up to either
2322  * the number of platforms for which availability information is available (as
2323  * returned by this function) or \c availability_size, whichever is smaller.
2324  *
2325  * \param availability_size The number of elements available in the
2326  * \c availability array.
2327  *
2328  * \returns The number of platforms (N) for which availability information is
2329  * available (which is unrelated to \c availability_size).
2330  *
2331  * Note that the client is responsible for calling
2332  * \c clang_disposeCXPlatformAvailability to free each of the
2333  * platform-availability structures returned. There are
2334  * \c min(N, availability_size) such structures.
2335  */
2336 CINDEX_LINKAGE int
2337 clang_getCursorPlatformAvailability(CXCursor cursor,
2338                                     int *always_deprecated,
2339                                     CXString *deprecated_message,
2340                                     int *always_unavailable,
2341                                     CXString *unavailable_message,
2342                                     CXPlatformAvailability *availability,
2343                                     int availability_size);
2344 
2345 /**
2346  * \brief Free the memory associated with a \c CXPlatformAvailability structure.
2347  */
2348 CINDEX_LINKAGE void
2349 clang_disposeCXPlatformAvailability(CXPlatformAvailability *availability);
2350 
2351 /**
2352  * \brief Describe the "language" of the entity referred to by a cursor.
2353  */
2354 CINDEX_LINKAGE enum CXLanguageKind {
2355   CXLanguage_Invalid = 0,
2356   CXLanguage_C,
2357   CXLanguage_ObjC,
2358   CXLanguage_CPlusPlus
2359 };
2360 
2361 /**
2362  * \brief Determine the "language" of the entity referred to by a given cursor.
2363  */
2364 CINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor);
2365 
2366 /**
2367  * \brief Returns the translation unit that a cursor originated from.
2368  */
2369 CINDEX_LINKAGE CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor);
2370 
2371 
2372 /**
2373  * \brief A fast container representing a set of CXCursors.
2374  */
2375 typedef struct CXCursorSetImpl *CXCursorSet;
2376 
2377 /**
2378  * \brief Creates an empty CXCursorSet.
2379  */
2380 CINDEX_LINKAGE CXCursorSet clang_createCXCursorSet(void);
2381 
2382 /**
2383  * \brief Disposes a CXCursorSet and releases its associated memory.
2384  */
2385 CINDEX_LINKAGE void clang_disposeCXCursorSet(CXCursorSet cset);
2386 
2387 /**
2388  * \brief Queries a CXCursorSet to see if it contains a specific CXCursor.
2389  *
2390  * \returns non-zero if the set contains the specified cursor.
2391 */
2392 CINDEX_LINKAGE unsigned clang_CXCursorSet_contains(CXCursorSet cset,
2393                                                    CXCursor cursor);
2394 
2395 /**
2396  * \brief Inserts a CXCursor into a CXCursorSet.
2397  *
2398  * \returns zero if the CXCursor was already in the set, and non-zero otherwise.
2399 */
2400 CINDEX_LINKAGE unsigned clang_CXCursorSet_insert(CXCursorSet cset,
2401                                                  CXCursor cursor);
2402 
2403 /**
2404  * \brief Determine the semantic parent of the given cursor.
2405  *
2406  * The semantic parent of a cursor is the cursor that semantically contains
2407  * the given \p cursor. For many declarations, the lexical and semantic parents
2408  * are equivalent (the lexical parent is returned by
2409  * \c clang_getCursorLexicalParent()). They diverge when declarations or
2410  * definitions are provided out-of-line. For example:
2411  *
2412  * \code
2413  * class C {
2414  *  void f();
2415  * };
2416  *
2417  * void C::f() { }
2418  * \endcode
2419  *
2420  * In the out-of-line definition of \c C::f, the semantic parent is the
2421  * the class \c C, of which this function is a member. The lexical parent is
2422  * the place where the declaration actually occurs in the source code; in this
2423  * case, the definition occurs in the translation unit. In general, the
2424  * lexical parent for a given entity can change without affecting the semantics
2425  * of the program, and the lexical parent of different declarations of the
2426  * same entity may be different. Changing the semantic parent of a declaration,
2427  * on the other hand, can have a major impact on semantics, and redeclarations
2428  * of a particular entity should all have the same semantic context.
2429  *
2430  * In the example above, both declarations of \c C::f have \c C as their
2431  * semantic context, while the lexical context of the first \c C::f is \c C
2432  * and the lexical context of the second \c C::f is the translation unit.
2433  *
2434  * For global declarations, the semantic parent is the translation unit.
2435  */
2436 CINDEX_LINKAGE CXCursor clang_getCursorSemanticParent(CXCursor cursor);
2437 
2438 /**
2439  * \brief Determine the lexical parent of the given cursor.
2440  *
2441  * The lexical parent of a cursor is the cursor in which the given \p cursor
2442  * was actually written. For many declarations, the lexical and semantic parents
2443  * are equivalent (the semantic parent is returned by
2444  * \c clang_getCursorSemanticParent()). They diverge when declarations or
2445  * definitions are provided out-of-line. For example:
2446  *
2447  * \code
2448  * class C {
2449  *  void f();
2450  * };
2451  *
2452  * void C::f() { }
2453  * \endcode
2454  *
2455  * In the out-of-line definition of \c C::f, the semantic parent is the
2456  * the class \c C, of which this function is a member. The lexical parent is
2457  * the place where the declaration actually occurs in the source code; in this
2458  * case, the definition occurs in the translation unit. In general, the
2459  * lexical parent for a given entity can change without affecting the semantics
2460  * of the program, and the lexical parent of different declarations of the
2461  * same entity may be different. Changing the semantic parent of a declaration,
2462  * on the other hand, can have a major impact on semantics, and redeclarations
2463  * of a particular entity should all have the same semantic context.
2464  *
2465  * In the example above, both declarations of \c C::f have \c C as their
2466  * semantic context, while the lexical context of the first \c C::f is \c C
2467  * and the lexical context of the second \c C::f is the translation unit.
2468  *
2469  * For declarations written in the global scope, the lexical parent is
2470  * the translation unit.
2471  */
2472 CINDEX_LINKAGE CXCursor clang_getCursorLexicalParent(CXCursor cursor);
2473 
2474 /**
2475  * \brief Determine the set of methods that are overridden by the given
2476  * method.
2477  *
2478  * In both Objective-C and C++, a method (aka virtual member function,
2479  * in C++) can override a virtual method in a base class. For
2480  * Objective-C, a method is said to override any method in the class's
2481  * base class, its protocols, or its categories' protocols, that has the same
2482  * selector and is of the same kind (class or instance).
2483  * If no such method exists, the search continues to the class's superclass,
2484  * its protocols, and its categories, and so on. A method from an Objective-C
2485  * implementation is considered to override the same methods as its
2486  * corresponding method in the interface.
2487  *
2488  * For C++, a virtual member function overrides any virtual member
2489  * function with the same signature that occurs in its base
2490  * classes. With multiple inheritance, a virtual member function can
2491  * override several virtual member functions coming from different
2492  * base classes.
2493  *
2494  * In all cases, this function determines the immediate overridden
2495  * method, rather than all of the overridden methods. For example, if
2496  * a method is originally declared in a class A, then overridden in B
2497  * (which in inherits from A) and also in C (which inherited from B),
2498  * then the only overridden method returned from this function when
2499  * invoked on C's method will be B's method. The client may then
2500  * invoke this function again, given the previously-found overridden
2501  * methods, to map out the complete method-override set.
2502  *
2503  * \param cursor A cursor representing an Objective-C or C++
2504  * method. This routine will compute the set of methods that this
2505  * method overrides.
2506  *
2507  * \param overridden A pointer whose pointee will be replaced with a
2508  * pointer to an array of cursors, representing the set of overridden
2509  * methods. If there are no overridden methods, the pointee will be
2510  * set to NULL. The pointee must be freed via a call to
2511  * \c clang_disposeOverriddenCursors().
2512  *
2513  * \param num_overridden A pointer to the number of overridden
2514  * functions, will be set to the number of overridden functions in the
2515  * array pointed to by \p overridden.
2516  */
2517 CINDEX_LINKAGE void clang_getOverriddenCursors(CXCursor cursor,
2518                                                CXCursor **overridden,
2519                                                unsigned *num_overridden);
2520 
2521 /**
2522  * \brief Free the set of overridden cursors returned by \c
2523  * clang_getOverriddenCursors().
2524  */
2525 CINDEX_LINKAGE void clang_disposeOverriddenCursors(CXCursor *overridden);
2526 
2527 /**
2528  * \brief Retrieve the file that is included by the given inclusion directive
2529  * cursor.
2530  */
2531 CINDEX_LINKAGE CXFile clang_getIncludedFile(CXCursor cursor);
2532 
2533 /**
2534  * @}
2535  */
2536 
2537 /**
2538  * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code
2539  *
2540  * Cursors represent a location within the Abstract Syntax Tree (AST). These
2541  * routines help map between cursors and the physical locations where the
2542  * described entities occur in the source code. The mapping is provided in
2543  * both directions, so one can map from source code to the AST and back.
2544  *
2545  * @{
2546  */
2547 
2548 /**
2549  * \brief Map a source location to the cursor that describes the entity at that
2550  * location in the source code.
2551  *
2552  * clang_getCursor() maps an arbitrary source location within a translation
2553  * unit down to the most specific cursor that describes the entity at that
2554  * location. For example, given an expression \c x + y, invoking
2555  * clang_getCursor() with a source location pointing to "x" will return the
2556  * cursor for "x"; similarly for "y". If the cursor points anywhere between
2557  * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor()
2558  * will return a cursor referring to the "+" expression.
2559  *
2560  * \returns a cursor representing the entity at the given source location, or
2561  * a NULL cursor if no such entity can be found.
2562  */
2563 CINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, CXSourceLocation);
2564 
2565 /**
2566  * \brief Retrieve the physical location of the source constructor referenced
2567  * by the given cursor.
2568  *
2569  * The location of a declaration is typically the location of the name of that
2570  * declaration, where the name of that declaration would occur if it is
2571  * unnamed, or some keyword that introduces that particular declaration.
2572  * The location of a reference is where that reference occurs within the
2573  * source code.
2574  */
2575 CINDEX_LINKAGE CXSourceLocation clang_getCursorLocation(CXCursor);
2576 
2577 /**
2578  * \brief Retrieve the physical extent of the source construct referenced by
2579  * the given cursor.
2580  *
2581  * The extent of a cursor starts with the file/line/column pointing at the
2582  * first character within the source construct that the cursor refers to and
2583  * ends with the last character withinin that source construct. For a
2584  * declaration, the extent covers the declaration itself. For a reference,
2585  * the extent covers the location of the reference (e.g., where the referenced
2586  * entity was actually used).
2587  */
2588 CINDEX_LINKAGE CXSourceRange clang_getCursorExtent(CXCursor);
2589 
2590 /**
2591  * @}
2592  */
2593 
2594 /**
2595  * \defgroup CINDEX_TYPES Type information for CXCursors
2596  *
2597  * @{
2598  */
2599 
2600 /**
2601  * \brief Describes the kind of type
2602  */
2603 enum CXTypeKind {
2604   /**
2605    * \brief Reprents an invalid type (e.g., where no type is available).
2606    */
2607   CXType_Invalid = 0,
2608 
2609   /**
2610    * \brief A type whose specific kind is not exposed via this
2611    * interface.
2612    */
2613   CXType_Unexposed = 1,
2614 
2615   /* Builtin types */
2616   CXType_Void = 2,
2617   CXType_Bool = 3,
2618   CXType_Char_U = 4,
2619   CXType_UChar = 5,
2620   CXType_Char16 = 6,
2621   CXType_Char32 = 7,
2622   CXType_UShort = 8,
2623   CXType_UInt = 9,
2624   CXType_ULong = 10,
2625   CXType_ULongLong = 11,
2626   CXType_UInt128 = 12,
2627   CXType_Char_S = 13,
2628   CXType_SChar = 14,
2629   CXType_WChar = 15,
2630   CXType_Short = 16,
2631   CXType_Int = 17,
2632   CXType_Long = 18,
2633   CXType_LongLong = 19,
2634   CXType_Int128 = 20,
2635   CXType_Float = 21,
2636   CXType_Double = 22,
2637   CXType_LongDouble = 23,
2638   CXType_NullPtr = 24,
2639   CXType_Overload = 25,
2640   CXType_Dependent = 26,
2641   CXType_ObjCId = 27,
2642   CXType_ObjCClass = 28,
2643   CXType_ObjCSel = 29,
2644   CXType_FirstBuiltin = CXType_Void,
2645   CXType_LastBuiltin  = CXType_ObjCSel,
2646 
2647   CXType_Complex = 100,
2648   CXType_Pointer = 101,
2649   CXType_BlockPointer = 102,
2650   CXType_LValueReference = 103,
2651   CXType_RValueReference = 104,
2652   CXType_Record = 105,
2653   CXType_Enum = 106,
2654   CXType_Typedef = 107,
2655   CXType_ObjCInterface = 108,
2656   CXType_ObjCObjectPointer = 109,
2657   CXType_FunctionNoProto = 110,
2658   CXType_FunctionProto = 111,
2659   CXType_ConstantArray = 112,
2660   CXType_Vector = 113
2661 };
2662 
2663 /**
2664  * \brief Describes the calling convention of a function type
2665  */
2666 enum CXCallingConv {
2667   CXCallingConv_Default = 0,
2668   CXCallingConv_C = 1,
2669   CXCallingConv_X86StdCall = 2,
2670   CXCallingConv_X86FastCall = 3,
2671   CXCallingConv_X86ThisCall = 4,
2672   CXCallingConv_X86Pascal = 5,
2673   CXCallingConv_AAPCS = 6,
2674   CXCallingConv_AAPCS_VFP = 7,
2675   CXCallingConv_PnaclCall = 8,
2676   CXCallingConv_IntelOclBicc = 9,
2677 
2678   CXCallingConv_Invalid = 100,
2679   CXCallingConv_Unexposed = 200
2680 };
2681 
2682 
2683 /**
2684  * \brief The type of an element in the abstract syntax tree.
2685  *
2686  */
2687 typedef struct {
2688   enum CXTypeKind kind;
2689   void *data[2];
2690 } CXType;
2691 
2692 /**
2693  * \brief Retrieve the type of a CXCursor (if any).
2694  */
2695 CINDEX_LINKAGE CXType clang_getCursorType(CXCursor C);
2696 
2697 /**
2698  * \brief Pretty-print the underlying type using the rules of the
2699  * language of the translation unit from which it came.
2700  *
2701  * If the type is invalid, an empty string is returned.
2702  */
2703 CINDEX_LINKAGE CXString clang_getTypeSpelling(CXType CT);
2704 
2705 /**
2706  * \brief Retrieve the underlying type of a typedef declaration.
2707  *
2708  * If the cursor does not reference a typedef declaration, an invalid type is
2709  * returned.
2710  */
2711 CINDEX_LINKAGE CXType clang_getTypedefDeclUnderlyingType(CXCursor C);
2712 
2713 /**
2714  * \brief Retrieve the integer type of an enum declaration.
2715  *
2716  * If the cursor does not reference an enum declaration, an invalid type is
2717  * returned.
2718  */
2719 CINDEX_LINKAGE CXType clang_getEnumDeclIntegerType(CXCursor C);
2720 
2721 /**
2722  * \brief Retrieve the integer value of an enum constant declaration as a signed
2723  *  long long.
2724  *
2725  * If the cursor does not reference an enum constant declaration, LLONG_MIN is returned.
2726  * Since this is also potentially a valid constant value, the kind of the cursor
2727  * must be verified before calling this function.
2728  */
2729 CINDEX_LINKAGE long long clang_getEnumConstantDeclValue(CXCursor C);
2730 
2731 /**
2732  * \brief Retrieve the integer value of an enum constant declaration as an unsigned
2733  *  long long.
2734  *
2735  * If the cursor does not reference an enum constant declaration, ULLONG_MAX is returned.
2736  * Since this is also potentially a valid constant value, the kind of the cursor
2737  * must be verified before calling this function.
2738  */
2739 CINDEX_LINKAGE unsigned long long clang_getEnumConstantDeclUnsignedValue(CXCursor C);
2740 
2741 /**
2742  * \brief Retrieve the bit width of a bit field declaration as an integer.
2743  *
2744  * If a cursor that is not a bit field declaration is passed in, -1 is returned.
2745  */
2746 CINDEX_LINKAGE int clang_getFieldDeclBitWidth(CXCursor C);
2747 
2748 /**
2749  * \brief Retrieve the number of non-variadic arguments associated with a given
2750  * cursor.
2751  *
2752  * If a cursor that is not a function or method is passed in, -1 is returned.
2753  */
2754 CINDEX_LINKAGE int clang_Cursor_getNumArguments(CXCursor C);
2755 
2756 /**
2757  * \brief Retrieve the argument cursor of a function or method.
2758  *
2759  * If a cursor that is not a function or method is passed in or the index
2760  * exceeds the number of arguments, an invalid cursor is returned.
2761  */
2762 CINDEX_LINKAGE CXCursor clang_Cursor_getArgument(CXCursor C, unsigned i);
2763 
2764 /**
2765  * \brief Determine whether two CXTypes represent the same type.
2766  *
2767  * \returns non-zero if the CXTypes represent the same type and
2768  *          zero otherwise.
2769  */
2770 CINDEX_LINKAGE unsigned clang_equalTypes(CXType A, CXType B);
2771 
2772 /**
2773  * \brief Return the canonical type for a CXType.
2774  *
2775  * Clang's type system explicitly models typedefs and all the ways
2776  * a specific type can be represented.  The canonical type is the underlying
2777  * type with all the "sugar" removed.  For example, if 'T' is a typedef
2778  * for 'int', the canonical type for 'T' would be 'int'.
2779  */
2780 CINDEX_LINKAGE CXType clang_getCanonicalType(CXType T);
2781 
2782 /**
2783  * \brief Determine whether a CXType has the "const" qualifier set,
2784  * without looking through typedefs that may have added "const" at a
2785  * different level.
2786  */
2787 CINDEX_LINKAGE unsigned clang_isConstQualifiedType(CXType T);
2788 
2789 /**
2790  * \brief Determine whether a CXType has the "volatile" qualifier set,
2791  * without looking through typedefs that may have added "volatile" at
2792  * a different level.
2793  */
2794 CINDEX_LINKAGE unsigned clang_isVolatileQualifiedType(CXType T);
2795 
2796 /**
2797  * \brief Determine whether a CXType has the "restrict" qualifier set,
2798  * without looking through typedefs that may have added "restrict" at a
2799  * different level.
2800  */
2801 CINDEX_LINKAGE unsigned clang_isRestrictQualifiedType(CXType T);
2802 
2803 /**
2804  * \brief For pointer types, returns the type of the pointee.
2805  */
2806 CINDEX_LINKAGE CXType clang_getPointeeType(CXType T);
2807 
2808 /**
2809  * \brief Return the cursor for the declaration of the given type.
2810  */
2811 CINDEX_LINKAGE CXCursor clang_getTypeDeclaration(CXType T);
2812 
2813 /**
2814  * Returns the Objective-C type encoding for the specified declaration.
2815  */
2816 CINDEX_LINKAGE CXString clang_getDeclObjCTypeEncoding(CXCursor C);
2817 
2818 /**
2819  * \brief Retrieve the spelling of a given CXTypeKind.
2820  */
2821 CINDEX_LINKAGE CXString clang_getTypeKindSpelling(enum CXTypeKind K);
2822 
2823 /**
2824  * \brief Retrieve the calling convention associated with a function type.
2825  *
2826  * If a non-function type is passed in, CXCallingConv_Invalid is returned.
2827  */
2828 CINDEX_LINKAGE enum CXCallingConv clang_getFunctionTypeCallingConv(CXType T);
2829 
2830 /**
2831  * \brief Retrieve the result type associated with a function type.
2832  *
2833  * If a non-function type is passed in, an invalid type is returned.
2834  */
2835 CINDEX_LINKAGE CXType clang_getResultType(CXType T);
2836 
2837 /**
2838  * \brief Retrieve the number of non-variadic arguments associated with a
2839  * function type.
2840  *
2841  * If a non-function type is passed in, -1 is returned.
2842  */
2843 CINDEX_LINKAGE int clang_getNumArgTypes(CXType T);
2844 
2845 /**
2846  * \brief Retrieve the type of an argument of a function type.
2847  *
2848  * If a non-function type is passed in or the function does not have enough
2849  * parameters, an invalid type is returned.
2850  */
2851 CINDEX_LINKAGE CXType clang_getArgType(CXType T, unsigned i);
2852 
2853 /**
2854  * \brief Return 1 if the CXType is a variadic function type, and 0 otherwise.
2855  */
2856 CINDEX_LINKAGE unsigned clang_isFunctionTypeVariadic(CXType T);
2857 
2858 /**
2859  * \brief Retrieve the result type associated with a given cursor.
2860  *
2861  * This only returns a valid type if the cursor refers to a function or method.
2862  */
2863 CINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C);
2864 
2865 /**
2866  * \brief Return 1 if the CXType is a POD (plain old data) type, and 0
2867  *  otherwise.
2868  */
2869 CINDEX_LINKAGE unsigned clang_isPODType(CXType T);
2870 
2871 /**
2872  * \brief Return the element type of an array, complex, or vector type.
2873  *
2874  * If a type is passed in that is not an array, complex, or vector type,
2875  * an invalid type is returned.
2876  */
2877 CINDEX_LINKAGE CXType clang_getElementType(CXType T);
2878 
2879 /**
2880  * \brief Return the number of elements of an array or vector type.
2881  *
2882  * If a type is passed in that is not an array or vector type,
2883  * -1 is returned.
2884  */
2885 CINDEX_LINKAGE long long clang_getNumElements(CXType T);
2886 
2887 /**
2888  * \brief Return the element type of an array type.
2889  *
2890  * If a non-array type is passed in, an invalid type is returned.
2891  */
2892 CINDEX_LINKAGE CXType clang_getArrayElementType(CXType T);
2893 
2894 /**
2895  * \brief Return the array size of a constant array.
2896  *
2897  * If a non-array type is passed in, -1 is returned.
2898  */
2899 CINDEX_LINKAGE long long clang_getArraySize(CXType T);
2900 
2901 /**
2902  * \brief Returns 1 if the base class specified by the cursor with kind
2903  *   CX_CXXBaseSpecifier is virtual.
2904  */
2905 CINDEX_LINKAGE unsigned clang_isVirtualBase(CXCursor);
2906 
2907 /**
2908  * \brief Represents the C++ access control level to a base class for a
2909  * cursor with kind CX_CXXBaseSpecifier.
2910  */
2911 enum CX_CXXAccessSpecifier {
2912   CX_CXXInvalidAccessSpecifier,
2913   CX_CXXPublic,
2914   CX_CXXProtected,
2915   CX_CXXPrivate
2916 };
2917 
2918 /**
2919  * \brief Returns the access control level for the C++ base specifier
2920  * represented by a cursor with kind CXCursor_CXXBaseSpecifier or
2921  * CXCursor_AccessSpecifier.
2922  */
2923 CINDEX_LINKAGE enum CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor);
2924 
2925 /**
2926  * \brief Determine the number of overloaded declarations referenced by a
2927  * \c CXCursor_OverloadedDeclRef cursor.
2928  *
2929  * \param cursor The cursor whose overloaded declarations are being queried.
2930  *
2931  * \returns The number of overloaded declarations referenced by \c cursor. If it
2932  * is not a \c CXCursor_OverloadedDeclRef cursor, returns 0.
2933  */
2934 CINDEX_LINKAGE unsigned clang_getNumOverloadedDecls(CXCursor cursor);
2935 
2936 /**
2937  * \brief Retrieve a cursor for one of the overloaded declarations referenced
2938  * by a \c CXCursor_OverloadedDeclRef cursor.
2939  *
2940  * \param cursor The cursor whose overloaded declarations are being queried.
2941  *
2942  * \param index The zero-based index into the set of overloaded declarations in
2943  * the cursor.
2944  *
2945  * \returns A cursor representing the declaration referenced by the given
2946  * \c cursor at the specified \c index. If the cursor does not have an
2947  * associated set of overloaded declarations, or if the index is out of bounds,
2948  * returns \c clang_getNullCursor();
2949  */
2950 CINDEX_LINKAGE CXCursor clang_getOverloadedDecl(CXCursor cursor,
2951                                                 unsigned index);
2952 
2953 /**
2954  * @}
2955  */
2956 
2957 /**
2958  * \defgroup CINDEX_ATTRIBUTES Information for attributes
2959  *
2960  * @{
2961  */
2962 
2963 
2964 /**
2965  * \brief For cursors representing an iboutletcollection attribute,
2966  *  this function returns the collection element type.
2967  *
2968  */
2969 CINDEX_LINKAGE CXType clang_getIBOutletCollectionType(CXCursor);
2970 
2971 /**
2972  * @}
2973  */
2974 
2975 /**
2976  * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors
2977  *
2978  * These routines provide the ability to traverse the abstract syntax tree
2979  * using cursors.
2980  *
2981  * @{
2982  */
2983 
2984 /**
2985  * \brief Describes how the traversal of the children of a particular
2986  * cursor should proceed after visiting a particular child cursor.
2987  *
2988  * A value of this enumeration type should be returned by each
2989  * \c CXCursorVisitor to indicate how clang_visitChildren() proceed.
2990  */
2991 enum CXChildVisitResult {
2992   /**
2993    * \brief Terminates the cursor traversal.
2994    */
2995   CXChildVisit_Break,
2996   /**
2997    * \brief Continues the cursor traversal with the next sibling of
2998    * the cursor just visited, without visiting its children.
2999    */
3000   CXChildVisit_Continue,
3001   /**
3002    * \brief Recursively traverse the children of this cursor, using
3003    * the same visitor and client data.
3004    */
3005   CXChildVisit_Recurse
3006 };
3007 
3008 /**
3009  * \brief Visitor invoked for each cursor found by a traversal.
3010  *
3011  * This visitor function will be invoked for each cursor found by
3012  * clang_visitCursorChildren(). Its first argument is the cursor being
3013  * visited, its second argument is the parent visitor for that cursor,
3014  * and its third argument is the client data provided to
3015  * clang_visitCursorChildren().
3016  *
3017  * The visitor should return one of the \c CXChildVisitResult values
3018  * to direct clang_visitCursorChildren().
3019  */
3020 typedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor,
3021                                                    CXCursor parent,
3022                                                    CXClientData client_data);
3023 
3024 /**
3025  * \brief Visit the children of a particular cursor.
3026  *
3027  * This function visits all the direct children of the given cursor,
3028  * invoking the given \p visitor function with the cursors of each
3029  * visited child. The traversal may be recursive, if the visitor returns
3030  * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if
3031  * the visitor returns \c CXChildVisit_Break.
3032  *
3033  * \param parent the cursor whose child may be visited. All kinds of
3034  * cursors can be visited, including invalid cursors (which, by
3035  * definition, have no children).
3036  *
3037  * \param visitor the visitor function that will be invoked for each
3038  * child of \p parent.
3039  *
3040  * \param client_data pointer data supplied by the client, which will
3041  * be passed to the visitor each time it is invoked.
3042  *
3043  * \returns a non-zero value if the traversal was terminated
3044  * prematurely by the visitor returning \c CXChildVisit_Break.
3045  */
3046 CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent,
3047                                             CXCursorVisitor visitor,
3048                                             CXClientData client_data);
3049 #ifdef __has_feature
3050 #  if __has_feature(blocks)
3051 /**
3052  * \brief Visitor invoked for each cursor found by a traversal.
3053  *
3054  * This visitor block will be invoked for each cursor found by
3055  * clang_visitChildrenWithBlock(). Its first argument is the cursor being
3056  * visited, its second argument is the parent visitor for that cursor.
3057  *
3058  * The visitor should return one of the \c CXChildVisitResult values
3059  * to direct clang_visitChildrenWithBlock().
3060  */
3061 typedef enum CXChildVisitResult
3062      (^CXCursorVisitorBlock)(CXCursor cursor, CXCursor parent);
3063 
3064 /**
3065  * Visits the children of a cursor using the specified block.  Behaves
3066  * identically to clang_visitChildren() in all other respects.
3067  */
3068 unsigned clang_visitChildrenWithBlock(CXCursor parent,
3069                                       CXCursorVisitorBlock block);
3070 #  endif
3071 #endif
3072 
3073 /**
3074  * @}
3075  */
3076 
3077 /**
3078  * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST
3079  *
3080  * These routines provide the ability to determine references within and
3081  * across translation units, by providing the names of the entities referenced
3082  * by cursors, follow reference cursors to the declarations they reference,
3083  * and associate declarations with their definitions.
3084  *
3085  * @{
3086  */
3087 
3088 /**
3089  * \brief Retrieve a Unified Symbol Resolution (USR) for the entity referenced
3090  * by the given cursor.
3091  *
3092  * A Unified Symbol Resolution (USR) is a string that identifies a particular
3093  * entity (function, class, variable, etc.) within a program. USRs can be
3094  * compared across translation units to determine, e.g., when references in
3095  * one translation refer to an entity defined in another translation unit.
3096  */
3097 CINDEX_LINKAGE CXString clang_getCursorUSR(CXCursor);
3098 
3099 /**
3100  * \brief Construct a USR for a specified Objective-C class.
3101  */
3102 CINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name);
3103 
3104 /**
3105  * \brief Construct a USR for a specified Objective-C category.
3106  */
3107 CINDEX_LINKAGE CXString
3108   clang_constructUSR_ObjCCategory(const char *class_name,
3109                                  const char *category_name);
3110 
3111 /**
3112  * \brief Construct a USR for a specified Objective-C protocol.
3113  */
3114 CINDEX_LINKAGE CXString
3115   clang_constructUSR_ObjCProtocol(const char *protocol_name);
3116 
3117 
3118 /**
3119  * \brief Construct a USR for a specified Objective-C instance variable and
3120  *   the USR for its containing class.
3121  */
3122 CINDEX_LINKAGE CXString clang_constructUSR_ObjCIvar(const char *name,
3123                                                     CXString classUSR);
3124 
3125 /**
3126  * \brief Construct a USR for a specified Objective-C method and
3127  *   the USR for its containing class.
3128  */
3129 CINDEX_LINKAGE CXString clang_constructUSR_ObjCMethod(const char *name,
3130                                                       unsigned isInstanceMethod,
3131                                                       CXString classUSR);
3132 
3133 /**
3134  * \brief Construct a USR for a specified Objective-C property and the USR
3135  *  for its containing class.
3136  */
3137 CINDEX_LINKAGE CXString clang_constructUSR_ObjCProperty(const char *property,
3138                                                         CXString classUSR);
3139 
3140 /**
3141  * \brief Retrieve a name for the entity referenced by this cursor.
3142  */
3143 CINDEX_LINKAGE CXString clang_getCursorSpelling(CXCursor);
3144 
3145 /**
3146  * \brief Retrieve a range for a piece that forms the cursors spelling name.
3147  * Most of the times there is only one range for the complete spelling but for
3148  * objc methods and objc message expressions, there are multiple pieces for each
3149  * selector identifier.
3150  *
3151  * \param pieceIndex the index of the spelling name piece. If this is greater
3152  * than the actual number of pieces, it will return a NULL (invalid) range.
3153  *
3154  * \param options Reserved.
3155  */
3156 CINDEX_LINKAGE CXSourceRange clang_Cursor_getSpellingNameRange(CXCursor,
3157                                                           unsigned pieceIndex,
3158                                                           unsigned options);
3159 
3160 /**
3161  * \brief Retrieve the display name for the entity referenced by this cursor.
3162  *
3163  * The display name contains extra information that helps identify the cursor,
3164  * such as the parameters of a function or template or the arguments of a
3165  * class template specialization.
3166  */
3167 CINDEX_LINKAGE CXString clang_getCursorDisplayName(CXCursor);
3168 
3169 /** \brief For a cursor that is a reference, retrieve a cursor representing the
3170  * entity that it references.
3171  *
3172  * Reference cursors refer to other entities in the AST. For example, an
3173  * Objective-C superclass reference cursor refers to an Objective-C class.
3174  * This function produces the cursor for the Objective-C class from the
3175  * cursor for the superclass reference. If the input cursor is a declaration or
3176  * definition, it returns that declaration or definition unchanged.
3177  * Otherwise, returns the NULL cursor.
3178  */
3179 CINDEX_LINKAGE CXCursor clang_getCursorReferenced(CXCursor);
3180 
3181 /**
3182  *  \brief For a cursor that is either a reference to or a declaration
3183  *  of some entity, retrieve a cursor that describes the definition of
3184  *  that entity.
3185  *
3186  *  Some entities can be declared multiple times within a translation
3187  *  unit, but only one of those declarations can also be a
3188  *  definition. For example, given:
3189  *
3190  *  \code
3191  *  int f(int, int);
3192  *  int g(int x, int y) { return f(x, y); }
3193  *  int f(int a, int b) { return a + b; }
3194  *  int f(int, int);
3195  *  \endcode
3196  *
3197  *  there are three declarations of the function "f", but only the
3198  *  second one is a definition. The clang_getCursorDefinition()
3199  *  function will take any cursor pointing to a declaration of "f"
3200  *  (the first or fourth lines of the example) or a cursor referenced
3201  *  that uses "f" (the call to "f' inside "g") and will return a
3202  *  declaration cursor pointing to the definition (the second "f"
3203  *  declaration).
3204  *
3205  *  If given a cursor for which there is no corresponding definition,
3206  *  e.g., because there is no definition of that entity within this
3207  *  translation unit, returns a NULL cursor.
3208  */
3209 CINDEX_LINKAGE CXCursor clang_getCursorDefinition(CXCursor);
3210 
3211 /**
3212  * \brief Determine whether the declaration pointed to by this cursor
3213  * is also a definition of that entity.
3214  */
3215 CINDEX_LINKAGE unsigned clang_isCursorDefinition(CXCursor);
3216 
3217 /**
3218  * \brief Retrieve the canonical cursor corresponding to the given cursor.
3219  *
3220  * In the C family of languages, many kinds of entities can be declared several
3221  * times within a single translation unit. For example, a structure type can
3222  * be forward-declared (possibly multiple times) and later defined:
3223  *
3224  * \code
3225  * struct X;
3226  * struct X;
3227  * struct X {
3228  *   int member;
3229  * };
3230  * \endcode
3231  *
3232  * The declarations and the definition of \c X are represented by three
3233  * different cursors, all of which are declarations of the same underlying
3234  * entity. One of these cursor is considered the "canonical" cursor, which
3235  * is effectively the representative for the underlying entity. One can
3236  * determine if two cursors are declarations of the same underlying entity by
3237  * comparing their canonical cursors.
3238  *
3239  * \returns The canonical cursor for the entity referred to by the given cursor.
3240  */
3241 CINDEX_LINKAGE CXCursor clang_getCanonicalCursor(CXCursor);
3242 
3243 
3244 /**
3245  * \brief If the cursor points to a selector identifier in a objc method or
3246  * message expression, this returns the selector index.
3247  *
3248  * After getting a cursor with #clang_getCursor, this can be called to
3249  * determine if the location points to a selector identifier.
3250  *
3251  * \returns The selector index if the cursor is an objc method or message
3252  * expression and the cursor is pointing to a selector identifier, or -1
3253  * otherwise.
3254  */
3255 CINDEX_LINKAGE int clang_Cursor_getObjCSelectorIndex(CXCursor);
3256 
3257 /**
3258  * \brief Given a cursor pointing to a C++ method call or an ObjC message,
3259  * returns non-zero if the method/message is "dynamic", meaning:
3260  *
3261  * For a C++ method: the call is virtual.
3262  * For an ObjC message: the receiver is an object instance, not 'super' or a
3263  * specific class.
3264  *
3265  * If the method/message is "static" or the cursor does not point to a
3266  * method/message, it will return zero.
3267  */
3268 CINDEX_LINKAGE int clang_Cursor_isDynamicCall(CXCursor C);
3269 
3270 /**
3271  * \brief Given a cursor pointing to an ObjC message, returns the CXType of the
3272  * receiver.
3273  */
3274 CINDEX_LINKAGE CXType clang_Cursor_getReceiverType(CXCursor C);
3275 
3276 /**
3277  * \brief Given a cursor that represents a declaration, return the associated
3278  * comment's source range.  The range may include multiple consecutive comments
3279  * with whitespace in between.
3280  */
3281 CINDEX_LINKAGE CXSourceRange clang_Cursor_getCommentRange(CXCursor C);
3282 
3283 /**
3284  * \brief Given a cursor that represents a declaration, return the associated
3285  * comment text, including comment markers.
3286  */
3287 CINDEX_LINKAGE CXString clang_Cursor_getRawCommentText(CXCursor C);
3288 
3289 /**
3290  * \brief Given a cursor that represents a documentable entity (e.g.,
3291  * declaration), return the associated \\brief paragraph; otherwise return the
3292  * first paragraph.
3293  */
3294 CINDEX_LINKAGE CXString clang_Cursor_getBriefCommentText(CXCursor C);
3295 
3296 /**
3297  * \brief Given a cursor that represents a documentable entity (e.g.,
3298  * declaration), return the associated parsed comment as a
3299  * \c CXComment_FullComment AST node.
3300  */
3301 CINDEX_LINKAGE CXComment clang_Cursor_getParsedComment(CXCursor C);
3302 
3303 /**
3304  * @}
3305  */
3306 
3307 /**
3308  * \defgroup CINDEX_MODULE Module introspection
3309  *
3310  * The functions in this group provide access to information about modules.
3311  *
3312  * @{
3313  */
3314 
3315 typedef void *CXModule;
3316 
3317 /**
3318  * \brief Given a CXCursor_ModuleImportDecl cursor, return the associated module.
3319  */
3320 CINDEX_LINKAGE CXModule clang_Cursor_getModule(CXCursor C);
3321 
3322 /**
3323  * \param Module a module object.
3324  *
3325  * \returns the parent of a sub-module or NULL if the given module is top-level,
3326  * e.g. for 'std.vector' it will return the 'std' module.
3327  */
3328 CINDEX_LINKAGE CXModule clang_Module_getParent(CXModule Module);
3329 
3330 /**
3331  * \param Module a module object.
3332  *
3333  * \returns the name of the module, e.g. for the 'std.vector' sub-module it
3334  * will return "vector".
3335  */
3336 CINDEX_LINKAGE CXString clang_Module_getName(CXModule Module);
3337 
3338 /**
3339  * \param Module a module object.
3340  *
3341  * \returns the full name of the module, e.g. "std.vector".
3342  */
3343 CINDEX_LINKAGE CXString clang_Module_getFullName(CXModule Module);
3344 
3345 /**
3346  * \param Module a module object.
3347  *
3348  * \returns the number of top level headers associated with this module.
3349  */
3350 CINDEX_LINKAGE unsigned clang_Module_getNumTopLevelHeaders(CXTranslationUnit,
3351                                                            CXModule Module);
3352 
3353 /**
3354  * \param Module a module object.
3355  *
3356  * \param Index top level header index (zero-based).
3357  *
3358  * \returns the specified top level header associated with the module.
3359  */
3360 CINDEX_LINKAGE
3361 CXFile clang_Module_getTopLevelHeader(CXTranslationUnit,
3362                                       CXModule Module, unsigned Index);
3363 
3364 /**
3365  * @}
3366  */
3367 
3368 /**
3369  * \defgroup CINDEX_COMMENT Comment AST introspection
3370  *
3371  * The routines in this group provide access to information in the
3372  * documentation comment ASTs.
3373  *
3374  * @{
3375  */
3376 
3377 /**
3378  * \brief Describes the type of the comment AST node (\c CXComment).  A comment
3379  * node can be considered block content (e. g., paragraph), inline content
3380  * (plain text) or neither (the root AST node).
3381  */
3382 enum CXCommentKind {
3383   /**
3384    * \brief Null comment.  No AST node is constructed at the requested location
3385    * because there is no text or a syntax error.
3386    */
3387   CXComment_Null = 0,
3388 
3389   /**
3390    * \brief Plain text.  Inline content.
3391    */
3392   CXComment_Text = 1,
3393 
3394   /**
3395    * \brief A command with word-like arguments that is considered inline content.
3396    *
3397    * For example: \\c command.
3398    */
3399   CXComment_InlineCommand = 2,
3400 
3401   /**
3402    * \brief HTML start tag with attributes (name-value pairs).  Considered
3403    * inline content.
3404    *
3405    * For example:
3406    * \verbatim
3407    * <br> <br /> <a href="http://example.org/">
3408    * \endverbatim
3409    */
3410   CXComment_HTMLStartTag = 3,
3411 
3412   /**
3413    * \brief HTML end tag.  Considered inline content.
3414    *
3415    * For example:
3416    * \verbatim
3417    * </a>
3418    * \endverbatim
3419    */
3420   CXComment_HTMLEndTag = 4,
3421 
3422   /**
3423    * \brief A paragraph, contains inline comment.  The paragraph itself is
3424    * block content.
3425    */
3426   CXComment_Paragraph = 5,
3427 
3428   /**
3429    * \brief A command that has zero or more word-like arguments (number of
3430    * word-like arguments depends on command name) and a paragraph as an
3431    * argument.  Block command is block content.
3432    *
3433    * Paragraph argument is also a child of the block command.
3434    *
3435    * For example: \\brief has 0 word-like arguments and a paragraph argument.
3436    *
3437    * AST nodes of special kinds that parser knows about (e. g., \\param
3438    * command) have their own node kinds.
3439    */
3440   CXComment_BlockCommand = 6,
3441 
3442   /**
3443    * \brief A \\param or \\arg command that describes the function parameter
3444    * (name, passing direction, description).
3445    *
3446    * For example: \\param [in] ParamName description.
3447    */
3448   CXComment_ParamCommand = 7,
3449 
3450   /**
3451    * \brief A \\tparam command that describes a template parameter (name and
3452    * description).
3453    *
3454    * For example: \\tparam T description.
3455    */
3456   CXComment_TParamCommand = 8,
3457 
3458   /**
3459    * \brief A verbatim block command (e. g., preformatted code).  Verbatim
3460    * block has an opening and a closing command and contains multiple lines of
3461    * text (\c CXComment_VerbatimBlockLine child nodes).
3462    *
3463    * For example:
3464    * \\verbatim
3465    * aaa
3466    * \\endverbatim
3467    */
3468   CXComment_VerbatimBlockCommand = 9,
3469 
3470   /**
3471    * \brief A line of text that is contained within a
3472    * CXComment_VerbatimBlockCommand node.
3473    */
3474   CXComment_VerbatimBlockLine = 10,
3475 
3476   /**
3477    * \brief A verbatim line command.  Verbatim line has an opening command,
3478    * a single line of text (up to the newline after the opening command) and
3479    * has no closing command.
3480    */
3481   CXComment_VerbatimLine = 11,
3482 
3483   /**
3484    * \brief A full comment attached to a declaration, contains block content.
3485    */
3486   CXComment_FullComment = 12
3487 };
3488 
3489 /**
3490  * \brief The most appropriate rendering mode for an inline command, chosen on
3491  * command semantics in Doxygen.
3492  */
3493 enum CXCommentInlineCommandRenderKind {
3494   /**
3495    * \brief Command argument should be rendered in a normal font.
3496    */
3497   CXCommentInlineCommandRenderKind_Normal,
3498 
3499   /**
3500    * \brief Command argument should be rendered in a bold font.
3501    */
3502   CXCommentInlineCommandRenderKind_Bold,
3503 
3504   /**
3505    * \brief Command argument should be rendered in a monospaced font.
3506    */
3507   CXCommentInlineCommandRenderKind_Monospaced,
3508 
3509   /**
3510    * \brief Command argument should be rendered emphasized (typically italic
3511    * font).
3512    */
3513   CXCommentInlineCommandRenderKind_Emphasized
3514 };
3515 
3516 /**
3517  * \brief Describes parameter passing direction for \\param or \\arg command.
3518  */
3519 enum CXCommentParamPassDirection {
3520   /**
3521    * \brief The parameter is an input parameter.
3522    */
3523   CXCommentParamPassDirection_In,
3524 
3525   /**
3526    * \brief The parameter is an output parameter.
3527    */
3528   CXCommentParamPassDirection_Out,
3529 
3530   /**
3531    * \brief The parameter is an input and output parameter.
3532    */
3533   CXCommentParamPassDirection_InOut
3534 };
3535 
3536 /**
3537  * \param Comment AST node of any kind.
3538  *
3539  * \returns the type of the AST node.
3540  */
3541 CINDEX_LINKAGE enum CXCommentKind clang_Comment_getKind(CXComment Comment);
3542 
3543 /**
3544  * \param Comment AST node of any kind.
3545  *
3546  * \returns number of children of the AST node.
3547  */
3548 CINDEX_LINKAGE unsigned clang_Comment_getNumChildren(CXComment Comment);
3549 
3550 /**
3551  * \param Comment AST node of any kind.
3552  *
3553  * \param ChildIdx child index (zero-based).
3554  *
3555  * \returns the specified child of the AST node.
3556  */
3557 CINDEX_LINKAGE
3558 CXComment clang_Comment_getChild(CXComment Comment, unsigned ChildIdx);
3559 
3560 /**
3561  * \brief A \c CXComment_Paragraph node is considered whitespace if it contains
3562  * only \c CXComment_Text nodes that are empty or whitespace.
3563  *
3564  * Other AST nodes (except \c CXComment_Paragraph and \c CXComment_Text) are
3565  * never considered whitespace.
3566  *
3567  * \returns non-zero if \c Comment is whitespace.
3568  */
3569 CINDEX_LINKAGE unsigned clang_Comment_isWhitespace(CXComment Comment);
3570 
3571 /**
3572  * \returns non-zero if \c Comment is inline content and has a newline
3573  * immediately following it in the comment text.  Newlines between paragraphs
3574  * do not count.
3575  */
3576 CINDEX_LINKAGE
3577 unsigned clang_InlineContentComment_hasTrailingNewline(CXComment Comment);
3578 
3579 /**
3580  * \param Comment a \c CXComment_Text AST node.
3581  *
3582  * \returns text contained in the AST node.
3583  */
3584 CINDEX_LINKAGE CXString clang_TextComment_getText(CXComment Comment);
3585 
3586 /**
3587  * \param Comment a \c CXComment_InlineCommand AST node.
3588  *
3589  * \returns name of the inline command.
3590  */
3591 CINDEX_LINKAGE
3592 CXString clang_InlineCommandComment_getCommandName(CXComment Comment);
3593 
3594 /**
3595  * \param Comment a \c CXComment_InlineCommand AST node.
3596  *
3597  * \returns the most appropriate rendering mode, chosen on command
3598  * semantics in Doxygen.
3599  */
3600 CINDEX_LINKAGE enum CXCommentInlineCommandRenderKind
3601 clang_InlineCommandComment_getRenderKind(CXComment Comment);
3602 
3603 /**
3604  * \param Comment a \c CXComment_InlineCommand AST node.
3605  *
3606  * \returns number of command arguments.
3607  */
3608 CINDEX_LINKAGE
3609 unsigned clang_InlineCommandComment_getNumArgs(CXComment Comment);
3610 
3611 /**
3612  * \param Comment a \c CXComment_InlineCommand AST node.
3613  *
3614  * \param ArgIdx argument index (zero-based).
3615  *
3616  * \returns text of the specified argument.
3617  */
3618 CINDEX_LINKAGE
3619 CXString clang_InlineCommandComment_getArgText(CXComment Comment,
3620                                                unsigned ArgIdx);
3621 
3622 /**
3623  * \param Comment a \c CXComment_HTMLStartTag or \c CXComment_HTMLEndTag AST
3624  * node.
3625  *
3626  * \returns HTML tag name.
3627  */
3628 CINDEX_LINKAGE CXString clang_HTMLTagComment_getTagName(CXComment Comment);
3629 
3630 /**
3631  * \param Comment a \c CXComment_HTMLStartTag AST node.
3632  *
3633  * \returns non-zero if tag is self-closing (for example, &lt;br /&gt;).
3634  */
3635 CINDEX_LINKAGE
3636 unsigned clang_HTMLStartTagComment_isSelfClosing(CXComment Comment);
3637 
3638 /**
3639  * \param Comment a \c CXComment_HTMLStartTag AST node.
3640  *
3641  * \returns number of attributes (name-value pairs) attached to the start tag.
3642  */
3643 CINDEX_LINKAGE unsigned clang_HTMLStartTag_getNumAttrs(CXComment Comment);
3644 
3645 /**
3646  * \param Comment a \c CXComment_HTMLStartTag AST node.
3647  *
3648  * \param AttrIdx attribute index (zero-based).
3649  *
3650  * \returns name of the specified attribute.
3651  */
3652 CINDEX_LINKAGE
3653 CXString clang_HTMLStartTag_getAttrName(CXComment Comment, unsigned AttrIdx);
3654 
3655 /**
3656  * \param Comment a \c CXComment_HTMLStartTag AST node.
3657  *
3658  * \param AttrIdx attribute index (zero-based).
3659  *
3660  * \returns value of the specified attribute.
3661  */
3662 CINDEX_LINKAGE
3663 CXString clang_HTMLStartTag_getAttrValue(CXComment Comment, unsigned AttrIdx);
3664 
3665 /**
3666  * \param Comment a \c CXComment_BlockCommand AST node.
3667  *
3668  * \returns name of the block command.
3669  */
3670 CINDEX_LINKAGE
3671 CXString clang_BlockCommandComment_getCommandName(CXComment Comment);
3672 
3673 /**
3674  * \param Comment a \c CXComment_BlockCommand AST node.
3675  *
3676  * \returns number of word-like arguments.
3677  */
3678 CINDEX_LINKAGE
3679 unsigned clang_BlockCommandComment_getNumArgs(CXComment Comment);
3680 
3681 /**
3682  * \param Comment a \c CXComment_BlockCommand AST node.
3683  *
3684  * \param ArgIdx argument index (zero-based).
3685  *
3686  * \returns text of the specified word-like argument.
3687  */
3688 CINDEX_LINKAGE
3689 CXString clang_BlockCommandComment_getArgText(CXComment Comment,
3690                                               unsigned ArgIdx);
3691 
3692 /**
3693  * \param Comment a \c CXComment_BlockCommand or
3694  * \c CXComment_VerbatimBlockCommand AST node.
3695  *
3696  * \returns paragraph argument of the block command.
3697  */
3698 CINDEX_LINKAGE
3699 CXComment clang_BlockCommandComment_getParagraph(CXComment Comment);
3700 
3701 /**
3702  * \param Comment a \c CXComment_ParamCommand AST node.
3703  *
3704  * \returns parameter name.
3705  */
3706 CINDEX_LINKAGE
3707 CXString clang_ParamCommandComment_getParamName(CXComment Comment);
3708 
3709 /**
3710  * \param Comment a \c CXComment_ParamCommand AST node.
3711  *
3712  * \returns non-zero if the parameter that this AST node represents was found
3713  * in the function prototype and \c clang_ParamCommandComment_getParamIndex
3714  * function will return a meaningful value.
3715  */
3716 CINDEX_LINKAGE
3717 unsigned clang_ParamCommandComment_isParamIndexValid(CXComment Comment);
3718 
3719 /**
3720  * \param Comment a \c CXComment_ParamCommand AST node.
3721  *
3722  * \returns zero-based parameter index in function prototype.
3723  */
3724 CINDEX_LINKAGE
3725 unsigned clang_ParamCommandComment_getParamIndex(CXComment Comment);
3726 
3727 /**
3728  * \param Comment a \c CXComment_ParamCommand AST node.
3729  *
3730  * \returns non-zero if parameter passing direction was specified explicitly in
3731  * the comment.
3732  */
3733 CINDEX_LINKAGE
3734 unsigned clang_ParamCommandComment_isDirectionExplicit(CXComment Comment);
3735 
3736 /**
3737  * \param Comment a \c CXComment_ParamCommand AST node.
3738  *
3739  * \returns parameter passing direction.
3740  */
3741 CINDEX_LINKAGE
3742 enum CXCommentParamPassDirection clang_ParamCommandComment_getDirection(
3743                                                             CXComment Comment);
3744 
3745 /**
3746  * \param Comment a \c CXComment_TParamCommand AST node.
3747  *
3748  * \returns template parameter name.
3749  */
3750 CINDEX_LINKAGE
3751 CXString clang_TParamCommandComment_getParamName(CXComment Comment);
3752 
3753 /**
3754  * \param Comment a \c CXComment_TParamCommand AST node.
3755  *
3756  * \returns non-zero if the parameter that this AST node represents was found
3757  * in the template parameter list and
3758  * \c clang_TParamCommandComment_getDepth and
3759  * \c clang_TParamCommandComment_getIndex functions will return a meaningful
3760  * value.
3761  */
3762 CINDEX_LINKAGE
3763 unsigned clang_TParamCommandComment_isParamPositionValid(CXComment Comment);
3764 
3765 /**
3766  * \param Comment a \c CXComment_TParamCommand AST node.
3767  *
3768  * \returns zero-based nesting depth of this parameter in the template parameter list.
3769  *
3770  * For example,
3771  * \verbatim
3772  *     template<typename C, template<typename T> class TT>
3773  *     void test(TT<int> aaa);
3774  * \endverbatim
3775  * for C and TT nesting depth is 0,
3776  * for T nesting depth is 1.
3777  */
3778 CINDEX_LINKAGE
3779 unsigned clang_TParamCommandComment_getDepth(CXComment Comment);
3780 
3781 /**
3782  * \param Comment a \c CXComment_TParamCommand AST node.
3783  *
3784  * \returns zero-based parameter index in the template parameter list at a
3785  * given nesting depth.
3786  *
3787  * For example,
3788  * \verbatim
3789  *     template<typename C, template<typename T> class TT>
3790  *     void test(TT<int> aaa);
3791  * \endverbatim
3792  * for C and TT nesting depth is 0, so we can ask for index at depth 0:
3793  * at depth 0 C's index is 0, TT's index is 1.
3794  *
3795  * For T nesting depth is 1, so we can ask for index at depth 0 and 1:
3796  * at depth 0 T's index is 1 (same as TT's),
3797  * at depth 1 T's index is 0.
3798  */
3799 CINDEX_LINKAGE
3800 unsigned clang_TParamCommandComment_getIndex(CXComment Comment, unsigned Depth);
3801 
3802 /**
3803  * \param Comment a \c CXComment_VerbatimBlockLine AST node.
3804  *
3805  * \returns text contained in the AST node.
3806  */
3807 CINDEX_LINKAGE
3808 CXString clang_VerbatimBlockLineComment_getText(CXComment Comment);
3809 
3810 /**
3811  * \param Comment a \c CXComment_VerbatimLine AST node.
3812  *
3813  * \returns text contained in the AST node.
3814  */
3815 CINDEX_LINKAGE CXString clang_VerbatimLineComment_getText(CXComment Comment);
3816 
3817 /**
3818  * \brief Convert an HTML tag AST node to string.
3819  *
3820  * \param Comment a \c CXComment_HTMLStartTag or \c CXComment_HTMLEndTag AST
3821  * node.
3822  *
3823  * \returns string containing an HTML tag.
3824  */
3825 CINDEX_LINKAGE CXString clang_HTMLTagComment_getAsString(CXComment Comment);
3826 
3827 /**
3828  * \brief Convert a given full parsed comment to an HTML fragment.
3829  *
3830  * Specific details of HTML layout are subject to change.  Don't try to parse
3831  * this HTML back into an AST, use other APIs instead.
3832  *
3833  * Currently the following CSS classes are used:
3834  * \li "para-brief" for \\brief paragraph and equivalent commands;
3835  * \li "para-returns" for \\returns paragraph and equivalent commands;
3836  * \li "word-returns" for the "Returns" word in \\returns paragraph.
3837  *
3838  * Function argument documentation is rendered as a \<dl\> list with arguments
3839  * sorted in function prototype order.  CSS classes used:
3840  * \li "param-name-index-NUMBER" for parameter name (\<dt\>);
3841  * \li "param-descr-index-NUMBER" for parameter description (\<dd\>);
3842  * \li "param-name-index-invalid" and "param-descr-index-invalid" are used if
3843  * parameter index is invalid.
3844  *
3845  * Template parameter documentation is rendered as a \<dl\> list with
3846  * parameters sorted in template parameter list order.  CSS classes used:
3847  * \li "tparam-name-index-NUMBER" for parameter name (\<dt\>);
3848  * \li "tparam-descr-index-NUMBER" for parameter description (\<dd\>);
3849  * \li "tparam-name-index-other" and "tparam-descr-index-other" are used for
3850  * names inside template template parameters;
3851  * \li "tparam-name-index-invalid" and "tparam-descr-index-invalid" are used if
3852  * parameter position is invalid.
3853  *
3854  * \param Comment a \c CXComment_FullComment AST node.
3855  *
3856  * \returns string containing an HTML fragment.
3857  */
3858 CINDEX_LINKAGE CXString clang_FullComment_getAsHTML(CXComment Comment);
3859 
3860 /**
3861  * \brief Convert a given full parsed comment to an XML document.
3862  *
3863  * A Relax NG schema for the XML can be found in comment-xml-schema.rng file
3864  * inside clang source tree.
3865  *
3866  * \param Comment a \c CXComment_FullComment AST node.
3867  *
3868  * \returns string containing an XML document.
3869  */
3870 CINDEX_LINKAGE CXString clang_FullComment_getAsXML(CXComment Comment);
3871 
3872 /**
3873  * @}
3874  */
3875 
3876 /**
3877  * \defgroup CINDEX_CPP C++ AST introspection
3878  *
3879  * The routines in this group provide access information in the ASTs specific
3880  * to C++ language features.
3881  *
3882  * @{
3883  */
3884 
3885 /**
3886  * \brief Determine if a C++ member function or member function template is
3887  * declared 'static'.
3888  */
3889 CINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C);
3890 
3891 /**
3892  * \brief Determine if a C++ member function or member function template is
3893  * explicitly declared 'virtual' or if it overrides a virtual method from
3894  * one of the base classes.
3895  */
3896 CINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual(CXCursor C);
3897 
3898 /**
3899  * \brief Given a cursor that represents a template, determine
3900  * the cursor kind of the specializations would be generated by instantiating
3901  * the template.
3902  *
3903  * This routine can be used to determine what flavor of function template,
3904  * class template, or class template partial specialization is stored in the
3905  * cursor. For example, it can describe whether a class template cursor is
3906  * declared with "struct", "class" or "union".
3907  *
3908  * \param C The cursor to query. This cursor should represent a template
3909  * declaration.
3910  *
3911  * \returns The cursor kind of the specializations that would be generated
3912  * by instantiating the template \p C. If \p C is not a template, returns
3913  * \c CXCursor_NoDeclFound.
3914  */
3915 CINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind(CXCursor C);
3916 
3917 /**
3918  * \brief Given a cursor that may represent a specialization or instantiation
3919  * of a template, retrieve the cursor that represents the template that it
3920  * specializes or from which it was instantiated.
3921  *
3922  * This routine determines the template involved both for explicit
3923  * specializations of templates and for implicit instantiations of the template,
3924  * both of which are referred to as "specializations". For a class template
3925  * specialization (e.g., \c std::vector<bool>), this routine will return
3926  * either the primary template (\c std::vector) or, if the specialization was
3927  * instantiated from a class template partial specialization, the class template
3928  * partial specialization. For a class template partial specialization and a
3929  * function template specialization (including instantiations), this
3930  * this routine will return the specialized template.
3931  *
3932  * For members of a class template (e.g., member functions, member classes, or
3933  * static data members), returns the specialized or instantiated member.
3934  * Although not strictly "templates" in the C++ language, members of class
3935  * templates have the same notions of specializations and instantiations that
3936  * templates do, so this routine treats them similarly.
3937  *
3938  * \param C A cursor that may be a specialization of a template or a member
3939  * of a template.
3940  *
3941  * \returns If the given cursor is a specialization or instantiation of a
3942  * template or a member thereof, the template or member that it specializes or
3943  * from which it was instantiated. Otherwise, returns a NULL cursor.
3944  */
3945 CINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate(CXCursor C);
3946 
3947 /**
3948  * \brief Given a cursor that references something else, return the source range
3949  * covering that reference.
3950  *
3951  * \param C A cursor pointing to a member reference, a declaration reference, or
3952  * an operator call.
3953  * \param NameFlags A bitset with three independent flags:
3954  * CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and
3955  * CXNameRange_WantSinglePiece.
3956  * \param PieceIndex For contiguous names or when passing the flag
3957  * CXNameRange_WantSinglePiece, only one piece with index 0 is
3958  * available. When the CXNameRange_WantSinglePiece flag is not passed for a
3959  * non-contiguous names, this index can be used to retrieve the individual
3960  * pieces of the name. See also CXNameRange_WantSinglePiece.
3961  *
3962  * \returns The piece of the name pointed to by the given cursor. If there is no
3963  * name, or if the PieceIndex is out-of-range, a null-cursor will be returned.
3964  */
3965 CINDEX_LINKAGE CXSourceRange clang_getCursorReferenceNameRange(CXCursor C,
3966                                                 unsigned NameFlags,
3967                                                 unsigned PieceIndex);
3968 
3969 enum CXNameRefFlags {
3970   /**
3971    * \brief Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the
3972    * range.
3973    */
3974   CXNameRange_WantQualifier = 0x1,
3975 
3976   /**
3977    * \brief Include the explicit template arguments, e.g. \<int> in x.f<int>,
3978    * in the range.
3979    */
3980   CXNameRange_WantTemplateArgs = 0x2,
3981 
3982   /**
3983    * \brief If the name is non-contiguous, return the full spanning range.
3984    *
3985    * Non-contiguous names occur in Objective-C when a selector with two or more
3986    * parameters is used, or in C++ when using an operator:
3987    * \code
3988    * [object doSomething:here withValue:there]; // ObjC
3989    * return some_vector[1]; // C++
3990    * \endcode
3991    */
3992   CXNameRange_WantSinglePiece = 0x4
3993 };
3994 
3995 /**
3996  * @}
3997  */
3998 
3999 /**
4000  * \defgroup CINDEX_LEX Token extraction and manipulation
4001  *
4002  * The routines in this group provide access to the tokens within a
4003  * translation unit, along with a semantic mapping of those tokens to
4004  * their corresponding cursors.
4005  *
4006  * @{
4007  */
4008 
4009 /**
4010  * \brief Describes a kind of token.
4011  */
4012 typedef enum CXTokenKind {
4013   /**
4014    * \brief A token that contains some kind of punctuation.
4015    */
4016   CXToken_Punctuation,
4017 
4018   /**
4019    * \brief A language keyword.
4020    */
4021   CXToken_Keyword,
4022 
4023   /**
4024    * \brief An identifier (that is not a keyword).
4025    */
4026   CXToken_Identifier,
4027 
4028   /**
4029    * \brief A numeric, string, or character literal.
4030    */
4031   CXToken_Literal,
4032 
4033   /**
4034    * \brief A comment.
4035    */
4036   CXToken_Comment
4037 } CXTokenKind;
4038 
4039 /**
4040  * \brief Describes a single preprocessing token.
4041  */
4042 typedef struct {
4043   unsigned int_data[4];
4044   void *ptr_data;
4045 } CXToken;
4046 
4047 /**
4048  * \brief Determine the kind of the given token.
4049  */
4050 CINDEX_LINKAGE CXTokenKind clang_getTokenKind(CXToken);
4051 
4052 /**
4053  * \brief Determine the spelling of the given token.
4054  *
4055  * The spelling of a token is the textual representation of that token, e.g.,
4056  * the text of an identifier or keyword.
4057  */
4058 CINDEX_LINKAGE CXString clang_getTokenSpelling(CXTranslationUnit, CXToken);
4059 
4060 /**
4061  * \brief Retrieve the source location of the given token.
4062  */
4063 CINDEX_LINKAGE CXSourceLocation clang_getTokenLocation(CXTranslationUnit,
4064                                                        CXToken);
4065 
4066 /**
4067  * \brief Retrieve a source range that covers the given token.
4068  */
4069 CINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken);
4070 
4071 /**
4072  * \brief Tokenize the source code described by the given range into raw
4073  * lexical tokens.
4074  *
4075  * \param TU the translation unit whose text is being tokenized.
4076  *
4077  * \param Range the source range in which text should be tokenized. All of the
4078  * tokens produced by tokenization will fall within this source range,
4079  *
4080  * \param Tokens this pointer will be set to point to the array of tokens
4081  * that occur within the given source range. The returned pointer must be
4082  * freed with clang_disposeTokens() before the translation unit is destroyed.
4083  *
4084  * \param NumTokens will be set to the number of tokens in the \c *Tokens
4085  * array.
4086  *
4087  */
4088 CINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
4089                                    CXToken **Tokens, unsigned *NumTokens);
4090 
4091 /**
4092  * \brief Annotate the given set of tokens by providing cursors for each token
4093  * that can be mapped to a specific entity within the abstract syntax tree.
4094  *
4095  * This token-annotation routine is equivalent to invoking
4096  * clang_getCursor() for the source locations of each of the
4097  * tokens. The cursors provided are filtered, so that only those
4098  * cursors that have a direct correspondence to the token are
4099  * accepted. For example, given a function call \c f(x),
4100  * clang_getCursor() would provide the following cursors:
4101  *
4102  *   * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'.
4103  *   * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'.
4104  *   * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'.
4105  *
4106  * Only the first and last of these cursors will occur within the
4107  * annotate, since the tokens "f" and "x' directly refer to a function
4108  * and a variable, respectively, but the parentheses are just a small
4109  * part of the full syntax of the function call expression, which is
4110  * not provided as an annotation.
4111  *
4112  * \param TU the translation unit that owns the given tokens.
4113  *
4114  * \param Tokens the set of tokens to annotate.
4115  *
4116  * \param NumTokens the number of tokens in \p Tokens.
4117  *
4118  * \param Cursors an array of \p NumTokens cursors, whose contents will be
4119  * replaced with the cursors corresponding to each token.
4120  */
4121 CINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU,
4122                                          CXToken *Tokens, unsigned NumTokens,
4123                                          CXCursor *Cursors);
4124 
4125 /**
4126  * \brief Free the given set of tokens.
4127  */
4128 CINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU,
4129                                         CXToken *Tokens, unsigned NumTokens);
4130 
4131 /**
4132  * @}
4133  */
4134 
4135 /**
4136  * \defgroup CINDEX_DEBUG Debugging facilities
4137  *
4138  * These routines are used for testing and debugging, only, and should not
4139  * be relied upon.
4140  *
4141  * @{
4142  */
4143 
4144 /* for debug/testing */
4145 CINDEX_LINKAGE CXString clang_getCursorKindSpelling(enum CXCursorKind Kind);
4146 CINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(CXCursor,
4147                                           const char **startBuf,
4148                                           const char **endBuf,
4149                                           unsigned *startLine,
4150                                           unsigned *startColumn,
4151                                           unsigned *endLine,
4152                                           unsigned *endColumn);
4153 CINDEX_LINKAGE void clang_enableStackTraces(void);
4154 CINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void*), void *user_data,
4155                                           unsigned stack_size);
4156 
4157 /**
4158  * @}
4159  */
4160 
4161 /**
4162  * \defgroup CINDEX_CODE_COMPLET Code completion
4163  *
4164  * Code completion involves taking an (incomplete) source file, along with
4165  * knowledge of where the user is actively editing that file, and suggesting
4166  * syntactically- and semantically-valid constructs that the user might want to
4167  * use at that particular point in the source code. These data structures and
4168  * routines provide support for code completion.
4169  *
4170  * @{
4171  */
4172 
4173 /**
4174  * \brief A semantic string that describes a code-completion result.
4175  *
4176  * A semantic string that describes the formatting of a code-completion
4177  * result as a single "template" of text that should be inserted into the
4178  * source buffer when a particular code-completion result is selected.
4179  * Each semantic string is made up of some number of "chunks", each of which
4180  * contains some text along with a description of what that text means, e.g.,
4181  * the name of the entity being referenced, whether the text chunk is part of
4182  * the template, or whether it is a "placeholder" that the user should replace
4183  * with actual code,of a specific kind. See \c CXCompletionChunkKind for a
4184  * description of the different kinds of chunks.
4185  */
4186 typedef void *CXCompletionString;
4187 
4188 /**
4189  * \brief A single result of code completion.
4190  */
4191 typedef struct {
4192   /**
4193    * \brief The kind of entity that this completion refers to.
4194    *
4195    * The cursor kind will be a macro, keyword, or a declaration (one of the
4196    * *Decl cursor kinds), describing the entity that the completion is
4197    * referring to.
4198    *
4199    * \todo In the future, we would like to provide a full cursor, to allow
4200    * the client to extract additional information from declaration.
4201    */
4202   enum CXCursorKind CursorKind;
4203 
4204   /**
4205    * \brief The code-completion string that describes how to insert this
4206    * code-completion result into the editing buffer.
4207    */
4208   CXCompletionString CompletionString;
4209 } CXCompletionResult;
4210 
4211 /**
4212  * \brief Describes a single piece of text within a code-completion string.
4213  *
4214  * Each "chunk" within a code-completion string (\c CXCompletionString) is
4215  * either a piece of text with a specific "kind" that describes how that text
4216  * should be interpreted by the client or is another completion string.
4217  */
4218 enum CXCompletionChunkKind {
4219   /**
4220    * \brief A code-completion string that describes "optional" text that
4221    * could be a part of the template (but is not required).
4222    *
4223    * The Optional chunk is the only kind of chunk that has a code-completion
4224    * string for its representation, which is accessible via
4225    * \c clang_getCompletionChunkCompletionString(). The code-completion string
4226    * describes an additional part of the template that is completely optional.
4227    * For example, optional chunks can be used to describe the placeholders for
4228    * arguments that match up with defaulted function parameters, e.g. given:
4229    *
4230    * \code
4231    * void f(int x, float y = 3.14, double z = 2.71828);
4232    * \endcode
4233    *
4234    * The code-completion string for this function would contain:
4235    *   - a TypedText chunk for "f".
4236    *   - a LeftParen chunk for "(".
4237    *   - a Placeholder chunk for "int x"
4238    *   - an Optional chunk containing the remaining defaulted arguments, e.g.,
4239    *       - a Comma chunk for ","
4240    *       - a Placeholder chunk for "float y"
4241    *       - an Optional chunk containing the last defaulted argument:
4242    *           - a Comma chunk for ","
4243    *           - a Placeholder chunk for "double z"
4244    *   - a RightParen chunk for ")"
4245    *
4246    * There are many ways to handle Optional chunks. Two simple approaches are:
4247    *   - Completely ignore optional chunks, in which case the template for the
4248    *     function "f" would only include the first parameter ("int x").
4249    *   - Fully expand all optional chunks, in which case the template for the
4250    *     function "f" would have all of the parameters.
4251    */
4252   CXCompletionChunk_Optional,
4253   /**
4254    * \brief Text that a user would be expected to type to get this
4255    * code-completion result.
4256    *
4257    * There will be exactly one "typed text" chunk in a semantic string, which
4258    * will typically provide the spelling of a keyword or the name of a
4259    * declaration that could be used at the current code point. Clients are
4260    * expected to filter the code-completion results based on the text in this
4261    * chunk.
4262    */
4263   CXCompletionChunk_TypedText,
4264   /**
4265    * \brief Text that should be inserted as part of a code-completion result.
4266    *
4267    * A "text" chunk represents text that is part of the template to be
4268    * inserted into user code should this particular code-completion result
4269    * be selected.
4270    */
4271   CXCompletionChunk_Text,
4272   /**
4273    * \brief Placeholder text that should be replaced by the user.
4274    *
4275    * A "placeholder" chunk marks a place where the user should insert text
4276    * into the code-completion template. For example, placeholders might mark
4277    * the function parameters for a function declaration, to indicate that the
4278    * user should provide arguments for each of those parameters. The actual
4279    * text in a placeholder is a suggestion for the text to display before
4280    * the user replaces the placeholder with real code.
4281    */
4282   CXCompletionChunk_Placeholder,
4283   /**
4284    * \brief Informative text that should be displayed but never inserted as
4285    * part of the template.
4286    *
4287    * An "informative" chunk contains annotations that can be displayed to
4288    * help the user decide whether a particular code-completion result is the
4289    * right option, but which is not part of the actual template to be inserted
4290    * by code completion.
4291    */
4292   CXCompletionChunk_Informative,
4293   /**
4294    * \brief Text that describes the current parameter when code-completion is
4295    * referring to function call, message send, or template specialization.
4296    *
4297    * A "current parameter" chunk occurs when code-completion is providing
4298    * information about a parameter corresponding to the argument at the
4299    * code-completion point. For example, given a function
4300    *
4301    * \code
4302    * int add(int x, int y);
4303    * \endcode
4304    *
4305    * and the source code \c add(, where the code-completion point is after the
4306    * "(", the code-completion string will contain a "current parameter" chunk
4307    * for "int x", indicating that the current argument will initialize that
4308    * parameter. After typing further, to \c add(17, (where the code-completion
4309    * point is after the ","), the code-completion string will contain a
4310    * "current paremeter" chunk to "int y".
4311    */
4312   CXCompletionChunk_CurrentParameter,
4313   /**
4314    * \brief A left parenthesis ('('), used to initiate a function call or
4315    * signal the beginning of a function parameter list.
4316    */
4317   CXCompletionChunk_LeftParen,
4318   /**
4319    * \brief A right parenthesis (')'), used to finish a function call or
4320    * signal the end of a function parameter list.
4321    */
4322   CXCompletionChunk_RightParen,
4323   /**
4324    * \brief A left bracket ('[').
4325    */
4326   CXCompletionChunk_LeftBracket,
4327   /**
4328    * \brief A right bracket (']').
4329    */
4330   CXCompletionChunk_RightBracket,
4331   /**
4332    * \brief A left brace ('{').
4333    */
4334   CXCompletionChunk_LeftBrace,
4335   /**
4336    * \brief A right brace ('}').
4337    */
4338   CXCompletionChunk_RightBrace,
4339   /**
4340    * \brief A left angle bracket ('<').
4341    */
4342   CXCompletionChunk_LeftAngle,
4343   /**
4344    * \brief A right angle bracket ('>').
4345    */
4346   CXCompletionChunk_RightAngle,
4347   /**
4348    * \brief A comma separator (',').
4349    */
4350   CXCompletionChunk_Comma,
4351   /**
4352    * \brief Text that specifies the result type of a given result.
4353    *
4354    * This special kind of informative chunk is not meant to be inserted into
4355    * the text buffer. Rather, it is meant to illustrate the type that an
4356    * expression using the given completion string would have.
4357    */
4358   CXCompletionChunk_ResultType,
4359   /**
4360    * \brief A colon (':').
4361    */
4362   CXCompletionChunk_Colon,
4363   /**
4364    * \brief A semicolon (';').
4365    */
4366   CXCompletionChunk_SemiColon,
4367   /**
4368    * \brief An '=' sign.
4369    */
4370   CXCompletionChunk_Equal,
4371   /**
4372    * Horizontal space (' ').
4373    */
4374   CXCompletionChunk_HorizontalSpace,
4375   /**
4376    * Vertical space ('\n'), after which it is generally a good idea to
4377    * perform indentation.
4378    */
4379   CXCompletionChunk_VerticalSpace
4380 };
4381 
4382 /**
4383  * \brief Determine the kind of a particular chunk within a completion string.
4384  *
4385  * \param completion_string the completion string to query.
4386  *
4387  * \param chunk_number the 0-based index of the chunk in the completion string.
4388  *
4389  * \returns the kind of the chunk at the index \c chunk_number.
4390  */
4391 CINDEX_LINKAGE enum CXCompletionChunkKind
4392 clang_getCompletionChunkKind(CXCompletionString completion_string,
4393                              unsigned chunk_number);
4394 
4395 /**
4396  * \brief Retrieve the text associated with a particular chunk within a
4397  * completion string.
4398  *
4399  * \param completion_string the completion string to query.
4400  *
4401  * \param chunk_number the 0-based index of the chunk in the completion string.
4402  *
4403  * \returns the text associated with the chunk at index \c chunk_number.
4404  */
4405 CINDEX_LINKAGE CXString
4406 clang_getCompletionChunkText(CXCompletionString completion_string,
4407                              unsigned chunk_number);
4408 
4409 /**
4410  * \brief Retrieve the completion string associated with a particular chunk
4411  * within a completion string.
4412  *
4413  * \param completion_string the completion string to query.
4414  *
4415  * \param chunk_number the 0-based index of the chunk in the completion string.
4416  *
4417  * \returns the completion string associated with the chunk at index
4418  * \c chunk_number.
4419  */
4420 CINDEX_LINKAGE CXCompletionString
4421 clang_getCompletionChunkCompletionString(CXCompletionString completion_string,
4422                                          unsigned chunk_number);
4423 
4424 /**
4425  * \brief Retrieve the number of chunks in the given code-completion string.
4426  */
4427 CINDEX_LINKAGE unsigned
4428 clang_getNumCompletionChunks(CXCompletionString completion_string);
4429 
4430 /**
4431  * \brief Determine the priority of this code completion.
4432  *
4433  * The priority of a code completion indicates how likely it is that this
4434  * particular completion is the completion that the user will select. The
4435  * priority is selected by various internal heuristics.
4436  *
4437  * \param completion_string The completion string to query.
4438  *
4439  * \returns The priority of this completion string. Smaller values indicate
4440  * higher-priority (more likely) completions.
4441  */
4442 CINDEX_LINKAGE unsigned
4443 clang_getCompletionPriority(CXCompletionString completion_string);
4444 
4445 /**
4446  * \brief Determine the availability of the entity that this code-completion
4447  * string refers to.
4448  *
4449  * \param completion_string The completion string to query.
4450  *
4451  * \returns The availability of the completion string.
4452  */
4453 CINDEX_LINKAGE enum CXAvailabilityKind
4454 clang_getCompletionAvailability(CXCompletionString completion_string);
4455 
4456 /**
4457  * \brief Retrieve the number of annotations associated with the given
4458  * completion string.
4459  *
4460  * \param completion_string the completion string to query.
4461  *
4462  * \returns the number of annotations associated with the given completion
4463  * string.
4464  */
4465 CINDEX_LINKAGE unsigned
4466 clang_getCompletionNumAnnotations(CXCompletionString completion_string);
4467 
4468 /**
4469  * \brief Retrieve the annotation associated with the given completion string.
4470  *
4471  * \param completion_string the completion string to query.
4472  *
4473  * \param annotation_number the 0-based index of the annotation of the
4474  * completion string.
4475  *
4476  * \returns annotation string associated with the completion at index
4477  * \c annotation_number, or a NULL string if that annotation is not available.
4478  */
4479 CINDEX_LINKAGE CXString
4480 clang_getCompletionAnnotation(CXCompletionString completion_string,
4481                               unsigned annotation_number);
4482 
4483 /**
4484  * \brief Retrieve the parent context of the given completion string.
4485  *
4486  * The parent context of a completion string is the semantic parent of
4487  * the declaration (if any) that the code completion represents. For example,
4488  * a code completion for an Objective-C method would have the method's class
4489  * or protocol as its context.
4490  *
4491  * \param completion_string The code completion string whose parent is
4492  * being queried.
4493  *
4494  * \param kind DEPRECATED: always set to CXCursor_NotImplemented if non-NULL.
4495  *
4496  * \returns The name of the completion parent, e.g., "NSObject" if
4497  * the completion string represents a method in the NSObject class.
4498  */
4499 CINDEX_LINKAGE CXString
4500 clang_getCompletionParent(CXCompletionString completion_string,
4501                           enum CXCursorKind *kind);
4502 
4503 /**
4504  * \brief Retrieve the brief documentation comment attached to the declaration
4505  * that corresponds to the given completion string.
4506  */
4507 CINDEX_LINKAGE CXString
4508 clang_getCompletionBriefComment(CXCompletionString completion_string);
4509 
4510 /**
4511  * \brief Retrieve a completion string for an arbitrary declaration or macro
4512  * definition cursor.
4513  *
4514  * \param cursor The cursor to query.
4515  *
4516  * \returns A non-context-sensitive completion string for declaration and macro
4517  * definition cursors, or NULL for other kinds of cursors.
4518  */
4519 CINDEX_LINKAGE CXCompletionString
4520 clang_getCursorCompletionString(CXCursor cursor);
4521 
4522 /**
4523  * \brief Contains the results of code-completion.
4524  *
4525  * This data structure contains the results of code completion, as
4526  * produced by \c clang_codeCompleteAt(). Its contents must be freed by
4527  * \c clang_disposeCodeCompleteResults.
4528  */
4529 typedef struct {
4530   /**
4531    * \brief The code-completion results.
4532    */
4533   CXCompletionResult *Results;
4534 
4535   /**
4536    * \brief The number of code-completion results stored in the
4537    * \c Results array.
4538    */
4539   unsigned NumResults;
4540 } CXCodeCompleteResults;
4541 
4542 /**
4543  * \brief Flags that can be passed to \c clang_codeCompleteAt() to
4544  * modify its behavior.
4545  *
4546  * The enumerators in this enumeration can be bitwise-OR'd together to
4547  * provide multiple options to \c clang_codeCompleteAt().
4548  */
4549 enum CXCodeComplete_Flags {
4550   /**
4551    * \brief Whether to include macros within the set of code
4552    * completions returned.
4553    */
4554   CXCodeComplete_IncludeMacros = 0x01,
4555 
4556   /**
4557    * \brief Whether to include code patterns for language constructs
4558    * within the set of code completions, e.g., for loops.
4559    */
4560   CXCodeComplete_IncludeCodePatterns = 0x02,
4561 
4562   /**
4563    * \brief Whether to include brief documentation within the set of code
4564    * completions returned.
4565    */
4566   CXCodeComplete_IncludeBriefComments = 0x04
4567 };
4568 
4569 /**
4570  * \brief Bits that represent the context under which completion is occurring.
4571  *
4572  * The enumerators in this enumeration may be bitwise-OR'd together if multiple
4573  * contexts are occurring simultaneously.
4574  */
4575 enum CXCompletionContext {
4576   /**
4577    * \brief The context for completions is unexposed, as only Clang results
4578    * should be included. (This is equivalent to having no context bits set.)
4579    */
4580   CXCompletionContext_Unexposed = 0,
4581 
4582   /**
4583    * \brief Completions for any possible type should be included in the results.
4584    */
4585   CXCompletionContext_AnyType = 1 << 0,
4586 
4587   /**
4588    * \brief Completions for any possible value (variables, function calls, etc.)
4589    * should be included in the results.
4590    */
4591   CXCompletionContext_AnyValue = 1 << 1,
4592   /**
4593    * \brief Completions for values that resolve to an Objective-C object should
4594    * be included in the results.
4595    */
4596   CXCompletionContext_ObjCObjectValue = 1 << 2,
4597   /**
4598    * \brief Completions for values that resolve to an Objective-C selector
4599    * should be included in the results.
4600    */
4601   CXCompletionContext_ObjCSelectorValue = 1 << 3,
4602   /**
4603    * \brief Completions for values that resolve to a C++ class type should be
4604    * included in the results.
4605    */
4606   CXCompletionContext_CXXClassTypeValue = 1 << 4,
4607 
4608   /**
4609    * \brief Completions for fields of the member being accessed using the dot
4610    * operator should be included in the results.
4611    */
4612   CXCompletionContext_DotMemberAccess = 1 << 5,
4613   /**
4614    * \brief Completions for fields of the member being accessed using the arrow
4615    * operator should be included in the results.
4616    */
4617   CXCompletionContext_ArrowMemberAccess = 1 << 6,
4618   /**
4619    * \brief Completions for properties of the Objective-C object being accessed
4620    * using the dot operator should be included in the results.
4621    */
4622   CXCompletionContext_ObjCPropertyAccess = 1 << 7,
4623 
4624   /**
4625    * \brief Completions for enum tags should be included in the results.
4626    */
4627   CXCompletionContext_EnumTag = 1 << 8,
4628   /**
4629    * \brief Completions for union tags should be included in the results.
4630    */
4631   CXCompletionContext_UnionTag = 1 << 9,
4632   /**
4633    * \brief Completions for struct tags should be included in the results.
4634    */
4635   CXCompletionContext_StructTag = 1 << 10,
4636 
4637   /**
4638    * \brief Completions for C++ class names should be included in the results.
4639    */
4640   CXCompletionContext_ClassTag = 1 << 11,
4641   /**
4642    * \brief Completions for C++ namespaces and namespace aliases should be
4643    * included in the results.
4644    */
4645   CXCompletionContext_Namespace = 1 << 12,
4646   /**
4647    * \brief Completions for C++ nested name specifiers should be included in
4648    * the results.
4649    */
4650   CXCompletionContext_NestedNameSpecifier = 1 << 13,
4651 
4652   /**
4653    * \brief Completions for Objective-C interfaces (classes) should be included
4654    * in the results.
4655    */
4656   CXCompletionContext_ObjCInterface = 1 << 14,
4657   /**
4658    * \brief Completions for Objective-C protocols should be included in
4659    * the results.
4660    */
4661   CXCompletionContext_ObjCProtocol = 1 << 15,
4662   /**
4663    * \brief Completions for Objective-C categories should be included in
4664    * the results.
4665    */
4666   CXCompletionContext_ObjCCategory = 1 << 16,
4667   /**
4668    * \brief Completions for Objective-C instance messages should be included
4669    * in the results.
4670    */
4671   CXCompletionContext_ObjCInstanceMessage = 1 << 17,
4672   /**
4673    * \brief Completions for Objective-C class messages should be included in
4674    * the results.
4675    */
4676   CXCompletionContext_ObjCClassMessage = 1 << 18,
4677   /**
4678    * \brief Completions for Objective-C selector names should be included in
4679    * the results.
4680    */
4681   CXCompletionContext_ObjCSelectorName = 1 << 19,
4682 
4683   /**
4684    * \brief Completions for preprocessor macro names should be included in
4685    * the results.
4686    */
4687   CXCompletionContext_MacroName = 1 << 20,
4688 
4689   /**
4690    * \brief Natural language completions should be included in the results.
4691    */
4692   CXCompletionContext_NaturalLanguage = 1 << 21,
4693 
4694   /**
4695    * \brief The current context is unknown, so set all contexts.
4696    */
4697   CXCompletionContext_Unknown = ((1 << 22) - 1)
4698 };
4699 
4700 /**
4701  * \brief Returns a default set of code-completion options that can be
4702  * passed to\c clang_codeCompleteAt().
4703  */
4704 CINDEX_LINKAGE unsigned clang_defaultCodeCompleteOptions(void);
4705 
4706 /**
4707  * \brief Perform code completion at a given location in a translation unit.
4708  *
4709  * This function performs code completion at a particular file, line, and
4710  * column within source code, providing results that suggest potential
4711  * code snippets based on the context of the completion. The basic model
4712  * for code completion is that Clang will parse a complete source file,
4713  * performing syntax checking up to the location where code-completion has
4714  * been requested. At that point, a special code-completion token is passed
4715  * to the parser, which recognizes this token and determines, based on the
4716  * current location in the C/Objective-C/C++ grammar and the state of
4717  * semantic analysis, what completions to provide. These completions are
4718  * returned via a new \c CXCodeCompleteResults structure.
4719  *
4720  * Code completion itself is meant to be triggered by the client when the
4721  * user types punctuation characters or whitespace, at which point the
4722  * code-completion location will coincide with the cursor. For example, if \c p
4723  * is a pointer, code-completion might be triggered after the "-" and then
4724  * after the ">" in \c p->. When the code-completion location is afer the ">",
4725  * the completion results will provide, e.g., the members of the struct that
4726  * "p" points to. The client is responsible for placing the cursor at the
4727  * beginning of the token currently being typed, then filtering the results
4728  * based on the contents of the token. For example, when code-completing for
4729  * the expression \c p->get, the client should provide the location just after
4730  * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the
4731  * client can filter the results based on the current token text ("get"), only
4732  * showing those results that start with "get". The intent of this interface
4733  * is to separate the relatively high-latency acquisition of code-completion
4734  * results from the filtering of results on a per-character basis, which must
4735  * have a lower latency.
4736  *
4737  * \param TU The translation unit in which code-completion should
4738  * occur. The source files for this translation unit need not be
4739  * completely up-to-date (and the contents of those source files may
4740  * be overridden via \p unsaved_files). Cursors referring into the
4741  * translation unit may be invalidated by this invocation.
4742  *
4743  * \param complete_filename The name of the source file where code
4744  * completion should be performed. This filename may be any file
4745  * included in the translation unit.
4746  *
4747  * \param complete_line The line at which code-completion should occur.
4748  *
4749  * \param complete_column The column at which code-completion should occur.
4750  * Note that the column should point just after the syntactic construct that
4751  * initiated code completion, and not in the middle of a lexical token.
4752  *
4753  * \param unsaved_files the Tiles that have not yet been saved to disk
4754  * but may be required for parsing or code completion, including the
4755  * contents of those files.  The contents and name of these files (as
4756  * specified by CXUnsavedFile) are copied when necessary, so the
4757  * client only needs to guarantee their validity until the call to
4758  * this function returns.
4759  *
4760  * \param num_unsaved_files The number of unsaved file entries in \p
4761  * unsaved_files.
4762  *
4763  * \param options Extra options that control the behavior of code
4764  * completion, expressed as a bitwise OR of the enumerators of the
4765  * CXCodeComplete_Flags enumeration. The
4766  * \c clang_defaultCodeCompleteOptions() function returns a default set
4767  * of code-completion options.
4768  *
4769  * \returns If successful, a new \c CXCodeCompleteResults structure
4770  * containing code-completion results, which should eventually be
4771  * freed with \c clang_disposeCodeCompleteResults(). If code
4772  * completion fails, returns NULL.
4773  */
4774 CINDEX_LINKAGE
4775 CXCodeCompleteResults *clang_codeCompleteAt(CXTranslationUnit TU,
4776                                             const char *complete_filename,
4777                                             unsigned complete_line,
4778                                             unsigned complete_column,
4779                                             struct CXUnsavedFile *unsaved_files,
4780                                             unsigned num_unsaved_files,
4781                                             unsigned options);
4782 
4783 /**
4784  * \brief Sort the code-completion results in case-insensitive alphabetical
4785  * order.
4786  *
4787  * \param Results The set of results to sort.
4788  * \param NumResults The number of results in \p Results.
4789  */
4790 CINDEX_LINKAGE
4791 void clang_sortCodeCompletionResults(CXCompletionResult *Results,
4792                                      unsigned NumResults);
4793 
4794 /**
4795  * \brief Free the given set of code-completion results.
4796  */
4797 CINDEX_LINKAGE
4798 void clang_disposeCodeCompleteResults(CXCodeCompleteResults *Results);
4799 
4800 /**
4801  * \brief Determine the number of diagnostics produced prior to the
4802  * location where code completion was performed.
4803  */
4804 CINDEX_LINKAGE
4805 unsigned clang_codeCompleteGetNumDiagnostics(CXCodeCompleteResults *Results);
4806 
4807 /**
4808  * \brief Retrieve a diagnostic associated with the given code completion.
4809  *
4810  * \param Results the code completion results to query.
4811  * \param Index the zero-based diagnostic number to retrieve.
4812  *
4813  * \returns the requested diagnostic. This diagnostic must be freed
4814  * via a call to \c clang_disposeDiagnostic().
4815  */
4816 CINDEX_LINKAGE
4817 CXDiagnostic clang_codeCompleteGetDiagnostic(CXCodeCompleteResults *Results,
4818                                              unsigned Index);
4819 
4820 /**
4821  * \brief Determines what compeltions are appropriate for the context
4822  * the given code completion.
4823  *
4824  * \param Results the code completion results to query
4825  *
4826  * \returns the kinds of completions that are appropriate for use
4827  * along with the given code completion results.
4828  */
4829 CINDEX_LINKAGE
4830 unsigned long long clang_codeCompleteGetContexts(
4831                                                 CXCodeCompleteResults *Results);
4832 
4833 /**
4834  * \brief Returns the cursor kind for the container for the current code
4835  * completion context. The container is only guaranteed to be set for
4836  * contexts where a container exists (i.e. member accesses or Objective-C
4837  * message sends); if there is not a container, this function will return
4838  * CXCursor_InvalidCode.
4839  *
4840  * \param Results the code completion results to query
4841  *
4842  * \param IsIncomplete on return, this value will be false if Clang has complete
4843  * information about the container. If Clang does not have complete
4844  * information, this value will be true.
4845  *
4846  * \returns the container kind, or CXCursor_InvalidCode if there is not a
4847  * container
4848  */
4849 CINDEX_LINKAGE
4850 enum CXCursorKind clang_codeCompleteGetContainerKind(
4851                                                  CXCodeCompleteResults *Results,
4852                                                      unsigned *IsIncomplete);
4853 
4854 /**
4855  * \brief Returns the USR for the container for the current code completion
4856  * context. If there is not a container for the current context, this
4857  * function will return the empty string.
4858  *
4859  * \param Results the code completion results to query
4860  *
4861  * \returns the USR for the container
4862  */
4863 CINDEX_LINKAGE
4864 CXString clang_codeCompleteGetContainerUSR(CXCodeCompleteResults *Results);
4865 
4866 
4867 /**
4868  * \brief Returns the currently-entered selector for an Objective-C message
4869  * send, formatted like "initWithFoo:bar:". Only guaranteed to return a
4870  * non-empty string for CXCompletionContext_ObjCInstanceMessage and
4871  * CXCompletionContext_ObjCClassMessage.
4872  *
4873  * \param Results the code completion results to query
4874  *
4875  * \returns the selector (or partial selector) that has been entered thus far
4876  * for an Objective-C message send.
4877  */
4878 CINDEX_LINKAGE
4879 CXString clang_codeCompleteGetObjCSelector(CXCodeCompleteResults *Results);
4880 
4881 /**
4882  * @}
4883  */
4884 
4885 
4886 /**
4887  * \defgroup CINDEX_MISC Miscellaneous utility functions
4888  *
4889  * @{
4890  */
4891 
4892 /**
4893  * \brief Return a version string, suitable for showing to a user, but not
4894  *        intended to be parsed (the format is not guaranteed to be stable).
4895  */
4896 CINDEX_LINKAGE CXString clang_getClangVersion(void);
4897 
4898 
4899 /**
4900  * \brief Enable/disable crash recovery.
4901  *
4902  * \param isEnabled Flag to indicate if crash recovery is enabled.  A non-zero
4903  *        value enables crash recovery, while 0 disables it.
4904  */
4905 CINDEX_LINKAGE void clang_toggleCrashRecovery(unsigned isEnabled);
4906 
4907  /**
4908   * \brief Visitor invoked for each file in a translation unit
4909   *        (used with clang_getInclusions()).
4910   *
4911   * This visitor function will be invoked by clang_getInclusions() for each
4912   * file included (either at the top-level or by \#include directives) within
4913   * a translation unit.  The first argument is the file being included, and
4914   * the second and third arguments provide the inclusion stack.  The
4915   * array is sorted in order of immediate inclusion.  For example,
4916   * the first element refers to the location that included 'included_file'.
4917   */
4918 typedef void (*CXInclusionVisitor)(CXFile included_file,
4919                                    CXSourceLocation* inclusion_stack,
4920                                    unsigned include_len,
4921                                    CXClientData client_data);
4922 
4923 /**
4924  * \brief Visit the set of preprocessor inclusions in a translation unit.
4925  *   The visitor function is called with the provided data for every included
4926  *   file.  This does not include headers included by the PCH file (unless one
4927  *   is inspecting the inclusions in the PCH file itself).
4928  */
4929 CINDEX_LINKAGE void clang_getInclusions(CXTranslationUnit tu,
4930                                         CXInclusionVisitor visitor,
4931                                         CXClientData client_data);
4932 
4933 /**
4934  * @}
4935  */
4936 
4937 /** \defgroup CINDEX_REMAPPING Remapping functions
4938  *
4939  * @{
4940  */
4941 
4942 /**
4943  * \brief A remapping of original source files and their translated files.
4944  */
4945 typedef void *CXRemapping;
4946 
4947 /**
4948  * \brief Retrieve a remapping.
4949  *
4950  * \param path the path that contains metadata about remappings.
4951  *
4952  * \returns the requested remapping. This remapping must be freed
4953  * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
4954  */
4955 CINDEX_LINKAGE CXRemapping clang_getRemappings(const char *path);
4956 
4957 /**
4958  * \brief Retrieve a remapping.
4959  *
4960  * \param filePaths pointer to an array of file paths containing remapping info.
4961  *
4962  * \param numFiles number of file paths.
4963  *
4964  * \returns the requested remapping. This remapping must be freed
4965  * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
4966  */
4967 CINDEX_LINKAGE
4968 CXRemapping clang_getRemappingsFromFileList(const char **filePaths,
4969                                             unsigned numFiles);
4970 
4971 /**
4972  * \brief Determine the number of remappings.
4973  */
4974 CINDEX_LINKAGE unsigned clang_remap_getNumFiles(CXRemapping);
4975 
4976 /**
4977  * \brief Get the original and the associated filename from the remapping.
4978  *
4979  * \param original If non-NULL, will be set to the original filename.
4980  *
4981  * \param transformed If non-NULL, will be set to the filename that the original
4982  * is associated with.
4983  */
4984 CINDEX_LINKAGE void clang_remap_getFilenames(CXRemapping, unsigned index,
4985                                      CXString *original, CXString *transformed);
4986 
4987 /**
4988  * \brief Dispose the remapping.
4989  */
4990 CINDEX_LINKAGE void clang_remap_dispose(CXRemapping);
4991 
4992 /**
4993  * @}
4994  */
4995 
4996 /** \defgroup CINDEX_HIGH Higher level API functions
4997  *
4998  * @{
4999  */
5000 
5001 enum CXVisitorResult {
5002   CXVisit_Break,
5003   CXVisit_Continue
5004 };
5005 
5006 typedef struct {
5007   void *context;
5008   enum CXVisitorResult (*visit)(void *context, CXCursor, CXSourceRange);
5009 } CXCursorAndRangeVisitor;
5010 
5011 typedef enum {
5012   /**
5013    * \brief Function returned successfully.
5014    */
5015   CXResult_Success = 0,
5016   /**
5017    * \brief One of the parameters was invalid for the function.
5018    */
5019   CXResult_Invalid = 1,
5020   /**
5021    * \brief The function was terminated by a callback (e.g. it returned
5022    * CXVisit_Break)
5023    */
5024   CXResult_VisitBreak = 2
5025 
5026 } CXResult;
5027 
5028 /**
5029  * \brief Find references of a declaration in a specific file.
5030  *
5031  * \param cursor pointing to a declaration or a reference of one.
5032  *
5033  * \param file to search for references.
5034  *
5035  * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
5036  * each reference found.
5037  * The CXSourceRange will point inside the file; if the reference is inside
5038  * a macro (and not a macro argument) the CXSourceRange will be invalid.
5039  *
5040  * \returns one of the CXResult enumerators.
5041  */
5042 CINDEX_LINKAGE CXResult clang_findReferencesInFile(CXCursor cursor, CXFile file,
5043                                                CXCursorAndRangeVisitor visitor);
5044 
5045 /**
5046  * \brief Find #import/#include directives in a specific file.
5047  *
5048  * \param TU translation unit containing the file to query.
5049  *
5050  * \param file to search for #import/#include directives.
5051  *
5052  * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
5053  * each directive found.
5054  *
5055  * \returns one of the CXResult enumerators.
5056  */
5057 CINDEX_LINKAGE CXResult clang_findIncludesInFile(CXTranslationUnit TU,
5058                                                  CXFile file,
5059                                               CXCursorAndRangeVisitor visitor);
5060 
5061 #ifdef __has_feature
5062 #  if __has_feature(blocks)
5063 
5064 typedef enum CXVisitorResult
5065     (^CXCursorAndRangeVisitorBlock)(CXCursor, CXSourceRange);
5066 
5067 CINDEX_LINKAGE
5068 CXResult clang_findReferencesInFileWithBlock(CXCursor, CXFile,
5069                                              CXCursorAndRangeVisitorBlock);
5070 
5071 CINDEX_LINKAGE
5072 CXResult clang_findIncludesInFileWithBlock(CXTranslationUnit, CXFile,
5073                                            CXCursorAndRangeVisitorBlock);
5074 
5075 #  endif
5076 #endif
5077 
5078 /**
5079  * \brief The client's data object that is associated with a CXFile.
5080  */
5081 typedef void *CXIdxClientFile;
5082 
5083 /**
5084  * \brief The client's data object that is associated with a semantic entity.
5085  */
5086 typedef void *CXIdxClientEntity;
5087 
5088 /**
5089  * \brief The client's data object that is associated with a semantic container
5090  * of entities.
5091  */
5092 typedef void *CXIdxClientContainer;
5093 
5094 /**
5095  * \brief The client's data object that is associated with an AST file (PCH
5096  * or module).
5097  */
5098 typedef void *CXIdxClientASTFile;
5099 
5100 /**
5101  * \brief Source location passed to index callbacks.
5102  */
5103 typedef struct {
5104   void *ptr_data[2];
5105   unsigned int_data;
5106 } CXIdxLoc;
5107 
5108 /**
5109  * \brief Data for ppIncludedFile callback.
5110  */
5111 typedef struct {
5112   /**
5113    * \brief Location of '#' in the \#include/\#import directive.
5114    */
5115   CXIdxLoc hashLoc;
5116   /**
5117    * \brief Filename as written in the \#include/\#import directive.
5118    */
5119   const char *filename;
5120   /**
5121    * \brief The actual file that the \#include/\#import directive resolved to.
5122    */
5123   CXFile file;
5124   int isImport;
5125   int isAngled;
5126   /**
5127    * \brief Non-zero if the directive was automatically turned into a module
5128    * import.
5129    */
5130   int isModuleImport;
5131 } CXIdxIncludedFileInfo;
5132 
5133 /**
5134  * \brief Data for IndexerCallbacks#importedASTFile.
5135  */
5136 typedef struct {
5137   /**
5138    * \brief Top level AST file containing the imported PCH, module or submodule.
5139    */
5140   CXFile file;
5141   /**
5142    * \brief The imported module or NULL if the AST file is a PCH.
5143    */
5144   CXModule module;
5145   /**
5146    * \brief Location where the file is imported. Applicable only for modules.
5147    */
5148   CXIdxLoc loc;
5149   /**
5150    * \brief Non-zero if an inclusion directive was automatically turned into
5151    * a module import. Applicable only for modules.
5152    */
5153   int isImplicit;
5154 
5155 } CXIdxImportedASTFileInfo;
5156 
5157 typedef enum {
5158   CXIdxEntity_Unexposed     = 0,
5159   CXIdxEntity_Typedef       = 1,
5160   CXIdxEntity_Function      = 2,
5161   CXIdxEntity_Variable      = 3,
5162   CXIdxEntity_Field         = 4,
5163   CXIdxEntity_EnumConstant  = 5,
5164 
5165   CXIdxEntity_ObjCClass     = 6,
5166   CXIdxEntity_ObjCProtocol  = 7,
5167   CXIdxEntity_ObjCCategory  = 8,
5168 
5169   CXIdxEntity_ObjCInstanceMethod = 9,
5170   CXIdxEntity_ObjCClassMethod    = 10,
5171   CXIdxEntity_ObjCProperty  = 11,
5172   CXIdxEntity_ObjCIvar      = 12,
5173 
5174   CXIdxEntity_Enum          = 13,
5175   CXIdxEntity_Struct        = 14,
5176   CXIdxEntity_Union         = 15,
5177 
5178   CXIdxEntity_CXXClass              = 16,
5179   CXIdxEntity_CXXNamespace          = 17,
5180   CXIdxEntity_CXXNamespaceAlias     = 18,
5181   CXIdxEntity_CXXStaticVariable     = 19,
5182   CXIdxEntity_CXXStaticMethod       = 20,
5183   CXIdxEntity_CXXInstanceMethod     = 21,
5184   CXIdxEntity_CXXConstructor        = 22,
5185   CXIdxEntity_CXXDestructor         = 23,
5186   CXIdxEntity_CXXConversionFunction = 24,
5187   CXIdxEntity_CXXTypeAlias          = 25,
5188   CXIdxEntity_CXXInterface          = 26
5189 
5190 } CXIdxEntityKind;
5191 
5192 typedef enum {
5193   CXIdxEntityLang_None = 0,
5194   CXIdxEntityLang_C    = 1,
5195   CXIdxEntityLang_ObjC = 2,
5196   CXIdxEntityLang_CXX  = 3
5197 } CXIdxEntityLanguage;
5198 
5199 /**
5200  * \brief Extra C++ template information for an entity. This can apply to:
5201  * CXIdxEntity_Function
5202  * CXIdxEntity_CXXClass
5203  * CXIdxEntity_CXXStaticMethod
5204  * CXIdxEntity_CXXInstanceMethod
5205  * CXIdxEntity_CXXConstructor
5206  * CXIdxEntity_CXXConversionFunction
5207  * CXIdxEntity_CXXTypeAlias
5208  */
5209 typedef enum {
5210   CXIdxEntity_NonTemplate   = 0,
5211   CXIdxEntity_Template      = 1,
5212   CXIdxEntity_TemplatePartialSpecialization = 2,
5213   CXIdxEntity_TemplateSpecialization = 3
5214 } CXIdxEntityCXXTemplateKind;
5215 
5216 typedef enum {
5217   CXIdxAttr_Unexposed     = 0,
5218   CXIdxAttr_IBAction      = 1,
5219   CXIdxAttr_IBOutlet      = 2,
5220   CXIdxAttr_IBOutletCollection = 3
5221 } CXIdxAttrKind;
5222 
5223 typedef struct {
5224   CXIdxAttrKind kind;
5225   CXCursor cursor;
5226   CXIdxLoc loc;
5227 } CXIdxAttrInfo;
5228 
5229 typedef struct {
5230   CXIdxEntityKind kind;
5231   CXIdxEntityCXXTemplateKind templateKind;
5232   CXIdxEntityLanguage lang;
5233   const char *name;
5234   const char *USR;
5235   CXCursor cursor;
5236   const CXIdxAttrInfo *const *attributes;
5237   unsigned numAttributes;
5238 } CXIdxEntityInfo;
5239 
5240 typedef struct {
5241   CXCursor cursor;
5242 } CXIdxContainerInfo;
5243 
5244 typedef struct {
5245   const CXIdxAttrInfo *attrInfo;
5246   const CXIdxEntityInfo *objcClass;
5247   CXCursor classCursor;
5248   CXIdxLoc classLoc;
5249 } CXIdxIBOutletCollectionAttrInfo;
5250 
5251 typedef enum {
5252   CXIdxDeclFlag_Skipped = 0x1
5253 } CXIdxDeclInfoFlags;
5254 
5255 typedef struct {
5256   const CXIdxEntityInfo *entityInfo;
5257   CXCursor cursor;
5258   CXIdxLoc loc;
5259   const CXIdxContainerInfo *semanticContainer;
5260   /**
5261    * \brief Generally same as #semanticContainer but can be different in
5262    * cases like out-of-line C++ member functions.
5263    */
5264   const CXIdxContainerInfo *lexicalContainer;
5265   int isRedeclaration;
5266   int isDefinition;
5267   int isContainer;
5268   const CXIdxContainerInfo *declAsContainer;
5269   /**
5270    * \brief Whether the declaration exists in code or was created implicitly
5271    * by the compiler, e.g. implicit objc methods for properties.
5272    */
5273   int isImplicit;
5274   const CXIdxAttrInfo *const *attributes;
5275   unsigned numAttributes;
5276 
5277   unsigned flags;
5278 
5279 } CXIdxDeclInfo;
5280 
5281 typedef enum {
5282   CXIdxObjCContainer_ForwardRef = 0,
5283   CXIdxObjCContainer_Interface = 1,
5284   CXIdxObjCContainer_Implementation = 2
5285 } CXIdxObjCContainerKind;
5286 
5287 typedef struct {
5288   const CXIdxDeclInfo *declInfo;
5289   CXIdxObjCContainerKind kind;
5290 } CXIdxObjCContainerDeclInfo;
5291 
5292 typedef struct {
5293   const CXIdxEntityInfo *base;
5294   CXCursor cursor;
5295   CXIdxLoc loc;
5296 } CXIdxBaseClassInfo;
5297 
5298 typedef struct {
5299   const CXIdxEntityInfo *protocol;
5300   CXCursor cursor;
5301   CXIdxLoc loc;
5302 } CXIdxObjCProtocolRefInfo;
5303 
5304 typedef struct {
5305   const CXIdxObjCProtocolRefInfo *const *protocols;
5306   unsigned numProtocols;
5307 } CXIdxObjCProtocolRefListInfo;
5308 
5309 typedef struct {
5310   const CXIdxObjCContainerDeclInfo *containerInfo;
5311   const CXIdxBaseClassInfo *superInfo;
5312   const CXIdxObjCProtocolRefListInfo *protocols;
5313 } CXIdxObjCInterfaceDeclInfo;
5314 
5315 typedef struct {
5316   const CXIdxObjCContainerDeclInfo *containerInfo;
5317   const CXIdxEntityInfo *objcClass;
5318   CXCursor classCursor;
5319   CXIdxLoc classLoc;
5320   const CXIdxObjCProtocolRefListInfo *protocols;
5321 } CXIdxObjCCategoryDeclInfo;
5322 
5323 typedef struct {
5324   const CXIdxDeclInfo *declInfo;
5325   const CXIdxEntityInfo *getter;
5326   const CXIdxEntityInfo *setter;
5327 } CXIdxObjCPropertyDeclInfo;
5328 
5329 typedef struct {
5330   const CXIdxDeclInfo *declInfo;
5331   const CXIdxBaseClassInfo *const *bases;
5332   unsigned numBases;
5333 } CXIdxCXXClassDeclInfo;
5334 
5335 /**
5336  * \brief Data for IndexerCallbacks#indexEntityReference.
5337  */
5338 typedef enum {
5339   /**
5340    * \brief The entity is referenced directly in user's code.
5341    */
5342   CXIdxEntityRef_Direct = 1,
5343   /**
5344    * \brief An implicit reference, e.g. a reference of an ObjC method via the
5345    * dot syntax.
5346    */
5347   CXIdxEntityRef_Implicit = 2
5348 } CXIdxEntityRefKind;
5349 
5350 /**
5351  * \brief Data for IndexerCallbacks#indexEntityReference.
5352  */
5353 typedef struct {
5354   CXIdxEntityRefKind kind;
5355   /**
5356    * \brief Reference cursor.
5357    */
5358   CXCursor cursor;
5359   CXIdxLoc loc;
5360   /**
5361    * \brief The entity that gets referenced.
5362    */
5363   const CXIdxEntityInfo *referencedEntity;
5364   /**
5365    * \brief Immediate "parent" of the reference. For example:
5366    *
5367    * \code
5368    * Foo *var;
5369    * \endcode
5370    *
5371    * The parent of reference of type 'Foo' is the variable 'var'.
5372    * For references inside statement bodies of functions/methods,
5373    * the parentEntity will be the function/method.
5374    */
5375   const CXIdxEntityInfo *parentEntity;
5376   /**
5377    * \brief Lexical container context of the reference.
5378    */
5379   const CXIdxContainerInfo *container;
5380 } CXIdxEntityRefInfo;
5381 
5382 /**
5383  * \brief A group of callbacks used by #clang_indexSourceFile and
5384  * #clang_indexTranslationUnit.
5385  */
5386 typedef struct {
5387   /**
5388    * \brief Called periodically to check whether indexing should be aborted.
5389    * Should return 0 to continue, and non-zero to abort.
5390    */
5391   int (*abortQuery)(CXClientData client_data, void *reserved);
5392 
5393   /**
5394    * \brief Called at the end of indexing; passes the complete diagnostic set.
5395    */
5396   void (*diagnostic)(CXClientData client_data,
5397                      CXDiagnosticSet, void *reserved);
5398 
5399   CXIdxClientFile (*enteredMainFile)(CXClientData client_data,
5400                                      CXFile mainFile, void *reserved);
5401 
5402   /**
5403    * \brief Called when a file gets \#included/\#imported.
5404    */
5405   CXIdxClientFile (*ppIncludedFile)(CXClientData client_data,
5406                                     const CXIdxIncludedFileInfo *);
5407 
5408   /**
5409    * \brief Called when a AST file (PCH or module) gets imported.
5410    *
5411    * AST files will not get indexed (there will not be callbacks to index all
5412    * the entities in an AST file). The recommended action is that, if the AST
5413    * file is not already indexed, to initiate a new indexing job specific to
5414    * the AST file.
5415    */
5416   CXIdxClientASTFile (*importedASTFile)(CXClientData client_data,
5417                                         const CXIdxImportedASTFileInfo *);
5418 
5419   /**
5420    * \brief Called at the beginning of indexing a translation unit.
5421    */
5422   CXIdxClientContainer (*startedTranslationUnit)(CXClientData client_data,
5423                                                  void *reserved);
5424 
5425   void (*indexDeclaration)(CXClientData client_data,
5426                            const CXIdxDeclInfo *);
5427 
5428   /**
5429    * \brief Called to index a reference of an entity.
5430    */
5431   void (*indexEntityReference)(CXClientData client_data,
5432                                const CXIdxEntityRefInfo *);
5433 
5434 } IndexerCallbacks;
5435 
5436 CINDEX_LINKAGE int clang_index_isEntityObjCContainerKind(CXIdxEntityKind);
5437 CINDEX_LINKAGE const CXIdxObjCContainerDeclInfo *
5438 clang_index_getObjCContainerDeclInfo(const CXIdxDeclInfo *);
5439 
5440 CINDEX_LINKAGE const CXIdxObjCInterfaceDeclInfo *
5441 clang_index_getObjCInterfaceDeclInfo(const CXIdxDeclInfo *);
5442 
5443 CINDEX_LINKAGE
5444 const CXIdxObjCCategoryDeclInfo *
5445 clang_index_getObjCCategoryDeclInfo(const CXIdxDeclInfo *);
5446 
5447 CINDEX_LINKAGE const CXIdxObjCProtocolRefListInfo *
5448 clang_index_getObjCProtocolRefListInfo(const CXIdxDeclInfo *);
5449 
5450 CINDEX_LINKAGE const CXIdxObjCPropertyDeclInfo *
5451 clang_index_getObjCPropertyDeclInfo(const CXIdxDeclInfo *);
5452 
5453 CINDEX_LINKAGE const CXIdxIBOutletCollectionAttrInfo *
5454 clang_index_getIBOutletCollectionAttrInfo(const CXIdxAttrInfo *);
5455 
5456 CINDEX_LINKAGE const CXIdxCXXClassDeclInfo *
5457 clang_index_getCXXClassDeclInfo(const CXIdxDeclInfo *);
5458 
5459 /**
5460  * \brief For retrieving a custom CXIdxClientContainer attached to a
5461  * container.
5462  */
5463 CINDEX_LINKAGE CXIdxClientContainer
5464 clang_index_getClientContainer(const CXIdxContainerInfo *);
5465 
5466 /**
5467  * \brief For setting a custom CXIdxClientContainer attached to a
5468  * container.
5469  */
5470 CINDEX_LINKAGE void
5471 clang_index_setClientContainer(const CXIdxContainerInfo *,CXIdxClientContainer);
5472 
5473 /**
5474  * \brief For retrieving a custom CXIdxClientEntity attached to an entity.
5475  */
5476 CINDEX_LINKAGE CXIdxClientEntity
5477 clang_index_getClientEntity(const CXIdxEntityInfo *);
5478 
5479 /**
5480  * \brief For setting a custom CXIdxClientEntity attached to an entity.
5481  */
5482 CINDEX_LINKAGE void
5483 clang_index_setClientEntity(const CXIdxEntityInfo *, CXIdxClientEntity);
5484 
5485 /**
5486  * \brief An indexing action/session, to be applied to one or multiple
5487  * translation units.
5488  */
5489 typedef void *CXIndexAction;
5490 
5491 /**
5492  * \brief An indexing action/session, to be applied to one or multiple
5493  * translation units.
5494  *
5495  * \param CIdx The index object with which the index action will be associated.
5496  */
5497 CINDEX_LINKAGE CXIndexAction clang_IndexAction_create(CXIndex CIdx);
5498 
5499 /**
5500  * \brief Destroy the given index action.
5501  *
5502  * The index action must not be destroyed until all of the translation units
5503  * created within that index action have been destroyed.
5504  */
5505 CINDEX_LINKAGE void clang_IndexAction_dispose(CXIndexAction);
5506 
5507 typedef enum {
5508   /**
5509    * \brief Used to indicate that no special indexing options are needed.
5510    */
5511   CXIndexOpt_None = 0x0,
5512 
5513   /**
5514    * \brief Used to indicate that IndexerCallbacks#indexEntityReference should
5515    * be invoked for only one reference of an entity per source file that does
5516    * not also include a declaration/definition of the entity.
5517    */
5518   CXIndexOpt_SuppressRedundantRefs = 0x1,
5519 
5520   /**
5521    * \brief Function-local symbols should be indexed. If this is not set
5522    * function-local symbols will be ignored.
5523    */
5524   CXIndexOpt_IndexFunctionLocalSymbols = 0x2,
5525 
5526   /**
5527    * \brief Implicit function/class template instantiations should be indexed.
5528    * If this is not set, implicit instantiations will be ignored.
5529    */
5530   CXIndexOpt_IndexImplicitTemplateInstantiations = 0x4,
5531 
5532   /**
5533    * \brief Suppress all compiler warnings when parsing for indexing.
5534    */
5535   CXIndexOpt_SuppressWarnings = 0x8,
5536 
5537   /**
5538    * \brief Skip a function/method body that was already parsed during an
5539    * indexing session assosiated with a \c CXIndexAction object.
5540    * Bodies in system headers are always skipped.
5541    */
5542   CXIndexOpt_SkipParsedBodiesInSession = 0x10
5543 
5544 } CXIndexOptFlags;
5545 
5546 /**
5547  * \brief Index the given source file and the translation unit corresponding
5548  * to that file via callbacks implemented through #IndexerCallbacks.
5549  *
5550  * \param client_data pointer data supplied by the client, which will
5551  * be passed to the invoked callbacks.
5552  *
5553  * \param index_callbacks Pointer to indexing callbacks that the client
5554  * implements.
5555  *
5556  * \param index_callbacks_size Size of #IndexerCallbacks structure that gets
5557  * passed in index_callbacks.
5558  *
5559  * \param index_options A bitmask of options that affects how indexing is
5560  * performed. This should be a bitwise OR of the CXIndexOpt_XXX flags.
5561  *
5562  * \param out_TU [out] pointer to store a CXTranslationUnit that can be reused
5563  * after indexing is finished. Set to NULL if you do not require it.
5564  *
5565  * \returns If there is a failure from which the there is no recovery, returns
5566  * non-zero, otherwise returns 0.
5567  *
5568  * The rest of the parameters are the same as #clang_parseTranslationUnit.
5569  */
5570 CINDEX_LINKAGE int clang_indexSourceFile(CXIndexAction,
5571                                          CXClientData client_data,
5572                                          IndexerCallbacks *index_callbacks,
5573                                          unsigned index_callbacks_size,
5574                                          unsigned index_options,
5575                                          const char *source_filename,
5576                                          const char * const *command_line_args,
5577                                          int num_command_line_args,
5578                                          struct CXUnsavedFile *unsaved_files,
5579                                          unsigned num_unsaved_files,
5580                                          CXTranslationUnit *out_TU,
5581                                          unsigned TU_options);
5582 
5583 /**
5584  * \brief Index the given translation unit via callbacks implemented through
5585  * #IndexerCallbacks.
5586  *
5587  * The order of callback invocations is not guaranteed to be the same as
5588  * when indexing a source file. The high level order will be:
5589  *
5590  *   -Preprocessor callbacks invocations
5591  *   -Declaration/reference callbacks invocations
5592  *   -Diagnostic callback invocations
5593  *
5594  * The parameters are the same as #clang_indexSourceFile.
5595  *
5596  * \returns If there is a failure from which the there is no recovery, returns
5597  * non-zero, otherwise returns 0.
5598  */
5599 CINDEX_LINKAGE int clang_indexTranslationUnit(CXIndexAction,
5600                                               CXClientData client_data,
5601                                               IndexerCallbacks *index_callbacks,
5602                                               unsigned index_callbacks_size,
5603                                               unsigned index_options,
5604                                               CXTranslationUnit);
5605 
5606 /**
5607  * \brief Retrieve the CXIdxFile, file, line, column, and offset represented by
5608  * the given CXIdxLoc.
5609  *
5610  * If the location refers into a macro expansion, retrieves the
5611  * location of the macro expansion and if it refers into a macro argument
5612  * retrieves the location of the argument.
5613  */
5614 CINDEX_LINKAGE void clang_indexLoc_getFileLocation(CXIdxLoc loc,
5615                                                    CXIdxClientFile *indexFile,
5616                                                    CXFile *file,
5617                                                    unsigned *line,
5618                                                    unsigned *column,
5619                                                    unsigned *offset);
5620 
5621 /**
5622  * \brief Retrieve the CXSourceLocation represented by the given CXIdxLoc.
5623  */
5624 CINDEX_LINKAGE
5625 CXSourceLocation clang_indexLoc_getCXSourceLocation(CXIdxLoc loc);
5626 
5627 /**
5628  * @}
5629  */
5630 
5631 /**
5632  * @}
5633  */
5634 
5635 #ifdef __cplusplus
5636 }
5637 #endif
5638 #endif
5639 
5640