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 = 62;
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 5.0 [2.1.5, 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     /** OpenMP 5.0 [2.1.4, Array Shaping].
2219      */
2220     ompArrayShapingExpr = 150,
2221 
2222     /**
2223      * OpenMP 5.0 [2.1.6 Iterators]
2224      */
2225     ompIteratorExpr = 151,
2226 
2227     /** OpenCL's addrspace_cast<> expression.
2228      */
2229     cxxAddrspaceCastExpr = 152,
2230 
2231     /**
2232      * Expression that references a C++20 concept.
2233      */
2234     conceptSpecializationExpr = 153,
2235 
2236     /**
2237      * Expression that references a C++20 concept.
2238      */
2239     requiresExpr = 154,
2240 
2241     lastExpr = requiresExpr,
2242 
2243     /* Statements */
2244     firstStmt = 200,
2245     /**
2246      * A statement whose specific kind is not exposed via this
2247      * interface.
2248      *
2249      * Unexposed statements have the same operations as any other kind of
2250      * statement; one can extract their location information, spelling,
2251      * children, etc. However, the specific kind of the statement is not
2252      * reported.
2253      */
2254     unexposedStmt = 200,
2255 
2256     /** A labelled statement in a function.
2257      *
2258      * This cursor kind is used to describe the "start_over:" label statement in
2259      * the following example:
2260      *
2261      * \code
2262      *   start_over:
2263      *     ++counter;
2264      * \endcode
2265      *
2266      */
2267     labelStmt = 201,
2268 
2269     /** A group of statements like { stmt stmt }.
2270      *
2271      * This cursor kind is used to describe compound statements, e.g. function
2272      * bodies.
2273      */
2274     compoundStmt = 202,
2275 
2276     /** A case statement.
2277      */
2278     caseStmt = 203,
2279 
2280     /** A default statement.
2281      */
2282     defaultStmt = 204,
2283 
2284     /** An if statement
2285      */
2286     ifStmt = 205,
2287 
2288     /** A switch statement.
2289      */
2290     switchStmt = 206,
2291 
2292     /** A while statement.
2293      */
2294     whileStmt = 207,
2295 
2296     /** A do statement.
2297      */
2298     doStmt = 208,
2299 
2300     /** A for statement.
2301      */
2302     forStmt = 209,
2303 
2304     /** A goto statement.
2305      */
2306     gotoStmt = 210,
2307 
2308     /** An indirect goto statement.
2309      */
2310     indirectGotoStmt = 211,
2311 
2312     /** A continue statement.
2313      */
2314     continueStmt = 212,
2315 
2316     /** A break statement.
2317      */
2318     breakStmt = 213,
2319 
2320     /** A return statement.
2321      */
2322     returnStmt = 214,
2323 
2324     /** A GCC inline assembly statement extension.
2325      */
2326     gccAsmStmt = 215,
2327     asmStmt = gccAsmStmt,
2328 
2329     /** Objective-C's overall \@try-\@catch-\@finally statement.
2330      */
2331     objCAtTryStmt = 216,
2332 
2333     /** Objective-C's \@catch statement.
2334      */
2335     objCAtCatchStmt = 217,
2336 
2337     /** Objective-C's \@finally statement.
2338      */
2339     objCAtFinallyStmt = 218,
2340 
2341     /** Objective-C's \@throw statement.
2342      */
2343     objCAtThrowStmt = 219,
2344 
2345     /** Objective-C's \@synchronized statement.
2346      */
2347     objCAtSynchronizedStmt = 220,
2348 
2349     /** Objective-C's autorelease pool statement.
2350      */
2351     objCAutoreleasePoolStmt = 221,
2352 
2353     /** Objective-C's collection statement.
2354      */
2355     objCForCollectionStmt = 222,
2356 
2357     /** C++'s catch statement.
2358      */
2359     cxxCatchStmt = 223,
2360 
2361     /** C++'s try statement.
2362      */
2363     cxxTryStmt = 224,
2364 
2365     /** C++'s for (* : *) statement.
2366      */
2367     cxxForRangeStmt = 225,
2368 
2369     /** Windows Structured Exception Handling's try statement.
2370      */
2371     sehTryStmt = 226,
2372 
2373     /** Windows Structured Exception Handling's except statement.
2374      */
2375     sehExceptStmt = 227,
2376 
2377     /** Windows Structured Exception Handling's finally statement.
2378      */
2379     sehFinallyStmt = 228,
2380 
2381     /** A MS inline assembly statement extension.
2382      */
2383     msAsmStmt = 229,
2384 
2385     /** The null statement ";": C99 6.8.3p3.
2386      *
2387      * This cursor kind is used to describe the null statement.
2388      */
2389     nullStmt = 230,
2390 
2391     /** Adaptor class for mixing declarations with statements and
2392      * expressions.
2393      */
2394     declStmt = 231,
2395 
2396     /** OpenMP parallel directive.
2397      */
2398     ompParallelDirective = 232,
2399 
2400     /** OpenMP SIMD directive.
2401      */
2402     ompSimdDirective = 233,
2403 
2404     /** OpenMP for directive.
2405      */
2406     ompForDirective = 234,
2407 
2408     /** OpenMP sections directive.
2409      */
2410     ompSectionsDirective = 235,
2411 
2412     /** OpenMP section directive.
2413      */
2414     ompSectionDirective = 236,
2415 
2416     /** OpenMP single directive.
2417      */
2418     ompSingleDirective = 237,
2419 
2420     /** OpenMP parallel for directive.
2421      */
2422     ompParallelForDirective = 238,
2423 
2424     /** OpenMP parallel sections directive.
2425      */
2426     ompParallelSectionsDirective = 239,
2427 
2428     /** OpenMP task directive.
2429      */
2430     ompTaskDirective = 240,
2431 
2432     /** OpenMP master directive.
2433      */
2434     ompMasterDirective = 241,
2435 
2436     /** OpenMP critical directive.
2437      */
2438     ompCriticalDirective = 242,
2439 
2440     /** OpenMP taskyield directive.
2441      */
2442     ompTaskyieldDirective = 243,
2443 
2444     /** OpenMP barrier directive.
2445      */
2446     ompBarrierDirective = 244,
2447 
2448     /** OpenMP taskwait directive.
2449      */
2450     ompTaskwaitDirective = 245,
2451 
2452     /** OpenMP flush directive.
2453      */
2454     ompFlushDirective = 246,
2455 
2456     /** Windows Structured Exception Handling's leave statement.
2457      */
2458     sehLeaveStmt = 247,
2459 
2460     /** OpenMP ordered directive.
2461      */
2462     ompOrderedDirective = 248,
2463 
2464     /** OpenMP atomic directive.
2465      */
2466     ompAtomicDirective = 249,
2467 
2468     /** OpenMP for SIMD directive.
2469      */
2470     ompForSimdDirective = 250,
2471 
2472     /** OpenMP parallel for SIMD directive.
2473      */
2474     ompParallelForSimdDirective = 251,
2475 
2476     /** OpenMP target directive.
2477      */
2478     ompTargetDirective = 252,
2479 
2480     /** OpenMP teams directive.
2481      */
2482     ompTeamsDirective = 253,
2483 
2484     /** OpenMP taskgroup directive.
2485      */
2486     ompTaskgroupDirective = 254,
2487 
2488     /** OpenMP cancellation point directive.
2489      */
2490     ompCancellationPointDirective = 255,
2491 
2492     /** OpenMP cancel directive.
2493      */
2494     ompCancelDirective = 256,
2495 
2496     /** OpenMP target data directive.
2497      */
2498     ompTargetDataDirective = 257,
2499 
2500     /** OpenMP taskloop directive.
2501      */
2502     ompTaskLoopDirective = 258,
2503 
2504     /** OpenMP taskloop simd directive.
2505      */
2506     ompTaskLoopSimdDirective = 259,
2507 
2508     /** OpenMP distribute directive.
2509      */
2510     ompDistributeDirective = 260,
2511 
2512     /** OpenMP target enter data directive.
2513      */
2514     ompTargetEnterDataDirective = 261,
2515 
2516     /** OpenMP target exit data directive.
2517      */
2518     ompTargetExitDataDirective = 262,
2519 
2520     /** OpenMP target parallel directive.
2521      */
2522     ompTargetParallelDirective = 263,
2523 
2524     /** OpenMP target parallel for directive.
2525      */
2526     ompTargetParallelForDirective = 264,
2527 
2528     /** OpenMP target update directive.
2529      */
2530     ompTargetUpdateDirective = 265,
2531 
2532     /** OpenMP distribute parallel for directive.
2533      */
2534     ompDistributeParallelForDirective = 266,
2535 
2536     /** OpenMP distribute parallel for simd directive.
2537      */
2538     ompDistributeParallelForSimdDirective = 267,
2539 
2540     /** OpenMP distribute simd directive.
2541      */
2542     ompDistributeSimdDirective = 268,
2543 
2544     /** OpenMP target parallel for simd directive.
2545      */
2546     ompTargetParallelForSimdDirective = 269,
2547 
2548     /** OpenMP target simd directive.
2549      */
2550     ompTargetSimdDirective = 270,
2551 
2552     /** OpenMP teams distribute directive.
2553      */
2554     ompTeamsDistributeDirective = 271,
2555 
2556     /** OpenMP teams distribute simd directive.
2557      */
2558     ompTeamsDistributeSimdDirective = 272,
2559 
2560     /** OpenMP teams distribute parallel for simd directive.
2561      */
2562     ompTeamsDistributeParallelForSimdDirective = 273,
2563 
2564     /** OpenMP teams distribute parallel for directive.
2565      */
2566     ompTeamsDistributeParallelForDirective = 274,
2567 
2568     /** OpenMP target teams directive.
2569      */
2570     ompTargetTeamsDirective = 275,
2571 
2572     /** OpenMP target teams distribute directive.
2573      */
2574     ompTargetTeamsDistributeDirective = 276,
2575 
2576     /** OpenMP target teams distribute parallel for directive.
2577      */
2578     ompTargetTeamsDistributeParallelForDirective = 277,
2579 
2580     /** OpenMP target teams distribute parallel for simd directive.
2581      */
2582     ompTargetTeamsDistributeParallelForSimdDirective = 278,
2583 
2584     /** OpenMP target teams distribute simd directive.
2585      */
2586     ompTargetTeamsDistributeSimdDirective = 279,
2587 
2588     /** C++2a std::bit_cast expression.
2589      */
2590     builtinBitCastExpr = 280,
2591 
2592     /** OpenMP master taskloop directive.
2593      */
2594     ompMasterTaskLoopDirective = 281,
2595 
2596     /** OpenMP parallel master taskloop directive.
2597      */
2598     ompParallelMasterTaskLoopDirective = 282,
2599 
2600     /** OpenMP master taskloop simd directive.
2601      */
2602     ompMasterTaskLoopSimdDirective = 283,
2603 
2604     /** OpenMP parallel master taskloop simd directive.
2605      */
2606     ompParallelMasterTaskLoopSimdDirective = 284,
2607 
2608     /** OpenMP parallel master directive.
2609      */
2610     ompParallelMasterDirective = 285,
2611 
2612     /** OpenMP depobj directive.
2613      */
2614     ompDepobjDirective = 286,
2615 
2616     /** OpenMP scan directive.
2617      */
2618     ompScanDirective = 287,
2619 
2620     /** OpenMP tile directive.
2621      */
2622     ompTileDirective = 288,
2623 
2624     /** OpenMP canonical loop.
2625      */
2626     ompCanonicalLoop = 289,
2627 
2628     /** OpenMP interop directive.
2629      */
2630     ompInteropDirective = 290,
2631 
2632     /** OpenMP dispatch directive.
2633      */
2634     ompDispatchDirective = 291,
2635 
2636     /** OpenMP masked directive.
2637      */
2638     ompMaskedDirective = 292,
2639 
2640     /** OpenMP unroll directive.
2641      */
2642     ompUnrollDirective = 293,
2643 
2644     /** OpenMP metadirective directive.
2645      */
2646     ompMetaDirective = 294,
2647 
2648     /** OpenMP loop directive.
2649      */
2650     ompGenericLoopDirective = 295,
2651 
2652     /** OpenMP teams loop directive.
2653      */
2654     ompTeamsGenericLoopDirective = 296,
2655 
2656     /** OpenMP target teams loop directive.
2657      */
2658     ompTargetTeamsGenericLoopDirective = 297,
2659 
2660     /** OpenMP parallel loop directive.
2661      */
2662     ompParallelGenericLoopDirective = 298,
2663 
2664     /** OpenMP target parallel loop directive.
2665      */
2666     ompTargetParallelGenericLoopDirective = 299,
2667 
2668     /** OpenMP parallel masked directive.
2669      */
2670     ompParallelMaskedDirective = 300,
2671 
2672     /** OpenMP masked taskloop directive.
2673      */
2674     ompMaskedTaskLoopDirective = 301,
2675 
2676     /** OpenMP masked taskloop simd directive.
2677      */
2678     ompMaskedTaskLoopSimdDirective = 302,
2679 
2680     /** OpenMP parallel masked taskloop directive.
2681      */
2682     ompParallelMaskedTaskLoopDirective = 303,
2683 
2684     /** OpenMP parallel masked taskloop simd directive.
2685      */
2686     ompParallelMaskedTaskLoopSimdDirective = 304,
2687 
2688     lastStmt = ompParallelMaskedTaskLoopSimdDirective,
2689 
2690     /**
2691      * Cursor that represents the translation unit itself.
2692      *
2693      * The translation unit cursor exists primarily to act as the root
2694      * cursor for traversing the contents of a translation unit.
2695      */
2696     translationUnit = 350,
2697 
2698     /* Attributes */
2699     firstAttr = 400,
2700     /**
2701      * An attribute whose specific kind is not exposed via this
2702      * interface.
2703      */
2704     unexposedAttr = 400,
2705 
2706     ibActionAttr = 401,
2707     ibOutletAttr = 402,
2708     ibOutletCollectionAttr = 403,
2709     cxxFinalAttr = 404,
2710     cxxOverrideAttr = 405,
2711     annotateAttr = 406,
2712     asmLabelAttr = 407,
2713     packedAttr = 408,
2714     pureAttr = 409,
2715     constAttr = 410,
2716     noDuplicateAttr = 411,
2717     cudaConstantAttr = 412,
2718     cudaDeviceAttr = 413,
2719     cudaGlobalAttr = 414,
2720     cudaHostAttr = 415,
2721     cudaSharedAttr = 416,
2722     visibilityAttr = 417,
2723     dllExport = 418,
2724     dllImport = 419,
2725     nsReturnsRetained = 420,
2726     nsReturnsNotRetained = 421,
2727     nsReturnsAutoreleased = 422,
2728     nsConsumesSelf = 423,
2729     nsConsumed = 424,
2730     objCException = 425,
2731     objCNSObject = 426,
2732     objCIndependentClass = 427,
2733     objCPreciseLifetime = 428,
2734     objCReturnsInnerPointer = 429,
2735     objCRequiresSuper = 430,
2736     objCRootClass = 431,
2737     objCSubclassingRestricted = 432,
2738     objCExplicitProtocolImpl = 433,
2739     objCDesignatedInitializer = 434,
2740     objCRuntimeVisible = 435,
2741     objCBoxable = 436,
2742     flagEnum = 437,
2743     convergentAttr = 438,
2744     warnUnusedAttr = 439,
2745     warnUnusedResultAttr = 440,
2746     alignedAttr = 441,
2747     lastAttr = alignedAttr,
2748 
2749     /* Preprocessing */
2750     preprocessingDirective = 500,
2751     macroDefinition = 501,
2752     macroExpansion = 502,
2753     macroInstantiation = macroExpansion,
2754     inclusionDirective = 503,
2755     firstPreprocessing = preprocessingDirective,
2756     lastPreprocessing = inclusionDirective,
2757 
2758     /* Extra Declarations */
2759     /**
2760      * A module import declaration.
2761      */
2762     moduleImportDecl = 600,
2763     typeAliasTemplateDecl = 601,
2764     /**
2765      * A static_assert or _Static_assert node
2766      */
2767     staticAssert = 602,
2768     /**
2769      * a friend declaration.
2770      */
2771     friendDecl = 603,
2772     /**
2773      * a concept declaration.
2774      */
2775     conceptDecl = 604,
2776 
2777     firstExtraDecl = moduleImportDecl,
2778     lastExtraDecl = conceptDecl,
2779 
2780     /**
2781      * A code completion overload candidate.
2782      */
2783     overloadCandidate = 700
2784 }
2785 
2786 /**
2787  * A cursor representing some element in the abstract syntax tree for
2788  * a translation unit.
2789  *
2790  * The cursor abstraction unifies the different kinds of entities in a
2791  * program--declaration, statements, expressions, references to declarations,
2792  * etc.--under a single "cursor" abstraction with a common set of operations.
2793  * Common operation for a cursor include: getting the physical location in
2794  * a source file where the cursor points, getting the name associated with a
2795  * cursor, and retrieving cursors for any child nodes of a particular cursor.
2796  *
2797  * Cursors can be produced in two specific ways.
2798  * clang_getTranslationUnitCursor() produces a cursor for a translation unit,
2799  * from which one can use clang_visitChildren() to explore the rest of the
2800  * translation unit. clang_getCursor() maps from a physical source location
2801  * to the entity that resides at that location, allowing one to map from the
2802  * source code into the AST.
2803  */
2804 struct CXCursor
2805 {
2806     CXCursorKind kind;
2807     int xdata;
2808     const(void)*[3] data;
2809 }
2810 
2811 /**
2812  * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations
2813  *
2814  * @{
2815  */
2816 
2817 /**
2818  * Retrieve the NULL cursor, which represents no entity.
2819  */
2820 CXCursor clang_getNullCursor();
2821 
2822 /**
2823  * Retrieve the cursor that represents the given translation unit.
2824  *
2825  * The translation unit cursor can be used to start traversing the
2826  * various declarations within the given translation unit.
2827  */
2828 CXCursor clang_getTranslationUnitCursor(CXTranslationUnit);
2829 
2830 /**
2831  * Determine whether two cursors are equivalent.
2832  */
2833 uint clang_equalCursors(CXCursor, CXCursor);
2834 
2835 /**
2836  * Returns non-zero if \p cursor is null.
2837  */
2838 int clang_Cursor_isNull(CXCursor cursor);
2839 
2840 /**
2841  * Compute a hash value for the given cursor.
2842  */
2843 uint clang_hashCursor(CXCursor);
2844 
2845 /**
2846  * Retrieve the kind of the given cursor.
2847  */
2848 CXCursorKind clang_getCursorKind(CXCursor);
2849 
2850 /**
2851  * Determine whether the given cursor kind represents a declaration.
2852  */
2853 uint clang_isDeclaration(CXCursorKind);
2854 
2855 /**
2856  * Determine whether the given declaration is invalid.
2857  *
2858  * A declaration is invalid if it could not be parsed successfully.
2859  *
2860  * \returns non-zero if the cursor represents a declaration and it is
2861  * invalid, otherwise NULL.
2862  */
2863 uint clang_isInvalidDeclaration(CXCursor);
2864 
2865 /**
2866  * Determine whether the given cursor kind represents a simple
2867  * reference.
2868  *
2869  * Note that other kinds of cursors (such as expressions) can also refer to
2870  * other cursors. Use clang_getCursorReferenced() to determine whether a
2871  * particular cursor refers to another entity.
2872  */
2873 uint clang_isReference(CXCursorKind);
2874 
2875 /**
2876  * Determine whether the given cursor kind represents an expression.
2877  */
2878 uint clang_isExpression(CXCursorKind);
2879 
2880 /**
2881  * Determine whether the given cursor kind represents a statement.
2882  */
2883 uint clang_isStatement(CXCursorKind);
2884 
2885 /**
2886  * Determine whether the given cursor kind represents an attribute.
2887  */
2888 uint clang_isAttribute(CXCursorKind);
2889 
2890 /**
2891  * Determine whether the given cursor has any attributes.
2892  */
2893 uint clang_Cursor_hasAttrs(CXCursor C);
2894 
2895 /**
2896  * Determine whether the given cursor kind represents an invalid
2897  * cursor.
2898  */
2899 uint clang_isInvalid(CXCursorKind);
2900 
2901 /**
2902  * Determine whether the given cursor kind represents a translation
2903  * unit.
2904  */
2905 uint clang_isTranslationUnit(CXCursorKind);
2906 
2907 /***
2908  * Determine whether the given cursor represents a preprocessing
2909  * element, such as a preprocessor directive or macro instantiation.
2910  */
2911 uint clang_isPreprocessing(CXCursorKind);
2912 
2913 /***
2914  * Determine whether the given cursor represents a currently
2915  *  unexposed piece of the AST (e.g., CXCursor_UnexposedStmt).
2916  */
2917 uint clang_isUnexposed(CXCursorKind);
2918 
2919 /**
2920  * Describe the linkage of the entity referred to by a cursor.
2921  */
2922 enum CXLinkageKind
2923 {
2924     /** This value indicates that no linkage information is available
2925      * for a provided CXCursor. */
2926     invalid = 0,
2927     /**
2928      * This is the linkage for variables, parameters, and so on that
2929      *  have automatic storage.  This covers normal (non-extern) local variables.
2930      */
2931     noLinkage = 1,
2932     /** This is the linkage for static variables and static functions. */
2933     internal = 2,
2934     /** This is the linkage for entities with external linkage that live
2935      * in C++ anonymous namespaces.*/
2936     uniqueExternal = 3,
2937     /** This is the linkage for entities with true, external linkage. */
2938     external = 4
2939 }
2940 
2941 /**
2942  * Determine the linkage of the entity referred to by a given cursor.
2943  */
2944 CXLinkageKind clang_getCursorLinkage(CXCursor cursor);
2945 
2946 enum CXVisibilityKind
2947 {
2948     /** This value indicates that no visibility information is available
2949      * for a provided CXCursor. */
2950     invalid = 0,
2951 
2952     /** Symbol not seen by the linker. */
2953     hidden = 1,
2954     /** Symbol seen by the linker but resolves to a symbol inside this object. */
2955     protected_ = 2,
2956     /** Symbol seen by the linker and acts like a normal symbol. */
2957     default_ = 3
2958 }
2959 
2960 /**
2961  * Describe the visibility of the entity referred to by a cursor.
2962  *
2963  * This returns the default visibility if not explicitly specified by
2964  * a visibility attribute. The default visibility may be changed by
2965  * commandline arguments.
2966  *
2967  * \param cursor The cursor to query.
2968  *
2969  * \returns The visibility of the cursor.
2970  */
2971 CXVisibilityKind clang_getCursorVisibility(CXCursor cursor);
2972 
2973 /**
2974  * Determine the availability of the entity that this cursor refers to,
2975  * taking the current target platform into account.
2976  *
2977  * \param cursor The cursor to query.
2978  *
2979  * \returns The availability of the cursor.
2980  */
2981 CXAvailabilityKind clang_getCursorAvailability(CXCursor cursor);
2982 
2983 /**
2984  * Describes the availability of a given entity on a particular platform, e.g.,
2985  * a particular class might only be available on Mac OS 10.7 or newer.
2986  */
2987 struct CXPlatformAvailability
2988 {
2989     /**
2990      * A string that describes the platform for which this structure
2991      * provides availability information.
2992      *
2993      * Possible values are "ios" or "macos".
2994      */
2995     CXString Platform;
2996     /**
2997      * The version number in which this entity was introduced.
2998      */
2999     CXVersion Introduced;
3000     /**
3001      * The version number in which this entity was deprecated (but is
3002      * still available).
3003      */
3004     CXVersion Deprecated;
3005     /**
3006      * The version number in which this entity was obsoleted, and therefore
3007      * is no longer available.
3008      */
3009     CXVersion Obsoleted;
3010     /**
3011      * Whether the entity is unconditionally unavailable on this platform.
3012      */
3013     int Unavailable;
3014     /**
3015      * An optional message to provide to a user of this API, e.g., to
3016      * suggest replacement APIs.
3017      */
3018     CXString Message;
3019 }
3020 
3021 /**
3022  * Determine the availability of the entity that this cursor refers to
3023  * on any platforms for which availability information is known.
3024  *
3025  * \param cursor The cursor to query.
3026  *
3027  * \param always_deprecated If non-NULL, will be set to indicate whether the
3028  * entity is deprecated on all platforms.
3029  *
3030  * \param deprecated_message If non-NULL, will be set to the message text
3031  * provided along with the unconditional deprecation of this entity. The client
3032  * is responsible for deallocating this string.
3033  *
3034  * \param always_unavailable If non-NULL, will be set to indicate whether the
3035  * entity is unavailable on all platforms.
3036  *
3037  * \param unavailable_message If non-NULL, will be set to the message text
3038  * provided along with the unconditional unavailability of this entity. The
3039  * client is responsible for deallocating this string.
3040  *
3041  * \param availability If non-NULL, an array of CXPlatformAvailability instances
3042  * that will be populated with platform availability information, up to either
3043  * the number of platforms for which availability information is available (as
3044  * returned by this function) or \c availability_size, whichever is smaller.
3045  *
3046  * \param availability_size The number of elements available in the
3047  * \c availability array.
3048  *
3049  * \returns The number of platforms (N) for which availability information is
3050  * available (which is unrelated to \c availability_size).
3051  *
3052  * Note that the client is responsible for calling
3053  * \c clang_disposeCXPlatformAvailability to free each of the
3054  * platform-availability structures returned. There are
3055  * \c min(N, availability_size) such structures.
3056  */
3057 int clang_getCursorPlatformAvailability(
3058     CXCursor cursor,
3059     int* always_deprecated,
3060     CXString* deprecated_message,
3061     int* always_unavailable,
3062     CXString* unavailable_message,
3063     CXPlatformAvailability* availability,
3064     int availability_size);
3065 
3066 /**
3067  * Free the memory associated with a \c CXPlatformAvailability structure.
3068  */
3069 void clang_disposeCXPlatformAvailability(CXPlatformAvailability* availability);
3070 
3071 /**
3072  * If cursor refers to a variable declaration and it has initializer returns
3073  * cursor referring to the initializer otherwise return null cursor.
3074  */
3075 CXCursor clang_Cursor_getVarDeclInitializer(CXCursor cursor);
3076 
3077 /**
3078  * If cursor refers to a variable declaration that has global storage returns 1.
3079  * If cursor refers to a variable declaration that doesn't have global storage
3080  * returns 0. Otherwise returns -1.
3081  */
3082 int clang_Cursor_hasVarDeclGlobalStorage(CXCursor cursor);
3083 
3084 /**
3085  * If cursor refers to a variable declaration that has external storage
3086  * returns 1. If cursor refers to a variable declaration that doesn't have
3087  * external storage returns 0. Otherwise returns -1.
3088  */
3089 int clang_Cursor_hasVarDeclExternalStorage(CXCursor cursor);
3090 
3091 /**
3092  * Describe the "language" of the entity referred to by a cursor.
3093  */
3094 enum CXLanguageKind
3095 {
3096     invalid = 0,
3097     c = 1,
3098     objC = 2,
3099     cPlusPlus = 3
3100 }
3101 
3102 /**
3103  * Determine the "language" of the entity referred to by a given cursor.
3104  */
3105 CXLanguageKind clang_getCursorLanguage(CXCursor cursor);
3106 
3107 /**
3108  * Describe the "thread-local storage (TLS) kind" of the declaration
3109  * referred to by a cursor.
3110  */
3111 enum CXTLSKind
3112 {
3113     none = 0,
3114     dynamic = 1,
3115     static_ = 2
3116 }
3117 
3118 /**
3119  * Determine the "thread-local storage (TLS) kind" of the declaration
3120  * referred to by a cursor.
3121  */
3122 CXTLSKind clang_getCursorTLSKind(CXCursor cursor);
3123 
3124 /**
3125  * Returns the translation unit that a cursor originated from.
3126  */
3127 CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor);
3128 
3129 /**
3130  * A fast container representing a set of CXCursors.
3131  */
3132 struct CXCursorSetImpl;
3133 alias CXCursorSet = CXCursorSetImpl*;
3134 
3135 /**
3136  * Creates an empty CXCursorSet.
3137  */
3138 CXCursorSet clang_createCXCursorSet();
3139 
3140 /**
3141  * Disposes a CXCursorSet and releases its associated memory.
3142  */
3143 void clang_disposeCXCursorSet(CXCursorSet cset);
3144 
3145 /**
3146  * Queries a CXCursorSet to see if it contains a specific CXCursor.
3147  *
3148  * \returns non-zero if the set contains the specified cursor.
3149  */
3150 uint clang_CXCursorSet_contains(CXCursorSet cset, CXCursor cursor);
3151 
3152 /**
3153  * Inserts a CXCursor into a CXCursorSet.
3154  *
3155  * \returns zero if the CXCursor was already in the set, and non-zero otherwise.
3156  */
3157 uint clang_CXCursorSet_insert(CXCursorSet cset, CXCursor cursor);
3158 
3159 /**
3160  * Determine the semantic parent of the given cursor.
3161  *
3162  * The semantic parent of a cursor is the cursor that semantically contains
3163  * the given \p cursor. For many declarations, the lexical and semantic parents
3164  * are equivalent (the lexical parent is returned by
3165  * \c clang_getCursorLexicalParent()). They diverge when declarations or
3166  * definitions are provided out-of-line. For example:
3167  *
3168  * \code
3169  * class C {
3170  *  void f();
3171  * };
3172  *
3173  * void C::f() { }
3174  * \endcode
3175  *
3176  * In the out-of-line definition of \c C::f, the semantic parent is
3177  * the class \c C, of which this function is a member. The lexical parent is
3178  * the place where the declaration actually occurs in the source code; in this
3179  * case, the definition occurs in the translation unit. In general, the
3180  * lexical parent for a given entity can change without affecting the semantics
3181  * of the program, and the lexical parent of different declarations of the
3182  * same entity may be different. Changing the semantic parent of a declaration,
3183  * on the other hand, can have a major impact on semantics, and redeclarations
3184  * of a particular entity should all have the same semantic context.
3185  *
3186  * In the example above, both declarations of \c C::f have \c C as their
3187  * semantic context, while the lexical context of the first \c C::f is \c C
3188  * and the lexical context of the second \c C::f is the translation unit.
3189  *
3190  * For global declarations, the semantic parent is the translation unit.
3191  */
3192 CXCursor clang_getCursorSemanticParent(CXCursor cursor);
3193 
3194 /**
3195  * Determine the lexical parent of the given cursor.
3196  *
3197  * The lexical parent of a cursor is the cursor in which the given \p cursor
3198  * was actually written. For many declarations, the lexical and semantic parents
3199  * are equivalent (the semantic parent is returned by
3200  * \c clang_getCursorSemanticParent()). They diverge when declarations or
3201  * definitions are provided out-of-line. For example:
3202  *
3203  * \code
3204  * class C {
3205  *  void f();
3206  * };
3207  *
3208  * void C::f() { }
3209  * \endcode
3210  *
3211  * In the out-of-line definition of \c C::f, the semantic parent is
3212  * the class \c C, of which this function is a member. The lexical parent is
3213  * the place where the declaration actually occurs in the source code; in this
3214  * case, the definition occurs in the translation unit. In general, the
3215  * lexical parent for a given entity can change without affecting the semantics
3216  * of the program, and the lexical parent of different declarations of the
3217  * same entity may be different. Changing the semantic parent of a declaration,
3218  * on the other hand, can have a major impact on semantics, and redeclarations
3219  * of a particular entity should all have the same semantic context.
3220  *
3221  * In the example above, both declarations of \c C::f have \c C as their
3222  * semantic context, while the lexical context of the first \c C::f is \c C
3223  * and the lexical context of the second \c C::f is the translation unit.
3224  *
3225  * For declarations written in the global scope, the lexical parent is
3226  * the translation unit.
3227  */
3228 CXCursor clang_getCursorLexicalParent(CXCursor cursor);
3229 
3230 /**
3231  * Determine the set of methods that are overridden by the given
3232  * method.
3233  *
3234  * In both Objective-C and C++, a method (aka virtual member function,
3235  * in C++) can override a virtual method in a base class. For
3236  * Objective-C, a method is said to override any method in the class's
3237  * base class, its protocols, or its categories' protocols, that has the same
3238  * selector and is of the same kind (class or instance).
3239  * If no such method exists, the search continues to the class's superclass,
3240  * its protocols, and its categories, and so on. A method from an Objective-C
3241  * implementation is considered to override the same methods as its
3242  * corresponding method in the interface.
3243  *
3244  * For C++, a virtual member function overrides any virtual member
3245  * function with the same signature that occurs in its base
3246  * classes. With multiple inheritance, a virtual member function can
3247  * override several virtual member functions coming from different
3248  * base classes.
3249  *
3250  * In all cases, this function determines the immediate overridden
3251  * method, rather than all of the overridden methods. For example, if
3252  * a method is originally declared in a class A, then overridden in B
3253  * (which in inherits from A) and also in C (which inherited from B),
3254  * then the only overridden method returned from this function when
3255  * invoked on C's method will be B's method. The client may then
3256  * invoke this function again, given the previously-found overridden
3257  * methods, to map out the complete method-override set.
3258  *
3259  * \param cursor A cursor representing an Objective-C or C++
3260  * method. This routine will compute the set of methods that this
3261  * method overrides.
3262  *
3263  * \param overridden A pointer whose pointee will be replaced with a
3264  * pointer to an array of cursors, representing the set of overridden
3265  * methods. If there are no overridden methods, the pointee will be
3266  * set to NULL. The pointee must be freed via a call to
3267  * \c clang_disposeOverriddenCursors().
3268  *
3269  * \param num_overridden A pointer to the number of overridden
3270  * functions, will be set to the number of overridden functions in the
3271  * array pointed to by \p overridden.
3272  */
3273 void clang_getOverriddenCursors(
3274     CXCursor cursor,
3275     CXCursor** overridden,
3276     uint* num_overridden);
3277 
3278 /**
3279  * Free the set of overridden cursors returned by \c
3280  * clang_getOverriddenCursors().
3281  */
3282 void clang_disposeOverriddenCursors(CXCursor* overridden);
3283 
3284 /**
3285  * Retrieve the file that is included by the given inclusion directive
3286  * cursor.
3287  */
3288 CXFile clang_getIncludedFile(CXCursor cursor);
3289 
3290 /**
3291  * @}
3292  */
3293 
3294 /**
3295  * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code
3296  *
3297  * Cursors represent a location within the Abstract Syntax Tree (AST). These
3298  * routines help map between cursors and the physical locations where the
3299  * described entities occur in the source code. The mapping is provided in
3300  * both directions, so one can map from source code to the AST and back.
3301  *
3302  * @{
3303  */
3304 
3305 /**
3306  * Map a source location to the cursor that describes the entity at that
3307  * location in the source code.
3308  *
3309  * clang_getCursor() maps an arbitrary source location within a translation
3310  * unit down to the most specific cursor that describes the entity at that
3311  * location. For example, given an expression \c x + y, invoking
3312  * clang_getCursor() with a source location pointing to "x" will return the
3313  * cursor for "x"; similarly for "y". If the cursor points anywhere between
3314  * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor()
3315  * will return a cursor referring to the "+" expression.
3316  *
3317  * \returns a cursor representing the entity at the given source location, or
3318  * a NULL cursor if no such entity can be found.
3319  */
3320 CXCursor clang_getCursor(CXTranslationUnit, CXSourceLocation);
3321 
3322 /**
3323  * Retrieve the physical location of the source constructor referenced
3324  * by the given cursor.
3325  *
3326  * The location of a declaration is typically the location of the name of that
3327  * declaration, where the name of that declaration would occur if it is
3328  * unnamed, or some keyword that introduces that particular declaration.
3329  * The location of a reference is where that reference occurs within the
3330  * source code.
3331  */
3332 CXSourceLocation clang_getCursorLocation(CXCursor);
3333 
3334 /**
3335  * Retrieve the physical extent of the source construct referenced by
3336  * the given cursor.
3337  *
3338  * The extent of a cursor starts with the file/line/column pointing at the
3339  * first character within the source construct that the cursor refers to and
3340  * ends with the last character within that source construct. For a
3341  * declaration, the extent covers the declaration itself. For a reference,
3342  * the extent covers the location of the reference (e.g., where the referenced
3343  * entity was actually used).
3344  */
3345 CXSourceRange clang_getCursorExtent(CXCursor);
3346 
3347 /**
3348  * @}
3349  */
3350 
3351 /**
3352  * \defgroup CINDEX_TYPES Type information for CXCursors
3353  *
3354  * @{
3355  */
3356 
3357 /**
3358  * Describes the kind of type
3359  */
3360 enum CXTypeKind
3361 {
3362     /**
3363      * Represents an invalid type (e.g., where no type is available).
3364      */
3365     invalid = 0,
3366 
3367     /**
3368      * A type whose specific kind is not exposed via this
3369      * interface.
3370      */
3371     unexposed = 1,
3372 
3373     /* Builtin types */
3374     void_ = 2,
3375     bool_ = 3,
3376     charU = 4,
3377     uChar = 5,
3378     char16 = 6,
3379     char32 = 7,
3380     uShort = 8,
3381     uInt = 9,
3382     uLong = 10,
3383     uLongLong = 11,
3384     uInt128 = 12,
3385     charS = 13,
3386     sChar = 14,
3387     wChar = 15,
3388     short_ = 16,
3389     int_ = 17,
3390     long_ = 18,
3391     longLong = 19,
3392     int128 = 20,
3393     float_ = 21,
3394     double_ = 22,
3395     longDouble = 23,
3396     nullPtr = 24,
3397     overload = 25,
3398     dependent = 26,
3399     objCId = 27,
3400     objCClass = 28,
3401     objCSel = 29,
3402     float128 = 30,
3403     half = 31,
3404     float16 = 32,
3405     shortAccum = 33,
3406     accum = 34,
3407     longAccum = 35,
3408     uShortAccum = 36,
3409     uAccum = 37,
3410     uLongAccum = 38,
3411     bFloat16 = 39,
3412     ibm128 = 40,
3413     firstBuiltin = void_,
3414     lastBuiltin = ibm128,
3415 
3416     complex = 100,
3417     pointer = 101,
3418     blockPointer = 102,
3419     lValueReference = 103,
3420     rValueReference = 104,
3421     record = 105,
3422     enum_ = 106,
3423     typedef_ = 107,
3424     objCInterface = 108,
3425     objCObjectPointer = 109,
3426     functionNoProto = 110,
3427     functionProto = 111,
3428     constantArray = 112,
3429     vector = 113,
3430     incompleteArray = 114,
3431     variableArray = 115,
3432     dependentSizedArray = 116,
3433     memberPointer = 117,
3434     auto_ = 118,
3435 
3436     /**
3437      * Represents a type that was referred to using an elaborated type keyword.
3438      *
3439      * E.g., struct S, or via a qualified name, e.g., N::M::type, or both.
3440      */
3441     elaborated = 119,
3442 
3443     /* OpenCL PipeType. */
3444     pipe = 120,
3445 
3446     /* OpenCL builtin types. */
3447     oclImage1dRO = 121,
3448     oclImage1dArrayRO = 122,
3449     oclImage1dBufferRO = 123,
3450     oclImage2dRO = 124,
3451     oclImage2dArrayRO = 125,
3452     oclImage2dDepthRO = 126,
3453     oclImage2dArrayDepthRO = 127,
3454     oclImage2dMSAARO = 128,
3455     oclImage2dArrayMSAARO = 129,
3456     oclImage2dMSAADepthRO = 130,
3457     oclImage2dArrayMSAADepthRO = 131,
3458     oclImage3dRO = 132,
3459     oclImage1dWO = 133,
3460     oclImage1dArrayWO = 134,
3461     oclImage1dBufferWO = 135,
3462     oclImage2dWO = 136,
3463     oclImage2dArrayWO = 137,
3464     oclImage2dDepthWO = 138,
3465     oclImage2dArrayDepthWO = 139,
3466     oclImage2dMSAAWO = 140,
3467     oclImage2dArrayMSAAWO = 141,
3468     oclImage2dMSAADepthWO = 142,
3469     oclImage2dArrayMSAADepthWO = 143,
3470     oclImage3dWO = 144,
3471     oclImage1dRW = 145,
3472     oclImage1dArrayRW = 146,
3473     oclImage1dBufferRW = 147,
3474     oclImage2dRW = 148,
3475     oclImage2dArrayRW = 149,
3476     oclImage2dDepthRW = 150,
3477     oclImage2dArrayDepthRW = 151,
3478     oclImage2dMSAARW = 152,
3479     oclImage2dArrayMSAARW = 153,
3480     oclImage2dMSAADepthRW = 154,
3481     oclImage2dArrayMSAADepthRW = 155,
3482     oclImage3dRW = 156,
3483     oclSampler = 157,
3484     oclEvent = 158,
3485     oclQueue = 159,
3486     oclReserveID = 160,
3487 
3488     objCObject = 161,
3489     objCTypeParam = 162,
3490     attributed = 163,
3491 
3492     oclIntelSubgroupAVCMcePayload = 164,
3493     oclIntelSubgroupAVCImePayload = 165,
3494     oclIntelSubgroupAVCRefPayload = 166,
3495     oclIntelSubgroupAVCSicPayload = 167,
3496     oclIntelSubgroupAVCMceResult = 168,
3497     oclIntelSubgroupAVCImeResult = 169,
3498     oclIntelSubgroupAVCRefResult = 170,
3499     oclIntelSubgroupAVCSicResult = 171,
3500     oclIntelSubgroupAVCImeResultSingleRefStreamout = 172,
3501     oclIntelSubgroupAVCImeResultDualRefStreamout = 173,
3502     oclIntelSubgroupAVCImeSingleRefStreamin = 174,
3503 
3504     oclIntelSubgroupAVCImeDualRefStreamin = 175,
3505 
3506     extVector = 176,
3507     atomic = 177,
3508     btfTagAttributed = 178
3509 }
3510 
3511 /**
3512  * Describes the calling convention of a function type
3513  */
3514 enum CXCallingConv
3515 {
3516     default_ = 0,
3517     c = 1,
3518     x86StdCall = 2,
3519     x86FastCall = 3,
3520     x86ThisCall = 4,
3521     x86Pascal = 5,
3522     aapcs = 6,
3523     aapcsVfp = 7,
3524     x86RegCall = 8,
3525     intelOclBicc = 9,
3526     win64 = 10,
3527     /* Alias for compatibility with older versions of API. */
3528     x8664Win64 = win64,
3529     x8664SysV = 11,
3530     x86VectorCall = 12,
3531     swift = 13,
3532     preserveMost = 14,
3533     preserveAll = 15,
3534     aArch64VectorCall = 16,
3535     swiftAsync = 17,
3536     aArch64SVEPCS = 18,
3537 
3538     invalid = 100,
3539     unexposed = 200
3540 }
3541 
3542 /**
3543  * The type of an element in the abstract syntax tree.
3544  *
3545  */
3546 struct CXType
3547 {
3548     CXTypeKind kind;
3549     void*[2] data;
3550 }
3551 
3552 /**
3553  * Retrieve the type of a CXCursor (if any).
3554  */
3555 CXType clang_getCursorType(CXCursor C);
3556 
3557 /**
3558  * Pretty-print the underlying type using the rules of the
3559  * language of the translation unit from which it came.
3560  *
3561  * If the type is invalid, an empty string is returned.
3562  */
3563 CXString clang_getTypeSpelling(CXType CT);
3564 
3565 /**
3566  * Retrieve the underlying type of a typedef declaration.
3567  *
3568  * If the cursor does not reference a typedef declaration, an invalid type is
3569  * returned.
3570  */
3571 CXType clang_getTypedefDeclUnderlyingType(CXCursor C);
3572 
3573 /**
3574  * Retrieve the integer type of an enum declaration.
3575  *
3576  * If the cursor does not reference an enum declaration, an invalid type is
3577  * returned.
3578  */
3579 CXType clang_getEnumDeclIntegerType(CXCursor C);
3580 
3581 /**
3582  * Retrieve the integer value of an enum constant declaration as a signed
3583  *  long long.
3584  *
3585  * If the cursor does not reference an enum constant declaration, LLONG_MIN is
3586  * returned. Since this is also potentially a valid constant value, the kind of
3587  * the cursor must be verified before calling this function.
3588  */
3589 long clang_getEnumConstantDeclValue(CXCursor C);
3590 
3591 /**
3592  * Retrieve the integer value of an enum constant declaration as an unsigned
3593  *  long long.
3594  *
3595  * If the cursor does not reference an enum constant declaration, ULLONG_MAX is
3596  * returned. Since this is also potentially a valid constant value, the kind of
3597  * the cursor must be verified before calling this function.
3598  */
3599 ulong clang_getEnumConstantDeclUnsignedValue(CXCursor C);
3600 
3601 /**
3602  * Retrieve the bit width of a bit field declaration as an integer.
3603  *
3604  * If a cursor that is not a bit field declaration is passed in, -1 is returned.
3605  */
3606 int clang_getFieldDeclBitWidth(CXCursor C);
3607 
3608 /**
3609  * Retrieve the number of non-variadic arguments associated with a given
3610  * cursor.
3611  *
3612  * The number of arguments can be determined for calls as well as for
3613  * declarations of functions or methods. For other cursors -1 is returned.
3614  */
3615 int clang_Cursor_getNumArguments(CXCursor C);
3616 
3617 /**
3618  * Retrieve the argument cursor of a function or method.
3619  *
3620  * The argument cursor can be determined for calls as well as for declarations
3621  * of functions or methods. For other cursors and for invalid indices, an
3622  * invalid cursor is returned.
3623  */
3624 CXCursor clang_Cursor_getArgument(CXCursor C, uint i);
3625 
3626 /**
3627  * Describes the kind of a template argument.
3628  *
3629  * See the definition of llvm::clang::TemplateArgument::ArgKind for full
3630  * element descriptions.
3631  */
3632 enum CXTemplateArgumentKind
3633 {
3634     null_ = 0,
3635     type = 1,
3636     declaration = 2,
3637     nullPtr = 3,
3638     integral = 4,
3639     template_ = 5,
3640     templateExpansion = 6,
3641     expression = 7,
3642     pack = 8,
3643     /* Indicates an error case, preventing the kind from being deduced. */
3644     invalid = 9
3645 }
3646 
3647 /**
3648  *Returns the number of template args of a function decl representing a
3649  * template specialization.
3650  *
3651  * If the argument cursor cannot be converted into a template function
3652  * declaration, -1 is returned.
3653  *
3654  * For example, for the following declaration and specialization:
3655  *   template <typename T, int kInt, bool kBool>
3656  *   void foo() { ... }
3657  *
3658  *   template <>
3659  *   void foo<float, -7, true>();
3660  *
3661  * The value 3 would be returned from this call.
3662  */
3663 int clang_Cursor_getNumTemplateArguments(CXCursor C);
3664 
3665 /**
3666  * Retrieve the kind of the I'th template argument of the CXCursor C.
3667  *
3668  * If the argument CXCursor does not represent a FunctionDecl, an invalid
3669  * template argument kind is returned.
3670  *
3671  * For example, for the following declaration and specialization:
3672  *   template <typename T, int kInt, bool kBool>
3673  *   void foo() { ... }
3674  *
3675  *   template <>
3676  *   void foo<float, -7, true>();
3677  *
3678  * For I = 0, 1, and 2, Type, Integral, and Integral will be returned,
3679  * respectively.
3680  */
3681 CXTemplateArgumentKind clang_Cursor_getTemplateArgumentKind(CXCursor C, uint I);
3682 
3683 /**
3684  * Retrieve a CXType representing the type of a TemplateArgument of a
3685  *  function decl representing a template specialization.
3686  *
3687  * If the argument CXCursor does not represent a FunctionDecl whose I'th
3688  * template argument has a kind of CXTemplateArgKind_Integral, an invalid type
3689  * is returned.
3690  *
3691  * For example, for the following declaration and specialization:
3692  *   template <typename T, int kInt, bool kBool>
3693  *   void foo() { ... }
3694  *
3695  *   template <>
3696  *   void foo<float, -7, true>();
3697  *
3698  * If called with I = 0, "float", will be returned.
3699  * Invalid types will be returned for I == 1 or 2.
3700  */
3701 CXType clang_Cursor_getTemplateArgumentType(CXCursor C, uint I);
3702 
3703 /**
3704  * Retrieve the value of an Integral TemplateArgument (of a function
3705  *  decl representing a template specialization) as a signed long long.
3706  *
3707  * It is undefined to call this function on a CXCursor that does not represent a
3708  * FunctionDecl or whose I'th template argument is not an integral value.
3709  *
3710  * For example, for the following declaration and specialization:
3711  *   template <typename T, int kInt, bool kBool>
3712  *   void foo() { ... }
3713  *
3714  *   template <>
3715  *   void foo<float, -7, true>();
3716  *
3717  * If called with I = 1 or 2, -7 or true will be returned, respectively.
3718  * For I == 0, this function's behavior is undefined.
3719  */
3720 long clang_Cursor_getTemplateArgumentValue(CXCursor C, uint I);
3721 
3722 /**
3723  * Retrieve the value of an Integral TemplateArgument (of a function
3724  *  decl representing a template specialization) as an unsigned long long.
3725  *
3726  * It is undefined to call this function on a CXCursor that does not represent a
3727  * FunctionDecl or whose I'th template argument is not an integral value.
3728  *
3729  * For example, for the following declaration and specialization:
3730  *   template <typename T, int kInt, bool kBool>
3731  *   void foo() { ... }
3732  *
3733  *   template <>
3734  *   void foo<float, 2147483649, true>();
3735  *
3736  * If called with I = 1 or 2, 2147483649 or true will be returned, respectively.
3737  * For I == 0, this function's behavior is undefined.
3738  */
3739 ulong clang_Cursor_getTemplateArgumentUnsignedValue(CXCursor C, uint I);
3740 
3741 /**
3742  * Determine whether two CXTypes represent the same type.
3743  *
3744  * \returns non-zero if the CXTypes represent the same type and
3745  *          zero otherwise.
3746  */
3747 uint clang_equalTypes(CXType A, CXType B);
3748 
3749 /**
3750  * Return the canonical type for a CXType.
3751  *
3752  * Clang's type system explicitly models typedefs and all the ways
3753  * a specific type can be represented.  The canonical type is the underlying
3754  * type with all the "sugar" removed.  For example, if 'T' is a typedef
3755  * for 'int', the canonical type for 'T' would be 'int'.
3756  */
3757 CXType clang_getCanonicalType(CXType T);
3758 
3759 /**
3760  * Determine whether a CXType has the "const" qualifier set,
3761  * without looking through typedefs that may have added "const" at a
3762  * different level.
3763  */
3764 uint clang_isConstQualifiedType(CXType T);
3765 
3766 /**
3767  * Determine whether a  CXCursor that is a macro, is
3768  * function like.
3769  */
3770 uint clang_Cursor_isMacroFunctionLike(CXCursor C);
3771 
3772 /**
3773  * Determine whether a  CXCursor that is a macro, is a
3774  * builtin one.
3775  */
3776 uint clang_Cursor_isMacroBuiltin(CXCursor C);
3777 
3778 /**
3779  * Determine whether a  CXCursor that is a function declaration, is an
3780  * inline declaration.
3781  */
3782 uint clang_Cursor_isFunctionInlined(CXCursor C);
3783 
3784 /**
3785  * Determine whether a CXType has the "volatile" qualifier set,
3786  * without looking through typedefs that may have added "volatile" at
3787  * a different level.
3788  */
3789 uint clang_isVolatileQualifiedType(CXType T);
3790 
3791 /**
3792  * Determine whether a CXType has the "restrict" qualifier set,
3793  * without looking through typedefs that may have added "restrict" at a
3794  * different level.
3795  */
3796 uint clang_isRestrictQualifiedType(CXType T);
3797 
3798 /**
3799  * Returns the address space of the given type.
3800  */
3801 uint clang_getAddressSpace(CXType T);
3802 
3803 /**
3804  * Returns the typedef name of the given type.
3805  */
3806 CXString clang_getTypedefName(CXType CT);
3807 
3808 /**
3809  * For pointer types, returns the type of the pointee.
3810  */
3811 CXType clang_getPointeeType(CXType T);
3812 
3813 /**
3814  * Return the cursor for the declaration of the given type.
3815  */
3816 CXCursor clang_getTypeDeclaration(CXType T);
3817 
3818 /**
3819  * Returns the Objective-C type encoding for the specified declaration.
3820  */
3821 CXString clang_getDeclObjCTypeEncoding(CXCursor C);
3822 
3823 /**
3824  * Returns the Objective-C type encoding for the specified CXType.
3825  */
3826 CXString clang_Type_getObjCEncoding(CXType type);
3827 
3828 /**
3829  * Retrieve the spelling of a given CXTypeKind.
3830  */
3831 CXString clang_getTypeKindSpelling(CXTypeKind K);
3832 
3833 /**
3834  * Retrieve the calling convention associated with a function type.
3835  *
3836  * If a non-function type is passed in, CXCallingConv_Invalid is returned.
3837  */
3838 CXCallingConv clang_getFunctionTypeCallingConv(CXType T);
3839 
3840 /**
3841  * Retrieve the return type associated with a function type.
3842  *
3843  * If a non-function type is passed in, an invalid type is returned.
3844  */
3845 CXType clang_getResultType(CXType T);
3846 
3847 /**
3848  * Retrieve the exception specification type associated with a function type.
3849  * This is a value of type CXCursor_ExceptionSpecificationKind.
3850  *
3851  * If a non-function type is passed in, an error code of -1 is returned.
3852  */
3853 int clang_getExceptionSpecificationType(CXType T);
3854 
3855 /**
3856  * Retrieve the number of non-variadic parameters associated with a
3857  * function type.
3858  *
3859  * If a non-function type is passed in, -1 is returned.
3860  */
3861 int clang_getNumArgTypes(CXType T);
3862 
3863 /**
3864  * Retrieve the type of a parameter of a function type.
3865  *
3866  * If a non-function type is passed in or the function does not have enough
3867  * parameters, an invalid type is returned.
3868  */
3869 CXType clang_getArgType(CXType T, uint i);
3870 
3871 /**
3872  * Retrieves the base type of the ObjCObjectType.
3873  *
3874  * If the type is not an ObjC object, an invalid type is returned.
3875  */
3876 CXType clang_Type_getObjCObjectBaseType(CXType T);
3877 
3878 /**
3879  * Retrieve the number of protocol references associated with an ObjC object/id.
3880  *
3881  * If the type is not an ObjC object, 0 is returned.
3882  */
3883 uint clang_Type_getNumObjCProtocolRefs(CXType T);
3884 
3885 /**
3886  * Retrieve the decl for a protocol reference for an ObjC object/id.
3887  *
3888  * If the type is not an ObjC object or there are not enough protocol
3889  * references, an invalid cursor is returned.
3890  */
3891 CXCursor clang_Type_getObjCProtocolDecl(CXType T, uint i);
3892 
3893 /**
3894  * Retrieve the number of type arguments associated with an ObjC object.
3895  *
3896  * If the type is not an ObjC object, 0 is returned.
3897  */
3898 uint clang_Type_getNumObjCTypeArgs(CXType T);
3899 
3900 /**
3901  * Retrieve a type argument associated with an ObjC object.
3902  *
3903  * If the type is not an ObjC or the index is not valid,
3904  * an invalid type is returned.
3905  */
3906 CXType clang_Type_getObjCTypeArg(CXType T, uint i);
3907 
3908 /**
3909  * Return 1 if the CXType is a variadic function type, and 0 otherwise.
3910  */
3911 uint clang_isFunctionTypeVariadic(CXType T);
3912 
3913 /**
3914  * Retrieve the return type associated with a given cursor.
3915  *
3916  * This only returns a valid type if the cursor refers to a function or method.
3917  */
3918 CXType clang_getCursorResultType(CXCursor C);
3919 
3920 /**
3921  * Retrieve the exception specification type associated with a given cursor.
3922  * This is a value of type CXCursor_ExceptionSpecificationKind.
3923  *
3924  * This only returns a valid result if the cursor refers to a function or
3925  * method.
3926  */
3927 int clang_getCursorExceptionSpecificationType(CXCursor C);
3928 
3929 /**
3930  * Return 1 if the CXType is a POD (plain old data) type, and 0
3931  *  otherwise.
3932  */
3933 uint clang_isPODType(CXType T);
3934 
3935 /**
3936  * Return the element type of an array, complex, or vector type.
3937  *
3938  * If a type is passed in that is not an array, complex, or vector type,
3939  * an invalid type is returned.
3940  */
3941 CXType clang_getElementType(CXType T);
3942 
3943 /**
3944  * Return the number of elements of an array or vector type.
3945  *
3946  * If a type is passed in that is not an array or vector type,
3947  * -1 is returned.
3948  */
3949 long clang_getNumElements(CXType T);
3950 
3951 /**
3952  * Return the element type of an array type.
3953  *
3954  * If a non-array type is passed in, an invalid type is returned.
3955  */
3956 CXType clang_getArrayElementType(CXType T);
3957 
3958 /**
3959  * Return the array size of a constant array.
3960  *
3961  * If a non-array type is passed in, -1 is returned.
3962  */
3963 long clang_getArraySize(CXType T);
3964 
3965 /**
3966  * Retrieve the type named by the qualified-id.
3967  *
3968  * If a non-elaborated type is passed in, an invalid type is returned.
3969  */
3970 CXType clang_Type_getNamedType(CXType T);
3971 
3972 /**
3973  * Determine if a typedef is 'transparent' tag.
3974  *
3975  * A typedef is considered 'transparent' if it shares a name and spelling
3976  * location with its underlying tag type, as is the case with the NS_ENUM macro.
3977  *
3978  * \returns non-zero if transparent and zero otherwise.
3979  */
3980 uint clang_Type_isTransparentTagTypedef(CXType T);
3981 
3982 enum CXTypeNullabilityKind
3983 {
3984     /**
3985      * Values of this type can never be null.
3986      */
3987     nonNull = 0,
3988     /**
3989      * Values of this type can be null.
3990      */
3991     nullable = 1,
3992     /**
3993      * Whether values of this type can be null is (explicitly)
3994      * unspecified. This captures a (fairly rare) case where we
3995      * can't conclude anything about the nullability of the type even
3996      * though it has been considered.
3997      */
3998     unspecified = 2,
3999     /**
4000      * Nullability is not applicable to this type.
4001      */
4002     invalid = 3,
4003 
4004     /**
4005      * Generally behaves like Nullable, except when used in a block parameter that
4006      * was imported into a swift async method. There, swift will assume that the
4007      * parameter can get null even if no error occurred. _Nullable parameters are
4008      * assumed to only get null on error.
4009      */
4010     nullableResult = 4
4011 }
4012 
4013 /**
4014  * Retrieve the nullability kind of a pointer type.
4015  */
4016 CXTypeNullabilityKind clang_Type_getNullability(CXType T);
4017 
4018 /**
4019  * List the possible error codes for \c clang_Type_getSizeOf,
4020  *   \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf and
4021  *   \c clang_Cursor_getOffsetOf.
4022  *
4023  * A value of this enumeration type can be returned if the target type is not
4024  * a valid argument to sizeof, alignof or offsetof.
4025  */
4026 enum CXTypeLayoutError
4027 {
4028     /**
4029      * Type is of kind CXType_Invalid.
4030      */
4031     invalid = -1,
4032     /**
4033      * The type is an incomplete Type.
4034      */
4035     incomplete = -2,
4036     /**
4037      * The type is a dependent Type.
4038      */
4039     dependent = -3,
4040     /**
4041      * The type is not a constant size type.
4042      */
4043     notConstantSize = -4,
4044     /**
4045      * The Field name is not valid for this record.
4046      */
4047     invalidFieldName = -5,
4048     /**
4049      * The type is undeduced.
4050      */
4051     undeduced = -6
4052 }
4053 
4054 /**
4055  * Return the alignment of a type in bytes as per C++[expr.alignof]
4056  *   standard.
4057  *
4058  * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
4059  * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
4060  *   is returned.
4061  * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
4062  *   returned.
4063  * If the type declaration is not a constant size type,
4064  *   CXTypeLayoutError_NotConstantSize is returned.
4065  */
4066 long clang_Type_getAlignOf(CXType T);
4067 
4068 /**
4069  * Return the class type of an member pointer type.
4070  *
4071  * If a non-member-pointer type is passed in, an invalid type is returned.
4072  */
4073 CXType clang_Type_getClassType(CXType T);
4074 
4075 /**
4076  * Return the size of a type in bytes as per C++[expr.sizeof] standard.
4077  *
4078  * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
4079  * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
4080  *   is returned.
4081  * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
4082  *   returned.
4083  */
4084 long clang_Type_getSizeOf(CXType T);
4085 
4086 /**
4087  * Return the offset of a field named S in a record of type T in bits
4088  *   as it would be returned by __offsetof__ as per C++11[18.2p4]
4089  *
4090  * If the cursor is not a record field declaration, CXTypeLayoutError_Invalid
4091  *   is returned.
4092  * If the field's type declaration is an incomplete type,
4093  *   CXTypeLayoutError_Incomplete is returned.
4094  * If the field's type declaration is a dependent type,
4095  *   CXTypeLayoutError_Dependent is returned.
4096  * If the field's name S is not found,
4097  *   CXTypeLayoutError_InvalidFieldName is returned.
4098  */
4099 long clang_Type_getOffsetOf(CXType T, const(char)* S);
4100 
4101 /**
4102  * Return the type that was modified by this attributed type.
4103  *
4104  * If the type is not an attributed type, an invalid type is returned.
4105  */
4106 CXType clang_Type_getModifiedType(CXType T);
4107 
4108 /**
4109  * Gets the type contained by this atomic type.
4110  *
4111  * If a non-atomic type is passed in, an invalid type is returned.
4112  */
4113 CXType clang_Type_getValueType(CXType CT);
4114 
4115 /**
4116  * Return the offset of the field represented by the Cursor.
4117  *
4118  * If the cursor is not a field declaration, -1 is returned.
4119  * If the cursor semantic parent is not a record field declaration,
4120  *   CXTypeLayoutError_Invalid is returned.
4121  * If the field's type declaration is an incomplete type,
4122  *   CXTypeLayoutError_Incomplete is returned.
4123  * If the field's type declaration is a dependent type,
4124  *   CXTypeLayoutError_Dependent is returned.
4125  * If the field's name S is not found,
4126  *   CXTypeLayoutError_InvalidFieldName is returned.
4127  */
4128 long clang_Cursor_getOffsetOfField(CXCursor C);
4129 
4130 /**
4131  * Determine whether the given cursor represents an anonymous
4132  * tag or namespace
4133  */
4134 uint clang_Cursor_isAnonymous(CXCursor C);
4135 
4136 /**
4137  * Determine whether the given cursor represents an anonymous record
4138  * declaration.
4139  */
4140 uint clang_Cursor_isAnonymousRecordDecl(CXCursor C);
4141 
4142 /**
4143  * Determine whether the given cursor represents an inline namespace
4144  * declaration.
4145  */
4146 uint clang_Cursor_isInlineNamespace(CXCursor C);
4147 
4148 enum CXRefQualifierKind
4149 {
4150     /** No ref-qualifier was provided. */
4151     none = 0,
4152     /** An lvalue ref-qualifier was provided (\c &). */
4153     lValue = 1,
4154     /** An rvalue ref-qualifier was provided (\c &&). */
4155     rValue = 2
4156 }
4157 
4158 /**
4159  * Returns the number of template arguments for given template
4160  * specialization, or -1 if type \c T is not a template specialization.
4161  */
4162 int clang_Type_getNumTemplateArguments(CXType T);
4163 
4164 /**
4165  * Returns the type template argument of a template class specialization
4166  * at given index.
4167  *
4168  * This function only returns template type arguments and does not handle
4169  * template template arguments or variadic packs.
4170  */
4171 CXType clang_Type_getTemplateArgumentAsType(CXType T, uint i);
4172 
4173 /**
4174  * Retrieve the ref-qualifier kind of a function or method.
4175  *
4176  * The ref-qualifier is returned for C++ functions or methods. For other types
4177  * or non-C++ declarations, CXRefQualifier_None is returned.
4178  */
4179 CXRefQualifierKind clang_Type_getCXXRefQualifier(CXType T);
4180 
4181 /**
4182  * Returns non-zero if the cursor specifies a Record member that is a
4183  *   bitfield.
4184  */
4185 uint clang_Cursor_isBitField(CXCursor C);
4186 
4187 /**
4188  * Returns 1 if the base class specified by the cursor with kind
4189  *   CX_CXXBaseSpecifier is virtual.
4190  */
4191 uint clang_isVirtualBase(CXCursor);
4192 
4193 /**
4194  * Represents the C++ access control level to a base class for a
4195  * cursor with kind CX_CXXBaseSpecifier.
4196  */
4197 enum CX_CXXAccessSpecifier
4198 {
4199     cxxInvalidAccessSpecifier = 0,
4200     cxxPublic = 1,
4201     cxxProtected = 2,
4202     cxxPrivate = 3
4203 }
4204 
4205 /**
4206  * Returns the access control level for the referenced object.
4207  *
4208  * If the cursor refers to a C++ declaration, its access control level within
4209  * its parent scope is returned. Otherwise, if the cursor refers to a base
4210  * specifier or access specifier, the specifier itself is returned.
4211  */
4212 CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor);
4213 
4214 /**
4215  * Represents the storage classes as declared in the source. CX_SC_Invalid
4216  * was added for the case that the passed cursor in not a declaration.
4217  */
4218 enum CX_StorageClass
4219 {
4220     invalid = 0,
4221     none = 1,
4222     extern_ = 2,
4223     static_ = 3,
4224     privateExtern = 4,
4225     openCLWorkGroupLocal = 5,
4226     auto_ = 6,
4227     register = 7
4228 }
4229 
4230 /**
4231  * Returns the storage class for a function or variable declaration.
4232  *
4233  * If the passed in Cursor is not a function or variable declaration,
4234  * CX_SC_Invalid is returned else the storage class.
4235  */
4236 CX_StorageClass clang_Cursor_getStorageClass(CXCursor);
4237 
4238 /**
4239  * Determine the number of overloaded declarations referenced by a
4240  * \c CXCursor_OverloadedDeclRef cursor.
4241  *
4242  * \param cursor The cursor whose overloaded declarations are being queried.
4243  *
4244  * \returns The number of overloaded declarations referenced by \c cursor. If it
4245  * is not a \c CXCursor_OverloadedDeclRef cursor, returns 0.
4246  */
4247 uint clang_getNumOverloadedDecls(CXCursor cursor);
4248 
4249 /**
4250  * Retrieve a cursor for one of the overloaded declarations referenced
4251  * by a \c CXCursor_OverloadedDeclRef cursor.
4252  *
4253  * \param cursor The cursor whose overloaded declarations are being queried.
4254  *
4255  * \param index The zero-based index into the set of overloaded declarations in
4256  * the cursor.
4257  *
4258  * \returns A cursor representing the declaration referenced by the given
4259  * \c cursor at the specified \c index. If the cursor does not have an
4260  * associated set of overloaded declarations, or if the index is out of bounds,
4261  * returns \c clang_getNullCursor();
4262  */
4263 CXCursor clang_getOverloadedDecl(CXCursor cursor, uint index);
4264 
4265 /**
4266  * @}
4267  */
4268 
4269 /**
4270  * \defgroup CINDEX_ATTRIBUTES Information for attributes
4271  *
4272  * @{
4273  */
4274 
4275 /**
4276  * For cursors representing an iboutletcollection attribute,
4277  *  this function returns the collection element type.
4278  *
4279  */
4280 CXType clang_getIBOutletCollectionType(CXCursor);
4281 
4282 /**
4283  * @}
4284  */
4285 
4286 /**
4287  * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors
4288  *
4289  * These routines provide the ability to traverse the abstract syntax tree
4290  * using cursors.
4291  *
4292  * @{
4293  */
4294 
4295 /**
4296  * Describes how the traversal of the children of a particular
4297  * cursor should proceed after visiting a particular child cursor.
4298  *
4299  * A value of this enumeration type should be returned by each
4300  * \c CXCursorVisitor to indicate how clang_visitChildren() proceed.
4301  */
4302 enum CXChildVisitResult
4303 {
4304     /**
4305      * Terminates the cursor traversal.
4306      */
4307     break_ = 0,
4308     /**
4309      * Continues the cursor traversal with the next sibling of
4310      * the cursor just visited, without visiting its children.
4311      */
4312     continue_ = 1,
4313     /**
4314      * Recursively traverse the children of this cursor, using
4315      * the same visitor and client data.
4316      */
4317     recurse = 2
4318 }
4319 
4320 /**
4321  * Visitor invoked for each cursor found by a traversal.
4322  *
4323  * This visitor function will be invoked for each cursor found by
4324  * clang_visitCursorChildren(). Its first argument is the cursor being
4325  * visited, its second argument is the parent visitor for that cursor,
4326  * and its third argument is the client data provided to
4327  * clang_visitCursorChildren().
4328  *
4329  * The visitor should return one of the \c CXChildVisitResult values
4330  * to direct clang_visitCursorChildren().
4331  */
4332 alias CXCursorVisitor = CXChildVisitResult function(
4333     CXCursor cursor,
4334     CXCursor parent,
4335     CXClientData client_data);
4336 
4337 /**
4338  * Visit the children of a particular cursor.
4339  *
4340  * This function visits all the direct children of the given cursor,
4341  * invoking the given \p visitor function with the cursors of each
4342  * visited child. The traversal may be recursive, if the visitor returns
4343  * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if
4344  * the visitor returns \c CXChildVisit_Break.
4345  *
4346  * \param parent the cursor whose child may be visited. All kinds of
4347  * cursors can be visited, including invalid cursors (which, by
4348  * definition, have no children).
4349  *
4350  * \param visitor the visitor function that will be invoked for each
4351  * child of \p parent.
4352  *
4353  * \param client_data pointer data supplied by the client, which will
4354  * be passed to the visitor each time it is invoked.
4355  *
4356  * \returns a non-zero value if the traversal was terminated
4357  * prematurely by the visitor returning \c CXChildVisit_Break.
4358  */
4359 uint clang_visitChildren(
4360     CXCursor parent,
4361     CXCursorVisitor visitor,
4362     CXClientData client_data);
4363 /**
4364  * Visitor invoked for each cursor found by a traversal.
4365  *
4366  * This visitor block will be invoked for each cursor found by
4367  * clang_visitChildrenWithBlock(). Its first argument is the cursor being
4368  * visited, its second argument is the parent visitor for that cursor.
4369  *
4370  * The visitor should return one of the \c CXChildVisitResult values
4371  * to direct clang_visitChildrenWithBlock().
4372  */
4373 
4374 /**
4375  * Visits the children of a cursor using the specified block.  Behaves
4376  * identically to clang_visitChildren() in all other respects.
4377  */
4378 
4379 /**
4380  * @}
4381  */
4382 
4383 /**
4384  * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST
4385  *
4386  * These routines provide the ability to determine references within and
4387  * across translation units, by providing the names of the entities referenced
4388  * by cursors, follow reference cursors to the declarations they reference,
4389  * and associate declarations with their definitions.
4390  *
4391  * @{
4392  */
4393 
4394 /**
4395  * Retrieve a Unified Symbol Resolution (USR) for the entity referenced
4396  * by the given cursor.
4397  *
4398  * A Unified Symbol Resolution (USR) is a string that identifies a particular
4399  * entity (function, class, variable, etc.) within a program. USRs can be
4400  * compared across translation units to determine, e.g., when references in
4401  * one translation refer to an entity defined in another translation unit.
4402  */
4403 CXString clang_getCursorUSR(CXCursor);
4404 
4405 /**
4406  * Construct a USR for a specified Objective-C class.
4407  */
4408 CXString clang_constructUSR_ObjCClass(const(char)* class_name);
4409 
4410 /**
4411  * Construct a USR for a specified Objective-C category.
4412  */
4413 CXString clang_constructUSR_ObjCCategory(
4414     const(char)* class_name,
4415     const(char)* category_name);
4416 
4417 /**
4418  * Construct a USR for a specified Objective-C protocol.
4419  */
4420 CXString clang_constructUSR_ObjCProtocol(const(char)* protocol_name);
4421 
4422 /**
4423  * Construct a USR for a specified Objective-C instance variable and
4424  *   the USR for its containing class.
4425  */
4426 CXString clang_constructUSR_ObjCIvar(const(char)* name, CXString classUSR);
4427 
4428 /**
4429  * Construct a USR for a specified Objective-C method and
4430  *   the USR for its containing class.
4431  */
4432 CXString clang_constructUSR_ObjCMethod(
4433     const(char)* name,
4434     uint isInstanceMethod,
4435     CXString classUSR);
4436 
4437 /**
4438  * Construct a USR for a specified Objective-C property and the USR
4439  *  for its containing class.
4440  */
4441 CXString clang_constructUSR_ObjCProperty(
4442     const(char)* property,
4443     CXString classUSR);
4444 
4445 /**
4446  * Retrieve a name for the entity referenced by this cursor.
4447  */
4448 CXString clang_getCursorSpelling(CXCursor);
4449 
4450 /**
4451  * Retrieve a range for a piece that forms the cursors spelling name.
4452  * Most of the times there is only one range for the complete spelling but for
4453  * Objective-C methods and Objective-C message expressions, there are multiple
4454  * pieces for each selector identifier.
4455  *
4456  * \param pieceIndex the index of the spelling name piece. If this is greater
4457  * than the actual number of pieces, it will return a NULL (invalid) range.
4458  *
4459  * \param options Reserved.
4460  */
4461 CXSourceRange clang_Cursor_getSpellingNameRange(
4462     CXCursor,
4463     uint pieceIndex,
4464     uint options);
4465 
4466 /**
4467  * Opaque pointer representing a policy that controls pretty printing
4468  * for \c clang_getCursorPrettyPrinted.
4469  */
4470 alias CXPrintingPolicy = void*;
4471 
4472 /**
4473  * Properties for the printing policy.
4474  *
4475  * See \c clang::PrintingPolicy for more information.
4476  */
4477 enum CXPrintingPolicyProperty
4478 {
4479     indentation = 0,
4480     suppressSpecifiers = 1,
4481     suppressTagKeyword = 2,
4482     includeTagDefinition = 3,
4483     suppressScope = 4,
4484     suppressUnwrittenScope = 5,
4485     suppressInitializers = 6,
4486     constantArraySizeAsWritten = 7,
4487     anonymousTagLocations = 8,
4488     suppressStrongLifetime = 9,
4489     suppressLifetimeQualifiers = 10,
4490     suppressTemplateArgsInCXXConstructors = 11,
4491     bool_ = 12,
4492     restrict = 13,
4493     alignof_ = 14,
4494     underscoreAlignof = 15,
4495     useVoidForZeroParams = 16,
4496     terseOutput = 17,
4497     polishForDeclaration = 18,
4498     half = 19,
4499     mswChar = 20,
4500     includeNewlines = 21,
4501     msvcFormatting = 22,
4502     constantsAsWritten = 23,
4503     suppressImplicitBase = 24,
4504     fullyQualifiedName = 25,
4505 
4506     lastProperty = fullyQualifiedName
4507 }
4508 
4509 /**
4510  * Get a property value for the given printing policy.
4511  */
4512 uint clang_PrintingPolicy_getProperty(
4513     CXPrintingPolicy Policy,
4514     CXPrintingPolicyProperty Property);
4515 
4516 /**
4517  * Set a property value for the given printing policy.
4518  */
4519 void clang_PrintingPolicy_setProperty(
4520     CXPrintingPolicy Policy,
4521     CXPrintingPolicyProperty Property,
4522     uint Value);
4523 
4524 /**
4525  * Retrieve the default policy for the cursor.
4526  *
4527  * The policy should be released after use with \c
4528  * clang_PrintingPolicy_dispose.
4529  */
4530 CXPrintingPolicy clang_getCursorPrintingPolicy(CXCursor);
4531 
4532 /**
4533  * Release a printing policy.
4534  */
4535 void clang_PrintingPolicy_dispose(CXPrintingPolicy Policy);
4536 
4537 /**
4538  * Pretty print declarations.
4539  *
4540  * \param Cursor The cursor representing a declaration.
4541  *
4542  * \param Policy The policy to control the entities being printed. If
4543  * NULL, a default policy is used.
4544  *
4545  * \returns The pretty printed declaration or the empty string for
4546  * other cursors.
4547  */
4548 CXString clang_getCursorPrettyPrinted(CXCursor Cursor, CXPrintingPolicy Policy);
4549 
4550 /**
4551  * Retrieve the display name for the entity referenced by this cursor.
4552  *
4553  * The display name contains extra information that helps identify the cursor,
4554  * such as the parameters of a function or template or the arguments of a
4555  * class template specialization.
4556  */
4557 CXString clang_getCursorDisplayName(CXCursor);
4558 
4559 /** For a cursor that is a reference, retrieve a cursor representing the
4560  * entity that it references.
4561  *
4562  * Reference cursors refer to other entities in the AST. For example, an
4563  * Objective-C superclass reference cursor refers to an Objective-C class.
4564  * This function produces the cursor for the Objective-C class from the
4565  * cursor for the superclass reference. If the input cursor is a declaration or
4566  * definition, it returns that declaration or definition unchanged.
4567  * Otherwise, returns the NULL cursor.
4568  */
4569 CXCursor clang_getCursorReferenced(CXCursor);
4570 
4571 /**
4572  *  For a cursor that is either a reference to or a declaration
4573  *  of some entity, retrieve a cursor that describes the definition of
4574  *  that entity.
4575  *
4576  *  Some entities can be declared multiple times within a translation
4577  *  unit, but only one of those declarations can also be a
4578  *  definition. For example, given:
4579  *
4580  *  \code
4581  *  int f(int, int);
4582  *  int g(int x, int y) { return f(x, y); }
4583  *  int f(int a, int b) { return a + b; }
4584  *  int f(int, int);
4585  *  \endcode
4586  *
4587  *  there are three declarations of the function "f", but only the
4588  *  second one is a definition. The clang_getCursorDefinition()
4589  *  function will take any cursor pointing to a declaration of "f"
4590  *  (the first or fourth lines of the example) or a cursor referenced
4591  *  that uses "f" (the call to "f' inside "g") and will return a
4592  *  declaration cursor pointing to the definition (the second "f"
4593  *  declaration).
4594  *
4595  *  If given a cursor for which there is no corresponding definition,
4596  *  e.g., because there is no definition of that entity within this
4597  *  translation unit, returns a NULL cursor.
4598  */
4599 CXCursor clang_getCursorDefinition(CXCursor);
4600 
4601 /**
4602  * Determine whether the declaration pointed to by this cursor
4603  * is also a definition of that entity.
4604  */
4605 uint clang_isCursorDefinition(CXCursor);
4606 
4607 /**
4608  * Retrieve the canonical cursor corresponding to the given cursor.
4609  *
4610  * In the C family of languages, many kinds of entities can be declared several
4611  * times within a single translation unit. For example, a structure type can
4612  * be forward-declared (possibly multiple times) and later defined:
4613  *
4614  * \code
4615  * struct X;
4616  * struct X;
4617  * struct X {
4618  *   int member;
4619  * };
4620  * \endcode
4621  *
4622  * The declarations and the definition of \c X are represented by three
4623  * different cursors, all of which are declarations of the same underlying
4624  * entity. One of these cursor is considered the "canonical" cursor, which
4625  * is effectively the representative for the underlying entity. One can
4626  * determine if two cursors are declarations of the same underlying entity by
4627  * comparing their canonical cursors.
4628  *
4629  * \returns The canonical cursor for the entity referred to by the given cursor.
4630  */
4631 CXCursor clang_getCanonicalCursor(CXCursor);
4632 
4633 /**
4634  * If the cursor points to a selector identifier in an Objective-C
4635  * method or message expression, this returns the selector index.
4636  *
4637  * After getting a cursor with #clang_getCursor, this can be called to
4638  * determine if the location points to a selector identifier.
4639  *
4640  * \returns The selector index if the cursor is an Objective-C method or message
4641  * expression and the cursor is pointing to a selector identifier, or -1
4642  * otherwise.
4643  */
4644 int clang_Cursor_getObjCSelectorIndex(CXCursor);
4645 
4646 /**
4647  * Given a cursor pointing to a C++ method call or an Objective-C
4648  * message, returns non-zero if the method/message is "dynamic", meaning:
4649  *
4650  * For a C++ method: the call is virtual.
4651  * For an Objective-C message: the receiver is an object instance, not 'super'
4652  * or a specific class.
4653  *
4654  * If the method/message is "static" or the cursor does not point to a
4655  * method/message, it will return zero.
4656  */
4657 int clang_Cursor_isDynamicCall(CXCursor C);
4658 
4659 /**
4660  * Given a cursor pointing to an Objective-C message or property
4661  * reference, or C++ method call, returns the CXType of the receiver.
4662  */
4663 CXType clang_Cursor_getReceiverType(CXCursor C);
4664 
4665 /**
4666  * Property attributes for a \c CXCursor_ObjCPropertyDecl.
4667  */
4668 enum CXObjCPropertyAttrKind
4669 {
4670     noattr = 0x00,
4671     readonly = 0x01,
4672     getter = 0x02,
4673     assign = 0x04,
4674     readwrite = 0x08,
4675     retain = 0x10,
4676     copy = 0x20,
4677     nonatomic = 0x40,
4678     setter = 0x80,
4679     atomic = 0x100,
4680     weak = 0x200,
4681     strong = 0x400,
4682     unsafeUnretained = 0x800,
4683     class_ = 0x1000
4684 }
4685 
4686 /**
4687  * Given a cursor that represents a property declaration, return the
4688  * associated property attributes. The bits are formed from
4689  * \c CXObjCPropertyAttrKind.
4690  *
4691  * \param reserved Reserved for future use, pass 0.
4692  */
4693 uint clang_Cursor_getObjCPropertyAttributes(CXCursor C, uint reserved);
4694 
4695 /**
4696  * Given a cursor that represents a property declaration, return the
4697  * name of the method that implements the getter.
4698  */
4699 CXString clang_Cursor_getObjCPropertyGetterName(CXCursor C);
4700 
4701 /**
4702  * Given a cursor that represents a property declaration, return the
4703  * name of the method that implements the setter, if any.
4704  */
4705 CXString clang_Cursor_getObjCPropertySetterName(CXCursor C);
4706 
4707 /**
4708  * 'Qualifiers' written next to the return and parameter types in
4709  * Objective-C method declarations.
4710  */
4711 enum CXObjCDeclQualifierKind
4712 {
4713     none = 0x0,
4714     in_ = 0x1,
4715     inout_ = 0x2,
4716     out_ = 0x4,
4717     bycopy = 0x8,
4718     byref = 0x10,
4719     oneway = 0x20
4720 }
4721 
4722 /**
4723  * Given a cursor that represents an Objective-C method or parameter
4724  * declaration, return the associated Objective-C qualifiers for the return
4725  * type or the parameter respectively. The bits are formed from
4726  * CXObjCDeclQualifierKind.
4727  */
4728 uint clang_Cursor_getObjCDeclQualifiers(CXCursor C);
4729 
4730 /**
4731  * Given a cursor that represents an Objective-C method or property
4732  * declaration, return non-zero if the declaration was affected by "\@optional".
4733  * Returns zero if the cursor is not such a declaration or it is "\@required".
4734  */
4735 uint clang_Cursor_isObjCOptional(CXCursor C);
4736 
4737 /**
4738  * Returns non-zero if the given cursor is a variadic function or method.
4739  */
4740 uint clang_Cursor_isVariadic(CXCursor C);
4741 
4742 /**
4743  * Returns non-zero if the given cursor points to a symbol marked with
4744  * external_source_symbol attribute.
4745  *
4746  * \param language If non-NULL, and the attribute is present, will be set to
4747  * the 'language' string from the attribute.
4748  *
4749  * \param definedIn If non-NULL, and the attribute is present, will be set to
4750  * the 'definedIn' string from the attribute.
4751  *
4752  * \param isGenerated If non-NULL, and the attribute is present, will be set to
4753  * non-zero if the 'generated_declaration' is set in the attribute.
4754  */
4755 uint clang_Cursor_isExternalSymbol(
4756     CXCursor C,
4757     CXString* language,
4758     CXString* definedIn,
4759     uint* isGenerated);
4760 
4761 /**
4762  * Given a cursor that represents a declaration, return the associated
4763  * comment's source range.  The range may include multiple consecutive comments
4764  * with whitespace in between.
4765  */
4766 CXSourceRange clang_Cursor_getCommentRange(CXCursor C);
4767 
4768 /**
4769  * Given a cursor that represents a declaration, return the associated
4770  * comment text, including comment markers.
4771  */
4772 CXString clang_Cursor_getRawCommentText(CXCursor C);
4773 
4774 /**
4775  * Given a cursor that represents a documentable entity (e.g.,
4776  * declaration), return the associated \paragraph; otherwise return the
4777  * first paragraph.
4778  */
4779 CXString clang_Cursor_getBriefCommentText(CXCursor C);
4780 
4781 /**
4782  * @}
4783  */
4784 
4785 /** \defgroup CINDEX_MANGLE Name Mangling API Functions
4786  *
4787  * @{
4788  */
4789 
4790 /**
4791  * Retrieve the CXString representing the mangled name of the cursor.
4792  */
4793 CXString clang_Cursor_getMangling(CXCursor);
4794 
4795 /**
4796  * Retrieve the CXStrings representing the mangled symbols of the C++
4797  * constructor or destructor at the cursor.
4798  */
4799 CXStringSet* clang_Cursor_getCXXManglings(CXCursor);
4800 
4801 /**
4802  * Retrieve the CXStrings representing the mangled symbols of the ObjC
4803  * class interface or implementation at the cursor.
4804  */
4805 CXStringSet* clang_Cursor_getObjCManglings(CXCursor);
4806 
4807 /**
4808  * @}
4809  */
4810 
4811 /**
4812  * \defgroup CINDEX_MODULE Module introspection
4813  *
4814  * The functions in this group provide access to information about modules.
4815  *
4816  * @{
4817  */
4818 
4819 alias CXModule = void*;
4820 
4821 /**
4822  * Given a CXCursor_ModuleImportDecl cursor, return the associated module.
4823  */
4824 CXModule clang_Cursor_getModule(CXCursor C);
4825 
4826 /**
4827  * Given a CXFile header file, return the module that contains it, if one
4828  * exists.
4829  */
4830 CXModule clang_getModuleForFile(CXTranslationUnit, CXFile);
4831 
4832 /**
4833  * \param Module a module object.
4834  *
4835  * \returns the module file where the provided module object came from.
4836  */
4837 CXFile clang_Module_getASTFile(CXModule Module);
4838 
4839 /**
4840  * \param Module a module object.
4841  *
4842  * \returns the parent of a sub-module or NULL if the given module is top-level,
4843  * e.g. for 'std.vector' it will return the 'std' module.
4844  */
4845 CXModule clang_Module_getParent(CXModule Module);
4846 
4847 /**
4848  * \param Module a module object.
4849  *
4850  * \returns the name of the module, e.g. for the 'std.vector' sub-module it
4851  * will return "vector".
4852  */
4853 CXString clang_Module_getName(CXModule Module);
4854 
4855 /**
4856  * \param Module a module object.
4857  *
4858  * \returns the full name of the module, e.g. "std.vector".
4859  */
4860 CXString clang_Module_getFullName(CXModule Module);
4861 
4862 /**
4863  * \param Module a module object.
4864  *
4865  * \returns non-zero if the module is a system one.
4866  */
4867 int clang_Module_isSystem(CXModule Module);
4868 
4869 /**
4870  * \param Module a module object.
4871  *
4872  * \returns the number of top level headers associated with this module.
4873  */
4874 uint clang_Module_getNumTopLevelHeaders(CXTranslationUnit, CXModule Module);
4875 
4876 /**
4877  * \param Module a module object.
4878  *
4879  * \param Index top level header index (zero-based).
4880  *
4881  * \returns the specified top level header associated with the module.
4882  */
4883 CXFile clang_Module_getTopLevelHeader(
4884     CXTranslationUnit,
4885     CXModule Module,
4886     uint Index);
4887 
4888 /**
4889  * @}
4890  */
4891 
4892 /**
4893  * \defgroup CINDEX_CPP C++ AST introspection
4894  *
4895  * The routines in this group provide access information in the ASTs specific
4896  * to C++ language features.
4897  *
4898  * @{
4899  */
4900 
4901 /**
4902  * Determine if a C++ constructor is a converting constructor.
4903  */
4904 uint clang_CXXConstructor_isConvertingConstructor(CXCursor C);
4905 
4906 /**
4907  * Determine if a C++ constructor is a copy constructor.
4908  */
4909 uint clang_CXXConstructor_isCopyConstructor(CXCursor C);
4910 
4911 /**
4912  * Determine if a C++ constructor is the default constructor.
4913  */
4914 uint clang_CXXConstructor_isDefaultConstructor(CXCursor C);
4915 
4916 /**
4917  * Determine if a C++ constructor is a move constructor.
4918  */
4919 uint clang_CXXConstructor_isMoveConstructor(CXCursor C);
4920 
4921 /**
4922  * Determine if a C++ field is declared 'mutable'.
4923  */
4924 uint clang_CXXField_isMutable(CXCursor C);
4925 
4926 /**
4927  * Determine if a C++ method is declared '= default'.
4928  */
4929 uint clang_CXXMethod_isDefaulted(CXCursor C);
4930 
4931 /**
4932  * Determine if a C++ member function or member function template is
4933  * pure virtual.
4934  */
4935 uint clang_CXXMethod_isPureVirtual(CXCursor C);
4936 
4937 /**
4938  * Determine if a C++ member function or member function template is
4939  * declared 'static'.
4940  */
4941 uint clang_CXXMethod_isStatic(CXCursor C);
4942 
4943 /**
4944  * Determine if a C++ member function or member function template is
4945  * explicitly declared 'virtual' or if it overrides a virtual method from
4946  * one of the base classes.
4947  */
4948 uint clang_CXXMethod_isVirtual(CXCursor C);
4949 
4950 /**
4951  * Determine if a C++ record is abstract, i.e. whether a class or struct
4952  * has a pure virtual member function.
4953  */
4954 uint clang_CXXRecord_isAbstract(CXCursor C);
4955 
4956 /**
4957  * Determine if an enum declaration refers to a scoped enum.
4958  */
4959 uint clang_EnumDecl_isScoped(CXCursor C);
4960 
4961 /**
4962  * Determine if a C++ member function or member function template is
4963  * declared 'const'.
4964  */
4965 uint clang_CXXMethod_isConst(CXCursor C);
4966 
4967 /**
4968  * Given a cursor that represents a template, determine
4969  * the cursor kind of the specializations would be generated by instantiating
4970  * the template.
4971  *
4972  * This routine can be used to determine what flavor of function template,
4973  * class template, or class template partial specialization is stored in the
4974  * cursor. For example, it can describe whether a class template cursor is
4975  * declared with "struct", "class" or "union".
4976  *
4977  * \param C The cursor to query. This cursor should represent a template
4978  * declaration.
4979  *
4980  * \returns The cursor kind of the specializations that would be generated
4981  * by instantiating the template \p C. If \p C is not a template, returns
4982  * \c CXCursor_NoDeclFound.
4983  */
4984 CXCursorKind clang_getTemplateCursorKind(CXCursor C);
4985 
4986 /**
4987  * Given a cursor that may represent a specialization or instantiation
4988  * of a template, retrieve the cursor that represents the template that it
4989  * specializes or from which it was instantiated.
4990  *
4991  * This routine determines the template involved both for explicit
4992  * specializations of templates and for implicit instantiations of the template,
4993  * both of which are referred to as "specializations". For a class template
4994  * specialization (e.g., \c std::vector<bool>), this routine will return
4995  * either the primary template (\c std::vector) or, if the specialization was
4996  * instantiated from a class template partial specialization, the class template
4997  * partial specialization. For a class template partial specialization and a
4998  * function template specialization (including instantiations), this
4999  * this routine will return the specialized template.
5000  *
5001  * For members of a class template (e.g., member functions, member classes, or
5002  * static data members), returns the specialized or instantiated member.
5003  * Although not strictly "templates" in the C++ language, members of class
5004  * templates have the same notions of specializations and instantiations that
5005  * templates do, so this routine treats them similarly.
5006  *
5007  * \param C A cursor that may be a specialization of a template or a member
5008  * of a template.
5009  *
5010  * \returns If the given cursor is a specialization or instantiation of a
5011  * template or a member thereof, the template or member that it specializes or
5012  * from which it was instantiated. Otherwise, returns a NULL cursor.
5013  */
5014 CXCursor clang_getSpecializedCursorTemplate(CXCursor C);
5015 
5016 /**
5017  * Given a cursor that references something else, return the source range
5018  * covering that reference.
5019  *
5020  * \param C A cursor pointing to a member reference, a declaration reference, or
5021  * an operator call.
5022  * \param NameFlags A bitset with three independent flags:
5023  * CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and
5024  * CXNameRange_WantSinglePiece.
5025  * \param PieceIndex For contiguous names or when passing the flag
5026  * CXNameRange_WantSinglePiece, only one piece with index 0 is
5027  * available. When the CXNameRange_WantSinglePiece flag is not passed for a
5028  * non-contiguous names, this index can be used to retrieve the individual
5029  * pieces of the name. See also CXNameRange_WantSinglePiece.
5030  *
5031  * \returns The piece of the name pointed to by the given cursor. If there is no
5032  * name, or if the PieceIndex is out-of-range, a null-cursor will be returned.
5033  */
5034 CXSourceRange clang_getCursorReferenceNameRange(
5035     CXCursor C,
5036     uint NameFlags,
5037     uint PieceIndex);
5038 
5039 enum CXNameRefFlags
5040 {
5041     /**
5042      * Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the
5043      * range.
5044      */
5045     wantQualifier = 0x1,
5046 
5047     /**
5048      * Include the explicit template arguments, e.g. \<int> in x.f<int>,
5049      * in the range.
5050      */
5051     wantTemplateArgs = 0x2,
5052 
5053     /**
5054      * If the name is non-contiguous, return the full spanning range.
5055      *
5056      * Non-contiguous names occur in Objective-C when a selector with two or more
5057      * parameters is used, or in C++ when using an operator:
5058      * \code
5059      * [object doSomething:here withValue:there]; // Objective-C
5060      * return some_vector[1]; // C++
5061      * \endcode
5062      */
5063     wantSinglePiece = 0x4
5064 }
5065 
5066 /**
5067  * @}
5068  */
5069 
5070 /**
5071  * \defgroup CINDEX_LEX Token extraction and manipulation
5072  *
5073  * The routines in this group provide access to the tokens within a
5074  * translation unit, along with a semantic mapping of those tokens to
5075  * their corresponding cursors.
5076  *
5077  * @{
5078  */
5079 
5080 /**
5081  * Describes a kind of token.
5082  */
5083 enum CXTokenKind
5084 {
5085     /**
5086      * A token that contains some kind of punctuation.
5087      */
5088     punctuation = 0,
5089 
5090     /**
5091      * A language keyword.
5092      */
5093     keyword = 1,
5094 
5095     /**
5096      * An identifier (that is not a keyword).
5097      */
5098     identifier = 2,
5099 
5100     /**
5101      * A numeric, string, or character literal.
5102      */
5103     literal = 3,
5104 
5105     /**
5106      * A comment.
5107      */
5108     comment = 4
5109 }
5110 
5111 /**
5112  * Describes a single preprocessing token.
5113  */
5114 struct CXToken
5115 {
5116     uint[4] int_data;
5117     void* ptr_data;
5118 }
5119 
5120 /**
5121  * Get the raw lexical token starting with the given location.
5122  *
5123  * \param TU the translation unit whose text is being tokenized.
5124  *
5125  * \param Location the source location with which the token starts.
5126  *
5127  * \returns The token starting with the given location or NULL if no such token
5128  * exist. The returned pointer must be freed with clang_disposeTokens before the
5129  * translation unit is destroyed.
5130  */
5131 CXToken* clang_getToken(CXTranslationUnit TU, CXSourceLocation Location);
5132 
5133 /**
5134  * Determine the kind of the given token.
5135  */
5136 CXTokenKind clang_getTokenKind(CXToken);
5137 
5138 /**
5139  * Determine the spelling of the given token.
5140  *
5141  * The spelling of a token is the textual representation of that token, e.g.,
5142  * the text of an identifier or keyword.
5143  */
5144 CXString clang_getTokenSpelling(CXTranslationUnit, CXToken);
5145 
5146 /**
5147  * Retrieve the source location of the given token.
5148  */
5149 CXSourceLocation clang_getTokenLocation(CXTranslationUnit, CXToken);
5150 
5151 /**
5152  * Retrieve a source range that covers the given token.
5153  */
5154 CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken);
5155 
5156 /**
5157  * Tokenize the source code described by the given range into raw
5158  * lexical tokens.
5159  *
5160  * \param TU the translation unit whose text is being tokenized.
5161  *
5162  * \param Range the source range in which text should be tokenized. All of the
5163  * tokens produced by tokenization will fall within this source range,
5164  *
5165  * \param Tokens this pointer will be set to point to the array of tokens
5166  * that occur within the given source range. The returned pointer must be
5167  * freed with clang_disposeTokens() before the translation unit is destroyed.
5168  *
5169  * \param NumTokens will be set to the number of tokens in the \c *Tokens
5170  * array.
5171  *
5172  */
5173 void clang_tokenize(
5174     CXTranslationUnit TU,
5175     CXSourceRange Range,
5176     CXToken** Tokens,
5177     uint* NumTokens);
5178 
5179 /**
5180  * Annotate the given set of tokens by providing cursors for each token
5181  * that can be mapped to a specific entity within the abstract syntax tree.
5182  *
5183  * This token-annotation routine is equivalent to invoking
5184  * clang_getCursor() for the source locations of each of the
5185  * tokens. The cursors provided are filtered, so that only those
5186  * cursors that have a direct correspondence to the token are
5187  * accepted. For example, given a function call \c f(x),
5188  * clang_getCursor() would provide the following cursors:
5189  *
5190  *   * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'.
5191  *   * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'.
5192  *   * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'.
5193  *
5194  * Only the first and last of these cursors will occur within the
5195  * annotate, since the tokens "f" and "x' directly refer to a function
5196  * and a variable, respectively, but the parentheses are just a small
5197  * part of the full syntax of the function call expression, which is
5198  * not provided as an annotation.
5199  *
5200  * \param TU the translation unit that owns the given tokens.
5201  *
5202  * \param Tokens the set of tokens to annotate.
5203  *
5204  * \param NumTokens the number of tokens in \p Tokens.
5205  *
5206  * \param Cursors an array of \p NumTokens cursors, whose contents will be
5207  * replaced with the cursors corresponding to each token.
5208  */
5209 void clang_annotateTokens(
5210     CXTranslationUnit TU,
5211     CXToken* Tokens,
5212     uint NumTokens,
5213     CXCursor* Cursors);
5214 
5215 /**
5216  * Free the given set of tokens.
5217  */
5218 void clang_disposeTokens(CXTranslationUnit TU, CXToken* Tokens, uint NumTokens);
5219 
5220 /**
5221  * @}
5222  */
5223 
5224 /**
5225  * \defgroup CINDEX_DEBUG Debugging facilities
5226  *
5227  * These routines are used for testing and debugging, only, and should not
5228  * be relied upon.
5229  *
5230  * @{
5231  */
5232 
5233 /* for debug/testing */
5234 CXString clang_getCursorKindSpelling(CXCursorKind Kind);
5235 void clang_getDefinitionSpellingAndExtent(
5236     CXCursor,
5237     const(char*)* startBuf,
5238     const(char*)* endBuf,
5239     uint* startLine,
5240     uint* startColumn,
5241     uint* endLine,
5242     uint* endColumn);
5243 void clang_enableStackTraces();
5244 void clang_executeOnThread(
5245     void function(void*) fn,
5246     void* user_data,
5247     uint stack_size);
5248 
5249 /**
5250  * @}
5251  */
5252 
5253 /**
5254  * \defgroup CINDEX_CODE_COMPLET Code completion
5255  *
5256  * Code completion involves taking an (incomplete) source file, along with
5257  * knowledge of where the user is actively editing that file, and suggesting
5258  * syntactically- and semantically-valid constructs that the user might want to
5259  * use at that particular point in the source code. These data structures and
5260  * routines provide support for code completion.
5261  *
5262  * @{
5263  */
5264 
5265 /**
5266  * A semantic string that describes a code-completion result.
5267  *
5268  * A semantic string that describes the formatting of a code-completion
5269  * result as a single "template" of text that should be inserted into the
5270  * source buffer when a particular code-completion result is selected.
5271  * Each semantic string is made up of some number of "chunks", each of which
5272  * contains some text along with a description of what that text means, e.g.,
5273  * the name of the entity being referenced, whether the text chunk is part of
5274  * the template, or whether it is a "placeholder" that the user should replace
5275  * with actual code,of a specific kind. See \c CXCompletionChunkKind for a
5276  * description of the different kinds of chunks.
5277  */
5278 alias CXCompletionString = void*;
5279 
5280 /**
5281  * A single result of code completion.
5282  */
5283 struct CXCompletionResult
5284 {
5285     /**
5286      * The kind of entity that this completion refers to.
5287      *
5288      * The cursor kind will be a macro, keyword, or a declaration (one of the
5289      * *Decl cursor kinds), describing the entity that the completion is
5290      * referring to.
5291      *
5292      * \todo In the future, we would like to provide a full cursor, to allow
5293      * the client to extract additional information from declaration.
5294      */
5295     CXCursorKind CursorKind;
5296 
5297     /**
5298      * The code-completion string that describes how to insert this
5299      * code-completion result into the editing buffer.
5300      */
5301     CXCompletionString CompletionString;
5302 }
5303 
5304 /**
5305  * Describes a single piece of text within a code-completion string.
5306  *
5307  * Each "chunk" within a code-completion string (\c CXCompletionString) is
5308  * either a piece of text with a specific "kind" that describes how that text
5309  * should be interpreted by the client or is another completion string.
5310  */
5311 enum CXCompletionChunkKind
5312 {
5313     /**
5314      * A code-completion string that describes "optional" text that
5315      * could be a part of the template (but is not required).
5316      *
5317      * The Optional chunk is the only kind of chunk that has a code-completion
5318      * string for its representation, which is accessible via
5319      * \c clang_getCompletionChunkCompletionString(). The code-completion string
5320      * describes an additional part of the template that is completely optional.
5321      * For example, optional chunks can be used to describe the placeholders for
5322      * arguments that match up with defaulted function parameters, e.g. given:
5323      *
5324      * \code
5325      * void f(int x, float y = 3.14, double z = 2.71828);
5326      * \endcode
5327      *
5328      * The code-completion string for this function would contain:
5329      *   - a TypedText chunk for "f".
5330      *   - a LeftParen chunk for "(".
5331      *   - a Placeholder chunk for "int x"
5332      *   - an Optional chunk containing the remaining defaulted arguments, e.g.,
5333      *       - a Comma chunk for ","
5334      *       - a Placeholder chunk for "float y"
5335      *       - an Optional chunk containing the last defaulted argument:
5336      *           - a Comma chunk for ","
5337      *           - a Placeholder chunk for "double z"
5338      *   - a RightParen chunk for ")"
5339      *
5340      * There are many ways to handle Optional chunks. Two simple approaches are:
5341      *   - Completely ignore optional chunks, in which case the template for the
5342      *     function "f" would only include the first parameter ("int x").
5343      *   - Fully expand all optional chunks, in which case the template for the
5344      *     function "f" would have all of the parameters.
5345      */
5346     optional = 0,
5347     /**
5348      * Text that a user would be expected to type to get this
5349      * code-completion result.
5350      *
5351      * There will be exactly one "typed text" chunk in a semantic string, which
5352      * will typically provide the spelling of a keyword or the name of a
5353      * declaration that could be used at the current code point. Clients are
5354      * expected to filter the code-completion results based on the text in this
5355      * chunk.
5356      */
5357     typedText = 1,
5358     /**
5359      * Text that should be inserted as part of a code-completion result.
5360      *
5361      * A "text" chunk represents text that is part of the template to be
5362      * inserted into user code should this particular code-completion result
5363      * be selected.
5364      */
5365     text = 2,
5366     /**
5367      * Placeholder text that should be replaced by the user.
5368      *
5369      * A "placeholder" chunk marks a place where the user should insert text
5370      * into the code-completion template. For example, placeholders might mark
5371      * the function parameters for a function declaration, to indicate that the
5372      * user should provide arguments for each of those parameters. The actual
5373      * text in a placeholder is a suggestion for the text to display before
5374      * the user replaces the placeholder with real code.
5375      */
5376     placeholder = 3,
5377     /**
5378      * Informative text that should be displayed but never inserted as
5379      * part of the template.
5380      *
5381      * An "informative" chunk contains annotations that can be displayed to
5382      * help the user decide whether a particular code-completion result is the
5383      * right option, but which is not part of the actual template to be inserted
5384      * by code completion.
5385      */
5386     informative = 4,
5387     /**
5388      * Text that describes the current parameter when code-completion is
5389      * referring to function call, message send, or template specialization.
5390      *
5391      * A "current parameter" chunk occurs when code-completion is providing
5392      * information about a parameter corresponding to the argument at the
5393      * code-completion point. For example, given a function
5394      *
5395      * \code
5396      * int add(int x, int y);
5397      * \endcode
5398      *
5399      * and the source code \c add(, where the code-completion point is after the
5400      * "(", the code-completion string will contain a "current parameter" chunk
5401      * for "int x", indicating that the current argument will initialize that
5402      * parameter. After typing further, to \c add(17, (where the code-completion
5403      * point is after the ","), the code-completion string will contain a
5404      * "current parameter" chunk to "int y".
5405      */
5406     currentParameter = 5,
5407     /**
5408      * A left parenthesis ('('), used to initiate a function call or
5409      * signal the beginning of a function parameter list.
5410      */
5411     leftParen = 6,
5412     /**
5413      * A right parenthesis (')'), used to finish a function call or
5414      * signal the end of a function parameter list.
5415      */
5416     rightParen = 7,
5417     /**
5418      * A left bracket ('[').
5419      */
5420     leftBracket = 8,
5421     /**
5422      * A right bracket (']').
5423      */
5424     rightBracket = 9,
5425     /**
5426      * A left brace ('{').
5427      */
5428     leftBrace = 10,
5429     /**
5430      * A right brace ('}').
5431      */
5432     rightBrace = 11,
5433     /**
5434      * A left angle bracket ('<').
5435      */
5436     leftAngle = 12,
5437     /**
5438      * A right angle bracket ('>').
5439      */
5440     rightAngle = 13,
5441     /**
5442      * A comma separator (',').
5443      */
5444     comma = 14,
5445     /**
5446      * Text that specifies the result type of a given result.
5447      *
5448      * This special kind of informative chunk is not meant to be inserted into
5449      * the text buffer. Rather, it is meant to illustrate the type that an
5450      * expression using the given completion string would have.
5451      */
5452     resultType = 15,
5453     /**
5454      * A colon (':').
5455      */
5456     colon = 16,
5457     /**
5458      * A semicolon (';').
5459      */
5460     semiColon = 17,
5461     /**
5462      * An '=' sign.
5463      */
5464     equal = 18,
5465     /**
5466      * Horizontal space (' ').
5467      */
5468     horizontalSpace = 19,
5469     /**
5470      * Vertical space ('\\n'), after which it is generally a good idea to
5471      * perform indentation.
5472      */
5473     verticalSpace = 20
5474 }
5475 
5476 /**
5477  * Determine the kind of a particular chunk within a completion string.
5478  *
5479  * \param completion_string the completion string to query.
5480  *
5481  * \param chunk_number the 0-based index of the chunk in the completion string.
5482  *
5483  * \returns the kind of the chunk at the index \c chunk_number.
5484  */
5485 CXCompletionChunkKind clang_getCompletionChunkKind(
5486     CXCompletionString completion_string,
5487     uint chunk_number);
5488 
5489 /**
5490  * Retrieve the text associated with a particular chunk within a
5491  * completion string.
5492  *
5493  * \param completion_string the completion string to query.
5494  *
5495  * \param chunk_number the 0-based index of the chunk in the completion string.
5496  *
5497  * \returns the text associated with the chunk at index \c chunk_number.
5498  */
5499 CXString clang_getCompletionChunkText(
5500     CXCompletionString completion_string,
5501     uint chunk_number);
5502 
5503 /**
5504  * Retrieve the completion string associated with a particular chunk
5505  * within a completion string.
5506  *
5507  * \param completion_string the completion string to query.
5508  *
5509  * \param chunk_number the 0-based index of the chunk in the completion string.
5510  *
5511  * \returns the completion string associated with the chunk at index
5512  * \c chunk_number.
5513  */
5514 CXCompletionString clang_getCompletionChunkCompletionString(
5515     CXCompletionString completion_string,
5516     uint chunk_number);
5517 
5518 /**
5519  * Retrieve the number of chunks in the given code-completion string.
5520  */
5521 uint clang_getNumCompletionChunks(CXCompletionString completion_string);
5522 
5523 /**
5524  * Determine the priority of this code completion.
5525  *
5526  * The priority of a code completion indicates how likely it is that this
5527  * particular completion is the completion that the user will select. The
5528  * priority is selected by various internal heuristics.
5529  *
5530  * \param completion_string The completion string to query.
5531  *
5532  * \returns The priority of this completion string. Smaller values indicate
5533  * higher-priority (more likely) completions.
5534  */
5535 uint clang_getCompletionPriority(CXCompletionString completion_string);
5536 
5537 /**
5538  * Determine the availability of the entity that this code-completion
5539  * string refers to.
5540  *
5541  * \param completion_string The completion string to query.
5542  *
5543  * \returns The availability of the completion string.
5544  */
5545 CXAvailabilityKind clang_getCompletionAvailability(
5546     CXCompletionString completion_string);
5547 
5548 /**
5549  * Retrieve the number of annotations associated with the given
5550  * completion string.
5551  *
5552  * \param completion_string the completion string to query.
5553  *
5554  * \returns the number of annotations associated with the given completion
5555  * string.
5556  */
5557 uint clang_getCompletionNumAnnotations(CXCompletionString completion_string);
5558 
5559 /**
5560  * Retrieve the annotation associated with the given completion string.
5561  *
5562  * \param completion_string the completion string to query.
5563  *
5564  * \param annotation_number the 0-based index of the annotation of the
5565  * completion string.
5566  *
5567  * \returns annotation string associated with the completion at index
5568  * \c annotation_number, or a NULL string if that annotation is not available.
5569  */
5570 CXString clang_getCompletionAnnotation(
5571     CXCompletionString completion_string,
5572     uint annotation_number);
5573 
5574 /**
5575  * Retrieve the parent context of the given completion string.
5576  *
5577  * The parent context of a completion string is the semantic parent of
5578  * the declaration (if any) that the code completion represents. For example,
5579  * a code completion for an Objective-C method would have the method's class
5580  * or protocol as its context.
5581  *
5582  * \param completion_string The code completion string whose parent is
5583  * being queried.
5584  *
5585  * \param kind DEPRECATED: always set to CXCursor_NotImplemented if non-NULL.
5586  *
5587  * \returns The name of the completion parent, e.g., "NSObject" if
5588  * the completion string represents a method in the NSObject class.
5589  */
5590 CXString clang_getCompletionParent(
5591     CXCompletionString completion_string,
5592     CXCursorKind* kind);
5593 
5594 /**
5595  * Retrieve the brief documentation comment attached to the declaration
5596  * that corresponds to the given completion string.
5597  */
5598 CXString clang_getCompletionBriefComment(CXCompletionString completion_string);
5599 
5600 /**
5601  * Retrieve a completion string for an arbitrary declaration or macro
5602  * definition cursor.
5603  *
5604  * \param cursor The cursor to query.
5605  *
5606  * \returns A non-context-sensitive completion string for declaration and macro
5607  * definition cursors, or NULL for other kinds of cursors.
5608  */
5609 CXCompletionString clang_getCursorCompletionString(CXCursor cursor);
5610 
5611 /**
5612  * Contains the results of code-completion.
5613  *
5614  * This data structure contains the results of code completion, as
5615  * produced by \c clang_codeCompleteAt(). Its contents must be freed by
5616  * \c clang_disposeCodeCompleteResults.
5617  */
5618 struct CXCodeCompleteResults
5619 {
5620     /**
5621      * The code-completion results.
5622      */
5623     CXCompletionResult* Results;
5624 
5625     /**
5626      * The number of code-completion results stored in the
5627      * \c Results array.
5628      */
5629     uint NumResults;
5630 }
5631 
5632 /**
5633  * Retrieve the number of fix-its for the given completion index.
5634  *
5635  * Calling this makes sense only if CXCodeComplete_IncludeCompletionsWithFixIts
5636  * option was set.
5637  *
5638  * \param results The structure keeping all completion results
5639  *
5640  * \param completion_index The index of the completion
5641  *
5642  * \return The number of fix-its which must be applied before the completion at
5643  * completion_index can be applied
5644  */
5645 uint clang_getCompletionNumFixIts(
5646     CXCodeCompleteResults* results,
5647     uint completion_index);
5648 
5649 /**
5650  * Fix-its that *must* be applied before inserting the text for the
5651  * corresponding completion.
5652  *
5653  * By default, clang_codeCompleteAt() only returns completions with empty
5654  * fix-its. Extra completions with non-empty fix-its should be explicitly
5655  * requested by setting CXCodeComplete_IncludeCompletionsWithFixIts.
5656  *
5657  * For the clients to be able to compute position of the cursor after applying
5658  * fix-its, the following conditions are guaranteed to hold for
5659  * replacement_range of the stored fix-its:
5660  *  - Ranges in the fix-its are guaranteed to never contain the completion
5661  *  point (or identifier under completion point, if any) inside them, except
5662  *  at the start or at the end of the range.
5663  *  - If a fix-it range starts or ends with completion point (or starts or
5664  *  ends after the identifier under completion point), it will contain at
5665  *  least one character. It allows to unambiguously recompute completion
5666  *  point after applying the fix-it.
5667  *
5668  * The intuition is that provided fix-its change code around the identifier we
5669  * complete, but are not allowed to touch the identifier itself or the
5670  * completion point. One example of completions with corrections are the ones
5671  * replacing '.' with '->' and vice versa:
5672  *
5673  * std::unique_ptr<std::vector<int>> vec_ptr;
5674  * In 'vec_ptr.^', one of the completions is 'push_back', it requires
5675  * replacing '.' with '->'.
5676  * In 'vec_ptr->^', one of the completions is 'release', it requires
5677  * replacing '->' with '.'.
5678  *
5679  * \param results The structure keeping all completion results
5680  *
5681  * \param completion_index The index of the completion
5682  *
5683  * \param fixit_index The index of the fix-it for the completion at
5684  * completion_index
5685  *
5686  * \param replacement_range The fix-it range that must be replaced before the
5687  * completion at completion_index can be applied
5688  *
5689  * \returns The fix-it string that must replace the code at replacement_range
5690  * before the completion at completion_index can be applied
5691  */
5692 CXString clang_getCompletionFixIt(
5693     CXCodeCompleteResults* results,
5694     uint completion_index,
5695     uint fixit_index,
5696     CXSourceRange* replacement_range);
5697 
5698 /**
5699  * Flags that can be passed to \c clang_codeCompleteAt() to
5700  * modify its behavior.
5701  *
5702  * The enumerators in this enumeration can be bitwise-OR'd together to
5703  * provide multiple options to \c clang_codeCompleteAt().
5704  */
5705 enum CXCodeComplete_Flags
5706 {
5707     /**
5708      * Whether to include macros within the set of code
5709      * completions returned.
5710      */
5711     includeMacros = 0x01,
5712 
5713     /**
5714      * Whether to include code patterns for language constructs
5715      * within the set of code completions, e.g., for loops.
5716      */
5717     includeCodePatterns = 0x02,
5718 
5719     /**
5720      * Whether to include brief documentation within the set of code
5721      * completions returned.
5722      */
5723     includeBriefComments = 0x04,
5724 
5725     /**
5726      * Whether to speed up completion by omitting top- or namespace-level entities
5727      * defined in the preamble. There's no guarantee any particular entity is
5728      * omitted. This may be useful if the headers are indexed externally.
5729      */
5730     skipPreamble = 0x08,
5731 
5732     /**
5733      * Whether to include completions with small
5734      * fix-its, e.g. change '.' to '->' on member access, etc.
5735      */
5736     includeCompletionsWithFixIts = 0x10
5737 }
5738 
5739 /**
5740  * Bits that represent the context under which completion is occurring.
5741  *
5742  * The enumerators in this enumeration may be bitwise-OR'd together if multiple
5743  * contexts are occurring simultaneously.
5744  */
5745 enum CXCompletionContext
5746 {
5747     /**
5748      * The context for completions is unexposed, as only Clang results
5749      * should be included. (This is equivalent to having no context bits set.)
5750      */
5751     unexposed = 0,
5752 
5753     /**
5754      * Completions for any possible type should be included in the results.
5755      */
5756     anyType = 1 << 0,
5757 
5758     /**
5759      * Completions for any possible value (variables, function calls, etc.)
5760      * should be included in the results.
5761      */
5762     anyValue = 1 << 1,
5763     /**
5764      * Completions for values that resolve to an Objective-C object should
5765      * be included in the results.
5766      */
5767     objCObjectValue = 1 << 2,
5768     /**
5769      * Completions for values that resolve to an Objective-C selector
5770      * should be included in the results.
5771      */
5772     objCSelectorValue = 1 << 3,
5773     /**
5774      * Completions for values that resolve to a C++ class type should be
5775      * included in the results.
5776      */
5777     cxxClassTypeValue = 1 << 4,
5778 
5779     /**
5780      * Completions for fields of the member being accessed using the dot
5781      * operator should be included in the results.
5782      */
5783     dotMemberAccess = 1 << 5,
5784     /**
5785      * Completions for fields of the member being accessed using the arrow
5786      * operator should be included in the results.
5787      */
5788     arrowMemberAccess = 1 << 6,
5789     /**
5790      * Completions for properties of the Objective-C object being accessed
5791      * using the dot operator should be included in the results.
5792      */
5793     objCPropertyAccess = 1 << 7,
5794 
5795     /**
5796      * Completions for enum tags should be included in the results.
5797      */
5798     enumTag = 1 << 8,
5799     /**
5800      * Completions for union tags should be included in the results.
5801      */
5802     unionTag = 1 << 9,
5803     /**
5804      * Completions for struct tags should be included in the results.
5805      */
5806     structTag = 1 << 10,
5807 
5808     /**
5809      * Completions for C++ class names should be included in the results.
5810      */
5811     classTag = 1 << 11,
5812     /**
5813      * Completions for C++ namespaces and namespace aliases should be
5814      * included in the results.
5815      */
5816     namespace = 1 << 12,
5817     /**
5818      * Completions for C++ nested name specifiers should be included in
5819      * the results.
5820      */
5821     nestedNameSpecifier = 1 << 13,
5822 
5823     /**
5824      * Completions for Objective-C interfaces (classes) should be included
5825      * in the results.
5826      */
5827     objCInterface = 1 << 14,
5828     /**
5829      * Completions for Objective-C protocols should be included in
5830      * the results.
5831      */
5832     objCProtocol = 1 << 15,
5833     /**
5834      * Completions for Objective-C categories should be included in
5835      * the results.
5836      */
5837     objCCategory = 1 << 16,
5838     /**
5839      * Completions for Objective-C instance messages should be included
5840      * in the results.
5841      */
5842     objCInstanceMessage = 1 << 17,
5843     /**
5844      * Completions for Objective-C class messages should be included in
5845      * the results.
5846      */
5847     objCClassMessage = 1 << 18,
5848     /**
5849      * Completions for Objective-C selector names should be included in
5850      * the results.
5851      */
5852     objCSelectorName = 1 << 19,
5853 
5854     /**
5855      * Completions for preprocessor macro names should be included in
5856      * the results.
5857      */
5858     macroName = 1 << 20,
5859 
5860     /**
5861      * Natural language completions should be included in the results.
5862      */
5863     naturalLanguage = 1 << 21,
5864 
5865     /**
5866      * #include file completions should be included in the results.
5867      */
5868     includedFile = 1 << 22,
5869 
5870     /**
5871      * The current context is unknown, so set all contexts.
5872      */
5873     unknown = (1 << 23) - 1
5874 }
5875 
5876 /**
5877  * Returns a default set of code-completion options that can be
5878  * passed to\c clang_codeCompleteAt().
5879  */
5880 uint clang_defaultCodeCompleteOptions();
5881 
5882 /**
5883  * Perform code completion at a given location in a translation unit.
5884  *
5885  * This function performs code completion at a particular file, line, and
5886  * column within source code, providing results that suggest potential
5887  * code snippets based on the context of the completion. The basic model
5888  * for code completion is that Clang will parse a complete source file,
5889  * performing syntax checking up to the location where code-completion has
5890  * been requested. At that point, a special code-completion token is passed
5891  * to the parser, which recognizes this token and determines, based on the
5892  * current location in the C/Objective-C/C++ grammar and the state of
5893  * semantic analysis, what completions to provide. These completions are
5894  * returned via a new \c CXCodeCompleteResults structure.
5895  *
5896  * Code completion itself is meant to be triggered by the client when the
5897  * user types punctuation characters or whitespace, at which point the
5898  * code-completion location will coincide with the cursor. For example, if \c p
5899  * is a pointer, code-completion might be triggered after the "-" and then
5900  * after the ">" in \c p->. When the code-completion location is after the ">",
5901  * the completion results will provide, e.g., the members of the struct that
5902  * "p" points to. The client is responsible for placing the cursor at the
5903  * beginning of the token currently being typed, then filtering the results
5904  * based on the contents of the token. For example, when code-completing for
5905  * the expression \c p->get, the client should provide the location just after
5906  * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the
5907  * client can filter the results based on the current token text ("get"), only
5908  * showing those results that start with "get". The intent of this interface
5909  * is to separate the relatively high-latency acquisition of code-completion
5910  * results from the filtering of results on a per-character basis, which must
5911  * have a lower latency.
5912  *
5913  * \param TU The translation unit in which code-completion should
5914  * occur. The source files for this translation unit need not be
5915  * completely up-to-date (and the contents of those source files may
5916  * be overridden via \p unsaved_files). Cursors referring into the
5917  * translation unit may be invalidated by this invocation.
5918  *
5919  * \param complete_filename The name of the source file where code
5920  * completion should be performed. This filename may be any file
5921  * included in the translation unit.
5922  *
5923  * \param complete_line The line at which code-completion should occur.
5924  *
5925  * \param complete_column The column at which code-completion should occur.
5926  * Note that the column should point just after the syntactic construct that
5927  * initiated code completion, and not in the middle of a lexical token.
5928  *
5929  * \param unsaved_files the Files that have not yet been saved to disk
5930  * but may be required for parsing or code completion, including the
5931  * contents of those files.  The contents and name of these files (as
5932  * specified by CXUnsavedFile) are copied when necessary, so the
5933  * client only needs to guarantee their validity until the call to
5934  * this function returns.
5935  *
5936  * \param num_unsaved_files The number of unsaved file entries in \p
5937  * unsaved_files.
5938  *
5939  * \param options Extra options that control the behavior of code
5940  * completion, expressed as a bitwise OR of the enumerators of the
5941  * CXCodeComplete_Flags enumeration. The
5942  * \c clang_defaultCodeCompleteOptions() function returns a default set
5943  * of code-completion options.
5944  *
5945  * \returns If successful, a new \c CXCodeCompleteResults structure
5946  * containing code-completion results, which should eventually be
5947  * freed with \c clang_disposeCodeCompleteResults(). If code
5948  * completion fails, returns NULL.
5949  */
5950 CXCodeCompleteResults* clang_codeCompleteAt(
5951     CXTranslationUnit TU,
5952     const(char)* complete_filename,
5953     uint complete_line,
5954     uint complete_column,
5955     CXUnsavedFile* unsaved_files,
5956     uint num_unsaved_files,
5957     uint options);
5958 
5959 /**
5960  * Sort the code-completion results in case-insensitive alphabetical
5961  * order.
5962  *
5963  * \param Results The set of results to sort.
5964  * \param NumResults The number of results in \p Results.
5965  */
5966 void clang_sortCodeCompletionResults(
5967     CXCompletionResult* Results,
5968     uint NumResults);
5969 
5970 /**
5971  * Free the given set of code-completion results.
5972  */
5973 void clang_disposeCodeCompleteResults(CXCodeCompleteResults* Results);
5974 
5975 /**
5976  * Determine the number of diagnostics produced prior to the
5977  * location where code completion was performed.
5978  */
5979 uint clang_codeCompleteGetNumDiagnostics(CXCodeCompleteResults* Results);
5980 
5981 /**
5982  * Retrieve a diagnostic associated with the given code completion.
5983  *
5984  * \param Results the code completion results to query.
5985  * \param Index the zero-based diagnostic number to retrieve.
5986  *
5987  * \returns the requested diagnostic. This diagnostic must be freed
5988  * via a call to \c clang_disposeDiagnostic().
5989  */
5990 CXDiagnostic clang_codeCompleteGetDiagnostic(
5991     CXCodeCompleteResults* Results,
5992     uint Index);
5993 
5994 /**
5995  * Determines what completions are appropriate for the context
5996  * the given code completion.
5997  *
5998  * \param Results the code completion results to query
5999  *
6000  * \returns the kinds of completions that are appropriate for use
6001  * along with the given code completion results.
6002  */
6003 ulong clang_codeCompleteGetContexts(CXCodeCompleteResults* Results);
6004 
6005 /**
6006  * Returns the cursor kind for the container for the current code
6007  * completion context. The container is only guaranteed to be set for
6008  * contexts where a container exists (i.e. member accesses or Objective-C
6009  * message sends); if there is not a container, this function will return
6010  * CXCursor_InvalidCode.
6011  *
6012  * \param Results the code completion results to query
6013  *
6014  * \param IsIncomplete on return, this value will be false if Clang has complete
6015  * information about the container. If Clang does not have complete
6016  * information, this value will be true.
6017  *
6018  * \returns the container kind, or CXCursor_InvalidCode if there is not a
6019  * container
6020  */
6021 CXCursorKind clang_codeCompleteGetContainerKind(
6022     CXCodeCompleteResults* Results,
6023     uint* IsIncomplete);
6024 
6025 /**
6026  * Returns the USR for the container for the current code completion
6027  * context. If there is not a container for the current context, this
6028  * function will return the empty string.
6029  *
6030  * \param Results the code completion results to query
6031  *
6032  * \returns the USR for the container
6033  */
6034 CXString clang_codeCompleteGetContainerUSR(CXCodeCompleteResults* Results);
6035 
6036 /**
6037  * Returns the currently-entered selector for an Objective-C message
6038  * send, formatted like "initWithFoo:bar:". Only guaranteed to return a
6039  * non-empty string for CXCompletionContext_ObjCInstanceMessage and
6040  * CXCompletionContext_ObjCClassMessage.
6041  *
6042  * \param Results the code completion results to query
6043  *
6044  * \returns the selector (or partial selector) that has been entered thus far
6045  * for an Objective-C message send.
6046  */
6047 CXString clang_codeCompleteGetObjCSelector(CXCodeCompleteResults* Results);
6048 
6049 /**
6050  * @}
6051  */
6052 
6053 /**
6054  * \defgroup CINDEX_MISC Miscellaneous utility functions
6055  *
6056  * @{
6057  */
6058 
6059 /**
6060  * Return a version string, suitable for showing to a user, but not
6061  *        intended to be parsed (the format is not guaranteed to be stable).
6062  */
6063 CXString clang_getClangVersion();
6064 
6065 /**
6066  * Enable/disable crash recovery.
6067  *
6068  * \param isEnabled Flag to indicate if crash recovery is enabled.  A non-zero
6069  *        value enables crash recovery, while 0 disables it.
6070  */
6071 void clang_toggleCrashRecovery(uint isEnabled);
6072 
6073 /**
6074  * Visitor invoked for each file in a translation unit
6075  *        (used with clang_getInclusions()).
6076  *
6077  * This visitor function will be invoked by clang_getInclusions() for each
6078  * file included (either at the top-level or by \#include directives) within
6079  * a translation unit.  The first argument is the file being included, and
6080  * the second and third arguments provide the inclusion stack.  The
6081  * array is sorted in order of immediate inclusion.  For example,
6082  * the first element refers to the location that included 'included_file'.
6083  */
6084 alias CXInclusionVisitor = void function(
6085     CXFile included_file,
6086     CXSourceLocation* inclusion_stack,
6087     uint include_len,
6088     CXClientData client_data);
6089 
6090 /**
6091  * Visit the set of preprocessor inclusions in a translation unit.
6092  *   The visitor function is called with the provided data for every included
6093  *   file.  This does not include headers included by the PCH file (unless one
6094  *   is inspecting the inclusions in the PCH file itself).
6095  */
6096 void clang_getInclusions(
6097     CXTranslationUnit tu,
6098     CXInclusionVisitor visitor,
6099     CXClientData client_data);
6100 
6101 enum CXEvalResultKind
6102 {
6103     int_ = 1,
6104     float_ = 2,
6105     objCStrLiteral = 3,
6106     strLiteral = 4,
6107     cfStr = 5,
6108     other = 6,
6109 
6110     unExposed = 0
6111 }
6112 
6113 /**
6114  * Evaluation result of a cursor
6115  */
6116 alias CXEvalResult = void*;
6117 
6118 /**
6119  * If cursor is a statement declaration tries to evaluate the
6120  * statement and if its variable, tries to evaluate its initializer,
6121  * into its corresponding type.
6122  * If it's an expression, tries to evaluate the expression.
6123  */
6124 CXEvalResult clang_Cursor_Evaluate(CXCursor C);
6125 
6126 /**
6127  * Returns the kind of the evaluated result.
6128  */
6129 CXEvalResultKind clang_EvalResult_getKind(CXEvalResult E);
6130 
6131 /**
6132  * Returns the evaluation result as integer if the
6133  * kind is Int.
6134  */
6135 int clang_EvalResult_getAsInt(CXEvalResult E);
6136 
6137 /**
6138  * Returns the evaluation result as a long long integer if the
6139  * kind is Int. This prevents overflows that may happen if the result is
6140  * returned with clang_EvalResult_getAsInt.
6141  */
6142 long clang_EvalResult_getAsLongLong(CXEvalResult E);
6143 
6144 /**
6145  * Returns a non-zero value if the kind is Int and the evaluation
6146  * result resulted in an unsigned integer.
6147  */
6148 uint clang_EvalResult_isUnsignedInt(CXEvalResult E);
6149 
6150 /**
6151  * Returns the evaluation result as an unsigned integer if
6152  * the kind is Int and clang_EvalResult_isUnsignedInt is non-zero.
6153  */
6154 ulong clang_EvalResult_getAsUnsigned(CXEvalResult E);
6155 
6156 /**
6157  * Returns the evaluation result as double if the
6158  * kind is double.
6159  */
6160 double clang_EvalResult_getAsDouble(CXEvalResult E);
6161 
6162 /**
6163  * Returns the evaluation result as a constant string if the
6164  * kind is other than Int or float. User must not free this pointer,
6165  * instead call clang_EvalResult_dispose on the CXEvalResult returned
6166  * by clang_Cursor_Evaluate.
6167  */
6168 const(char)* clang_EvalResult_getAsStr(CXEvalResult E);
6169 
6170 /**
6171  * Disposes the created Eval memory.
6172  */
6173 void clang_EvalResult_dispose(CXEvalResult E);
6174 /**
6175  * @}
6176  */
6177 
6178 /** \defgroup CINDEX_REMAPPING Remapping functions
6179  *
6180  * @{
6181  */
6182 
6183 /**
6184  * A remapping of original source files and their translated files.
6185  */
6186 alias CXRemapping = void*;
6187 
6188 /**
6189  * Retrieve a remapping.
6190  *
6191  * \param path the path that contains metadata about remappings.
6192  *
6193  * \returns the requested remapping. This remapping must be freed
6194  * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
6195  */
6196 CXRemapping clang_getRemappings(const(char)* path);
6197 
6198 /**
6199  * Retrieve a remapping.
6200  *
6201  * \param filePaths pointer to an array of file paths containing remapping info.
6202  *
6203  * \param numFiles number of file paths.
6204  *
6205  * \returns the requested remapping. This remapping must be freed
6206  * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
6207  */
6208 CXRemapping clang_getRemappingsFromFileList(
6209     const(char*)* filePaths,
6210     uint numFiles);
6211 
6212 /**
6213  * Determine the number of remappings.
6214  */
6215 uint clang_remap_getNumFiles(CXRemapping);
6216 
6217 /**
6218  * Get the original and the associated filename from the remapping.
6219  *
6220  * \param original If non-NULL, will be set to the original filename.
6221  *
6222  * \param transformed If non-NULL, will be set to the filename that the original
6223  * is associated with.
6224  */
6225 void clang_remap_getFilenames(
6226     CXRemapping,
6227     uint index,
6228     CXString* original,
6229     CXString* transformed);
6230 
6231 /**
6232  * Dispose the remapping.
6233  */
6234 void clang_remap_dispose(CXRemapping);
6235 
6236 /**
6237  * @}
6238  */
6239 
6240 /** \defgroup CINDEX_HIGH Higher level API functions
6241  *
6242  * @{
6243  */
6244 
6245 enum CXVisitorResult
6246 {
6247     break_ = 0,
6248     continue_ = 1
6249 }
6250 
6251 struct CXCursorAndRangeVisitor
6252 {
6253     void* context;
6254     CXVisitorResult function(void* context, CXCursor, CXSourceRange) visit;
6255 }
6256 
6257 enum CXResult
6258 {
6259     /**
6260      * Function returned successfully.
6261      */
6262     success = 0,
6263     /**
6264      * One of the parameters was invalid for the function.
6265      */
6266     invalid = 1,
6267     /**
6268      * The function was terminated by a callback (e.g. it returned
6269      * CXVisit_Break)
6270      */
6271     visitBreak = 2
6272 }
6273 
6274 /**
6275  * Find references of a declaration in a specific file.
6276  *
6277  * \param cursor pointing to a declaration or a reference of one.
6278  *
6279  * \param file to search for references.
6280  *
6281  * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
6282  * each reference found.
6283  * The CXSourceRange will point inside the file; if the reference is inside
6284  * a macro (and not a macro argument) the CXSourceRange will be invalid.
6285  *
6286  * \returns one of the CXResult enumerators.
6287  */
6288 CXResult clang_findReferencesInFile(
6289     CXCursor cursor,
6290     CXFile file,
6291     CXCursorAndRangeVisitor visitor);
6292 
6293 /**
6294  * Find #import/#include directives in a specific file.
6295  *
6296  * \param TU translation unit containing the file to query.
6297  *
6298  * \param file to search for #import/#include directives.
6299  *
6300  * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
6301  * each directive found.
6302  *
6303  * \returns one of the CXResult enumerators.
6304  */
6305 CXResult clang_findIncludesInFile(
6306     CXTranslationUnit TU,
6307     CXFile file,
6308     CXCursorAndRangeVisitor visitor);
6309 
6310 /**
6311  * The client's data object that is associated with a CXFile.
6312  */
6313 alias CXIdxClientFile = void*;
6314 
6315 /**
6316  * The client's data object that is associated with a semantic entity.
6317  */
6318 alias CXIdxClientEntity = void*;
6319 
6320 /**
6321  * The client's data object that is associated with a semantic container
6322  * of entities.
6323  */
6324 alias CXIdxClientContainer = void*;
6325 
6326 /**
6327  * The client's data object that is associated with an AST file (PCH
6328  * or module).
6329  */
6330 alias CXIdxClientASTFile = void*;
6331 
6332 /**
6333  * Source location passed to index callbacks.
6334  */
6335 struct CXIdxLoc
6336 {
6337     void*[2] ptr_data;
6338     uint int_data;
6339 }
6340 
6341 /**
6342  * Data for ppIncludedFile callback.
6343  */
6344 struct CXIdxIncludedFileInfo
6345 {
6346     /**
6347      * Location of '#' in the \#include/\#import directive.
6348      */
6349     CXIdxLoc hashLoc;
6350     /**
6351      * Filename as written in the \#include/\#import directive.
6352      */
6353     const(char)* filename;
6354     /**
6355      * The actual file that the \#include/\#import directive resolved to.
6356      */
6357     CXFile file;
6358     int isImport;
6359     int isAngled;
6360     /**
6361      * Non-zero if the directive was automatically turned into a module
6362      * import.
6363      */
6364     int isModuleImport;
6365 }
6366 
6367 /**
6368  * Data for IndexerCallbacks#importedASTFile.
6369  */
6370 struct CXIdxImportedASTFileInfo
6371 {
6372     /**
6373      * Top level AST file containing the imported PCH, module or submodule.
6374      */
6375     CXFile file;
6376     /**
6377      * The imported module or NULL if the AST file is a PCH.
6378      */
6379     CXModule module_;
6380     /**
6381      * Location where the file is imported. Applicable only for modules.
6382      */
6383     CXIdxLoc loc;
6384     /**
6385      * Non-zero if an inclusion directive was automatically turned into
6386      * a module import. Applicable only for modules.
6387      */
6388     int isImplicit;
6389 }
6390 
6391 enum CXIdxEntityKind
6392 {
6393     unexposed = 0,
6394     typedef_ = 1,
6395     function_ = 2,
6396     variable = 3,
6397     field = 4,
6398     enumConstant = 5,
6399 
6400     objCClass = 6,
6401     objCProtocol = 7,
6402     objCCategory = 8,
6403 
6404     objCInstanceMethod = 9,
6405     objCClassMethod = 10,
6406     objCProperty = 11,
6407     objCIvar = 12,
6408 
6409     enum_ = 13,
6410     struct_ = 14,
6411     union_ = 15,
6412 
6413     cxxClass = 16,
6414     cxxNamespace = 17,
6415     cxxNamespaceAlias = 18,
6416     cxxStaticVariable = 19,
6417     cxxStaticMethod = 20,
6418     cxxInstanceMethod = 21,
6419     cxxConstructor = 22,
6420     cxxDestructor = 23,
6421     cxxConversionFunction = 24,
6422     cxxTypeAlias = 25,
6423     cxxInterface = 26,
6424     cxxConcept = 27
6425 }
6426 
6427 enum CXIdxEntityLanguage
6428 {
6429     none = 0,
6430     c = 1,
6431     objC = 2,
6432     cxx = 3,
6433     swift = 4
6434 }
6435 
6436 /**
6437  * Extra C++ template information for an entity. This can apply to:
6438  * CXIdxEntity_Function
6439  * CXIdxEntity_CXXClass
6440  * CXIdxEntity_CXXStaticMethod
6441  * CXIdxEntity_CXXInstanceMethod
6442  * CXIdxEntity_CXXConstructor
6443  * CXIdxEntity_CXXConversionFunction
6444  * CXIdxEntity_CXXTypeAlias
6445  */
6446 enum CXIdxEntityCXXTemplateKind
6447 {
6448     nonTemplate = 0,
6449     template_ = 1,
6450     templatePartialSpecialization = 2,
6451     templateSpecialization = 3
6452 }
6453 
6454 enum CXIdxAttrKind
6455 {
6456     unexposed = 0,
6457     ibAction = 1,
6458     ibOutlet = 2,
6459     ibOutletCollection = 3
6460 }
6461 
6462 struct CXIdxAttrInfo
6463 {
6464     CXIdxAttrKind kind;
6465     CXCursor cursor;
6466     CXIdxLoc loc;
6467 }
6468 
6469 struct CXIdxEntityInfo
6470 {
6471     CXIdxEntityKind kind;
6472     CXIdxEntityCXXTemplateKind templateKind;
6473     CXIdxEntityLanguage lang;
6474     const(char)* name;
6475     const(char)* USR;
6476     CXCursor cursor;
6477     const(CXIdxAttrInfo*)* attributes;
6478     uint numAttributes;
6479 }
6480 
6481 struct CXIdxContainerInfo
6482 {
6483     CXCursor cursor;
6484 }
6485 
6486 struct CXIdxIBOutletCollectionAttrInfo
6487 {
6488     const(CXIdxAttrInfo)* attrInfo;
6489     const(CXIdxEntityInfo)* objcClass;
6490     CXCursor classCursor;
6491     CXIdxLoc classLoc;
6492 }
6493 
6494 enum CXIdxDeclInfoFlags
6495 {
6496     skipped = 0x1
6497 }
6498 
6499 struct CXIdxDeclInfo
6500 {
6501     const(CXIdxEntityInfo)* entityInfo;
6502     CXCursor cursor;
6503     CXIdxLoc loc;
6504     const(CXIdxContainerInfo)* semanticContainer;
6505     /**
6506      * Generally same as #semanticContainer but can be different in
6507      * cases like out-of-line C++ member functions.
6508      */
6509     const(CXIdxContainerInfo)* lexicalContainer;
6510     int isRedeclaration;
6511     int isDefinition;
6512     int isContainer;
6513     const(CXIdxContainerInfo)* declAsContainer;
6514     /**
6515      * Whether the declaration exists in code or was created implicitly
6516      * by the compiler, e.g. implicit Objective-C methods for properties.
6517      */
6518     int isImplicit;
6519     const(CXIdxAttrInfo*)* attributes;
6520     uint numAttributes;
6521 
6522     uint flags;
6523 }
6524 
6525 enum CXIdxObjCContainerKind
6526 {
6527     forwardRef = 0,
6528     interface_ = 1,
6529     implementation = 2
6530 }
6531 
6532 struct CXIdxObjCContainerDeclInfo
6533 {
6534     const(CXIdxDeclInfo)* declInfo;
6535     CXIdxObjCContainerKind kind;
6536 }
6537 
6538 struct CXIdxBaseClassInfo
6539 {
6540     const(CXIdxEntityInfo)* base;
6541     CXCursor cursor;
6542     CXIdxLoc loc;
6543 }
6544 
6545 struct CXIdxObjCProtocolRefInfo
6546 {
6547     const(CXIdxEntityInfo)* protocol;
6548     CXCursor cursor;
6549     CXIdxLoc loc;
6550 }
6551 
6552 struct CXIdxObjCProtocolRefListInfo
6553 {
6554     const(CXIdxObjCProtocolRefInfo*)* protocols;
6555     uint numProtocols;
6556 }
6557 
6558 struct CXIdxObjCInterfaceDeclInfo
6559 {
6560     const(CXIdxObjCContainerDeclInfo)* containerInfo;
6561     const(CXIdxBaseClassInfo)* superInfo;
6562     const(CXIdxObjCProtocolRefListInfo)* protocols;
6563 }
6564 
6565 struct CXIdxObjCCategoryDeclInfo
6566 {
6567     const(CXIdxObjCContainerDeclInfo)* containerInfo;
6568     const(CXIdxEntityInfo)* objcClass;
6569     CXCursor classCursor;
6570     CXIdxLoc classLoc;
6571     const(CXIdxObjCProtocolRefListInfo)* protocols;
6572 }
6573 
6574 struct CXIdxObjCPropertyDeclInfo
6575 {
6576     const(CXIdxDeclInfo)* declInfo;
6577     const(CXIdxEntityInfo)* getter;
6578     const(CXIdxEntityInfo)* setter;
6579 }
6580 
6581 struct CXIdxCXXClassDeclInfo
6582 {
6583     const(CXIdxDeclInfo)* declInfo;
6584     const(CXIdxBaseClassInfo*)* bases;
6585     uint numBases;
6586 }
6587 
6588 /**
6589  * Data for IndexerCallbacks#indexEntityReference.
6590  *
6591  * This may be deprecated in a future version as this duplicates
6592  * the \c CXSymbolRole_Implicit bit in \c CXSymbolRole.
6593  */
6594 enum CXIdxEntityRefKind
6595 {
6596     /**
6597      * The entity is referenced directly in user's code.
6598      */
6599     direct = 1,
6600     /**
6601      * An implicit reference, e.g. a reference of an Objective-C method
6602      * via the dot syntax.
6603      */
6604     implicit = 2
6605 }
6606 
6607 /**
6608  * Roles that are attributed to symbol occurrences.
6609  *
6610  * Internal: this currently mirrors low 9 bits of clang::index::SymbolRole with
6611  * higher bits zeroed. These high bits may be exposed in the future.
6612  */
6613 enum CXSymbolRole
6614 {
6615     none = 0,
6616     declaration = 1 << 0,
6617     definition = 1 << 1,
6618     reference = 1 << 2,
6619     read = 1 << 3,
6620     write = 1 << 4,
6621     call = 1 << 5,
6622     dynamic = 1 << 6,
6623     addressOf = 1 << 7,
6624     implicit = 1 << 8
6625 }
6626 
6627 /**
6628  * Data for IndexerCallbacks#indexEntityReference.
6629  */
6630 struct CXIdxEntityRefInfo
6631 {
6632     CXIdxEntityRefKind kind;
6633     /**
6634      * Reference cursor.
6635      */
6636     CXCursor cursor;
6637     CXIdxLoc loc;
6638     /**
6639      * The entity that gets referenced.
6640      */
6641     const(CXIdxEntityInfo)* referencedEntity;
6642     /**
6643      * Immediate "parent" of the reference. For example:
6644      *
6645      * \code
6646      * Foo *var;
6647      * \endcode
6648      *
6649      * The parent of reference of type 'Foo' is the variable 'var'.
6650      * For references inside statement bodies of functions/methods,
6651      * the parentEntity will be the function/method.
6652      */
6653     const(CXIdxEntityInfo)* parentEntity;
6654     /**
6655      * Lexical container context of the reference.
6656      */
6657     const(CXIdxContainerInfo)* container;
6658     /**
6659      * Sets of symbol roles of the reference.
6660      */
6661     CXSymbolRole role;
6662 }
6663 
6664 /**
6665  * A group of callbacks used by #clang_indexSourceFile and
6666  * #clang_indexTranslationUnit.
6667  */
6668 struct IndexerCallbacks
6669 {
6670     /**
6671      * Called periodically to check whether indexing should be aborted.
6672      * Should return 0 to continue, and non-zero to abort.
6673      */
6674     int function(CXClientData client_data, void* reserved) abortQuery;
6675 
6676     /**
6677      * Called at the end of indexing; passes the complete diagnostic set.
6678      */
6679     void function(CXClientData client_data, CXDiagnosticSet, void* reserved) diagnostic;
6680 
6681     CXIdxClientFile function(
6682         CXClientData client_data,
6683         CXFile mainFile,
6684         void* reserved) enteredMainFile;
6685 
6686     /**
6687      * Called when a file gets \#included/\#imported.
6688      */
6689     CXIdxClientFile function(
6690         CXClientData client_data,
6691         const(CXIdxIncludedFileInfo)*) ppIncludedFile;
6692 
6693     /**
6694      * Called when a AST file (PCH or module) gets imported.
6695      *
6696      * AST files will not get indexed (there will not be callbacks to index all
6697      * the entities in an AST file). The recommended action is that, if the AST
6698      * file is not already indexed, to initiate a new indexing job specific to
6699      * the AST file.
6700      */
6701     CXIdxClientASTFile function(
6702         CXClientData client_data,
6703         const(CXIdxImportedASTFileInfo)*) importedASTFile;
6704 
6705     /**
6706      * Called at the beginning of indexing a translation unit.
6707      */
6708     CXIdxClientContainer function(
6709         CXClientData client_data,
6710         void* reserved) startedTranslationUnit;
6711 
6712     void function(CXClientData client_data, const(CXIdxDeclInfo)*) indexDeclaration;
6713 
6714     /**
6715      * Called to index a reference of an entity.
6716      */
6717     void function(
6718         CXClientData client_data,
6719         const(CXIdxEntityRefInfo)*) indexEntityReference;
6720 }
6721 
6722 int clang_index_isEntityObjCContainerKind(CXIdxEntityKind);
6723 const(CXIdxObjCContainerDeclInfo)* clang_index_getObjCContainerDeclInfo(
6724     const(CXIdxDeclInfo)*);
6725 
6726 const(CXIdxObjCInterfaceDeclInfo)* clang_index_getObjCInterfaceDeclInfo(
6727     const(CXIdxDeclInfo)*);
6728 
6729 const(CXIdxObjCCategoryDeclInfo)* clang_index_getObjCCategoryDeclInfo(
6730     const(CXIdxDeclInfo)*);
6731 
6732 const(CXIdxObjCProtocolRefListInfo)* clang_index_getObjCProtocolRefListInfo(
6733     const(CXIdxDeclInfo)*);
6734 
6735 const(CXIdxObjCPropertyDeclInfo)* clang_index_getObjCPropertyDeclInfo(
6736     const(CXIdxDeclInfo)*);
6737 
6738 const(CXIdxIBOutletCollectionAttrInfo)* clang_index_getIBOutletCollectionAttrInfo(
6739     const(CXIdxAttrInfo)*);
6740 
6741 const(CXIdxCXXClassDeclInfo)* clang_index_getCXXClassDeclInfo(
6742     const(CXIdxDeclInfo)*);
6743 
6744 /**
6745  * For retrieving a custom CXIdxClientContainer attached to a
6746  * container.
6747  */
6748 CXIdxClientContainer clang_index_getClientContainer(const(CXIdxContainerInfo)*);
6749 
6750 /**
6751  * For setting a custom CXIdxClientContainer attached to a
6752  * container.
6753  */
6754 void clang_index_setClientContainer(
6755     const(CXIdxContainerInfo)*,
6756     CXIdxClientContainer);
6757 
6758 /**
6759  * For retrieving a custom CXIdxClientEntity attached to an entity.
6760  */
6761 CXIdxClientEntity clang_index_getClientEntity(const(CXIdxEntityInfo)*);
6762 
6763 /**
6764  * For setting a custom CXIdxClientEntity attached to an entity.
6765  */
6766 void clang_index_setClientEntity(const(CXIdxEntityInfo)*, CXIdxClientEntity);
6767 
6768 /**
6769  * An indexing action/session, to be applied to one or multiple
6770  * translation units.
6771  */
6772 alias CXIndexAction = void*;
6773 
6774 /**
6775  * An indexing action/session, to be applied to one or multiple
6776  * translation units.
6777  *
6778  * \param CIdx The index object with which the index action will be associated.
6779  */
6780 CXIndexAction clang_IndexAction_create(CXIndex CIdx);
6781 
6782 /**
6783  * Destroy the given index action.
6784  *
6785  * The index action must not be destroyed until all of the translation units
6786  * created within that index action have been destroyed.
6787  */
6788 void clang_IndexAction_dispose(CXIndexAction);
6789 
6790 enum CXIndexOptFlags
6791 {
6792     /**
6793      * Used to indicate that no special indexing options are needed.
6794      */
6795     none = 0x0,
6796 
6797     /**
6798      * Used to indicate that IndexerCallbacks#indexEntityReference should
6799      * be invoked for only one reference of an entity per source file that does
6800      * not also include a declaration/definition of the entity.
6801      */
6802     suppressRedundantRefs = 0x1,
6803 
6804     /**
6805      * Function-local symbols should be indexed. If this is not set
6806      * function-local symbols will be ignored.
6807      */
6808     indexFunctionLocalSymbols = 0x2,
6809 
6810     /**
6811      * Implicit function/class template instantiations should be indexed.
6812      * If this is not set, implicit instantiations will be ignored.
6813      */
6814     indexImplicitTemplateInstantiations = 0x4,
6815 
6816     /**
6817      * Suppress all compiler warnings when parsing for indexing.
6818      */
6819     suppressWarnings = 0x8,
6820 
6821     /**
6822      * Skip a function/method body that was already parsed during an
6823      * indexing session associated with a \c CXIndexAction object.
6824      * Bodies in system headers are always skipped.
6825      */
6826     skipParsedBodiesInSession = 0x10
6827 }
6828 
6829 /**
6830  * Index the given source file and the translation unit corresponding
6831  * to that file via callbacks implemented through #IndexerCallbacks.
6832  *
6833  * \param client_data pointer data supplied by the client, which will
6834  * be passed to the invoked callbacks.
6835  *
6836  * \param index_callbacks Pointer to indexing callbacks that the client
6837  * implements.
6838  *
6839  * \param index_callbacks_size Size of #IndexerCallbacks structure that gets
6840  * passed in index_callbacks.
6841  *
6842  * \param index_options A bitmask of options that affects how indexing is
6843  * performed. This should be a bitwise OR of the CXIndexOpt_XXX flags.
6844  *
6845  * \param[out] out_TU pointer to store a \c CXTranslationUnit that can be
6846  * reused after indexing is finished. Set to \c NULL if you do not require it.
6847  *
6848  * \returns 0 on success or if there were errors from which the compiler could
6849  * recover.  If there is a failure from which there is no recovery, returns
6850  * a non-zero \c CXErrorCode.
6851  *
6852  * The rest of the parameters are the same as #clang_parseTranslationUnit.
6853  */
6854 int clang_indexSourceFile(
6855     CXIndexAction,
6856     CXClientData client_data,
6857     IndexerCallbacks* index_callbacks,
6858     uint index_callbacks_size,
6859     uint index_options,
6860     const(char)* source_filename,
6861     const(char*)* command_line_args,
6862     int num_command_line_args,
6863     CXUnsavedFile* unsaved_files,
6864     uint num_unsaved_files,
6865     CXTranslationUnit* out_TU,
6866     uint TU_options);
6867 
6868 /**
6869  * Same as clang_indexSourceFile but requires a full command line
6870  * for \c command_line_args including argv[0]. This is useful if the standard
6871  * library paths are relative to the binary.
6872  */
6873 int clang_indexSourceFileFullArgv(
6874     CXIndexAction,
6875     CXClientData client_data,
6876     IndexerCallbacks* index_callbacks,
6877     uint index_callbacks_size,
6878     uint index_options,
6879     const(char)* source_filename,
6880     const(char*)* command_line_args,
6881     int num_command_line_args,
6882     CXUnsavedFile* unsaved_files,
6883     uint num_unsaved_files,
6884     CXTranslationUnit* out_TU,
6885     uint TU_options);
6886 
6887 /**
6888  * Index the given translation unit via callbacks implemented through
6889  * #IndexerCallbacks.
6890  *
6891  * The order of callback invocations is not guaranteed to be the same as
6892  * when indexing a source file. The high level order will be:
6893  *
6894  *   -Preprocessor callbacks invocations
6895  *   -Declaration/reference callbacks invocations
6896  *   -Diagnostic callback invocations
6897  *
6898  * The parameters are the same as #clang_indexSourceFile.
6899  *
6900  * \returns If there is a failure from which there is no recovery, returns
6901  * non-zero, otherwise returns 0.
6902  */
6903 int clang_indexTranslationUnit(
6904     CXIndexAction,
6905     CXClientData client_data,
6906     IndexerCallbacks* index_callbacks,
6907     uint index_callbacks_size,
6908     uint index_options,
6909     CXTranslationUnit);
6910 
6911 /**
6912  * Retrieve the CXIdxFile, file, line, column, and offset represented by
6913  * the given CXIdxLoc.
6914  *
6915  * If the location refers into a macro expansion, retrieves the
6916  * location of the macro expansion and if it refers into a macro argument
6917  * retrieves the location of the argument.
6918  */
6919 void clang_indexLoc_getFileLocation(
6920     CXIdxLoc loc,
6921     CXIdxClientFile* indexFile,
6922     CXFile* file,
6923     uint* line,
6924     uint* column,
6925     uint* offset);
6926 
6927 /**
6928  * Retrieve the CXSourceLocation represented by the given CXIdxLoc.
6929  */
6930 CXSourceLocation clang_indexLoc_getCXSourceLocation(CXIdxLoc loc);
6931 
6932 /**
6933  * Visitor invoked for each field found by a traversal.
6934  *
6935  * This visitor function will be invoked for each field found by
6936  * \c clang_Type_visitFields. Its first argument is the cursor being
6937  * visited, its second argument is the client data provided to
6938  * \c clang_Type_visitFields.
6939  *
6940  * The visitor should return one of the \c CXVisitorResult values
6941  * to direct \c clang_Type_visitFields.
6942  */
6943 alias CXFieldVisitor = CXVisitorResult function(
6944     CXCursor C,
6945     CXClientData client_data);
6946 
6947 /**
6948  * Visit the fields of a particular type.
6949  *
6950  * This function visits all the direct fields of the given cursor,
6951  * invoking the given \p visitor function with the cursors of each
6952  * visited field. The traversal may be ended prematurely, if
6953  * the visitor returns \c CXFieldVisit_Break.
6954  *
6955  * \param T the record type whose field may be visited.
6956  *
6957  * \param visitor the visitor function that will be invoked for each
6958  * field of \p T.
6959  *
6960  * \param client_data pointer data supplied by the client, which will
6961  * be passed to the visitor each time it is invoked.
6962  *
6963  * \returns a non-zero value if the traversal was terminated
6964  * prematurely by the visitor returning \c CXFieldVisit_Break.
6965  */
6966 uint clang_Type_visitFields(
6967     CXType T,
6968     CXFieldVisitor visitor,
6969     CXClientData client_data);
6970 
6971 /**
6972  * @}
6973  */
6974 
6975 /**
6976  * @}
6977  */
6978