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