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