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