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