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