xref: /freebsd-src/contrib/llvm-project/clang/include/clang-c/Index.h (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
10b57cec5SDimitry Andric /*===-- clang-c/Index.h - Indexing Public C Interface -------------*- C -*-===*\
20b57cec5SDimitry Andric |*                                                                            *|
30b57cec5SDimitry Andric |* Part of the LLVM Project, under the Apache License v2.0 with LLVM          *|
40b57cec5SDimitry Andric |* Exceptions.                                                                *|
50b57cec5SDimitry Andric |* See https://llvm.org/LICENSE.txt for license information.                  *|
60b57cec5SDimitry Andric |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception                    *|
70b57cec5SDimitry Andric |*                                                                            *|
80b57cec5SDimitry Andric |*===----------------------------------------------------------------------===*|
90b57cec5SDimitry Andric |*                                                                            *|
100b57cec5SDimitry Andric |* This header provides a public interface to a Clang library for extracting  *|
110b57cec5SDimitry Andric |* high-level symbol information from source files without exposing the full  *|
120b57cec5SDimitry Andric |* Clang C++ API.                                                             *|
130b57cec5SDimitry Andric |*                                                                            *|
140b57cec5SDimitry Andric \*===----------------------------------------------------------------------===*/
150b57cec5SDimitry Andric 
160b57cec5SDimitry Andric #ifndef LLVM_CLANG_C_INDEX_H
170b57cec5SDimitry Andric #define LLVM_CLANG_C_INDEX_H
180b57cec5SDimitry Andric 
19480093f4SDimitry Andric #include "clang-c/BuildSystem.h"
20bdd1243dSDimitry Andric #include "clang-c/CXDiagnostic.h"
210b57cec5SDimitry Andric #include "clang-c/CXErrorCode.h"
22bdd1243dSDimitry Andric #include "clang-c/CXFile.h"
23bdd1243dSDimitry Andric #include "clang-c/CXSourceLocation.h"
240b57cec5SDimitry Andric #include "clang-c/CXString.h"
25480093f4SDimitry Andric #include "clang-c/ExternC.h"
26480093f4SDimitry Andric #include "clang-c/Platform.h"
270b57cec5SDimitry Andric 
280b57cec5SDimitry Andric /**
290b57cec5SDimitry Andric  * The version constants for the libclang API.
300b57cec5SDimitry Andric  * CINDEX_VERSION_MINOR should increase when there are API additions.
310b57cec5SDimitry Andric  * CINDEX_VERSION_MAJOR is intended for "major" source/ABI breaking changes.
320b57cec5SDimitry Andric  *
330b57cec5SDimitry Andric  * The policy about the libclang API was always to keep it source and ABI
340b57cec5SDimitry Andric  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
350b57cec5SDimitry Andric  */
360b57cec5SDimitry Andric #define CINDEX_VERSION_MAJOR 0
3706c3fb27SDimitry Andric #define CINDEX_VERSION_MINOR 64
380b57cec5SDimitry Andric 
395ffd83dbSDimitry Andric #define CINDEX_VERSION_ENCODE(major, minor) (((major)*10000) + ((minor)*1))
400b57cec5SDimitry Andric 
415ffd83dbSDimitry Andric #define CINDEX_VERSION                                                         \
425ffd83dbSDimitry Andric   CINDEX_VERSION_ENCODE(CINDEX_VERSION_MAJOR, CINDEX_VERSION_MINOR)
430b57cec5SDimitry Andric 
445ffd83dbSDimitry Andric #define CINDEX_VERSION_STRINGIZE_(major, minor) #major "." #minor
450b57cec5SDimitry Andric #define CINDEX_VERSION_STRINGIZE(major, minor)                                 \
460b57cec5SDimitry Andric   CINDEX_VERSION_STRINGIZE_(major, minor)
470b57cec5SDimitry Andric 
485ffd83dbSDimitry Andric #define CINDEX_VERSION_STRING                                                  \
495ffd83dbSDimitry Andric   CINDEX_VERSION_STRINGIZE(CINDEX_VERSION_MAJOR, CINDEX_VERSION_MINOR)
500b57cec5SDimitry Andric 
5106c3fb27SDimitry Andric #ifndef __has_feature
5206c3fb27SDimitry Andric #define __has_feature(feature) 0
5306c3fb27SDimitry Andric #endif
5406c3fb27SDimitry Andric 
55480093f4SDimitry Andric LLVM_CLANG_C_EXTERN_C_BEGIN
560b57cec5SDimitry Andric 
570b57cec5SDimitry Andric /** \defgroup CINDEX libclang: C Interface to Clang
580b57cec5SDimitry Andric  *
590b57cec5SDimitry Andric  * The C Interface to Clang provides a relatively small API that exposes
600b57cec5SDimitry Andric  * facilities for parsing source code into an abstract syntax tree (AST),
610b57cec5SDimitry Andric  * loading already-parsed ASTs, traversing the AST, associating
620b57cec5SDimitry Andric  * physical source locations with elements within the AST, and other
630b57cec5SDimitry Andric  * facilities that support Clang-based development tools.
640b57cec5SDimitry Andric  *
650b57cec5SDimitry Andric  * This C interface to Clang will never provide all of the information
660b57cec5SDimitry Andric  * representation stored in Clang's C++ AST, nor should it: the intent is to
670b57cec5SDimitry Andric  * maintain an API that is relatively stable from one release to the next,
680b57cec5SDimitry Andric  * providing only the basic functionality needed to support development tools.
690b57cec5SDimitry Andric  *
700b57cec5SDimitry Andric  * To avoid namespace pollution, data types are prefixed with "CX" and
710b57cec5SDimitry Andric  * functions are prefixed with "clang_".
720b57cec5SDimitry Andric  *
730b57cec5SDimitry Andric  * @{
740b57cec5SDimitry Andric  */
750b57cec5SDimitry Andric 
760b57cec5SDimitry Andric /**
770b57cec5SDimitry Andric  * An "index" that consists of a set of translation units that would
780b57cec5SDimitry Andric  * typically be linked together into an executable or library.
790b57cec5SDimitry Andric  */
800b57cec5SDimitry Andric typedef void *CXIndex;
810b57cec5SDimitry Andric 
820b57cec5SDimitry Andric /**
830b57cec5SDimitry Andric  * An opaque type representing target information for a given translation
840b57cec5SDimitry Andric  * unit.
850b57cec5SDimitry Andric  */
860b57cec5SDimitry Andric typedef struct CXTargetInfoImpl *CXTargetInfo;
870b57cec5SDimitry Andric 
880b57cec5SDimitry Andric /**
890b57cec5SDimitry Andric  * A single translation unit, which resides in an index.
900b57cec5SDimitry Andric  */
910b57cec5SDimitry Andric typedef struct CXTranslationUnitImpl *CXTranslationUnit;
920b57cec5SDimitry Andric 
930b57cec5SDimitry Andric /**
940b57cec5SDimitry Andric  * Opaque pointer representing client data that will be passed through
950b57cec5SDimitry Andric  * to various callbacks and visitors.
960b57cec5SDimitry Andric  */
970b57cec5SDimitry Andric typedef void *CXClientData;
980b57cec5SDimitry Andric 
990b57cec5SDimitry Andric /**
1000b57cec5SDimitry Andric  * Provides the contents of a file that has not yet been saved to disk.
1010b57cec5SDimitry Andric  *
1020b57cec5SDimitry Andric  * Each CXUnsavedFile instance provides the name of a file on the
1030b57cec5SDimitry Andric  * system along with the current contents of that file that have not
1040b57cec5SDimitry Andric  * yet been saved to disk.
1050b57cec5SDimitry Andric  */
1060b57cec5SDimitry Andric struct CXUnsavedFile {
1070b57cec5SDimitry Andric   /**
1080b57cec5SDimitry Andric    * The file whose contents have not yet been saved.
1090b57cec5SDimitry Andric    *
1100b57cec5SDimitry Andric    * This file must already exist in the file system.
1110b57cec5SDimitry Andric    */
1120b57cec5SDimitry Andric   const char *Filename;
1130b57cec5SDimitry Andric 
1140b57cec5SDimitry Andric   /**
1150b57cec5SDimitry Andric    * A buffer containing the unsaved contents of this file.
1160b57cec5SDimitry Andric    */
1170b57cec5SDimitry Andric   const char *Contents;
1180b57cec5SDimitry Andric 
1190b57cec5SDimitry Andric   /**
1200b57cec5SDimitry Andric    * The length of the unsaved contents of this buffer.
1210b57cec5SDimitry Andric    */
1220b57cec5SDimitry Andric   unsigned long Length;
1230b57cec5SDimitry Andric };
1240b57cec5SDimitry Andric 
1250b57cec5SDimitry Andric /**
1260b57cec5SDimitry Andric  * Describes the availability of a particular entity, which indicates
1270b57cec5SDimitry Andric  * whether the use of this entity will result in a warning or error due to
1280b57cec5SDimitry Andric  * it being deprecated or unavailable.
1290b57cec5SDimitry Andric  */
1300b57cec5SDimitry Andric enum CXAvailabilityKind {
1310b57cec5SDimitry Andric   /**
1320b57cec5SDimitry Andric    * The entity is available.
1330b57cec5SDimitry Andric    */
1340b57cec5SDimitry Andric   CXAvailability_Available,
1350b57cec5SDimitry Andric   /**
1360b57cec5SDimitry Andric    * The entity is available, but has been deprecated (and its use is
1370b57cec5SDimitry Andric    * not recommended).
1380b57cec5SDimitry Andric    */
1390b57cec5SDimitry Andric   CXAvailability_Deprecated,
1400b57cec5SDimitry Andric   /**
1410b57cec5SDimitry Andric    * The entity is not available; any use of it will be an error.
1420b57cec5SDimitry Andric    */
1430b57cec5SDimitry Andric   CXAvailability_NotAvailable,
1440b57cec5SDimitry Andric   /**
1450b57cec5SDimitry Andric    * The entity is available, but not accessible; any use of it will be
1460b57cec5SDimitry Andric    * an error.
1470b57cec5SDimitry Andric    */
1480b57cec5SDimitry Andric   CXAvailability_NotAccessible
1490b57cec5SDimitry Andric };
1500b57cec5SDimitry Andric 
1510b57cec5SDimitry Andric /**
1520b57cec5SDimitry Andric  * Describes a version number of the form major.minor.subminor.
1530b57cec5SDimitry Andric  */
1540b57cec5SDimitry Andric typedef struct CXVersion {
1550b57cec5SDimitry Andric   /**
1560b57cec5SDimitry Andric    * The major version number, e.g., the '10' in '10.7.3'. A negative
1570b57cec5SDimitry Andric    * value indicates that there is no version number at all.
1580b57cec5SDimitry Andric    */
1590b57cec5SDimitry Andric   int Major;
1600b57cec5SDimitry Andric   /**
1610b57cec5SDimitry Andric    * The minor version number, e.g., the '7' in '10.7.3'. This value
1620b57cec5SDimitry Andric    * will be negative if no minor version number was provided, e.g., for
1630b57cec5SDimitry Andric    * version '10'.
1640b57cec5SDimitry Andric    */
1650b57cec5SDimitry Andric   int Minor;
1660b57cec5SDimitry Andric   /**
1670b57cec5SDimitry Andric    * The subminor version number, e.g., the '3' in '10.7.3'. This value
1680b57cec5SDimitry Andric    * will be negative if no minor or subminor version number was provided,
1690b57cec5SDimitry Andric    * e.g., in version '10' or '10.7'.
1700b57cec5SDimitry Andric    */
1710b57cec5SDimitry Andric   int Subminor;
1720b57cec5SDimitry Andric } CXVersion;
1730b57cec5SDimitry Andric 
1740b57cec5SDimitry Andric /**
1750b57cec5SDimitry Andric  * Describes the exception specification of a cursor.
1760b57cec5SDimitry Andric  *
1770b57cec5SDimitry Andric  * A negative value indicates that the cursor is not a function declaration.
1780b57cec5SDimitry Andric  */
1790b57cec5SDimitry Andric enum CXCursor_ExceptionSpecificationKind {
1800b57cec5SDimitry Andric   /**
1810b57cec5SDimitry Andric    * The cursor has no exception specification.
1820b57cec5SDimitry Andric    */
1830b57cec5SDimitry Andric   CXCursor_ExceptionSpecificationKind_None,
1840b57cec5SDimitry Andric 
1850b57cec5SDimitry Andric   /**
1860b57cec5SDimitry Andric    * The cursor has exception specification throw()
1870b57cec5SDimitry Andric    */
1880b57cec5SDimitry Andric   CXCursor_ExceptionSpecificationKind_DynamicNone,
1890b57cec5SDimitry Andric 
1900b57cec5SDimitry Andric   /**
1910b57cec5SDimitry Andric    * The cursor has exception specification throw(T1, T2)
1920b57cec5SDimitry Andric    */
1930b57cec5SDimitry Andric   CXCursor_ExceptionSpecificationKind_Dynamic,
1940b57cec5SDimitry Andric 
1950b57cec5SDimitry Andric   /**
1960b57cec5SDimitry Andric    * The cursor has exception specification throw(...).
1970b57cec5SDimitry Andric    */
1980b57cec5SDimitry Andric   CXCursor_ExceptionSpecificationKind_MSAny,
1990b57cec5SDimitry Andric 
2000b57cec5SDimitry Andric   /**
2010b57cec5SDimitry Andric    * The cursor has exception specification basic noexcept.
2020b57cec5SDimitry Andric    */
2030b57cec5SDimitry Andric   CXCursor_ExceptionSpecificationKind_BasicNoexcept,
2040b57cec5SDimitry Andric 
2050b57cec5SDimitry Andric   /**
2060b57cec5SDimitry Andric    * The cursor has exception specification computed noexcept.
2070b57cec5SDimitry Andric    */
2080b57cec5SDimitry Andric   CXCursor_ExceptionSpecificationKind_ComputedNoexcept,
2090b57cec5SDimitry Andric 
2100b57cec5SDimitry Andric   /**
2110b57cec5SDimitry Andric    * The exception specification has not yet been evaluated.
2120b57cec5SDimitry Andric    */
2130b57cec5SDimitry Andric   CXCursor_ExceptionSpecificationKind_Unevaluated,
2140b57cec5SDimitry Andric 
2150b57cec5SDimitry Andric   /**
2160b57cec5SDimitry Andric    * The exception specification has not yet been instantiated.
2170b57cec5SDimitry Andric    */
2180b57cec5SDimitry Andric   CXCursor_ExceptionSpecificationKind_Uninstantiated,
2190b57cec5SDimitry Andric 
2200b57cec5SDimitry Andric   /**
2210b57cec5SDimitry Andric    * The exception specification has not been parsed yet.
2220b57cec5SDimitry Andric    */
2230b57cec5SDimitry Andric   CXCursor_ExceptionSpecificationKind_Unparsed,
2240b57cec5SDimitry Andric 
2250b57cec5SDimitry Andric   /**
2260b57cec5SDimitry Andric    * The cursor has a __declspec(nothrow) exception specification.
2270b57cec5SDimitry Andric    */
2280b57cec5SDimitry Andric   CXCursor_ExceptionSpecificationKind_NoThrow
2290b57cec5SDimitry Andric };
2300b57cec5SDimitry Andric 
2310b57cec5SDimitry Andric /**
2320b57cec5SDimitry Andric  * Provides a shared context for creating translation units.
2330b57cec5SDimitry Andric  *
2340b57cec5SDimitry Andric  * It provides two options:
2350b57cec5SDimitry Andric  *
2360b57cec5SDimitry Andric  * - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local"
2370b57cec5SDimitry Andric  * declarations (when loading any new translation units). A "local" declaration
2380b57cec5SDimitry Andric  * is one that belongs in the translation unit itself and not in a precompiled
2390b57cec5SDimitry Andric  * header that was used by the translation unit. If zero, all declarations
2400b57cec5SDimitry Andric  * will be enumerated.
2410b57cec5SDimitry Andric  *
2420b57cec5SDimitry Andric  * Here is an example:
2430b57cec5SDimitry Andric  *
2440b57cec5SDimitry Andric  * \code
2450b57cec5SDimitry Andric  *   // excludeDeclsFromPCH = 1, displayDiagnostics=1
2460b57cec5SDimitry Andric  *   Idx = clang_createIndex(1, 1);
2470b57cec5SDimitry Andric  *
2480b57cec5SDimitry Andric  *   // IndexTest.pch was produced with the following command:
2490b57cec5SDimitry Andric  *   // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch"
2500b57cec5SDimitry Andric  *   TU = clang_createTranslationUnit(Idx, "IndexTest.pch");
2510b57cec5SDimitry Andric  *
2520b57cec5SDimitry Andric  *   // This will load all the symbols from 'IndexTest.pch'
2530b57cec5SDimitry Andric  *   clang_visitChildren(clang_getTranslationUnitCursor(TU),
2540b57cec5SDimitry Andric  *                       TranslationUnitVisitor, 0);
2550b57cec5SDimitry Andric  *   clang_disposeTranslationUnit(TU);
2560b57cec5SDimitry Andric  *
2570b57cec5SDimitry Andric  *   // This will load all the symbols from 'IndexTest.c', excluding symbols
2580b57cec5SDimitry Andric  *   // from 'IndexTest.pch'.
2590b57cec5SDimitry Andric  *   char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" };
2600b57cec5SDimitry Andric  *   TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args,
2610b57cec5SDimitry Andric  *                                                  0, 0);
2620b57cec5SDimitry Andric  *   clang_visitChildren(clang_getTranslationUnitCursor(TU),
2630b57cec5SDimitry Andric  *                       TranslationUnitVisitor, 0);
2640b57cec5SDimitry Andric  *   clang_disposeTranslationUnit(TU);
2650b57cec5SDimitry Andric  * \endcode
2660b57cec5SDimitry Andric  *
2670b57cec5SDimitry Andric  * This process of creating the 'pch', loading it separately, and using it (via
2680b57cec5SDimitry Andric  * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks
2690b57cec5SDimitry Andric  * (which gives the indexer the same performance benefit as the compiler).
2700b57cec5SDimitry Andric  */
2710b57cec5SDimitry Andric CINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH,
2720b57cec5SDimitry Andric                                          int displayDiagnostics);
2730b57cec5SDimitry Andric 
2740b57cec5SDimitry Andric /**
2750b57cec5SDimitry Andric  * Destroy the given index.
2760b57cec5SDimitry Andric  *
2770b57cec5SDimitry Andric  * The index must not be destroyed until all of the translation units created
2780b57cec5SDimitry Andric  * within that index have been destroyed.
2790b57cec5SDimitry Andric  */
2800b57cec5SDimitry Andric CINDEX_LINKAGE void clang_disposeIndex(CXIndex index);
2810b57cec5SDimitry Andric 
2820b57cec5SDimitry Andric typedef enum {
2830b57cec5SDimitry Andric   /**
28406c3fb27SDimitry Andric    * Use the default value of an option that may depend on the process
28506c3fb27SDimitry Andric    * environment.
28606c3fb27SDimitry Andric    */
28706c3fb27SDimitry Andric   CXChoice_Default = 0,
28806c3fb27SDimitry Andric   /**
28906c3fb27SDimitry Andric    * Enable the option.
29006c3fb27SDimitry Andric    */
29106c3fb27SDimitry Andric   CXChoice_Enabled = 1,
29206c3fb27SDimitry Andric   /**
29306c3fb27SDimitry Andric    * Disable the option.
29406c3fb27SDimitry Andric    */
29506c3fb27SDimitry Andric   CXChoice_Disabled = 2
29606c3fb27SDimitry Andric } CXChoice;
29706c3fb27SDimitry Andric 
29806c3fb27SDimitry Andric typedef enum {
29906c3fb27SDimitry Andric   /**
3000b57cec5SDimitry Andric    * Used to indicate that no special CXIndex options are needed.
3010b57cec5SDimitry Andric    */
3020b57cec5SDimitry Andric   CXGlobalOpt_None = 0x0,
3030b57cec5SDimitry Andric 
3040b57cec5SDimitry Andric   /**
3050b57cec5SDimitry Andric    * Used to indicate that threads that libclang creates for indexing
3060b57cec5SDimitry Andric    * purposes should use background priority.
3070b57cec5SDimitry Andric    *
3080b57cec5SDimitry Andric    * Affects #clang_indexSourceFile, #clang_indexTranslationUnit,
3090b57cec5SDimitry Andric    * #clang_parseTranslationUnit, #clang_saveTranslationUnit.
3100b57cec5SDimitry Andric    */
3110b57cec5SDimitry Andric   CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1,
3120b57cec5SDimitry Andric 
3130b57cec5SDimitry Andric   /**
3140b57cec5SDimitry Andric    * Used to indicate that threads that libclang creates for editing
3150b57cec5SDimitry Andric    * purposes should use background priority.
3160b57cec5SDimitry Andric    *
3170b57cec5SDimitry Andric    * Affects #clang_reparseTranslationUnit, #clang_codeCompleteAt,
3180b57cec5SDimitry Andric    * #clang_annotateTokens
3190b57cec5SDimitry Andric    */
3200b57cec5SDimitry Andric   CXGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2,
3210b57cec5SDimitry Andric 
3220b57cec5SDimitry Andric   /**
3230b57cec5SDimitry Andric    * Used to indicate that all threads that libclang creates should use
3240b57cec5SDimitry Andric    * background priority.
3250b57cec5SDimitry Andric    */
3260b57cec5SDimitry Andric   CXGlobalOpt_ThreadBackgroundPriorityForAll =
3270b57cec5SDimitry Andric       CXGlobalOpt_ThreadBackgroundPriorityForIndexing |
3280b57cec5SDimitry Andric       CXGlobalOpt_ThreadBackgroundPriorityForEditing
3290b57cec5SDimitry Andric 
3300b57cec5SDimitry Andric } CXGlobalOptFlags;
3310b57cec5SDimitry Andric 
3320b57cec5SDimitry Andric /**
33306c3fb27SDimitry Andric  * Index initialization options.
33406c3fb27SDimitry Andric  *
33506c3fb27SDimitry Andric  * 0 is the default value of each member of this struct except for Size.
33606c3fb27SDimitry Andric  * Initialize the struct in one of the following three ways to avoid adapting
33706c3fb27SDimitry Andric  * code each time a new member is added to it:
33806c3fb27SDimitry Andric  * \code
33906c3fb27SDimitry Andric  * CXIndexOptions Opts;
34006c3fb27SDimitry Andric  * memset(&Opts, 0, sizeof(Opts));
34106c3fb27SDimitry Andric  * Opts.Size = sizeof(CXIndexOptions);
34206c3fb27SDimitry Andric  * \endcode
34306c3fb27SDimitry Andric  * or explicitly initialize the first data member and zero-initialize the rest:
34406c3fb27SDimitry Andric  * \code
34506c3fb27SDimitry Andric  * CXIndexOptions Opts = { sizeof(CXIndexOptions) };
34606c3fb27SDimitry Andric  * \endcode
34706c3fb27SDimitry Andric  * or to prevent the -Wmissing-field-initializers warning for the above version:
34806c3fb27SDimitry Andric  * \code
34906c3fb27SDimitry Andric  * CXIndexOptions Opts{};
35006c3fb27SDimitry Andric  * Opts.Size = sizeof(CXIndexOptions);
35106c3fb27SDimitry Andric  * \endcode
35206c3fb27SDimitry Andric  */
35306c3fb27SDimitry Andric typedef struct CXIndexOptions {
35406c3fb27SDimitry Andric   /**
35506c3fb27SDimitry Andric    * The size of struct CXIndexOptions used for option versioning.
35606c3fb27SDimitry Andric    *
35706c3fb27SDimitry Andric    * Always initialize this member to sizeof(CXIndexOptions), or assign
35806c3fb27SDimitry Andric    * sizeof(CXIndexOptions) to it right after creating a CXIndexOptions object.
35906c3fb27SDimitry Andric    */
36006c3fb27SDimitry Andric   unsigned Size;
36106c3fb27SDimitry Andric   /**
36206c3fb27SDimitry Andric    * A CXChoice enumerator that specifies the indexing priority policy.
36306c3fb27SDimitry Andric    * \sa CXGlobalOpt_ThreadBackgroundPriorityForIndexing
36406c3fb27SDimitry Andric    */
36506c3fb27SDimitry Andric   unsigned char ThreadBackgroundPriorityForIndexing;
36606c3fb27SDimitry Andric   /**
36706c3fb27SDimitry Andric    * A CXChoice enumerator that specifies the editing priority policy.
36806c3fb27SDimitry Andric    * \sa CXGlobalOpt_ThreadBackgroundPriorityForEditing
36906c3fb27SDimitry Andric    */
37006c3fb27SDimitry Andric   unsigned char ThreadBackgroundPriorityForEditing;
37106c3fb27SDimitry Andric   /**
37206c3fb27SDimitry Andric    * \see clang_createIndex()
37306c3fb27SDimitry Andric    */
37406c3fb27SDimitry Andric   unsigned ExcludeDeclarationsFromPCH : 1;
37506c3fb27SDimitry Andric   /**
37606c3fb27SDimitry Andric    * \see clang_createIndex()
37706c3fb27SDimitry Andric    */
37806c3fb27SDimitry Andric   unsigned DisplayDiagnostics : 1;
37906c3fb27SDimitry Andric   /**
38006c3fb27SDimitry Andric    * Store PCH in memory. If zero, PCH are stored in temporary files.
38106c3fb27SDimitry Andric    */
38206c3fb27SDimitry Andric   unsigned StorePreamblesInMemory : 1;
38306c3fb27SDimitry Andric   unsigned /*Reserved*/ : 13;
38406c3fb27SDimitry Andric 
38506c3fb27SDimitry Andric   /**
38606c3fb27SDimitry Andric    * The path to a directory, in which to store temporary PCH files. If null or
38706c3fb27SDimitry Andric    * empty, the default system temporary directory is used. These PCH files are
38806c3fb27SDimitry Andric    * deleted on clean exit but stay on disk if the program crashes or is killed.
38906c3fb27SDimitry Andric    *
39006c3fb27SDimitry Andric    * This option is ignored if \a StorePreamblesInMemory is non-zero.
39106c3fb27SDimitry Andric    *
39206c3fb27SDimitry Andric    * Libclang does not create the directory at the specified path in the file
39306c3fb27SDimitry Andric    * system. Therefore it must exist, or storing PCH files will fail.
39406c3fb27SDimitry Andric    */
39506c3fb27SDimitry Andric   const char *PreambleStoragePath;
39606c3fb27SDimitry Andric   /**
39706c3fb27SDimitry Andric    * Specifies a path which will contain log files for certain libclang
39806c3fb27SDimitry Andric    * invocations. A null value implies that libclang invocations are not logged.
39906c3fb27SDimitry Andric    */
40006c3fb27SDimitry Andric   const char *InvocationEmissionPath;
40106c3fb27SDimitry Andric } CXIndexOptions;
40206c3fb27SDimitry Andric 
40306c3fb27SDimitry Andric /**
40406c3fb27SDimitry Andric  * Provides a shared context for creating translation units.
40506c3fb27SDimitry Andric  *
40606c3fb27SDimitry Andric  * Call this function instead of clang_createIndex() if you need to configure
40706c3fb27SDimitry Andric  * the additional options in CXIndexOptions.
40806c3fb27SDimitry Andric  *
40906c3fb27SDimitry Andric  * \returns The created index or null in case of error, such as an unsupported
41006c3fb27SDimitry Andric  * value of options->Size.
41106c3fb27SDimitry Andric  *
41206c3fb27SDimitry Andric  * For example:
41306c3fb27SDimitry Andric  * \code
41406c3fb27SDimitry Andric  * CXIndex createIndex(const char *ApplicationTemporaryPath) {
41506c3fb27SDimitry Andric  *   const int ExcludeDeclarationsFromPCH = 1;
41606c3fb27SDimitry Andric  *   const int DisplayDiagnostics = 1;
41706c3fb27SDimitry Andric  *   CXIndex Idx;
41806c3fb27SDimitry Andric  * #if CINDEX_VERSION_MINOR >= 64
41906c3fb27SDimitry Andric  *   CXIndexOptions Opts;
42006c3fb27SDimitry Andric  *   memset(&Opts, 0, sizeof(Opts));
42106c3fb27SDimitry Andric  *   Opts.Size = sizeof(CXIndexOptions);
42206c3fb27SDimitry Andric  *   Opts.ThreadBackgroundPriorityForIndexing = 1;
42306c3fb27SDimitry Andric  *   Opts.ExcludeDeclarationsFromPCH = ExcludeDeclarationsFromPCH;
42406c3fb27SDimitry Andric  *   Opts.DisplayDiagnostics = DisplayDiagnostics;
42506c3fb27SDimitry Andric  *   Opts.PreambleStoragePath = ApplicationTemporaryPath;
42606c3fb27SDimitry Andric  *   Idx = clang_createIndexWithOptions(&Opts);
42706c3fb27SDimitry Andric  *   if (Idx)
42806c3fb27SDimitry Andric  *     return Idx;
42906c3fb27SDimitry Andric  *   fprintf(stderr,
43006c3fb27SDimitry Andric  *           "clang_createIndexWithOptions() failed. "
43106c3fb27SDimitry Andric  *           "CINDEX_VERSION_MINOR = %d, sizeof(CXIndexOptions) = %u\n",
43206c3fb27SDimitry Andric  *           CINDEX_VERSION_MINOR, Opts.Size);
43306c3fb27SDimitry Andric  * #else
43406c3fb27SDimitry Andric  *   (void)ApplicationTemporaryPath;
43506c3fb27SDimitry Andric  * #endif
43606c3fb27SDimitry Andric  *   Idx = clang_createIndex(ExcludeDeclarationsFromPCH, DisplayDiagnostics);
43706c3fb27SDimitry Andric  *   clang_CXIndex_setGlobalOptions(
43806c3fb27SDimitry Andric  *       Idx, clang_CXIndex_getGlobalOptions(Idx) |
43906c3fb27SDimitry Andric  *                CXGlobalOpt_ThreadBackgroundPriorityForIndexing);
44006c3fb27SDimitry Andric  *   return Idx;
44106c3fb27SDimitry Andric  * }
44206c3fb27SDimitry Andric  * \endcode
44306c3fb27SDimitry Andric  *
44406c3fb27SDimitry Andric  * \sa clang_createIndex()
44506c3fb27SDimitry Andric  */
44606c3fb27SDimitry Andric CINDEX_LINKAGE CXIndex
44706c3fb27SDimitry Andric clang_createIndexWithOptions(const CXIndexOptions *options);
44806c3fb27SDimitry Andric 
44906c3fb27SDimitry Andric /**
4500b57cec5SDimitry Andric  * Sets general options associated with a CXIndex.
4510b57cec5SDimitry Andric  *
45206c3fb27SDimitry Andric  * This function is DEPRECATED. Set
45306c3fb27SDimitry Andric  * CXIndexOptions::ThreadBackgroundPriorityForIndexing and/or
45406c3fb27SDimitry Andric  * CXIndexOptions::ThreadBackgroundPriorityForEditing and call
45506c3fb27SDimitry Andric  * clang_createIndexWithOptions() instead.
45606c3fb27SDimitry Andric  *
4570b57cec5SDimitry Andric  * For example:
4580b57cec5SDimitry Andric  * \code
4590b57cec5SDimitry Andric  * CXIndex idx = ...;
4600b57cec5SDimitry Andric  * clang_CXIndex_setGlobalOptions(idx,
4610b57cec5SDimitry Andric  *     clang_CXIndex_getGlobalOptions(idx) |
4620b57cec5SDimitry Andric  *     CXGlobalOpt_ThreadBackgroundPriorityForIndexing);
4630b57cec5SDimitry Andric  * \endcode
4640b57cec5SDimitry Andric  *
4650b57cec5SDimitry Andric  * \param options A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags.
4660b57cec5SDimitry Andric  */
4670b57cec5SDimitry Andric CINDEX_LINKAGE void clang_CXIndex_setGlobalOptions(CXIndex, unsigned options);
4680b57cec5SDimitry Andric 
4690b57cec5SDimitry Andric /**
4700b57cec5SDimitry Andric  * Gets the general options associated with a CXIndex.
4710b57cec5SDimitry Andric  *
47206c3fb27SDimitry Andric  * This function allows to obtain the final option values used by libclang after
47306c3fb27SDimitry Andric  * specifying the option policies via CXChoice enumerators.
47406c3fb27SDimitry Andric  *
4750b57cec5SDimitry Andric  * \returns A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags that
4760b57cec5SDimitry Andric  * are associated with the given CXIndex object.
4770b57cec5SDimitry Andric  */
4780b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_CXIndex_getGlobalOptions(CXIndex);
4790b57cec5SDimitry Andric 
4800b57cec5SDimitry Andric /**
4810b57cec5SDimitry Andric  * Sets the invocation emission path option in a CXIndex.
4820b57cec5SDimitry Andric  *
48306c3fb27SDimitry Andric  * This function is DEPRECATED. Set CXIndexOptions::InvocationEmissionPath and
48406c3fb27SDimitry Andric  * call clang_createIndexWithOptions() instead.
48506c3fb27SDimitry Andric  *
4860b57cec5SDimitry Andric  * The invocation emission path specifies a path which will contain log
4870b57cec5SDimitry Andric  * files for certain libclang invocations. A null value (default) implies that
4880b57cec5SDimitry Andric  * libclang invocations are not logged..
4890b57cec5SDimitry Andric  */
4900b57cec5SDimitry Andric CINDEX_LINKAGE void
4910b57cec5SDimitry Andric clang_CXIndex_setInvocationEmissionPathOption(CXIndex, const char *Path);
4920b57cec5SDimitry Andric 
4930b57cec5SDimitry Andric /**
4940b57cec5SDimitry Andric  * Determine whether the given header is guarded against
4950b57cec5SDimitry Andric  * multiple inclusions, either with the conventional
4960b57cec5SDimitry Andric  * \#ifndef/\#define/\#endif macro guards or with \#pragma once.
4970b57cec5SDimitry Andric  */
4985ffd83dbSDimitry Andric CINDEX_LINKAGE unsigned clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu,
4995ffd83dbSDimitry Andric                                                            CXFile file);
5000b57cec5SDimitry Andric 
5010b57cec5SDimitry Andric /**
5020b57cec5SDimitry Andric  * Retrieve a file handle within the given translation unit.
5030b57cec5SDimitry Andric  *
5040b57cec5SDimitry Andric  * \param tu the translation unit
5050b57cec5SDimitry Andric  *
5060b57cec5SDimitry Andric  * \param file_name the name of the file.
5070b57cec5SDimitry Andric  *
5080b57cec5SDimitry Andric  * \returns the file handle for the named file in the translation unit \p tu,
5090b57cec5SDimitry Andric  * or a NULL file handle if the file was not a part of this translation unit.
5100b57cec5SDimitry Andric  */
5110b57cec5SDimitry Andric CINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu,
5120b57cec5SDimitry Andric                                     const char *file_name);
5130b57cec5SDimitry Andric 
5140b57cec5SDimitry Andric /**
5150b57cec5SDimitry Andric  * Retrieve the buffer associated with the given file.
5160b57cec5SDimitry Andric  *
5170b57cec5SDimitry Andric  * \param tu the translation unit
5180b57cec5SDimitry Andric  *
5190b57cec5SDimitry Andric  * \param file the file for which to retrieve the buffer.
5200b57cec5SDimitry Andric  *
5210b57cec5SDimitry Andric  * \param size [out] if non-NULL, will be set to the size of the buffer.
5220b57cec5SDimitry Andric  *
5230b57cec5SDimitry Andric  * \returns a pointer to the buffer in memory that holds the contents of
5240b57cec5SDimitry Andric  * \p file, or a NULL pointer when the file is not loaded.
5250b57cec5SDimitry Andric  */
5260b57cec5SDimitry Andric CINDEX_LINKAGE const char *clang_getFileContents(CXTranslationUnit tu,
5270b57cec5SDimitry Andric                                                  CXFile file, size_t *size);
5280b57cec5SDimitry Andric 
5290b57cec5SDimitry Andric /**
5300b57cec5SDimitry Andric  * Retrieves the source location associated with a given file/line/column
5310b57cec5SDimitry Andric  * in a particular translation unit.
5320b57cec5SDimitry Andric  */
5330b57cec5SDimitry Andric CINDEX_LINKAGE CXSourceLocation clang_getLocation(CXTranslationUnit tu,
5345ffd83dbSDimitry Andric                                                   CXFile file, unsigned line,
5350b57cec5SDimitry Andric                                                   unsigned column);
5360b57cec5SDimitry Andric /**
5370b57cec5SDimitry Andric  * Retrieves the source location associated with a given character offset
5380b57cec5SDimitry Andric  * in a particular translation unit.
5390b57cec5SDimitry Andric  */
5400b57cec5SDimitry Andric CINDEX_LINKAGE CXSourceLocation clang_getLocationForOffset(CXTranslationUnit tu,
5410b57cec5SDimitry Andric                                                            CXFile file,
5420b57cec5SDimitry Andric                                                            unsigned offset);
5430b57cec5SDimitry Andric 
5440b57cec5SDimitry Andric /**
5450b57cec5SDimitry Andric  * Retrieve all ranges that were skipped by the preprocessor.
5460b57cec5SDimitry Andric  *
5470b57cec5SDimitry Andric  * The preprocessor will skip lines when they are surrounded by an
5480b57cec5SDimitry Andric  * if/ifdef/ifndef directive whose condition does not evaluate to true.
5490b57cec5SDimitry Andric  */
5500b57cec5SDimitry Andric CINDEX_LINKAGE CXSourceRangeList *clang_getSkippedRanges(CXTranslationUnit tu,
5510b57cec5SDimitry Andric                                                          CXFile file);
5520b57cec5SDimitry Andric 
5530b57cec5SDimitry Andric /**
5540b57cec5SDimitry Andric  * Retrieve all ranges from all files that were skipped by the
5550b57cec5SDimitry Andric  * preprocessor.
5560b57cec5SDimitry Andric  *
5570b57cec5SDimitry Andric  * The preprocessor will skip lines when they are surrounded by an
5580b57cec5SDimitry Andric  * if/ifdef/ifndef directive whose condition does not evaluate to true.
5590b57cec5SDimitry Andric  */
5605ffd83dbSDimitry Andric CINDEX_LINKAGE CXSourceRangeList *
5615ffd83dbSDimitry Andric clang_getAllSkippedRanges(CXTranslationUnit tu);
5620b57cec5SDimitry Andric 
5630b57cec5SDimitry Andric /**
5640b57cec5SDimitry Andric  * Determine the number of diagnostics produced for the given
5650b57cec5SDimitry Andric  * translation unit.
5660b57cec5SDimitry Andric  */
5670b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_getNumDiagnostics(CXTranslationUnit Unit);
5680b57cec5SDimitry Andric 
5690b57cec5SDimitry Andric /**
5700b57cec5SDimitry Andric  * Retrieve a diagnostic associated with the given translation unit.
5710b57cec5SDimitry Andric  *
5720b57cec5SDimitry Andric  * \param Unit the translation unit to query.
5730b57cec5SDimitry Andric  * \param Index the zero-based diagnostic number to retrieve.
5740b57cec5SDimitry Andric  *
5750b57cec5SDimitry Andric  * \returns the requested diagnostic. This diagnostic must be freed
5760b57cec5SDimitry Andric  * via a call to \c clang_disposeDiagnostic().
5770b57cec5SDimitry Andric  */
5780b57cec5SDimitry Andric CINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit,
5790b57cec5SDimitry Andric                                                 unsigned Index);
5800b57cec5SDimitry Andric 
5810b57cec5SDimitry Andric /**
5820b57cec5SDimitry Andric  * Retrieve the complete set of diagnostics associated with a
5830b57cec5SDimitry Andric  *        translation unit.
5840b57cec5SDimitry Andric  *
5850b57cec5SDimitry Andric  * \param Unit the translation unit to query.
5860b57cec5SDimitry Andric  */
5870b57cec5SDimitry Andric CINDEX_LINKAGE CXDiagnosticSet
5880b57cec5SDimitry Andric clang_getDiagnosticSetFromTU(CXTranslationUnit Unit);
5890b57cec5SDimitry Andric 
5900b57cec5SDimitry Andric /**
5910b57cec5SDimitry Andric  * \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation
5920b57cec5SDimitry Andric  *
5930b57cec5SDimitry Andric  * The routines in this group provide the ability to create and destroy
5940b57cec5SDimitry Andric  * translation units from files, either by parsing the contents of the files or
5950b57cec5SDimitry Andric  * by reading in a serialized representation of a translation unit.
5960b57cec5SDimitry Andric  *
5970b57cec5SDimitry Andric  * @{
5980b57cec5SDimitry Andric  */
5990b57cec5SDimitry Andric 
6000b57cec5SDimitry Andric /**
6010b57cec5SDimitry Andric  * Get the original translation unit source file name.
6020b57cec5SDimitry Andric  */
6030b57cec5SDimitry Andric CINDEX_LINKAGE CXString
6040b57cec5SDimitry Andric clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit);
6050b57cec5SDimitry Andric 
6060b57cec5SDimitry Andric /**
6070b57cec5SDimitry Andric  * Return the CXTranslationUnit for a given source file and the provided
6080b57cec5SDimitry Andric  * command line arguments one would pass to the compiler.
6090b57cec5SDimitry Andric  *
6100b57cec5SDimitry Andric  * Note: The 'source_filename' argument is optional.  If the caller provides a
6110b57cec5SDimitry Andric  * NULL pointer, the name of the source file is expected to reside in the
6120b57cec5SDimitry Andric  * specified command line arguments.
6130b57cec5SDimitry Andric  *
6140b57cec5SDimitry Andric  * Note: When encountered in 'clang_command_line_args', the following options
6150b57cec5SDimitry Andric  * are ignored:
6160b57cec5SDimitry Andric  *
6170b57cec5SDimitry Andric  *   '-c'
6180b57cec5SDimitry Andric  *   '-emit-ast'
6190b57cec5SDimitry Andric  *   '-fsyntax-only'
6200b57cec5SDimitry Andric  *   '-o \<output file>'  (both '-o' and '\<output file>' are ignored)
6210b57cec5SDimitry Andric  *
6220b57cec5SDimitry Andric  * \param CIdx The index object with which the translation unit will be
6230b57cec5SDimitry Andric  * associated.
6240b57cec5SDimitry Andric  *
6250b57cec5SDimitry Andric  * \param source_filename The name of the source file to load, or NULL if the
6260b57cec5SDimitry Andric  * source file is included in \p clang_command_line_args.
6270b57cec5SDimitry Andric  *
6280b57cec5SDimitry Andric  * \param num_clang_command_line_args The number of command-line arguments in
6290b57cec5SDimitry Andric  * \p clang_command_line_args.
6300b57cec5SDimitry Andric  *
6310b57cec5SDimitry Andric  * \param clang_command_line_args The command-line arguments that would be
6320b57cec5SDimitry Andric  * passed to the \c clang executable if it were being invoked out-of-process.
6330b57cec5SDimitry Andric  * These command-line options will be parsed and will affect how the translation
6340b57cec5SDimitry Andric  * unit is parsed. Note that the following options are ignored: '-c',
6350b57cec5SDimitry Andric  * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
6360b57cec5SDimitry Andric  *
6370b57cec5SDimitry Andric  * \param num_unsaved_files the number of unsaved file entries in \p
6380b57cec5SDimitry Andric  * unsaved_files.
6390b57cec5SDimitry Andric  *
6400b57cec5SDimitry Andric  * \param unsaved_files the files that have not yet been saved to disk
6410b57cec5SDimitry Andric  * but may be required for code completion, including the contents of
6420b57cec5SDimitry Andric  * those files.  The contents and name of these files (as specified by
6430b57cec5SDimitry Andric  * CXUnsavedFile) are copied when necessary, so the client only needs to
6440b57cec5SDimitry Andric  * guarantee their validity until the call to this function returns.
6450b57cec5SDimitry Andric  */
6460b57cec5SDimitry Andric CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnitFromSourceFile(
6475ffd83dbSDimitry Andric     CXIndex CIdx, const char *source_filename, int num_clang_command_line_args,
6485ffd83dbSDimitry Andric     const char *const *clang_command_line_args, unsigned num_unsaved_files,
6490b57cec5SDimitry Andric     struct CXUnsavedFile *unsaved_files);
6500b57cec5SDimitry Andric 
6510b57cec5SDimitry Andric /**
6520b57cec5SDimitry Andric  * Same as \c clang_createTranslationUnit2, but returns
6530b57cec5SDimitry Andric  * the \c CXTranslationUnit instead of an error code.  In case of an error this
6540b57cec5SDimitry Andric  * routine returns a \c NULL \c CXTranslationUnit, without further detailed
6550b57cec5SDimitry Andric  * error codes.
6560b57cec5SDimitry Andric  */
6575ffd83dbSDimitry Andric CINDEX_LINKAGE CXTranslationUnit
6585ffd83dbSDimitry Andric clang_createTranslationUnit(CXIndex CIdx, const char *ast_filename);
6590b57cec5SDimitry Andric 
6600b57cec5SDimitry Andric /**
6610b57cec5SDimitry Andric  * Create a translation unit from an AST file (\c -emit-ast).
6620b57cec5SDimitry Andric  *
6630b57cec5SDimitry Andric  * \param[out] out_TU A non-NULL pointer to store the created
6640b57cec5SDimitry Andric  * \c CXTranslationUnit.
6650b57cec5SDimitry Andric  *
6660b57cec5SDimitry Andric  * \returns Zero on success, otherwise returns an error code.
6670b57cec5SDimitry Andric  */
6685ffd83dbSDimitry Andric CINDEX_LINKAGE enum CXErrorCode
6695ffd83dbSDimitry Andric clang_createTranslationUnit2(CXIndex CIdx, const char *ast_filename,
6700b57cec5SDimitry Andric                              CXTranslationUnit *out_TU);
6710b57cec5SDimitry Andric 
6720b57cec5SDimitry Andric /**
6730b57cec5SDimitry Andric  * Flags that control the creation of translation units.
6740b57cec5SDimitry Andric  *
6750b57cec5SDimitry Andric  * The enumerators in this enumeration type are meant to be bitwise
6760b57cec5SDimitry Andric  * ORed together to specify which options should be used when
6770b57cec5SDimitry Andric  * constructing the translation unit.
6780b57cec5SDimitry Andric  */
6790b57cec5SDimitry Andric enum CXTranslationUnit_Flags {
6800b57cec5SDimitry Andric   /**
6810b57cec5SDimitry Andric    * Used to indicate that no special translation-unit options are
6820b57cec5SDimitry Andric    * needed.
6830b57cec5SDimitry Andric    */
6840b57cec5SDimitry Andric   CXTranslationUnit_None = 0x0,
6850b57cec5SDimitry Andric 
6860b57cec5SDimitry Andric   /**
6870b57cec5SDimitry Andric    * Used to indicate that the parser should construct a "detailed"
6880b57cec5SDimitry Andric    * preprocessing record, including all macro definitions and instantiations.
6890b57cec5SDimitry Andric    *
6900b57cec5SDimitry Andric    * Constructing a detailed preprocessing record requires more memory
6910b57cec5SDimitry Andric    * and time to parse, since the information contained in the record
6920b57cec5SDimitry Andric    * is usually not retained. However, it can be useful for
6930b57cec5SDimitry Andric    * applications that require more detailed information about the
6940b57cec5SDimitry Andric    * behavior of the preprocessor.
6950b57cec5SDimitry Andric    */
6960b57cec5SDimitry Andric   CXTranslationUnit_DetailedPreprocessingRecord = 0x01,
6970b57cec5SDimitry Andric 
6980b57cec5SDimitry Andric   /**
6990b57cec5SDimitry Andric    * Used to indicate that the translation unit is incomplete.
7000b57cec5SDimitry Andric    *
7010b57cec5SDimitry Andric    * When a translation unit is considered "incomplete", semantic
7020b57cec5SDimitry Andric    * analysis that is typically performed at the end of the
7030b57cec5SDimitry Andric    * translation unit will be suppressed. For example, this suppresses
7040b57cec5SDimitry Andric    * the completion of tentative declarations in C and of
7050b57cec5SDimitry Andric    * instantiation of implicitly-instantiation function templates in
7060b57cec5SDimitry Andric    * C++. This option is typically used when parsing a header with the
7070b57cec5SDimitry Andric    * intent of producing a precompiled header.
7080b57cec5SDimitry Andric    */
7090b57cec5SDimitry Andric   CXTranslationUnit_Incomplete = 0x02,
7100b57cec5SDimitry Andric 
7110b57cec5SDimitry Andric   /**
7120b57cec5SDimitry Andric    * Used to indicate that the translation unit should be built with an
7130b57cec5SDimitry Andric    * implicit precompiled header for the preamble.
7140b57cec5SDimitry Andric    *
7150b57cec5SDimitry Andric    * An implicit precompiled header is used as an optimization when a
7160b57cec5SDimitry Andric    * particular translation unit is likely to be reparsed many times
7170b57cec5SDimitry Andric    * when the sources aren't changing that often. In this case, an
7180b57cec5SDimitry Andric    * implicit precompiled header will be built containing all of the
7190b57cec5SDimitry Andric    * initial includes at the top of the main file (what we refer to as
7200b57cec5SDimitry Andric    * the "preamble" of the file). In subsequent parses, if the
7210b57cec5SDimitry Andric    * preamble or the files in it have not changed, \c
7220b57cec5SDimitry Andric    * clang_reparseTranslationUnit() will re-use the implicit
7230b57cec5SDimitry Andric    * precompiled header to improve parsing performance.
7240b57cec5SDimitry Andric    */
7250b57cec5SDimitry Andric   CXTranslationUnit_PrecompiledPreamble = 0x04,
7260b57cec5SDimitry Andric 
7270b57cec5SDimitry Andric   /**
7280b57cec5SDimitry Andric    * Used to indicate that the translation unit should cache some
7290b57cec5SDimitry Andric    * code-completion results with each reparse of the source file.
7300b57cec5SDimitry Andric    *
7310b57cec5SDimitry Andric    * Caching of code-completion results is a performance optimization that
7320b57cec5SDimitry Andric    * introduces some overhead to reparsing but improves the performance of
7330b57cec5SDimitry Andric    * code-completion operations.
7340b57cec5SDimitry Andric    */
7350b57cec5SDimitry Andric   CXTranslationUnit_CacheCompletionResults = 0x08,
7360b57cec5SDimitry Andric 
7370b57cec5SDimitry Andric   /**
7380b57cec5SDimitry Andric    * Used to indicate that the translation unit will be serialized with
7390b57cec5SDimitry Andric    * \c clang_saveTranslationUnit.
7400b57cec5SDimitry Andric    *
7410b57cec5SDimitry Andric    * This option is typically used when parsing a header with the intent of
7420b57cec5SDimitry Andric    * producing a precompiled header.
7430b57cec5SDimitry Andric    */
7440b57cec5SDimitry Andric   CXTranslationUnit_ForSerialization = 0x10,
7450b57cec5SDimitry Andric 
7460b57cec5SDimitry Andric   /**
7470b57cec5SDimitry Andric    * DEPRECATED: Enabled chained precompiled preambles in C++.
7480b57cec5SDimitry Andric    *
7490b57cec5SDimitry Andric    * Note: this is a *temporary* option that is available only while
7500b57cec5SDimitry Andric    * we are testing C++ precompiled preamble support. It is deprecated.
7510b57cec5SDimitry Andric    */
7520b57cec5SDimitry Andric   CXTranslationUnit_CXXChainedPCH = 0x20,
7530b57cec5SDimitry Andric 
7540b57cec5SDimitry Andric   /**
7550b57cec5SDimitry Andric    * Used to indicate that function/method bodies should be skipped while
7560b57cec5SDimitry Andric    * parsing.
7570b57cec5SDimitry Andric    *
7580b57cec5SDimitry Andric    * This option can be used to search for declarations/definitions while
7590b57cec5SDimitry Andric    * ignoring the usages.
7600b57cec5SDimitry Andric    */
7610b57cec5SDimitry Andric   CXTranslationUnit_SkipFunctionBodies = 0x40,
7620b57cec5SDimitry Andric 
7630b57cec5SDimitry Andric   /**
7640b57cec5SDimitry Andric    * Used to indicate that brief documentation comments should be
7650b57cec5SDimitry Andric    * included into the set of code completions returned from this translation
7660b57cec5SDimitry Andric    * unit.
7670b57cec5SDimitry Andric    */
7680b57cec5SDimitry Andric   CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 0x80,
7690b57cec5SDimitry Andric 
7700b57cec5SDimitry Andric   /**
7710b57cec5SDimitry Andric    * Used to indicate that the precompiled preamble should be created on
7720b57cec5SDimitry Andric    * the first parse. Otherwise it will be created on the first reparse. This
7730b57cec5SDimitry Andric    * trades runtime on the first parse (serializing the preamble takes time) for
7740b57cec5SDimitry Andric    * reduced runtime on the second parse (can now reuse the preamble).
7750b57cec5SDimitry Andric    */
7760b57cec5SDimitry Andric   CXTranslationUnit_CreatePreambleOnFirstParse = 0x100,
7770b57cec5SDimitry Andric 
7780b57cec5SDimitry Andric   /**
7790b57cec5SDimitry Andric    * Do not stop processing when fatal errors are encountered.
7800b57cec5SDimitry Andric    *
7810b57cec5SDimitry Andric    * When fatal errors are encountered while parsing a translation unit,
7820b57cec5SDimitry Andric    * semantic analysis is typically stopped early when compiling code. A common
7830b57cec5SDimitry Andric    * source for fatal errors are unresolvable include files. For the
7840b57cec5SDimitry Andric    * purposes of an IDE, this is undesirable behavior and as much information
7850b57cec5SDimitry Andric    * as possible should be reported. Use this flag to enable this behavior.
7860b57cec5SDimitry Andric    */
7870b57cec5SDimitry Andric   CXTranslationUnit_KeepGoing = 0x200,
7880b57cec5SDimitry Andric 
7890b57cec5SDimitry Andric   /**
7900b57cec5SDimitry Andric    * Sets the preprocessor in a mode for parsing a single file only.
7910b57cec5SDimitry Andric    */
7920b57cec5SDimitry Andric   CXTranslationUnit_SingleFileParse = 0x400,
7930b57cec5SDimitry Andric 
7940b57cec5SDimitry Andric   /**
7950b57cec5SDimitry Andric    * Used in combination with CXTranslationUnit_SkipFunctionBodies to
7960b57cec5SDimitry Andric    * constrain the skipping of function bodies to the preamble.
7970b57cec5SDimitry Andric    *
7980b57cec5SDimitry Andric    * The function bodies of the main file are not skipped.
7990b57cec5SDimitry Andric    */
8000b57cec5SDimitry Andric   CXTranslationUnit_LimitSkipFunctionBodiesToPreamble = 0x800,
8010b57cec5SDimitry Andric 
8020b57cec5SDimitry Andric   /**
8030b57cec5SDimitry Andric    * Used to indicate that attributed types should be included in CXType.
8040b57cec5SDimitry Andric    */
8050b57cec5SDimitry Andric   CXTranslationUnit_IncludeAttributedTypes = 0x1000,
8060b57cec5SDimitry Andric 
8070b57cec5SDimitry Andric   /**
8080b57cec5SDimitry Andric    * Used to indicate that implicit attributes should be visited.
8090b57cec5SDimitry Andric    */
8100b57cec5SDimitry Andric   CXTranslationUnit_VisitImplicitAttributes = 0x2000,
8110b57cec5SDimitry Andric 
8120b57cec5SDimitry Andric   /**
8130b57cec5SDimitry Andric    * Used to indicate that non-errors from included files should be ignored.
8140b57cec5SDimitry Andric    *
8150b57cec5SDimitry Andric    * If set, clang_getDiagnosticSetFromTU() will not report e.g. warnings from
8160b57cec5SDimitry Andric    * included files anymore. This speeds up clang_getDiagnosticSetFromTU() for
8170b57cec5SDimitry Andric    * the case where these warnings are not of interest, as for an IDE for
8180b57cec5SDimitry Andric    * example, which typically shows only the diagnostics in the main file.
8190b57cec5SDimitry Andric    */
820a7dea167SDimitry Andric   CXTranslationUnit_IgnoreNonErrorsFromIncludedFiles = 0x4000,
821a7dea167SDimitry Andric 
822a7dea167SDimitry Andric   /**
823a7dea167SDimitry Andric    * Tells the preprocessor not to skip excluded conditional blocks.
824a7dea167SDimitry Andric    */
825a7dea167SDimitry Andric   CXTranslationUnit_RetainExcludedConditionalBlocks = 0x8000
8260b57cec5SDimitry Andric };
8270b57cec5SDimitry Andric 
8280b57cec5SDimitry Andric /**
8290b57cec5SDimitry Andric  * Returns the set of flags that is suitable for parsing a translation
8300b57cec5SDimitry Andric  * unit that is being edited.
8310b57cec5SDimitry Andric  *
8320b57cec5SDimitry Andric  * The set of flags returned provide options for \c clang_parseTranslationUnit()
8330b57cec5SDimitry Andric  * to indicate that the translation unit is likely to be reparsed many times,
8340b57cec5SDimitry Andric  * either explicitly (via \c clang_reparseTranslationUnit()) or implicitly
8350b57cec5SDimitry Andric  * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag
8360b57cec5SDimitry Andric  * set contains an unspecified set of optimizations (e.g., the precompiled
8370b57cec5SDimitry Andric  * preamble) geared toward improving the performance of these routines. The
8380b57cec5SDimitry Andric  * set of optimizations enabled may change from one version to the next.
8390b57cec5SDimitry Andric  */
8400b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_defaultEditingTranslationUnitOptions(void);
8410b57cec5SDimitry Andric 
8420b57cec5SDimitry Andric /**
8430b57cec5SDimitry Andric  * Same as \c clang_parseTranslationUnit2, but returns
8440b57cec5SDimitry Andric  * the \c CXTranslationUnit instead of an error code.  In case of an error this
8450b57cec5SDimitry Andric  * routine returns a \c NULL \c CXTranslationUnit, without further detailed
8460b57cec5SDimitry Andric  * error codes.
8470b57cec5SDimitry Andric  */
8485ffd83dbSDimitry Andric CINDEX_LINKAGE CXTranslationUnit clang_parseTranslationUnit(
8495ffd83dbSDimitry Andric     CXIndex CIdx, const char *source_filename,
8505ffd83dbSDimitry Andric     const char *const *command_line_args, int num_command_line_args,
8515ffd83dbSDimitry Andric     struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files,
8520b57cec5SDimitry Andric     unsigned options);
8530b57cec5SDimitry Andric 
8540b57cec5SDimitry Andric /**
8550b57cec5SDimitry Andric  * Parse the given source file and the translation unit corresponding
8560b57cec5SDimitry Andric  * to that file.
8570b57cec5SDimitry Andric  *
8580b57cec5SDimitry Andric  * This routine is the main entry point for the Clang C API, providing the
8590b57cec5SDimitry Andric  * ability to parse a source file into a translation unit that can then be
8600b57cec5SDimitry Andric  * queried by other functions in the API. This routine accepts a set of
8610b57cec5SDimitry Andric  * command-line arguments so that the compilation can be configured in the same
8620b57cec5SDimitry Andric  * way that the compiler is configured on the command line.
8630b57cec5SDimitry Andric  *
8640b57cec5SDimitry Andric  * \param CIdx The index object with which the translation unit will be
8650b57cec5SDimitry Andric  * associated.
8660b57cec5SDimitry Andric  *
8670b57cec5SDimitry Andric  * \param source_filename The name of the source file to load, or NULL if the
8680b57cec5SDimitry Andric  * source file is included in \c command_line_args.
8690b57cec5SDimitry Andric  *
8700b57cec5SDimitry Andric  * \param command_line_args The command-line arguments that would be
8710b57cec5SDimitry Andric  * passed to the \c clang executable if it were being invoked out-of-process.
8720b57cec5SDimitry Andric  * These command-line options will be parsed and will affect how the translation
8730b57cec5SDimitry Andric  * unit is parsed. Note that the following options are ignored: '-c',
8740b57cec5SDimitry Andric  * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
8750b57cec5SDimitry Andric  *
8760b57cec5SDimitry Andric  * \param num_command_line_args The number of command-line arguments in
8770b57cec5SDimitry Andric  * \c command_line_args.
8780b57cec5SDimitry Andric  *
8790b57cec5SDimitry Andric  * \param unsaved_files the files that have not yet been saved to disk
8800b57cec5SDimitry Andric  * but may be required for parsing, including the contents of
8810b57cec5SDimitry Andric  * those files.  The contents and name of these files (as specified by
8820b57cec5SDimitry Andric  * CXUnsavedFile) are copied when necessary, so the client only needs to
8830b57cec5SDimitry Andric  * guarantee their validity until the call to this function returns.
8840b57cec5SDimitry Andric  *
8850b57cec5SDimitry Andric  * \param num_unsaved_files the number of unsaved file entries in \p
8860b57cec5SDimitry Andric  * unsaved_files.
8870b57cec5SDimitry Andric  *
8880b57cec5SDimitry Andric  * \param options A bitmask of options that affects how the translation unit
8890b57cec5SDimitry Andric  * is managed but not its compilation. This should be a bitwise OR of the
8900b57cec5SDimitry Andric  * CXTranslationUnit_XXX flags.
8910b57cec5SDimitry Andric  *
8920b57cec5SDimitry Andric  * \param[out] out_TU A non-NULL pointer to store the created
8930b57cec5SDimitry Andric  * \c CXTranslationUnit, describing the parsed code and containing any
8940b57cec5SDimitry Andric  * diagnostics produced by the compiler.
8950b57cec5SDimitry Andric  *
8960b57cec5SDimitry Andric  * \returns Zero on success, otherwise returns an error code.
8970b57cec5SDimitry Andric  */
8985ffd83dbSDimitry Andric CINDEX_LINKAGE enum CXErrorCode clang_parseTranslationUnit2(
8995ffd83dbSDimitry Andric     CXIndex CIdx, const char *source_filename,
9005ffd83dbSDimitry Andric     const char *const *command_line_args, int num_command_line_args,
9015ffd83dbSDimitry Andric     struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files,
9025ffd83dbSDimitry Andric     unsigned options, CXTranslationUnit *out_TU);
9030b57cec5SDimitry Andric 
9040b57cec5SDimitry Andric /**
9050b57cec5SDimitry Andric  * Same as clang_parseTranslationUnit2 but requires a full command line
9060b57cec5SDimitry Andric  * for \c command_line_args including argv[0]. This is useful if the standard
9070b57cec5SDimitry Andric  * library paths are relative to the binary.
9080b57cec5SDimitry Andric  */
9090b57cec5SDimitry Andric CINDEX_LINKAGE enum CXErrorCode clang_parseTranslationUnit2FullArgv(
9100b57cec5SDimitry Andric     CXIndex CIdx, const char *source_filename,
9110b57cec5SDimitry Andric     const char *const *command_line_args, int num_command_line_args,
9120b57cec5SDimitry Andric     struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files,
9130b57cec5SDimitry Andric     unsigned options, CXTranslationUnit *out_TU);
9140b57cec5SDimitry Andric 
9150b57cec5SDimitry Andric /**
9160b57cec5SDimitry Andric  * Flags that control how translation units are saved.
9170b57cec5SDimitry Andric  *
9180b57cec5SDimitry Andric  * The enumerators in this enumeration type are meant to be bitwise
9190b57cec5SDimitry Andric  * ORed together to specify which options should be used when
9200b57cec5SDimitry Andric  * saving the translation unit.
9210b57cec5SDimitry Andric  */
9220b57cec5SDimitry Andric enum CXSaveTranslationUnit_Flags {
9230b57cec5SDimitry Andric   /**
9240b57cec5SDimitry Andric    * Used to indicate that no special saving options are needed.
9250b57cec5SDimitry Andric    */
9260b57cec5SDimitry Andric   CXSaveTranslationUnit_None = 0x0
9270b57cec5SDimitry Andric };
9280b57cec5SDimitry Andric 
9290b57cec5SDimitry Andric /**
9300b57cec5SDimitry Andric  * Returns the set of flags that is suitable for saving a translation
9310b57cec5SDimitry Andric  * unit.
9320b57cec5SDimitry Andric  *
9330b57cec5SDimitry Andric  * The set of flags returned provide options for
9340b57cec5SDimitry Andric  * \c clang_saveTranslationUnit() by default. The returned flag
9350b57cec5SDimitry Andric  * set contains an unspecified set of options that save translation units with
9360b57cec5SDimitry Andric  * the most commonly-requested data.
9370b57cec5SDimitry Andric  */
9380b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_defaultSaveOptions(CXTranslationUnit TU);
9390b57cec5SDimitry Andric 
9400b57cec5SDimitry Andric /**
9410b57cec5SDimitry Andric  * Describes the kind of error that occurred (if any) in a call to
9420b57cec5SDimitry Andric  * \c clang_saveTranslationUnit().
9430b57cec5SDimitry Andric  */
9440b57cec5SDimitry Andric enum CXSaveError {
9450b57cec5SDimitry Andric   /**
9460b57cec5SDimitry Andric    * Indicates that no error occurred while saving a translation unit.
9470b57cec5SDimitry Andric    */
9480b57cec5SDimitry Andric   CXSaveError_None = 0,
9490b57cec5SDimitry Andric 
9500b57cec5SDimitry Andric   /**
9510b57cec5SDimitry Andric    * Indicates that an unknown error occurred while attempting to save
9520b57cec5SDimitry Andric    * the file.
9530b57cec5SDimitry Andric    *
9540b57cec5SDimitry Andric    * This error typically indicates that file I/O failed when attempting to
9550b57cec5SDimitry Andric    * write the file.
9560b57cec5SDimitry Andric    */
9570b57cec5SDimitry Andric   CXSaveError_Unknown = 1,
9580b57cec5SDimitry Andric 
9590b57cec5SDimitry Andric   /**
9600b57cec5SDimitry Andric    * Indicates that errors during translation prevented this attempt
9610b57cec5SDimitry Andric    * to save the translation unit.
9620b57cec5SDimitry Andric    *
9630b57cec5SDimitry Andric    * Errors that prevent the translation unit from being saved can be
9640b57cec5SDimitry Andric    * extracted using \c clang_getNumDiagnostics() and \c clang_getDiagnostic().
9650b57cec5SDimitry Andric    */
9660b57cec5SDimitry Andric   CXSaveError_TranslationErrors = 2,
9670b57cec5SDimitry Andric 
9680b57cec5SDimitry Andric   /**
9690b57cec5SDimitry Andric    * Indicates that the translation unit to be saved was somehow
9700b57cec5SDimitry Andric    * invalid (e.g., NULL).
9710b57cec5SDimitry Andric    */
9720b57cec5SDimitry Andric   CXSaveError_InvalidTU = 3
9730b57cec5SDimitry Andric };
9740b57cec5SDimitry Andric 
9750b57cec5SDimitry Andric /**
9760b57cec5SDimitry Andric  * Saves a translation unit into a serialized representation of
9770b57cec5SDimitry Andric  * that translation unit on disk.
9780b57cec5SDimitry Andric  *
9790b57cec5SDimitry Andric  * Any translation unit that was parsed without error can be saved
9800b57cec5SDimitry Andric  * into a file. The translation unit can then be deserialized into a
9810b57cec5SDimitry Andric  * new \c CXTranslationUnit with \c clang_createTranslationUnit() or,
9820b57cec5SDimitry Andric  * if it is an incomplete translation unit that corresponds to a
9830b57cec5SDimitry Andric  * header, used as a precompiled header when parsing other translation
9840b57cec5SDimitry Andric  * units.
9850b57cec5SDimitry Andric  *
9860b57cec5SDimitry Andric  * \param TU The translation unit to save.
9870b57cec5SDimitry Andric  *
9880b57cec5SDimitry Andric  * \param FileName The file to which the translation unit will be saved.
9890b57cec5SDimitry Andric  *
9900b57cec5SDimitry Andric  * \param options A bitmask of options that affects how the translation unit
9910b57cec5SDimitry Andric  * is saved. This should be a bitwise OR of the
9920b57cec5SDimitry Andric  * CXSaveTranslationUnit_XXX flags.
9930b57cec5SDimitry Andric  *
9940b57cec5SDimitry Andric  * \returns A value that will match one of the enumerators of the CXSaveError
9950b57cec5SDimitry Andric  * enumeration. Zero (CXSaveError_None) indicates that the translation unit was
9960b57cec5SDimitry Andric  * saved successfully, while a non-zero value indicates that a problem occurred.
9970b57cec5SDimitry Andric  */
9980b57cec5SDimitry Andric CINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU,
9990b57cec5SDimitry Andric                                              const char *FileName,
10000b57cec5SDimitry Andric                                              unsigned options);
10010b57cec5SDimitry Andric 
10020b57cec5SDimitry Andric /**
10030b57cec5SDimitry Andric  * Suspend a translation unit in order to free memory associated with it.
10040b57cec5SDimitry Andric  *
10050b57cec5SDimitry Andric  * A suspended translation unit uses significantly less memory but on the other
10060b57cec5SDimitry Andric  * side does not support any other calls than \c clang_reparseTranslationUnit
10070b57cec5SDimitry Andric  * to resume it or \c clang_disposeTranslationUnit to dispose it completely.
10080b57cec5SDimitry Andric  */
10090b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_suspendTranslationUnit(CXTranslationUnit);
10100b57cec5SDimitry Andric 
10110b57cec5SDimitry Andric /**
10120b57cec5SDimitry Andric  * Destroy the specified CXTranslationUnit object.
10130b57cec5SDimitry Andric  */
10140b57cec5SDimitry Andric CINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit);
10150b57cec5SDimitry Andric 
10160b57cec5SDimitry Andric /**
10170b57cec5SDimitry Andric  * Flags that control the reparsing of translation units.
10180b57cec5SDimitry Andric  *
10190b57cec5SDimitry Andric  * The enumerators in this enumeration type are meant to be bitwise
10200b57cec5SDimitry Andric  * ORed together to specify which options should be used when
10210b57cec5SDimitry Andric  * reparsing the translation unit.
10220b57cec5SDimitry Andric  */
10230b57cec5SDimitry Andric enum CXReparse_Flags {
10240b57cec5SDimitry Andric   /**
10250b57cec5SDimitry Andric    * Used to indicate that no special reparsing options are needed.
10260b57cec5SDimitry Andric    */
10270b57cec5SDimitry Andric   CXReparse_None = 0x0
10280b57cec5SDimitry Andric };
10290b57cec5SDimitry Andric 
10300b57cec5SDimitry Andric /**
10310b57cec5SDimitry Andric  * Returns the set of flags that is suitable for reparsing a translation
10320b57cec5SDimitry Andric  * unit.
10330b57cec5SDimitry Andric  *
10340b57cec5SDimitry Andric  * The set of flags returned provide options for
10350b57cec5SDimitry Andric  * \c clang_reparseTranslationUnit() by default. The returned flag
10360b57cec5SDimitry Andric  * set contains an unspecified set of optimizations geared toward common uses
10370b57cec5SDimitry Andric  * of reparsing. The set of optimizations enabled may change from one version
10380b57cec5SDimitry Andric  * to the next.
10390b57cec5SDimitry Andric  */
10400b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU);
10410b57cec5SDimitry Andric 
10420b57cec5SDimitry Andric /**
10430b57cec5SDimitry Andric  * Reparse the source files that produced this translation unit.
10440b57cec5SDimitry Andric  *
10450b57cec5SDimitry Andric  * This routine can be used to re-parse the source files that originally
10460b57cec5SDimitry Andric  * created the given translation unit, for example because those source files
10470b57cec5SDimitry Andric  * have changed (either on disk or as passed via \p unsaved_files). The
10480b57cec5SDimitry Andric  * source code will be reparsed with the same command-line options as it
10490b57cec5SDimitry Andric  * was originally parsed.
10500b57cec5SDimitry Andric  *
10510b57cec5SDimitry Andric  * Reparsing a translation unit invalidates all cursors and source locations
10520b57cec5SDimitry Andric  * that refer into that translation unit. This makes reparsing a translation
10530b57cec5SDimitry Andric  * unit semantically equivalent to destroying the translation unit and then
10540b57cec5SDimitry Andric  * creating a new translation unit with the same command-line arguments.
10550b57cec5SDimitry Andric  * However, it may be more efficient to reparse a translation
10560b57cec5SDimitry Andric  * unit using this routine.
10570b57cec5SDimitry Andric  *
10580b57cec5SDimitry Andric  * \param TU The translation unit whose contents will be re-parsed. The
10590b57cec5SDimitry Andric  * translation unit must originally have been built with
10600b57cec5SDimitry Andric  * \c clang_createTranslationUnitFromSourceFile().
10610b57cec5SDimitry Andric  *
10620b57cec5SDimitry Andric  * \param num_unsaved_files The number of unsaved file entries in \p
10630b57cec5SDimitry Andric  * unsaved_files.
10640b57cec5SDimitry Andric  *
10650b57cec5SDimitry Andric  * \param unsaved_files The files that have not yet been saved to disk
10660b57cec5SDimitry Andric  * but may be required for parsing, including the contents of
10670b57cec5SDimitry Andric  * those files.  The contents and name of these files (as specified by
10680b57cec5SDimitry Andric  * CXUnsavedFile) are copied when necessary, so the client only needs to
10690b57cec5SDimitry Andric  * guarantee their validity until the call to this function returns.
10700b57cec5SDimitry Andric  *
10710b57cec5SDimitry Andric  * \param options A bitset of options composed of the flags in CXReparse_Flags.
10720b57cec5SDimitry Andric  * The function \c clang_defaultReparseOptions() produces a default set of
10730b57cec5SDimitry Andric  * options recommended for most uses, based on the translation unit.
10740b57cec5SDimitry Andric  *
10750b57cec5SDimitry Andric  * \returns 0 if the sources could be reparsed.  A non-zero error code will be
10760b57cec5SDimitry Andric  * returned if reparsing was impossible, such that the translation unit is
10770b57cec5SDimitry Andric  * invalid. In such cases, the only valid call for \c TU is
10780b57cec5SDimitry Andric  * \c clang_disposeTranslationUnit(TU).  The error codes returned by this
10790b57cec5SDimitry Andric  * routine are described by the \c CXErrorCode enum.
10800b57cec5SDimitry Andric  */
10815ffd83dbSDimitry Andric CINDEX_LINKAGE int
10825ffd83dbSDimitry Andric clang_reparseTranslationUnit(CXTranslationUnit TU, unsigned num_unsaved_files,
10830b57cec5SDimitry Andric                              struct CXUnsavedFile *unsaved_files,
10840b57cec5SDimitry Andric                              unsigned options);
10850b57cec5SDimitry Andric 
10860b57cec5SDimitry Andric /**
10870b57cec5SDimitry Andric  * Categorizes how memory is being used by a translation unit.
10880b57cec5SDimitry Andric  */
10890b57cec5SDimitry Andric enum CXTUResourceUsageKind {
10900b57cec5SDimitry Andric   CXTUResourceUsage_AST = 1,
10910b57cec5SDimitry Andric   CXTUResourceUsage_Identifiers = 2,
10920b57cec5SDimitry Andric   CXTUResourceUsage_Selectors = 3,
10930b57cec5SDimitry Andric   CXTUResourceUsage_GlobalCompletionResults = 4,
10940b57cec5SDimitry Andric   CXTUResourceUsage_SourceManagerContentCache = 5,
10950b57cec5SDimitry Andric   CXTUResourceUsage_AST_SideTables = 6,
10960b57cec5SDimitry Andric   CXTUResourceUsage_SourceManager_Membuffer_Malloc = 7,
10970b57cec5SDimitry Andric   CXTUResourceUsage_SourceManager_Membuffer_MMap = 8,
10980b57cec5SDimitry Andric   CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc = 9,
10990b57cec5SDimitry Andric   CXTUResourceUsage_ExternalASTSource_Membuffer_MMap = 10,
11000b57cec5SDimitry Andric   CXTUResourceUsage_Preprocessor = 11,
11010b57cec5SDimitry Andric   CXTUResourceUsage_PreprocessingRecord = 12,
11020b57cec5SDimitry Andric   CXTUResourceUsage_SourceManager_DataStructures = 13,
11030b57cec5SDimitry Andric   CXTUResourceUsage_Preprocessor_HeaderSearch = 14,
11040b57cec5SDimitry Andric   CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST,
11050b57cec5SDimitry Andric   CXTUResourceUsage_MEMORY_IN_BYTES_END =
11060b57cec5SDimitry Andric       CXTUResourceUsage_Preprocessor_HeaderSearch,
11070b57cec5SDimitry Andric 
11080b57cec5SDimitry Andric   CXTUResourceUsage_First = CXTUResourceUsage_AST,
11090b57cec5SDimitry Andric   CXTUResourceUsage_Last = CXTUResourceUsage_Preprocessor_HeaderSearch
11100b57cec5SDimitry Andric };
11110b57cec5SDimitry Andric 
11120b57cec5SDimitry Andric /**
11130b57cec5SDimitry Andric  * Returns the human-readable null-terminated C string that represents
11140b57cec5SDimitry Andric  *  the name of the memory category.  This string should never be freed.
11150b57cec5SDimitry Andric  */
11160b57cec5SDimitry Andric CINDEX_LINKAGE
11170b57cec5SDimitry Andric const char *clang_getTUResourceUsageName(enum CXTUResourceUsageKind kind);
11180b57cec5SDimitry Andric 
11190b57cec5SDimitry Andric typedef struct CXTUResourceUsageEntry {
11200b57cec5SDimitry Andric   /* The memory usage category. */
11210b57cec5SDimitry Andric   enum CXTUResourceUsageKind kind;
11220b57cec5SDimitry Andric   /* Amount of resources used.
11230b57cec5SDimitry Andric       The units will depend on the resource kind. */
11240b57cec5SDimitry Andric   unsigned long amount;
11250b57cec5SDimitry Andric } CXTUResourceUsageEntry;
11260b57cec5SDimitry Andric 
11270b57cec5SDimitry Andric /**
11280b57cec5SDimitry Andric  * The memory usage of a CXTranslationUnit, broken into categories.
11290b57cec5SDimitry Andric  */
11300b57cec5SDimitry Andric typedef struct CXTUResourceUsage {
11310b57cec5SDimitry Andric   /* Private data member, used for queries. */
11320b57cec5SDimitry Andric   void *data;
11330b57cec5SDimitry Andric 
11340b57cec5SDimitry Andric   /* The number of entries in the 'entries' array. */
11350b57cec5SDimitry Andric   unsigned numEntries;
11360b57cec5SDimitry Andric 
11370b57cec5SDimitry Andric   /* An array of key-value pairs, representing the breakdown of memory
11380b57cec5SDimitry Andric             usage. */
11390b57cec5SDimitry Andric   CXTUResourceUsageEntry *entries;
11400b57cec5SDimitry Andric 
11410b57cec5SDimitry Andric } CXTUResourceUsage;
11420b57cec5SDimitry Andric 
11430b57cec5SDimitry Andric /**
11440b57cec5SDimitry Andric  * Return the memory usage of a translation unit.  This object
11450b57cec5SDimitry Andric  *  should be released with clang_disposeCXTUResourceUsage().
11460b57cec5SDimitry Andric  */
11475ffd83dbSDimitry Andric CINDEX_LINKAGE CXTUResourceUsage
11485ffd83dbSDimitry Andric clang_getCXTUResourceUsage(CXTranslationUnit TU);
11490b57cec5SDimitry Andric 
11500b57cec5SDimitry Andric CINDEX_LINKAGE void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage);
11510b57cec5SDimitry Andric 
11520b57cec5SDimitry Andric /**
11530b57cec5SDimitry Andric  * Get target information for this translation unit.
11540b57cec5SDimitry Andric  *
11550b57cec5SDimitry Andric  * The CXTargetInfo object cannot outlive the CXTranslationUnit object.
11560b57cec5SDimitry Andric  */
11570b57cec5SDimitry Andric CINDEX_LINKAGE CXTargetInfo
11580b57cec5SDimitry Andric clang_getTranslationUnitTargetInfo(CXTranslationUnit CTUnit);
11590b57cec5SDimitry Andric 
11600b57cec5SDimitry Andric /**
11610b57cec5SDimitry Andric  * Destroy the CXTargetInfo object.
11620b57cec5SDimitry Andric  */
11635ffd83dbSDimitry Andric CINDEX_LINKAGE void clang_TargetInfo_dispose(CXTargetInfo Info);
11640b57cec5SDimitry Andric 
11650b57cec5SDimitry Andric /**
11660b57cec5SDimitry Andric  * Get the normalized target triple as a string.
11670b57cec5SDimitry Andric  *
11680b57cec5SDimitry Andric  * Returns the empty string in case of any error.
11690b57cec5SDimitry Andric  */
11705ffd83dbSDimitry Andric CINDEX_LINKAGE CXString clang_TargetInfo_getTriple(CXTargetInfo Info);
11710b57cec5SDimitry Andric 
11720b57cec5SDimitry Andric /**
11730b57cec5SDimitry Andric  * Get the pointer width of the target in bits.
11740b57cec5SDimitry Andric  *
11750b57cec5SDimitry Andric  * Returns -1 in case of error.
11760b57cec5SDimitry Andric  */
11775ffd83dbSDimitry Andric CINDEX_LINKAGE int clang_TargetInfo_getPointerWidth(CXTargetInfo Info);
11780b57cec5SDimitry Andric 
11790b57cec5SDimitry Andric /**
11800b57cec5SDimitry Andric  * @}
11810b57cec5SDimitry Andric  */
11820b57cec5SDimitry Andric 
11830b57cec5SDimitry Andric /**
11840b57cec5SDimitry Andric  * Describes the kind of entity that a cursor refers to.
11850b57cec5SDimitry Andric  */
11860b57cec5SDimitry Andric enum CXCursorKind {
11870b57cec5SDimitry Andric   /* Declarations */
11880b57cec5SDimitry Andric   /**
11890b57cec5SDimitry Andric    * A declaration whose specific kind is not exposed via this
11900b57cec5SDimitry Andric    * interface.
11910b57cec5SDimitry Andric    *
11920b57cec5SDimitry Andric    * Unexposed declarations have the same operations as any other kind
11930b57cec5SDimitry Andric    * of declaration; one can extract their location information,
11940b57cec5SDimitry Andric    * spelling, find their definitions, etc. However, the specific kind
11950b57cec5SDimitry Andric    * of the declaration is not reported.
11960b57cec5SDimitry Andric    */
11970b57cec5SDimitry Andric   CXCursor_UnexposedDecl = 1,
11980b57cec5SDimitry Andric   /** A C or C++ struct. */
11990b57cec5SDimitry Andric   CXCursor_StructDecl = 2,
12000b57cec5SDimitry Andric   /** A C or C++ union. */
12010b57cec5SDimitry Andric   CXCursor_UnionDecl = 3,
12020b57cec5SDimitry Andric   /** A C++ class. */
12030b57cec5SDimitry Andric   CXCursor_ClassDecl = 4,
12040b57cec5SDimitry Andric   /** An enumeration. */
12050b57cec5SDimitry Andric   CXCursor_EnumDecl = 5,
12060b57cec5SDimitry Andric   /**
12070b57cec5SDimitry Andric    * A field (in C) or non-static data member (in C++) in a
12080b57cec5SDimitry Andric    * struct, union, or C++ class.
12090b57cec5SDimitry Andric    */
12100b57cec5SDimitry Andric   CXCursor_FieldDecl = 6,
12110b57cec5SDimitry Andric   /** An enumerator constant. */
12120b57cec5SDimitry Andric   CXCursor_EnumConstantDecl = 7,
12130b57cec5SDimitry Andric   /** A function. */
12140b57cec5SDimitry Andric   CXCursor_FunctionDecl = 8,
12150b57cec5SDimitry Andric   /** A variable. */
12160b57cec5SDimitry Andric   CXCursor_VarDecl = 9,
12170b57cec5SDimitry Andric   /** A function or method parameter. */
12180b57cec5SDimitry Andric   CXCursor_ParmDecl = 10,
12190b57cec5SDimitry Andric   /** An Objective-C \@interface. */
12200b57cec5SDimitry Andric   CXCursor_ObjCInterfaceDecl = 11,
12210b57cec5SDimitry Andric   /** An Objective-C \@interface for a category. */
12220b57cec5SDimitry Andric   CXCursor_ObjCCategoryDecl = 12,
12230b57cec5SDimitry Andric   /** An Objective-C \@protocol declaration. */
12240b57cec5SDimitry Andric   CXCursor_ObjCProtocolDecl = 13,
12250b57cec5SDimitry Andric   /** An Objective-C \@property declaration. */
12260b57cec5SDimitry Andric   CXCursor_ObjCPropertyDecl = 14,
12270b57cec5SDimitry Andric   /** An Objective-C instance variable. */
12280b57cec5SDimitry Andric   CXCursor_ObjCIvarDecl = 15,
12290b57cec5SDimitry Andric   /** An Objective-C instance method. */
12300b57cec5SDimitry Andric   CXCursor_ObjCInstanceMethodDecl = 16,
12310b57cec5SDimitry Andric   /** An Objective-C class method. */
12320b57cec5SDimitry Andric   CXCursor_ObjCClassMethodDecl = 17,
12330b57cec5SDimitry Andric   /** An Objective-C \@implementation. */
12340b57cec5SDimitry Andric   CXCursor_ObjCImplementationDecl = 18,
12350b57cec5SDimitry Andric   /** An Objective-C \@implementation for a category. */
12360b57cec5SDimitry Andric   CXCursor_ObjCCategoryImplDecl = 19,
12370b57cec5SDimitry Andric   /** A typedef. */
12380b57cec5SDimitry Andric   CXCursor_TypedefDecl = 20,
12390b57cec5SDimitry Andric   /** A C++ class method. */
12400b57cec5SDimitry Andric   CXCursor_CXXMethod = 21,
12410b57cec5SDimitry Andric   /** A C++ namespace. */
12420b57cec5SDimitry Andric   CXCursor_Namespace = 22,
12430b57cec5SDimitry Andric   /** A linkage specification, e.g. 'extern "C"'. */
12440b57cec5SDimitry Andric   CXCursor_LinkageSpec = 23,
12450b57cec5SDimitry Andric   /** A C++ constructor. */
12460b57cec5SDimitry Andric   CXCursor_Constructor = 24,
12470b57cec5SDimitry Andric   /** A C++ destructor. */
12480b57cec5SDimitry Andric   CXCursor_Destructor = 25,
12490b57cec5SDimitry Andric   /** A C++ conversion function. */
12500b57cec5SDimitry Andric   CXCursor_ConversionFunction = 26,
12510b57cec5SDimitry Andric   /** A C++ template type parameter. */
12520b57cec5SDimitry Andric   CXCursor_TemplateTypeParameter = 27,
12530b57cec5SDimitry Andric   /** A C++ non-type template parameter. */
12540b57cec5SDimitry Andric   CXCursor_NonTypeTemplateParameter = 28,
12550b57cec5SDimitry Andric   /** A C++ template template parameter. */
12560b57cec5SDimitry Andric   CXCursor_TemplateTemplateParameter = 29,
12570b57cec5SDimitry Andric   /** A C++ function template. */
12580b57cec5SDimitry Andric   CXCursor_FunctionTemplate = 30,
12590b57cec5SDimitry Andric   /** A C++ class template. */
12600b57cec5SDimitry Andric   CXCursor_ClassTemplate = 31,
12610b57cec5SDimitry Andric   /** A C++ class template partial specialization. */
12620b57cec5SDimitry Andric   CXCursor_ClassTemplatePartialSpecialization = 32,
12630b57cec5SDimitry Andric   /** A C++ namespace alias declaration. */
12640b57cec5SDimitry Andric   CXCursor_NamespaceAlias = 33,
12650b57cec5SDimitry Andric   /** A C++ using directive. */
12660b57cec5SDimitry Andric   CXCursor_UsingDirective = 34,
12670b57cec5SDimitry Andric   /** A C++ using declaration. */
12680b57cec5SDimitry Andric   CXCursor_UsingDeclaration = 35,
12690b57cec5SDimitry Andric   /** A C++ alias declaration */
12700b57cec5SDimitry Andric   CXCursor_TypeAliasDecl = 36,
12710b57cec5SDimitry Andric   /** An Objective-C \@synthesize definition. */
12720b57cec5SDimitry Andric   CXCursor_ObjCSynthesizeDecl = 37,
12730b57cec5SDimitry Andric   /** An Objective-C \@dynamic definition. */
12740b57cec5SDimitry Andric   CXCursor_ObjCDynamicDecl = 38,
12750b57cec5SDimitry Andric   /** An access specifier. */
12760b57cec5SDimitry Andric   CXCursor_CXXAccessSpecifier = 39,
12770b57cec5SDimitry Andric 
12780b57cec5SDimitry Andric   CXCursor_FirstDecl = CXCursor_UnexposedDecl,
12790b57cec5SDimitry Andric   CXCursor_LastDecl = CXCursor_CXXAccessSpecifier,
12800b57cec5SDimitry Andric 
12810b57cec5SDimitry Andric   /* References */
12820b57cec5SDimitry Andric   CXCursor_FirstRef = 40, /* Decl references */
12830b57cec5SDimitry Andric   CXCursor_ObjCSuperClassRef = 40,
12840b57cec5SDimitry Andric   CXCursor_ObjCProtocolRef = 41,
12850b57cec5SDimitry Andric   CXCursor_ObjCClassRef = 42,
12860b57cec5SDimitry Andric   /**
12870b57cec5SDimitry Andric    * A reference to a type declaration.
12880b57cec5SDimitry Andric    *
12890b57cec5SDimitry Andric    * A type reference occurs anywhere where a type is named but not
12900b57cec5SDimitry Andric    * declared. For example, given:
12910b57cec5SDimitry Andric    *
12920b57cec5SDimitry Andric    * \code
12930b57cec5SDimitry Andric    * typedef unsigned size_type;
12940b57cec5SDimitry Andric    * size_type size;
12950b57cec5SDimitry Andric    * \endcode
12960b57cec5SDimitry Andric    *
12970b57cec5SDimitry Andric    * The typedef is a declaration of size_type (CXCursor_TypedefDecl),
12980b57cec5SDimitry Andric    * while the type of the variable "size" is referenced. The cursor
12990b57cec5SDimitry Andric    * referenced by the type of size is the typedef for size_type.
13000b57cec5SDimitry Andric    */
13010b57cec5SDimitry Andric   CXCursor_TypeRef = 43,
13020b57cec5SDimitry Andric   CXCursor_CXXBaseSpecifier = 44,
13030b57cec5SDimitry Andric   /**
13040b57cec5SDimitry Andric    * A reference to a class template, function template, template
13050b57cec5SDimitry Andric    * template parameter, or class template partial specialization.
13060b57cec5SDimitry Andric    */
13070b57cec5SDimitry Andric   CXCursor_TemplateRef = 45,
13080b57cec5SDimitry Andric   /**
13090b57cec5SDimitry Andric    * A reference to a namespace or namespace alias.
13100b57cec5SDimitry Andric    */
13110b57cec5SDimitry Andric   CXCursor_NamespaceRef = 46,
13120b57cec5SDimitry Andric   /**
13130b57cec5SDimitry Andric    * A reference to a member of a struct, union, or class that occurs in
13140b57cec5SDimitry Andric    * some non-expression context, e.g., a designated initializer.
13150b57cec5SDimitry Andric    */
13160b57cec5SDimitry Andric   CXCursor_MemberRef = 47,
13170b57cec5SDimitry Andric   /**
13180b57cec5SDimitry Andric    * A reference to a labeled statement.
13190b57cec5SDimitry Andric    *
13200b57cec5SDimitry Andric    * This cursor kind is used to describe the jump to "start_over" in the
13210b57cec5SDimitry Andric    * goto statement in the following example:
13220b57cec5SDimitry Andric    *
13230b57cec5SDimitry Andric    * \code
13240b57cec5SDimitry Andric    *   start_over:
13250b57cec5SDimitry Andric    *     ++counter;
13260b57cec5SDimitry Andric    *
13270b57cec5SDimitry Andric    *     goto start_over;
13280b57cec5SDimitry Andric    * \endcode
13290b57cec5SDimitry Andric    *
13300b57cec5SDimitry Andric    * A label reference cursor refers to a label statement.
13310b57cec5SDimitry Andric    */
13320b57cec5SDimitry Andric   CXCursor_LabelRef = 48,
13330b57cec5SDimitry Andric 
13340b57cec5SDimitry Andric   /**
13350b57cec5SDimitry Andric    * A reference to a set of overloaded functions or function templates
13360b57cec5SDimitry Andric    * that has not yet been resolved to a specific function or function template.
13370b57cec5SDimitry Andric    *
13380b57cec5SDimitry Andric    * An overloaded declaration reference cursor occurs in C++ templates where
13390b57cec5SDimitry Andric    * a dependent name refers to a function. For example:
13400b57cec5SDimitry Andric    *
13410b57cec5SDimitry Andric    * \code
13420b57cec5SDimitry Andric    * template<typename T> void swap(T&, T&);
13430b57cec5SDimitry Andric    *
13440b57cec5SDimitry Andric    * struct X { ... };
13450b57cec5SDimitry Andric    * void swap(X&, X&);
13460b57cec5SDimitry Andric    *
13470b57cec5SDimitry Andric    * template<typename T>
13480b57cec5SDimitry Andric    * void reverse(T* first, T* last) {
13490b57cec5SDimitry Andric    *   while (first < last - 1) {
13500b57cec5SDimitry Andric    *     swap(*first, *--last);
13510b57cec5SDimitry Andric    *     ++first;
13520b57cec5SDimitry Andric    *   }
13530b57cec5SDimitry Andric    * }
13540b57cec5SDimitry Andric    *
13550b57cec5SDimitry Andric    * struct Y { };
13560b57cec5SDimitry Andric    * void swap(Y&, Y&);
13570b57cec5SDimitry Andric    * \endcode
13580b57cec5SDimitry Andric    *
13590b57cec5SDimitry Andric    * Here, the identifier "swap" is associated with an overloaded declaration
13600b57cec5SDimitry Andric    * reference. In the template definition, "swap" refers to either of the two
13610b57cec5SDimitry Andric    * "swap" functions declared above, so both results will be available. At
13620b57cec5SDimitry Andric    * instantiation time, "swap" may also refer to other functions found via
13630b57cec5SDimitry Andric    * argument-dependent lookup (e.g., the "swap" function at the end of the
13640b57cec5SDimitry Andric    * example).
13650b57cec5SDimitry Andric    *
13660b57cec5SDimitry Andric    * The functions \c clang_getNumOverloadedDecls() and
13670b57cec5SDimitry Andric    * \c clang_getOverloadedDecl() can be used to retrieve the definitions
13680b57cec5SDimitry Andric    * referenced by this cursor.
13690b57cec5SDimitry Andric    */
13700b57cec5SDimitry Andric   CXCursor_OverloadedDeclRef = 49,
13710b57cec5SDimitry Andric 
13720b57cec5SDimitry Andric   /**
13730b57cec5SDimitry Andric    * A reference to a variable that occurs in some non-expression
13740b57cec5SDimitry Andric    * context, e.g., a C++ lambda capture list.
13750b57cec5SDimitry Andric    */
13760b57cec5SDimitry Andric   CXCursor_VariableRef = 50,
13770b57cec5SDimitry Andric 
13780b57cec5SDimitry Andric   CXCursor_LastRef = CXCursor_VariableRef,
13790b57cec5SDimitry Andric 
13800b57cec5SDimitry Andric   /* Error conditions */
13810b57cec5SDimitry Andric   CXCursor_FirstInvalid = 70,
13820b57cec5SDimitry Andric   CXCursor_InvalidFile = 70,
13830b57cec5SDimitry Andric   CXCursor_NoDeclFound = 71,
13840b57cec5SDimitry Andric   CXCursor_NotImplemented = 72,
13850b57cec5SDimitry Andric   CXCursor_InvalidCode = 73,
13860b57cec5SDimitry Andric   CXCursor_LastInvalid = CXCursor_InvalidCode,
13870b57cec5SDimitry Andric 
13880b57cec5SDimitry Andric   /* Expressions */
13890b57cec5SDimitry Andric   CXCursor_FirstExpr = 100,
13900b57cec5SDimitry Andric 
13910b57cec5SDimitry Andric   /**
13920b57cec5SDimitry Andric    * An expression whose specific kind is not exposed via this
13930b57cec5SDimitry Andric    * interface.
13940b57cec5SDimitry Andric    *
13950b57cec5SDimitry Andric    * Unexposed expressions have the same operations as any other kind
13960b57cec5SDimitry Andric    * of expression; one can extract their location information,
13970b57cec5SDimitry Andric    * spelling, children, etc. However, the specific kind of the
13980b57cec5SDimitry Andric    * expression is not reported.
13990b57cec5SDimitry Andric    */
14000b57cec5SDimitry Andric   CXCursor_UnexposedExpr = 100,
14010b57cec5SDimitry Andric 
14020b57cec5SDimitry Andric   /**
14030b57cec5SDimitry Andric    * An expression that refers to some value declaration, such
14040b57cec5SDimitry Andric    * as a function, variable, or enumerator.
14050b57cec5SDimitry Andric    */
14060b57cec5SDimitry Andric   CXCursor_DeclRefExpr = 101,
14070b57cec5SDimitry Andric 
14080b57cec5SDimitry Andric   /**
14090b57cec5SDimitry Andric    * An expression that refers to a member of a struct, union,
14100b57cec5SDimitry Andric    * class, Objective-C class, etc.
14110b57cec5SDimitry Andric    */
14120b57cec5SDimitry Andric   CXCursor_MemberRefExpr = 102,
14130b57cec5SDimitry Andric 
14140b57cec5SDimitry Andric   /** An expression that calls a function. */
14150b57cec5SDimitry Andric   CXCursor_CallExpr = 103,
14160b57cec5SDimitry Andric 
14170b57cec5SDimitry Andric   /** An expression that sends a message to an Objective-C
14180b57cec5SDimitry Andric    object or class. */
14190b57cec5SDimitry Andric   CXCursor_ObjCMessageExpr = 104,
14200b57cec5SDimitry Andric 
14210b57cec5SDimitry Andric   /** An expression that represents a block literal. */
14220b57cec5SDimitry Andric   CXCursor_BlockExpr = 105,
14230b57cec5SDimitry Andric 
14240b57cec5SDimitry Andric   /** An integer literal.
14250b57cec5SDimitry Andric    */
14260b57cec5SDimitry Andric   CXCursor_IntegerLiteral = 106,
14270b57cec5SDimitry Andric 
14280b57cec5SDimitry Andric   /** A floating point number literal.
14290b57cec5SDimitry Andric    */
14300b57cec5SDimitry Andric   CXCursor_FloatingLiteral = 107,
14310b57cec5SDimitry Andric 
14320b57cec5SDimitry Andric   /** An imaginary number literal.
14330b57cec5SDimitry Andric    */
14340b57cec5SDimitry Andric   CXCursor_ImaginaryLiteral = 108,
14350b57cec5SDimitry Andric 
14360b57cec5SDimitry Andric   /** A string literal.
14370b57cec5SDimitry Andric    */
14380b57cec5SDimitry Andric   CXCursor_StringLiteral = 109,
14390b57cec5SDimitry Andric 
14400b57cec5SDimitry Andric   /** A character literal.
14410b57cec5SDimitry Andric    */
14420b57cec5SDimitry Andric   CXCursor_CharacterLiteral = 110,
14430b57cec5SDimitry Andric 
14440b57cec5SDimitry Andric   /** A parenthesized expression, e.g. "(1)".
14450b57cec5SDimitry Andric    *
14460b57cec5SDimitry Andric    * This AST node is only formed if full location information is requested.
14470b57cec5SDimitry Andric    */
14480b57cec5SDimitry Andric   CXCursor_ParenExpr = 111,
14490b57cec5SDimitry Andric 
14500b57cec5SDimitry Andric   /** This represents the unary-expression's (except sizeof and
14510b57cec5SDimitry Andric    * alignof).
14520b57cec5SDimitry Andric    */
14530b57cec5SDimitry Andric   CXCursor_UnaryOperator = 112,
14540b57cec5SDimitry Andric 
14550b57cec5SDimitry Andric   /** [C99 6.5.2.1] Array Subscripting.
14560b57cec5SDimitry Andric    */
14570b57cec5SDimitry Andric   CXCursor_ArraySubscriptExpr = 113,
14580b57cec5SDimitry Andric 
14590b57cec5SDimitry Andric   /** A builtin binary operation expression such as "x + y" or
14600b57cec5SDimitry Andric    * "x <= y".
14610b57cec5SDimitry Andric    */
14620b57cec5SDimitry Andric   CXCursor_BinaryOperator = 114,
14630b57cec5SDimitry Andric 
14640b57cec5SDimitry Andric   /** Compound assignment such as "+=".
14650b57cec5SDimitry Andric    */
14660b57cec5SDimitry Andric   CXCursor_CompoundAssignOperator = 115,
14670b57cec5SDimitry Andric 
14680b57cec5SDimitry Andric   /** The ?: ternary operator.
14690b57cec5SDimitry Andric    */
14700b57cec5SDimitry Andric   CXCursor_ConditionalOperator = 116,
14710b57cec5SDimitry Andric 
14720b57cec5SDimitry Andric   /** An explicit cast in C (C99 6.5.4) or a C-style cast in C++
14730b57cec5SDimitry Andric    * (C++ [expr.cast]), which uses the syntax (Type)expr.
14740b57cec5SDimitry Andric    *
14750b57cec5SDimitry Andric    * For example: (int)f.
14760b57cec5SDimitry Andric    */
14770b57cec5SDimitry Andric   CXCursor_CStyleCastExpr = 117,
14780b57cec5SDimitry Andric 
14790b57cec5SDimitry Andric   /** [C99 6.5.2.5]
14800b57cec5SDimitry Andric    */
14810b57cec5SDimitry Andric   CXCursor_CompoundLiteralExpr = 118,
14820b57cec5SDimitry Andric 
14830b57cec5SDimitry Andric   /** Describes an C or C++ initializer list.
14840b57cec5SDimitry Andric    */
14850b57cec5SDimitry Andric   CXCursor_InitListExpr = 119,
14860b57cec5SDimitry Andric 
14870b57cec5SDimitry Andric   /** The GNU address of label extension, representing &&label.
14880b57cec5SDimitry Andric    */
14890b57cec5SDimitry Andric   CXCursor_AddrLabelExpr = 120,
14900b57cec5SDimitry Andric 
14910b57cec5SDimitry Andric   /** This is the GNU Statement Expression extension: ({int X=4; X;})
14920b57cec5SDimitry Andric    */
14930b57cec5SDimitry Andric   CXCursor_StmtExpr = 121,
14940b57cec5SDimitry Andric 
14950b57cec5SDimitry Andric   /** Represents a C11 generic selection.
14960b57cec5SDimitry Andric    */
14970b57cec5SDimitry Andric   CXCursor_GenericSelectionExpr = 122,
14980b57cec5SDimitry Andric 
14990b57cec5SDimitry Andric   /** Implements the GNU __null extension, which is a name for a null
15000b57cec5SDimitry Andric    * pointer constant that has integral type (e.g., int or long) and is the same
15010b57cec5SDimitry Andric    * size and alignment as a pointer.
15020b57cec5SDimitry Andric    *
15030b57cec5SDimitry Andric    * The __null extension is typically only used by system headers, which define
15040b57cec5SDimitry Andric    * NULL as __null in C++ rather than using 0 (which is an integer that may not
15050b57cec5SDimitry Andric    * match the size of a pointer).
15060b57cec5SDimitry Andric    */
15070b57cec5SDimitry Andric   CXCursor_GNUNullExpr = 123,
15080b57cec5SDimitry Andric 
15090b57cec5SDimitry Andric   /** C++'s static_cast<> expression.
15100b57cec5SDimitry Andric    */
15110b57cec5SDimitry Andric   CXCursor_CXXStaticCastExpr = 124,
15120b57cec5SDimitry Andric 
15130b57cec5SDimitry Andric   /** C++'s dynamic_cast<> expression.
15140b57cec5SDimitry Andric    */
15150b57cec5SDimitry Andric   CXCursor_CXXDynamicCastExpr = 125,
15160b57cec5SDimitry Andric 
15170b57cec5SDimitry Andric   /** C++'s reinterpret_cast<> expression.
15180b57cec5SDimitry Andric    */
15190b57cec5SDimitry Andric   CXCursor_CXXReinterpretCastExpr = 126,
15200b57cec5SDimitry Andric 
15210b57cec5SDimitry Andric   /** C++'s const_cast<> expression.
15220b57cec5SDimitry Andric    */
15230b57cec5SDimitry Andric   CXCursor_CXXConstCastExpr = 127,
15240b57cec5SDimitry Andric 
15250b57cec5SDimitry Andric   /** Represents an explicit C++ type conversion that uses "functional"
15260b57cec5SDimitry Andric    * notion (C++ [expr.type.conv]).
15270b57cec5SDimitry Andric    *
15280b57cec5SDimitry Andric    * Example:
15290b57cec5SDimitry Andric    * \code
15300b57cec5SDimitry Andric    *   x = int(0.5);
15310b57cec5SDimitry Andric    * \endcode
15320b57cec5SDimitry Andric    */
15330b57cec5SDimitry Andric   CXCursor_CXXFunctionalCastExpr = 128,
15340b57cec5SDimitry Andric 
15350b57cec5SDimitry Andric   /** A C++ typeid expression (C++ [expr.typeid]).
15360b57cec5SDimitry Andric    */
1537e8d8bef9SDimitry Andric   CXCursor_CXXTypeidExpr = 129,
15380b57cec5SDimitry Andric 
15390b57cec5SDimitry Andric   /** [C++ 2.13.5] C++ Boolean Literal.
15400b57cec5SDimitry Andric    */
1541e8d8bef9SDimitry Andric   CXCursor_CXXBoolLiteralExpr = 130,
15420b57cec5SDimitry Andric 
15430b57cec5SDimitry Andric   /** [C++0x 2.14.7] C++ Pointer Literal.
15440b57cec5SDimitry Andric    */
1545e8d8bef9SDimitry Andric   CXCursor_CXXNullPtrLiteralExpr = 131,
15460b57cec5SDimitry Andric 
15470b57cec5SDimitry Andric   /** Represents the "this" expression in C++
15480b57cec5SDimitry Andric    */
1549e8d8bef9SDimitry Andric   CXCursor_CXXThisExpr = 132,
15500b57cec5SDimitry Andric 
15510b57cec5SDimitry Andric   /** [C++ 15] C++ Throw Expression.
15520b57cec5SDimitry Andric    *
15530b57cec5SDimitry Andric    * This handles 'throw' and 'throw' assignment-expression. When
15540b57cec5SDimitry Andric    * assignment-expression isn't present, Op will be null.
15550b57cec5SDimitry Andric    */
1556e8d8bef9SDimitry Andric   CXCursor_CXXThrowExpr = 133,
15570b57cec5SDimitry Andric 
15580b57cec5SDimitry Andric   /** A new expression for memory allocation and constructor calls, e.g:
15590b57cec5SDimitry Andric    * "new CXXNewExpr(foo)".
15600b57cec5SDimitry Andric    */
1561e8d8bef9SDimitry Andric   CXCursor_CXXNewExpr = 134,
15620b57cec5SDimitry Andric 
15630b57cec5SDimitry Andric   /** A delete expression for memory deallocation and destructor calls,
15640b57cec5SDimitry Andric    * e.g. "delete[] pArray".
15650b57cec5SDimitry Andric    */
1566e8d8bef9SDimitry Andric   CXCursor_CXXDeleteExpr = 135,
15670b57cec5SDimitry Andric 
15680b57cec5SDimitry Andric   /** A unary expression. (noexcept, sizeof, or other traits)
15690b57cec5SDimitry Andric    */
1570e8d8bef9SDimitry Andric   CXCursor_UnaryExpr = 136,
15710b57cec5SDimitry Andric 
15720b57cec5SDimitry Andric   /** An Objective-C string literal i.e. @"foo".
15730b57cec5SDimitry Andric    */
1574e8d8bef9SDimitry Andric   CXCursor_ObjCStringLiteral = 137,
15750b57cec5SDimitry Andric 
15760b57cec5SDimitry Andric   /** An Objective-C \@encode expression.
15770b57cec5SDimitry Andric    */
1578e8d8bef9SDimitry Andric   CXCursor_ObjCEncodeExpr = 138,
15790b57cec5SDimitry Andric 
15800b57cec5SDimitry Andric   /** An Objective-C \@selector expression.
15810b57cec5SDimitry Andric    */
1582e8d8bef9SDimitry Andric   CXCursor_ObjCSelectorExpr = 139,
15830b57cec5SDimitry Andric 
15840b57cec5SDimitry Andric   /** An Objective-C \@protocol expression.
15850b57cec5SDimitry Andric    */
1586e8d8bef9SDimitry Andric   CXCursor_ObjCProtocolExpr = 140,
15870b57cec5SDimitry Andric 
15880b57cec5SDimitry Andric   /** An Objective-C "bridged" cast expression, which casts between
15890b57cec5SDimitry Andric    * Objective-C pointers and C pointers, transferring ownership in the process.
15900b57cec5SDimitry Andric    *
15910b57cec5SDimitry Andric    * \code
15920b57cec5SDimitry Andric    *   NSString *str = (__bridge_transfer NSString *)CFCreateString();
15930b57cec5SDimitry Andric    * \endcode
15940b57cec5SDimitry Andric    */
1595e8d8bef9SDimitry Andric   CXCursor_ObjCBridgedCastExpr = 141,
15960b57cec5SDimitry Andric 
15970b57cec5SDimitry Andric   /** Represents a C++0x pack expansion that produces a sequence of
15980b57cec5SDimitry Andric    * expressions.
15990b57cec5SDimitry Andric    *
16000b57cec5SDimitry Andric    * A pack expansion expression contains a pattern (which itself is an
16010b57cec5SDimitry Andric    * expression) followed by an ellipsis. For example:
16020b57cec5SDimitry Andric    *
16030b57cec5SDimitry Andric    * \code
16040b57cec5SDimitry Andric    * template<typename F, typename ...Types>
16050b57cec5SDimitry Andric    * void forward(F f, Types &&...args) {
16060b57cec5SDimitry Andric    *  f(static_cast<Types&&>(args)...);
16070b57cec5SDimitry Andric    * }
16080b57cec5SDimitry Andric    * \endcode
16090b57cec5SDimitry Andric    */
1610e8d8bef9SDimitry Andric   CXCursor_PackExpansionExpr = 142,
16110b57cec5SDimitry Andric 
16120b57cec5SDimitry Andric   /** Represents an expression that computes the length of a parameter
16130b57cec5SDimitry Andric    * pack.
16140b57cec5SDimitry Andric    *
16150b57cec5SDimitry Andric    * \code
16160b57cec5SDimitry Andric    * template<typename ...Types>
16170b57cec5SDimitry Andric    * struct count {
16180b57cec5SDimitry Andric    *   static const unsigned value = sizeof...(Types);
16190b57cec5SDimitry Andric    * };
16200b57cec5SDimitry Andric    * \endcode
16210b57cec5SDimitry Andric    */
1622e8d8bef9SDimitry Andric   CXCursor_SizeOfPackExpr = 143,
16230b57cec5SDimitry Andric 
16240b57cec5SDimitry Andric   /* Represents a C++ lambda expression that produces a local function
16250b57cec5SDimitry Andric    * object.
16260b57cec5SDimitry Andric    *
16270b57cec5SDimitry Andric    * \code
16280b57cec5SDimitry Andric    * void abssort(float *x, unsigned N) {
16290b57cec5SDimitry Andric    *   std::sort(x, x + N,
16300b57cec5SDimitry Andric    *             [](float a, float b) {
16310b57cec5SDimitry Andric    *               return std::abs(a) < std::abs(b);
16320b57cec5SDimitry Andric    *             });
16330b57cec5SDimitry Andric    * }
16340b57cec5SDimitry Andric    * \endcode
16350b57cec5SDimitry Andric    */
1636e8d8bef9SDimitry Andric   CXCursor_LambdaExpr = 144,
16370b57cec5SDimitry Andric 
16380b57cec5SDimitry Andric   /** Objective-c Boolean Literal.
16390b57cec5SDimitry Andric    */
1640e8d8bef9SDimitry Andric   CXCursor_ObjCBoolLiteralExpr = 145,
16410b57cec5SDimitry Andric 
16420b57cec5SDimitry Andric   /** Represents the "self" expression in an Objective-C method.
16430b57cec5SDimitry Andric    */
1644e8d8bef9SDimitry Andric   CXCursor_ObjCSelfExpr = 146,
16450b57cec5SDimitry Andric 
16465ffd83dbSDimitry Andric   /** OpenMP 5.0 [2.1.5, Array Section].
1647*0fca6ea1SDimitry Andric    * OpenACC 3.3 [2.7.1, Data Specification for Data Clauses (Sub Arrays)]
16480b57cec5SDimitry Andric    */
1649*0fca6ea1SDimitry Andric   CXCursor_ArraySectionExpr = 147,
16500b57cec5SDimitry Andric 
16510b57cec5SDimitry Andric   /** Represents an @available(...) check.
16520b57cec5SDimitry Andric    */
1653e8d8bef9SDimitry Andric   CXCursor_ObjCAvailabilityCheckExpr = 148,
16540b57cec5SDimitry Andric 
16550b57cec5SDimitry Andric   /**
16560b57cec5SDimitry Andric    * Fixed point literal
16570b57cec5SDimitry Andric    */
1658e8d8bef9SDimitry Andric   CXCursor_FixedPointLiteral = 149,
16590b57cec5SDimitry Andric 
16605ffd83dbSDimitry Andric   /** OpenMP 5.0 [2.1.4, Array Shaping].
16615ffd83dbSDimitry Andric    */
1662e8d8bef9SDimitry Andric   CXCursor_OMPArrayShapingExpr = 150,
16635ffd83dbSDimitry Andric 
16645ffd83dbSDimitry Andric   /**
16655ffd83dbSDimitry Andric    * OpenMP 5.0 [2.1.6 Iterators]
16665ffd83dbSDimitry Andric    */
1667e8d8bef9SDimitry Andric   CXCursor_OMPIteratorExpr = 151,
16685ffd83dbSDimitry Andric 
1669e8d8bef9SDimitry Andric   /** OpenCL's addrspace_cast<> expression.
1670e8d8bef9SDimitry Andric    */
1671e8d8bef9SDimitry Andric   CXCursor_CXXAddrspaceCastExpr = 152,
1672e8d8bef9SDimitry Andric 
167381ad6265SDimitry Andric   /**
167481ad6265SDimitry Andric    * Expression that references a C++20 concept.
167581ad6265SDimitry Andric    */
167681ad6265SDimitry Andric   CXCursor_ConceptSpecializationExpr = 153,
167781ad6265SDimitry Andric 
167881ad6265SDimitry Andric   /**
1679*0fca6ea1SDimitry Andric    * Expression that references a C++20 requires expression.
168081ad6265SDimitry Andric    */
168181ad6265SDimitry Andric   CXCursor_RequiresExpr = 154,
168281ad6265SDimitry Andric 
1683bdd1243dSDimitry Andric   /**
1684bdd1243dSDimitry Andric    * Expression that references a C++20 parenthesized list aggregate
1685bdd1243dSDimitry Andric    * initializer.
1686bdd1243dSDimitry Andric    */
1687bdd1243dSDimitry Andric   CXCursor_CXXParenListInitExpr = 155,
1688bdd1243dSDimitry Andric 
1689*0fca6ea1SDimitry Andric   /**
1690*0fca6ea1SDimitry Andric    *  Represents a C++26 pack indexing expression.
1691*0fca6ea1SDimitry Andric    */
1692*0fca6ea1SDimitry Andric   CXCursor_PackIndexingExpr = 156,
1693*0fca6ea1SDimitry Andric 
1694*0fca6ea1SDimitry Andric   CXCursor_LastExpr = CXCursor_PackIndexingExpr,
16950b57cec5SDimitry Andric 
16960b57cec5SDimitry Andric   /* Statements */
16970b57cec5SDimitry Andric   CXCursor_FirstStmt = 200,
16980b57cec5SDimitry Andric   /**
16990b57cec5SDimitry Andric    * A statement whose specific kind is not exposed via this
17000b57cec5SDimitry Andric    * interface.
17010b57cec5SDimitry Andric    *
17020b57cec5SDimitry Andric    * Unexposed statements have the same operations as any other kind of
17030b57cec5SDimitry Andric    * statement; one can extract their location information, spelling,
17040b57cec5SDimitry Andric    * children, etc. However, the specific kind of the statement is not
17050b57cec5SDimitry Andric    * reported.
17060b57cec5SDimitry Andric    */
17070b57cec5SDimitry Andric   CXCursor_UnexposedStmt = 200,
17080b57cec5SDimitry Andric 
17090b57cec5SDimitry Andric   /** A labelled statement in a function.
17100b57cec5SDimitry Andric    *
17110b57cec5SDimitry Andric    * This cursor kind is used to describe the "start_over:" label statement in
17120b57cec5SDimitry Andric    * the following example:
17130b57cec5SDimitry Andric    *
17140b57cec5SDimitry Andric    * \code
17150b57cec5SDimitry Andric    *   start_over:
17160b57cec5SDimitry Andric    *     ++counter;
17170b57cec5SDimitry Andric    * \endcode
17180b57cec5SDimitry Andric    *
17190b57cec5SDimitry Andric    */
17200b57cec5SDimitry Andric   CXCursor_LabelStmt = 201,
17210b57cec5SDimitry Andric 
17220b57cec5SDimitry Andric   /** A group of statements like { stmt stmt }.
17230b57cec5SDimitry Andric    *
17240b57cec5SDimitry Andric    * This cursor kind is used to describe compound statements, e.g. function
17250b57cec5SDimitry Andric    * bodies.
17260b57cec5SDimitry Andric    */
17270b57cec5SDimitry Andric   CXCursor_CompoundStmt = 202,
17280b57cec5SDimitry Andric 
17290b57cec5SDimitry Andric   /** A case statement.
17300b57cec5SDimitry Andric    */
17310b57cec5SDimitry Andric   CXCursor_CaseStmt = 203,
17320b57cec5SDimitry Andric 
17330b57cec5SDimitry Andric   /** A default statement.
17340b57cec5SDimitry Andric    */
17350b57cec5SDimitry Andric   CXCursor_DefaultStmt = 204,
17360b57cec5SDimitry Andric 
17370b57cec5SDimitry Andric   /** An if statement
17380b57cec5SDimitry Andric    */
17390b57cec5SDimitry Andric   CXCursor_IfStmt = 205,
17400b57cec5SDimitry Andric 
17410b57cec5SDimitry Andric   /** A switch statement.
17420b57cec5SDimitry Andric    */
17430b57cec5SDimitry Andric   CXCursor_SwitchStmt = 206,
17440b57cec5SDimitry Andric 
17450b57cec5SDimitry Andric   /** A while statement.
17460b57cec5SDimitry Andric    */
17470b57cec5SDimitry Andric   CXCursor_WhileStmt = 207,
17480b57cec5SDimitry Andric 
17490b57cec5SDimitry Andric   /** A do statement.
17500b57cec5SDimitry Andric    */
17510b57cec5SDimitry Andric   CXCursor_DoStmt = 208,
17520b57cec5SDimitry Andric 
17530b57cec5SDimitry Andric   /** A for statement.
17540b57cec5SDimitry Andric    */
17550b57cec5SDimitry Andric   CXCursor_ForStmt = 209,
17560b57cec5SDimitry Andric 
17570b57cec5SDimitry Andric   /** A goto statement.
17580b57cec5SDimitry Andric    */
17590b57cec5SDimitry Andric   CXCursor_GotoStmt = 210,
17600b57cec5SDimitry Andric 
17610b57cec5SDimitry Andric   /** An indirect goto statement.
17620b57cec5SDimitry Andric    */
17630b57cec5SDimitry Andric   CXCursor_IndirectGotoStmt = 211,
17640b57cec5SDimitry Andric 
17650b57cec5SDimitry Andric   /** A continue statement.
17660b57cec5SDimitry Andric    */
17670b57cec5SDimitry Andric   CXCursor_ContinueStmt = 212,
17680b57cec5SDimitry Andric 
17690b57cec5SDimitry Andric   /** A break statement.
17700b57cec5SDimitry Andric    */
17710b57cec5SDimitry Andric   CXCursor_BreakStmt = 213,
17720b57cec5SDimitry Andric 
17730b57cec5SDimitry Andric   /** A return statement.
17740b57cec5SDimitry Andric    */
17750b57cec5SDimitry Andric   CXCursor_ReturnStmt = 214,
17760b57cec5SDimitry Andric 
17770b57cec5SDimitry Andric   /** A GCC inline assembly statement extension.
17780b57cec5SDimitry Andric    */
17790b57cec5SDimitry Andric   CXCursor_GCCAsmStmt = 215,
17800b57cec5SDimitry Andric   CXCursor_AsmStmt = CXCursor_GCCAsmStmt,
17810b57cec5SDimitry Andric 
17820b57cec5SDimitry Andric   /** Objective-C's overall \@try-\@catch-\@finally statement.
17830b57cec5SDimitry Andric    */
17840b57cec5SDimitry Andric   CXCursor_ObjCAtTryStmt = 216,
17850b57cec5SDimitry Andric 
17860b57cec5SDimitry Andric   /** Objective-C's \@catch statement.
17870b57cec5SDimitry Andric    */
17880b57cec5SDimitry Andric   CXCursor_ObjCAtCatchStmt = 217,
17890b57cec5SDimitry Andric 
17900b57cec5SDimitry Andric   /** Objective-C's \@finally statement.
17910b57cec5SDimitry Andric    */
17920b57cec5SDimitry Andric   CXCursor_ObjCAtFinallyStmt = 218,
17930b57cec5SDimitry Andric 
17940b57cec5SDimitry Andric   /** Objective-C's \@throw statement.
17950b57cec5SDimitry Andric    */
17960b57cec5SDimitry Andric   CXCursor_ObjCAtThrowStmt = 219,
17970b57cec5SDimitry Andric 
17980b57cec5SDimitry Andric   /** Objective-C's \@synchronized statement.
17990b57cec5SDimitry Andric    */
18000b57cec5SDimitry Andric   CXCursor_ObjCAtSynchronizedStmt = 220,
18010b57cec5SDimitry Andric 
18020b57cec5SDimitry Andric   /** Objective-C's autorelease pool statement.
18030b57cec5SDimitry Andric    */
18040b57cec5SDimitry Andric   CXCursor_ObjCAutoreleasePoolStmt = 221,
18050b57cec5SDimitry Andric 
18060b57cec5SDimitry Andric   /** Objective-C's collection statement.
18070b57cec5SDimitry Andric    */
18080b57cec5SDimitry Andric   CXCursor_ObjCForCollectionStmt = 222,
18090b57cec5SDimitry Andric 
18100b57cec5SDimitry Andric   /** C++'s catch statement.
18110b57cec5SDimitry Andric    */
18120b57cec5SDimitry Andric   CXCursor_CXXCatchStmt = 223,
18130b57cec5SDimitry Andric 
18140b57cec5SDimitry Andric   /** C++'s try statement.
18150b57cec5SDimitry Andric    */
18160b57cec5SDimitry Andric   CXCursor_CXXTryStmt = 224,
18170b57cec5SDimitry Andric 
18180b57cec5SDimitry Andric   /** C++'s for (* : *) statement.
18190b57cec5SDimitry Andric    */
18200b57cec5SDimitry Andric   CXCursor_CXXForRangeStmt = 225,
18210b57cec5SDimitry Andric 
18220b57cec5SDimitry Andric   /** Windows Structured Exception Handling's try statement.
18230b57cec5SDimitry Andric    */
18240b57cec5SDimitry Andric   CXCursor_SEHTryStmt = 226,
18250b57cec5SDimitry Andric 
18260b57cec5SDimitry Andric   /** Windows Structured Exception Handling's except statement.
18270b57cec5SDimitry Andric    */
18280b57cec5SDimitry Andric   CXCursor_SEHExceptStmt = 227,
18290b57cec5SDimitry Andric 
18300b57cec5SDimitry Andric   /** Windows Structured Exception Handling's finally statement.
18310b57cec5SDimitry Andric    */
18320b57cec5SDimitry Andric   CXCursor_SEHFinallyStmt = 228,
18330b57cec5SDimitry Andric 
18340b57cec5SDimitry Andric   /** A MS inline assembly statement extension.
18350b57cec5SDimitry Andric    */
18360b57cec5SDimitry Andric   CXCursor_MSAsmStmt = 229,
18370b57cec5SDimitry Andric 
18380b57cec5SDimitry Andric   /** The null statement ";": C99 6.8.3p3.
18390b57cec5SDimitry Andric    *
18400b57cec5SDimitry Andric    * This cursor kind is used to describe the null statement.
18410b57cec5SDimitry Andric    */
18420b57cec5SDimitry Andric   CXCursor_NullStmt = 230,
18430b57cec5SDimitry Andric 
18440b57cec5SDimitry Andric   /** Adaptor class for mixing declarations with statements and
18450b57cec5SDimitry Andric    * expressions.
18460b57cec5SDimitry Andric    */
18470b57cec5SDimitry Andric   CXCursor_DeclStmt = 231,
18480b57cec5SDimitry Andric 
18490b57cec5SDimitry Andric   /** OpenMP parallel directive.
18500b57cec5SDimitry Andric    */
18510b57cec5SDimitry Andric   CXCursor_OMPParallelDirective = 232,
18520b57cec5SDimitry Andric 
18530b57cec5SDimitry Andric   /** OpenMP SIMD directive.
18540b57cec5SDimitry Andric    */
18550b57cec5SDimitry Andric   CXCursor_OMPSimdDirective = 233,
18560b57cec5SDimitry Andric 
18570b57cec5SDimitry Andric   /** OpenMP for directive.
18580b57cec5SDimitry Andric    */
18590b57cec5SDimitry Andric   CXCursor_OMPForDirective = 234,
18600b57cec5SDimitry Andric 
18610b57cec5SDimitry Andric   /** OpenMP sections directive.
18620b57cec5SDimitry Andric    */
18630b57cec5SDimitry Andric   CXCursor_OMPSectionsDirective = 235,
18640b57cec5SDimitry Andric 
18650b57cec5SDimitry Andric   /** OpenMP section directive.
18660b57cec5SDimitry Andric    */
18670b57cec5SDimitry Andric   CXCursor_OMPSectionDirective = 236,
18680b57cec5SDimitry Andric 
18690b57cec5SDimitry Andric   /** OpenMP single directive.
18700b57cec5SDimitry Andric    */
18710b57cec5SDimitry Andric   CXCursor_OMPSingleDirective = 237,
18720b57cec5SDimitry Andric 
18730b57cec5SDimitry Andric   /** OpenMP parallel for directive.
18740b57cec5SDimitry Andric    */
18750b57cec5SDimitry Andric   CXCursor_OMPParallelForDirective = 238,
18760b57cec5SDimitry Andric 
18770b57cec5SDimitry Andric   /** OpenMP parallel sections directive.
18780b57cec5SDimitry Andric    */
18790b57cec5SDimitry Andric   CXCursor_OMPParallelSectionsDirective = 239,
18800b57cec5SDimitry Andric 
18810b57cec5SDimitry Andric   /** OpenMP task directive.
18820b57cec5SDimitry Andric    */
18830b57cec5SDimitry Andric   CXCursor_OMPTaskDirective = 240,
18840b57cec5SDimitry Andric 
18850b57cec5SDimitry Andric   /** OpenMP master directive.
18860b57cec5SDimitry Andric    */
18870b57cec5SDimitry Andric   CXCursor_OMPMasterDirective = 241,
18880b57cec5SDimitry Andric 
18890b57cec5SDimitry Andric   /** OpenMP critical directive.
18900b57cec5SDimitry Andric    */
18910b57cec5SDimitry Andric   CXCursor_OMPCriticalDirective = 242,
18920b57cec5SDimitry Andric 
18930b57cec5SDimitry Andric   /** OpenMP taskyield directive.
18940b57cec5SDimitry Andric    */
18950b57cec5SDimitry Andric   CXCursor_OMPTaskyieldDirective = 243,
18960b57cec5SDimitry Andric 
18970b57cec5SDimitry Andric   /** OpenMP barrier directive.
18980b57cec5SDimitry Andric    */
18990b57cec5SDimitry Andric   CXCursor_OMPBarrierDirective = 244,
19000b57cec5SDimitry Andric 
19010b57cec5SDimitry Andric   /** OpenMP taskwait directive.
19020b57cec5SDimitry Andric    */
19030b57cec5SDimitry Andric   CXCursor_OMPTaskwaitDirective = 245,
19040b57cec5SDimitry Andric 
19050b57cec5SDimitry Andric   /** OpenMP flush directive.
19060b57cec5SDimitry Andric    */
19070b57cec5SDimitry Andric   CXCursor_OMPFlushDirective = 246,
19080b57cec5SDimitry Andric 
19090b57cec5SDimitry Andric   /** Windows Structured Exception Handling's leave statement.
19100b57cec5SDimitry Andric    */
19110b57cec5SDimitry Andric   CXCursor_SEHLeaveStmt = 247,
19120b57cec5SDimitry Andric 
19130b57cec5SDimitry Andric   /** OpenMP ordered directive.
19140b57cec5SDimitry Andric    */
19150b57cec5SDimitry Andric   CXCursor_OMPOrderedDirective = 248,
19160b57cec5SDimitry Andric 
19170b57cec5SDimitry Andric   /** OpenMP atomic directive.
19180b57cec5SDimitry Andric    */
19190b57cec5SDimitry Andric   CXCursor_OMPAtomicDirective = 249,
19200b57cec5SDimitry Andric 
19210b57cec5SDimitry Andric   /** OpenMP for SIMD directive.
19220b57cec5SDimitry Andric    */
19230b57cec5SDimitry Andric   CXCursor_OMPForSimdDirective = 250,
19240b57cec5SDimitry Andric 
19250b57cec5SDimitry Andric   /** OpenMP parallel for SIMD directive.
19260b57cec5SDimitry Andric    */
19270b57cec5SDimitry Andric   CXCursor_OMPParallelForSimdDirective = 251,
19280b57cec5SDimitry Andric 
19290b57cec5SDimitry Andric   /** OpenMP target directive.
19300b57cec5SDimitry Andric    */
19310b57cec5SDimitry Andric   CXCursor_OMPTargetDirective = 252,
19320b57cec5SDimitry Andric 
19330b57cec5SDimitry Andric   /** OpenMP teams directive.
19340b57cec5SDimitry Andric    */
19350b57cec5SDimitry Andric   CXCursor_OMPTeamsDirective = 253,
19360b57cec5SDimitry Andric 
19370b57cec5SDimitry Andric   /** OpenMP taskgroup directive.
19380b57cec5SDimitry Andric    */
19390b57cec5SDimitry Andric   CXCursor_OMPTaskgroupDirective = 254,
19400b57cec5SDimitry Andric 
19410b57cec5SDimitry Andric   /** OpenMP cancellation point directive.
19420b57cec5SDimitry Andric    */
19430b57cec5SDimitry Andric   CXCursor_OMPCancellationPointDirective = 255,
19440b57cec5SDimitry Andric 
19450b57cec5SDimitry Andric   /** OpenMP cancel directive.
19460b57cec5SDimitry Andric    */
19470b57cec5SDimitry Andric   CXCursor_OMPCancelDirective = 256,
19480b57cec5SDimitry Andric 
19490b57cec5SDimitry Andric   /** OpenMP target data directive.
19500b57cec5SDimitry Andric    */
19510b57cec5SDimitry Andric   CXCursor_OMPTargetDataDirective = 257,
19520b57cec5SDimitry Andric 
19530b57cec5SDimitry Andric   /** OpenMP taskloop directive.
19540b57cec5SDimitry Andric    */
19550b57cec5SDimitry Andric   CXCursor_OMPTaskLoopDirective = 258,
19560b57cec5SDimitry Andric 
19570b57cec5SDimitry Andric   /** OpenMP taskloop simd directive.
19580b57cec5SDimitry Andric    */
19590b57cec5SDimitry Andric   CXCursor_OMPTaskLoopSimdDirective = 259,
19600b57cec5SDimitry Andric 
19610b57cec5SDimitry Andric   /** OpenMP distribute directive.
19620b57cec5SDimitry Andric    */
19630b57cec5SDimitry Andric   CXCursor_OMPDistributeDirective = 260,
19640b57cec5SDimitry Andric 
19650b57cec5SDimitry Andric   /** OpenMP target enter data directive.
19660b57cec5SDimitry Andric    */
19670b57cec5SDimitry Andric   CXCursor_OMPTargetEnterDataDirective = 261,
19680b57cec5SDimitry Andric 
19690b57cec5SDimitry Andric   /** OpenMP target exit data directive.
19700b57cec5SDimitry Andric    */
19710b57cec5SDimitry Andric   CXCursor_OMPTargetExitDataDirective = 262,
19720b57cec5SDimitry Andric 
19730b57cec5SDimitry Andric   /** OpenMP target parallel directive.
19740b57cec5SDimitry Andric    */
19750b57cec5SDimitry Andric   CXCursor_OMPTargetParallelDirective = 263,
19760b57cec5SDimitry Andric 
19770b57cec5SDimitry Andric   /** OpenMP target parallel for directive.
19780b57cec5SDimitry Andric    */
19790b57cec5SDimitry Andric   CXCursor_OMPTargetParallelForDirective = 264,
19800b57cec5SDimitry Andric 
19810b57cec5SDimitry Andric   /** OpenMP target update directive.
19820b57cec5SDimitry Andric    */
19830b57cec5SDimitry Andric   CXCursor_OMPTargetUpdateDirective = 265,
19840b57cec5SDimitry Andric 
19850b57cec5SDimitry Andric   /** OpenMP distribute parallel for directive.
19860b57cec5SDimitry Andric    */
19870b57cec5SDimitry Andric   CXCursor_OMPDistributeParallelForDirective = 266,
19880b57cec5SDimitry Andric 
19890b57cec5SDimitry Andric   /** OpenMP distribute parallel for simd directive.
19900b57cec5SDimitry Andric    */
19910b57cec5SDimitry Andric   CXCursor_OMPDistributeParallelForSimdDirective = 267,
19920b57cec5SDimitry Andric 
19930b57cec5SDimitry Andric   /** OpenMP distribute simd directive.
19940b57cec5SDimitry Andric    */
19950b57cec5SDimitry Andric   CXCursor_OMPDistributeSimdDirective = 268,
19960b57cec5SDimitry Andric 
19970b57cec5SDimitry Andric   /** OpenMP target parallel for simd directive.
19980b57cec5SDimitry Andric    */
19990b57cec5SDimitry Andric   CXCursor_OMPTargetParallelForSimdDirective = 269,
20000b57cec5SDimitry Andric 
20010b57cec5SDimitry Andric   /** OpenMP target simd directive.
20020b57cec5SDimitry Andric    */
20030b57cec5SDimitry Andric   CXCursor_OMPTargetSimdDirective = 270,
20040b57cec5SDimitry Andric 
20050b57cec5SDimitry Andric   /** OpenMP teams distribute directive.
20060b57cec5SDimitry Andric    */
20070b57cec5SDimitry Andric   CXCursor_OMPTeamsDistributeDirective = 271,
20080b57cec5SDimitry Andric 
20090b57cec5SDimitry Andric   /** OpenMP teams distribute simd directive.
20100b57cec5SDimitry Andric    */
20110b57cec5SDimitry Andric   CXCursor_OMPTeamsDistributeSimdDirective = 272,
20120b57cec5SDimitry Andric 
20130b57cec5SDimitry Andric   /** OpenMP teams distribute parallel for simd directive.
20140b57cec5SDimitry Andric    */
20150b57cec5SDimitry Andric   CXCursor_OMPTeamsDistributeParallelForSimdDirective = 273,
20160b57cec5SDimitry Andric 
20170b57cec5SDimitry Andric   /** OpenMP teams distribute parallel for directive.
20180b57cec5SDimitry Andric    */
20190b57cec5SDimitry Andric   CXCursor_OMPTeamsDistributeParallelForDirective = 274,
20200b57cec5SDimitry Andric 
20210b57cec5SDimitry Andric   /** OpenMP target teams directive.
20220b57cec5SDimitry Andric    */
20230b57cec5SDimitry Andric   CXCursor_OMPTargetTeamsDirective = 275,
20240b57cec5SDimitry Andric 
20250b57cec5SDimitry Andric   /** OpenMP target teams distribute directive.
20260b57cec5SDimitry Andric    */
20270b57cec5SDimitry Andric   CXCursor_OMPTargetTeamsDistributeDirective = 276,
20280b57cec5SDimitry Andric 
20290b57cec5SDimitry Andric   /** OpenMP target teams distribute parallel for directive.
20300b57cec5SDimitry Andric    */
20310b57cec5SDimitry Andric   CXCursor_OMPTargetTeamsDistributeParallelForDirective = 277,
20320b57cec5SDimitry Andric 
20330b57cec5SDimitry Andric   /** OpenMP target teams distribute parallel for simd directive.
20340b57cec5SDimitry Andric    */
20350b57cec5SDimitry Andric   CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective = 278,
20360b57cec5SDimitry Andric 
20370b57cec5SDimitry Andric   /** OpenMP target teams distribute simd directive.
20380b57cec5SDimitry Andric    */
20390b57cec5SDimitry Andric   CXCursor_OMPTargetTeamsDistributeSimdDirective = 279,
20400b57cec5SDimitry Andric 
20410b57cec5SDimitry Andric   /** C++2a std::bit_cast expression.
20420b57cec5SDimitry Andric    */
20430b57cec5SDimitry Andric   CXCursor_BuiltinBitCastExpr = 280,
20440b57cec5SDimitry Andric 
2045a7dea167SDimitry Andric   /** OpenMP master taskloop directive.
2046a7dea167SDimitry Andric    */
2047a7dea167SDimitry Andric   CXCursor_OMPMasterTaskLoopDirective = 281,
2048a7dea167SDimitry Andric 
2049a7dea167SDimitry Andric   /** OpenMP parallel master taskloop directive.
2050a7dea167SDimitry Andric    */
2051a7dea167SDimitry Andric   CXCursor_OMPParallelMasterTaskLoopDirective = 282,
2052a7dea167SDimitry Andric 
2053a7dea167SDimitry Andric   /** OpenMP master taskloop simd directive.
2054a7dea167SDimitry Andric    */
2055a7dea167SDimitry Andric   CXCursor_OMPMasterTaskLoopSimdDirective = 283,
2056a7dea167SDimitry Andric 
2057480093f4SDimitry Andric   /** OpenMP parallel master taskloop simd directive.
2058480093f4SDimitry Andric    */
2059480093f4SDimitry Andric   CXCursor_OMPParallelMasterTaskLoopSimdDirective = 284,
2060a7dea167SDimitry Andric 
2061480093f4SDimitry Andric   /** OpenMP parallel master directive.
2062480093f4SDimitry Andric    */
2063480093f4SDimitry Andric   CXCursor_OMPParallelMasterDirective = 285,
2064480093f4SDimitry Andric 
20655ffd83dbSDimitry Andric   /** OpenMP depobj directive.
20665ffd83dbSDimitry Andric    */
20675ffd83dbSDimitry Andric   CXCursor_OMPDepobjDirective = 286,
20685ffd83dbSDimitry Andric 
20695ffd83dbSDimitry Andric   /** OpenMP scan directive.
20705ffd83dbSDimitry Andric    */
20715ffd83dbSDimitry Andric   CXCursor_OMPScanDirective = 287,
20725ffd83dbSDimitry Andric 
2073fe6060f1SDimitry Andric   /** OpenMP tile directive.
2074fe6060f1SDimitry Andric    */
2075fe6060f1SDimitry Andric   CXCursor_OMPTileDirective = 288,
2076fe6060f1SDimitry Andric 
2077fe6060f1SDimitry Andric   /** OpenMP canonical loop.
2078fe6060f1SDimitry Andric    */
2079fe6060f1SDimitry Andric   CXCursor_OMPCanonicalLoop = 289,
2080fe6060f1SDimitry Andric 
2081fe6060f1SDimitry Andric   /** OpenMP interop directive.
2082fe6060f1SDimitry Andric    */
2083fe6060f1SDimitry Andric   CXCursor_OMPInteropDirective = 290,
2084fe6060f1SDimitry Andric 
2085fe6060f1SDimitry Andric   /** OpenMP dispatch directive.
2086fe6060f1SDimitry Andric    */
2087fe6060f1SDimitry Andric   CXCursor_OMPDispatchDirective = 291,
2088fe6060f1SDimitry Andric 
2089fe6060f1SDimitry Andric   /** OpenMP masked directive.
2090fe6060f1SDimitry Andric    */
2091fe6060f1SDimitry Andric   CXCursor_OMPMaskedDirective = 292,
2092fe6060f1SDimitry Andric 
2093fe6060f1SDimitry Andric   /** OpenMP unroll directive.
2094fe6060f1SDimitry Andric    */
2095fe6060f1SDimitry Andric   CXCursor_OMPUnrollDirective = 293,
2096fe6060f1SDimitry Andric 
2097349cc55cSDimitry Andric   /** OpenMP metadirective directive.
2098349cc55cSDimitry Andric    */
2099349cc55cSDimitry Andric   CXCursor_OMPMetaDirective = 294,
2100349cc55cSDimitry Andric 
2101349cc55cSDimitry Andric   /** OpenMP loop directive.
2102349cc55cSDimitry Andric    */
2103349cc55cSDimitry Andric   CXCursor_OMPGenericLoopDirective = 295,
2104349cc55cSDimitry Andric 
210581ad6265SDimitry Andric   /** OpenMP teams loop directive.
210681ad6265SDimitry Andric    */
210781ad6265SDimitry Andric   CXCursor_OMPTeamsGenericLoopDirective = 296,
210881ad6265SDimitry Andric 
210981ad6265SDimitry Andric   /** OpenMP target teams loop directive.
211081ad6265SDimitry Andric    */
211181ad6265SDimitry Andric   CXCursor_OMPTargetTeamsGenericLoopDirective = 297,
211281ad6265SDimitry Andric 
211381ad6265SDimitry Andric   /** OpenMP parallel loop directive.
211481ad6265SDimitry Andric    */
211581ad6265SDimitry Andric   CXCursor_OMPParallelGenericLoopDirective = 298,
211681ad6265SDimitry Andric 
211781ad6265SDimitry Andric   /** OpenMP target parallel loop directive.
211881ad6265SDimitry Andric    */
211981ad6265SDimitry Andric   CXCursor_OMPTargetParallelGenericLoopDirective = 299,
212081ad6265SDimitry Andric 
212181ad6265SDimitry Andric   /** OpenMP parallel masked directive.
212281ad6265SDimitry Andric    */
212381ad6265SDimitry Andric   CXCursor_OMPParallelMaskedDirective = 300,
212481ad6265SDimitry Andric 
212581ad6265SDimitry Andric   /** OpenMP masked taskloop directive.
212681ad6265SDimitry Andric    */
212781ad6265SDimitry Andric   CXCursor_OMPMaskedTaskLoopDirective = 301,
212881ad6265SDimitry Andric 
212981ad6265SDimitry Andric   /** OpenMP masked taskloop simd directive.
213081ad6265SDimitry Andric    */
213181ad6265SDimitry Andric   CXCursor_OMPMaskedTaskLoopSimdDirective = 302,
213281ad6265SDimitry Andric 
213381ad6265SDimitry Andric   /** OpenMP parallel masked taskloop directive.
213481ad6265SDimitry Andric    */
213581ad6265SDimitry Andric   CXCursor_OMPParallelMaskedTaskLoopDirective = 303,
213681ad6265SDimitry Andric 
213781ad6265SDimitry Andric   /** OpenMP parallel masked taskloop simd directive.
213881ad6265SDimitry Andric    */
213981ad6265SDimitry Andric   CXCursor_OMPParallelMaskedTaskLoopSimdDirective = 304,
214081ad6265SDimitry Andric 
2141bdd1243dSDimitry Andric   /** OpenMP error directive.
2142bdd1243dSDimitry Andric    */
2143bdd1243dSDimitry Andric   CXCursor_OMPErrorDirective = 305,
2144bdd1243dSDimitry Andric 
21455f757f3fSDimitry Andric   /** OpenMP scope directive.
21465f757f3fSDimitry Andric    */
21475f757f3fSDimitry Andric   CXCursor_OMPScopeDirective = 306,
21485f757f3fSDimitry Andric 
2149*0fca6ea1SDimitry Andric   /** OpenMP reverse directive.
2150*0fca6ea1SDimitry Andric    */
2151*0fca6ea1SDimitry Andric   CXCursor_OMPReverseDirective = 307,
2152*0fca6ea1SDimitry Andric 
2153*0fca6ea1SDimitry Andric   /** OpenMP interchange directive.
2154*0fca6ea1SDimitry Andric    */
2155*0fca6ea1SDimitry Andric   CXCursor_OMPInterchangeDirective = 308,
2156*0fca6ea1SDimitry Andric 
2157*0fca6ea1SDimitry Andric   /** OpenACC Compute Construct.
2158*0fca6ea1SDimitry Andric    */
2159*0fca6ea1SDimitry Andric   CXCursor_OpenACCComputeConstruct = 320,
2160*0fca6ea1SDimitry Andric 
2161*0fca6ea1SDimitry Andric   /** OpenACC Loop Construct.
2162*0fca6ea1SDimitry Andric    */
2163*0fca6ea1SDimitry Andric   CXCursor_OpenACCLoopConstruct = 321,
2164*0fca6ea1SDimitry Andric 
2165*0fca6ea1SDimitry Andric   CXCursor_LastStmt = CXCursor_OpenACCLoopConstruct,
21660b57cec5SDimitry Andric 
21670b57cec5SDimitry Andric   /**
21680b57cec5SDimitry Andric    * Cursor that represents the translation unit itself.
21690b57cec5SDimitry Andric    *
21700b57cec5SDimitry Andric    * The translation unit cursor exists primarily to act as the root
21710b57cec5SDimitry Andric    * cursor for traversing the contents of a translation unit.
21720b57cec5SDimitry Andric    */
217381ad6265SDimitry Andric   CXCursor_TranslationUnit = 350,
21740b57cec5SDimitry Andric 
21750b57cec5SDimitry Andric   /* Attributes */
21760b57cec5SDimitry Andric   CXCursor_FirstAttr = 400,
21770b57cec5SDimitry Andric   /**
21780b57cec5SDimitry Andric    * An attribute whose specific kind is not exposed via this
21790b57cec5SDimitry Andric    * interface.
21800b57cec5SDimitry Andric    */
21810b57cec5SDimitry Andric   CXCursor_UnexposedAttr = 400,
21820b57cec5SDimitry Andric 
21830b57cec5SDimitry Andric   CXCursor_IBActionAttr = 401,
21840b57cec5SDimitry Andric   CXCursor_IBOutletAttr = 402,
21850b57cec5SDimitry Andric   CXCursor_IBOutletCollectionAttr = 403,
21860b57cec5SDimitry Andric   CXCursor_CXXFinalAttr = 404,
21870b57cec5SDimitry Andric   CXCursor_CXXOverrideAttr = 405,
21880b57cec5SDimitry Andric   CXCursor_AnnotateAttr = 406,
21890b57cec5SDimitry Andric   CXCursor_AsmLabelAttr = 407,
21900b57cec5SDimitry Andric   CXCursor_PackedAttr = 408,
21910b57cec5SDimitry Andric   CXCursor_PureAttr = 409,
21920b57cec5SDimitry Andric   CXCursor_ConstAttr = 410,
21930b57cec5SDimitry Andric   CXCursor_NoDuplicateAttr = 411,
21940b57cec5SDimitry Andric   CXCursor_CUDAConstantAttr = 412,
21950b57cec5SDimitry Andric   CXCursor_CUDADeviceAttr = 413,
21960b57cec5SDimitry Andric   CXCursor_CUDAGlobalAttr = 414,
21970b57cec5SDimitry Andric   CXCursor_CUDAHostAttr = 415,
21980b57cec5SDimitry Andric   CXCursor_CUDASharedAttr = 416,
21990b57cec5SDimitry Andric   CXCursor_VisibilityAttr = 417,
22000b57cec5SDimitry Andric   CXCursor_DLLExport = 418,
22010b57cec5SDimitry Andric   CXCursor_DLLImport = 419,
22020b57cec5SDimitry Andric   CXCursor_NSReturnsRetained = 420,
22030b57cec5SDimitry Andric   CXCursor_NSReturnsNotRetained = 421,
22040b57cec5SDimitry Andric   CXCursor_NSReturnsAutoreleased = 422,
22050b57cec5SDimitry Andric   CXCursor_NSConsumesSelf = 423,
22060b57cec5SDimitry Andric   CXCursor_NSConsumed = 424,
22070b57cec5SDimitry Andric   CXCursor_ObjCException = 425,
22080b57cec5SDimitry Andric   CXCursor_ObjCNSObject = 426,
22090b57cec5SDimitry Andric   CXCursor_ObjCIndependentClass = 427,
22100b57cec5SDimitry Andric   CXCursor_ObjCPreciseLifetime = 428,
22110b57cec5SDimitry Andric   CXCursor_ObjCReturnsInnerPointer = 429,
22120b57cec5SDimitry Andric   CXCursor_ObjCRequiresSuper = 430,
22130b57cec5SDimitry Andric   CXCursor_ObjCRootClass = 431,
22140b57cec5SDimitry Andric   CXCursor_ObjCSubclassingRestricted = 432,
22150b57cec5SDimitry Andric   CXCursor_ObjCExplicitProtocolImpl = 433,
22160b57cec5SDimitry Andric   CXCursor_ObjCDesignatedInitializer = 434,
22170b57cec5SDimitry Andric   CXCursor_ObjCRuntimeVisible = 435,
22180b57cec5SDimitry Andric   CXCursor_ObjCBoxable = 436,
22190b57cec5SDimitry Andric   CXCursor_FlagEnum = 437,
22200b57cec5SDimitry Andric   CXCursor_ConvergentAttr = 438,
22210b57cec5SDimitry Andric   CXCursor_WarnUnusedAttr = 439,
22220b57cec5SDimitry Andric   CXCursor_WarnUnusedResultAttr = 440,
22230b57cec5SDimitry Andric   CXCursor_AlignedAttr = 441,
22240b57cec5SDimitry Andric   CXCursor_LastAttr = CXCursor_AlignedAttr,
22250b57cec5SDimitry Andric 
22260b57cec5SDimitry Andric   /* Preprocessing */
22270b57cec5SDimitry Andric   CXCursor_PreprocessingDirective = 500,
22280b57cec5SDimitry Andric   CXCursor_MacroDefinition = 501,
22290b57cec5SDimitry Andric   CXCursor_MacroExpansion = 502,
22300b57cec5SDimitry Andric   CXCursor_MacroInstantiation = CXCursor_MacroExpansion,
22310b57cec5SDimitry Andric   CXCursor_InclusionDirective = 503,
22320b57cec5SDimitry Andric   CXCursor_FirstPreprocessing = CXCursor_PreprocessingDirective,
22330b57cec5SDimitry Andric   CXCursor_LastPreprocessing = CXCursor_InclusionDirective,
22340b57cec5SDimitry Andric 
22350b57cec5SDimitry Andric   /* Extra Declarations */
22360b57cec5SDimitry Andric   /**
22370b57cec5SDimitry Andric    * A module import declaration.
22380b57cec5SDimitry Andric    */
22390b57cec5SDimitry Andric   CXCursor_ModuleImportDecl = 600,
22400b57cec5SDimitry Andric   CXCursor_TypeAliasTemplateDecl = 601,
22410b57cec5SDimitry Andric   /**
22420b57cec5SDimitry Andric    * A static_assert or _Static_assert node
22430b57cec5SDimitry Andric    */
22440b57cec5SDimitry Andric   CXCursor_StaticAssert = 602,
22450b57cec5SDimitry Andric   /**
22460b57cec5SDimitry Andric    * a friend declaration.
22470b57cec5SDimitry Andric    */
22480b57cec5SDimitry Andric   CXCursor_FriendDecl = 603,
224981ad6265SDimitry Andric   /**
225081ad6265SDimitry Andric    * a concept declaration.
225181ad6265SDimitry Andric    */
225281ad6265SDimitry Andric   CXCursor_ConceptDecl = 604,
225381ad6265SDimitry Andric 
22540b57cec5SDimitry Andric   CXCursor_FirstExtraDecl = CXCursor_ModuleImportDecl,
225581ad6265SDimitry Andric   CXCursor_LastExtraDecl = CXCursor_ConceptDecl,
22560b57cec5SDimitry Andric 
22570b57cec5SDimitry Andric   /**
22580b57cec5SDimitry Andric    * A code completion overload candidate.
22590b57cec5SDimitry Andric    */
22600b57cec5SDimitry Andric   CXCursor_OverloadCandidate = 700
22610b57cec5SDimitry Andric };
22620b57cec5SDimitry Andric 
22630b57cec5SDimitry Andric /**
22640b57cec5SDimitry Andric  * A cursor representing some element in the abstract syntax tree for
22650b57cec5SDimitry Andric  * a translation unit.
22660b57cec5SDimitry Andric  *
22670b57cec5SDimitry Andric  * The cursor abstraction unifies the different kinds of entities in a
22680b57cec5SDimitry Andric  * program--declaration, statements, expressions, references to declarations,
22690b57cec5SDimitry Andric  * etc.--under a single "cursor" abstraction with a common set of operations.
22700b57cec5SDimitry Andric  * Common operation for a cursor include: getting the physical location in
22710b57cec5SDimitry Andric  * a source file where the cursor points, getting the name associated with a
22720b57cec5SDimitry Andric  * cursor, and retrieving cursors for any child nodes of a particular cursor.
22730b57cec5SDimitry Andric  *
22740b57cec5SDimitry Andric  * Cursors can be produced in two specific ways.
22750b57cec5SDimitry Andric  * clang_getTranslationUnitCursor() produces a cursor for a translation unit,
22760b57cec5SDimitry Andric  * from which one can use clang_visitChildren() to explore the rest of the
22770b57cec5SDimitry Andric  * translation unit. clang_getCursor() maps from a physical source location
22780b57cec5SDimitry Andric  * to the entity that resides at that location, allowing one to map from the
22790b57cec5SDimitry Andric  * source code into the AST.
22800b57cec5SDimitry Andric  */
22810b57cec5SDimitry Andric typedef struct {
22820b57cec5SDimitry Andric   enum CXCursorKind kind;
22830b57cec5SDimitry Andric   int xdata;
22840b57cec5SDimitry Andric   const void *data[3];
22850b57cec5SDimitry Andric } CXCursor;
22860b57cec5SDimitry Andric 
22870b57cec5SDimitry Andric /**
22880b57cec5SDimitry Andric  * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations
22890b57cec5SDimitry Andric  *
22900b57cec5SDimitry Andric  * @{
22910b57cec5SDimitry Andric  */
22920b57cec5SDimitry Andric 
22930b57cec5SDimitry Andric /**
22940b57cec5SDimitry Andric  * Retrieve the NULL cursor, which represents no entity.
22950b57cec5SDimitry Andric  */
22960b57cec5SDimitry Andric CINDEX_LINKAGE CXCursor clang_getNullCursor(void);
22970b57cec5SDimitry Andric 
22980b57cec5SDimitry Andric /**
22990b57cec5SDimitry Andric  * Retrieve the cursor that represents the given translation unit.
23000b57cec5SDimitry Andric  *
23010b57cec5SDimitry Andric  * The translation unit cursor can be used to start traversing the
23020b57cec5SDimitry Andric  * various declarations within the given translation unit.
23030b57cec5SDimitry Andric  */
23040b57cec5SDimitry Andric CINDEX_LINKAGE CXCursor clang_getTranslationUnitCursor(CXTranslationUnit);
23050b57cec5SDimitry Andric 
23060b57cec5SDimitry Andric /**
23070b57cec5SDimitry Andric  * Determine whether two cursors are equivalent.
23080b57cec5SDimitry Andric  */
23090b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_equalCursors(CXCursor, CXCursor);
23100b57cec5SDimitry Andric 
23110b57cec5SDimitry Andric /**
23120b57cec5SDimitry Andric  * Returns non-zero if \p cursor is null.
23130b57cec5SDimitry Andric  */
23140b57cec5SDimitry Andric CINDEX_LINKAGE int clang_Cursor_isNull(CXCursor cursor);
23150b57cec5SDimitry Andric 
23160b57cec5SDimitry Andric /**
23170b57cec5SDimitry Andric  * Compute a hash value for the given cursor.
23180b57cec5SDimitry Andric  */
23190b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_hashCursor(CXCursor);
23200b57cec5SDimitry Andric 
23210b57cec5SDimitry Andric /**
23220b57cec5SDimitry Andric  * Retrieve the kind of the given cursor.
23230b57cec5SDimitry Andric  */
23240b57cec5SDimitry Andric CINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor);
23250b57cec5SDimitry Andric 
23260b57cec5SDimitry Andric /**
23270b57cec5SDimitry Andric  * Determine whether the given cursor kind represents a declaration.
23280b57cec5SDimitry Andric  */
23290b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind);
23300b57cec5SDimitry Andric 
23310b57cec5SDimitry Andric /**
23320b57cec5SDimitry Andric  * Determine whether the given declaration is invalid.
23330b57cec5SDimitry Andric  *
23340b57cec5SDimitry Andric  * A declaration is invalid if it could not be parsed successfully.
23350b57cec5SDimitry Andric  *
23360b57cec5SDimitry Andric  * \returns non-zero if the cursor represents a declaration and it is
23370b57cec5SDimitry Andric  * invalid, otherwise NULL.
23380b57cec5SDimitry Andric  */
23390b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_isInvalidDeclaration(CXCursor);
23400b57cec5SDimitry Andric 
23410b57cec5SDimitry Andric /**
23420b57cec5SDimitry Andric  * Determine whether the given cursor kind represents a simple
23430b57cec5SDimitry Andric  * reference.
23440b57cec5SDimitry Andric  *
23450b57cec5SDimitry Andric  * Note that other kinds of cursors (such as expressions) can also refer to
23460b57cec5SDimitry Andric  * other cursors. Use clang_getCursorReferenced() to determine whether a
23470b57cec5SDimitry Andric  * particular cursor refers to another entity.
23480b57cec5SDimitry Andric  */
23490b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_isReference(enum CXCursorKind);
23500b57cec5SDimitry Andric 
23510b57cec5SDimitry Andric /**
23520b57cec5SDimitry Andric  * Determine whether the given cursor kind represents an expression.
23530b57cec5SDimitry Andric  */
23540b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_isExpression(enum CXCursorKind);
23550b57cec5SDimitry Andric 
23560b57cec5SDimitry Andric /**
23570b57cec5SDimitry Andric  * Determine whether the given cursor kind represents a statement.
23580b57cec5SDimitry Andric  */
23590b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_isStatement(enum CXCursorKind);
23600b57cec5SDimitry Andric 
23610b57cec5SDimitry Andric /**
23620b57cec5SDimitry Andric  * Determine whether the given cursor kind represents an attribute.
23630b57cec5SDimitry Andric  */
23640b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_isAttribute(enum CXCursorKind);
23650b57cec5SDimitry Andric 
23660b57cec5SDimitry Andric /**
23670b57cec5SDimitry Andric  * Determine whether the given cursor has any attributes.
23680b57cec5SDimitry Andric  */
23690b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_Cursor_hasAttrs(CXCursor C);
23700b57cec5SDimitry Andric 
23710b57cec5SDimitry Andric /**
23720b57cec5SDimitry Andric  * Determine whether the given cursor kind represents an invalid
23730b57cec5SDimitry Andric  * cursor.
23740b57cec5SDimitry Andric  */
23750b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_isInvalid(enum CXCursorKind);
23760b57cec5SDimitry Andric 
23770b57cec5SDimitry Andric /**
23780b57cec5SDimitry Andric  * Determine whether the given cursor kind represents a translation
23790b57cec5SDimitry Andric  * unit.
23800b57cec5SDimitry Andric  */
23810b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_isTranslationUnit(enum CXCursorKind);
23820b57cec5SDimitry Andric 
23830b57cec5SDimitry Andric /***
23840b57cec5SDimitry Andric  * Determine whether the given cursor represents a preprocessing
23850b57cec5SDimitry Andric  * element, such as a preprocessor directive or macro instantiation.
23860b57cec5SDimitry Andric  */
23870b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_isPreprocessing(enum CXCursorKind);
23880b57cec5SDimitry Andric 
23890b57cec5SDimitry Andric /***
23900b57cec5SDimitry Andric  * Determine whether the given cursor represents a currently
23910b57cec5SDimitry Andric  *  unexposed piece of the AST (e.g., CXCursor_UnexposedStmt).
23920b57cec5SDimitry Andric  */
23930b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_isUnexposed(enum CXCursorKind);
23940b57cec5SDimitry Andric 
23950b57cec5SDimitry Andric /**
23960b57cec5SDimitry Andric  * Describe the linkage of the entity referred to by a cursor.
23970b57cec5SDimitry Andric  */
23980b57cec5SDimitry Andric enum CXLinkageKind {
23990b57cec5SDimitry Andric   /** This value indicates that no linkage information is available
24000b57cec5SDimitry Andric    * for a provided CXCursor. */
24010b57cec5SDimitry Andric   CXLinkage_Invalid,
24020b57cec5SDimitry Andric   /**
24030b57cec5SDimitry Andric    * This is the linkage for variables, parameters, and so on that
24040b57cec5SDimitry Andric    *  have automatic storage.  This covers normal (non-extern) local variables.
24050b57cec5SDimitry Andric    */
24060b57cec5SDimitry Andric   CXLinkage_NoLinkage,
24070b57cec5SDimitry Andric   /** This is the linkage for static variables and static functions. */
24080b57cec5SDimitry Andric   CXLinkage_Internal,
24090b57cec5SDimitry Andric   /** This is the linkage for entities with external linkage that live
24100b57cec5SDimitry Andric    * in C++ anonymous namespaces.*/
24110b57cec5SDimitry Andric   CXLinkage_UniqueExternal,
24120b57cec5SDimitry Andric   /** This is the linkage for entities with true, external linkage. */
24130b57cec5SDimitry Andric   CXLinkage_External
24140b57cec5SDimitry Andric };
24150b57cec5SDimitry Andric 
24160b57cec5SDimitry Andric /**
24170b57cec5SDimitry Andric  * Determine the linkage of the entity referred to by a given cursor.
24180b57cec5SDimitry Andric  */
24190b57cec5SDimitry Andric CINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor);
24200b57cec5SDimitry Andric 
24210b57cec5SDimitry Andric enum CXVisibilityKind {
24220b57cec5SDimitry Andric   /** This value indicates that no visibility information is available
24230b57cec5SDimitry Andric    * for a provided CXCursor. */
24240b57cec5SDimitry Andric   CXVisibility_Invalid,
24250b57cec5SDimitry Andric 
24260b57cec5SDimitry Andric   /** Symbol not seen by the linker. */
24270b57cec5SDimitry Andric   CXVisibility_Hidden,
24280b57cec5SDimitry Andric   /** Symbol seen by the linker but resolves to a symbol inside this object. */
24290b57cec5SDimitry Andric   CXVisibility_Protected,
24300b57cec5SDimitry Andric   /** Symbol seen by the linker and acts like a normal symbol. */
24310b57cec5SDimitry Andric   CXVisibility_Default
24320b57cec5SDimitry Andric };
24330b57cec5SDimitry Andric 
24340b57cec5SDimitry Andric /**
24350b57cec5SDimitry Andric  * Describe the visibility of the entity referred to by a cursor.
24360b57cec5SDimitry Andric  *
24370b57cec5SDimitry Andric  * This returns the default visibility if not explicitly specified by
24380b57cec5SDimitry Andric  * a visibility attribute. The default visibility may be changed by
24390b57cec5SDimitry Andric  * commandline arguments.
24400b57cec5SDimitry Andric  *
24410b57cec5SDimitry Andric  * \param cursor The cursor to query.
24420b57cec5SDimitry Andric  *
24430b57cec5SDimitry Andric  * \returns The visibility of the cursor.
24440b57cec5SDimitry Andric  */
24450b57cec5SDimitry Andric CINDEX_LINKAGE enum CXVisibilityKind clang_getCursorVisibility(CXCursor cursor);
24460b57cec5SDimitry Andric 
24470b57cec5SDimitry Andric /**
24480b57cec5SDimitry Andric  * Determine the availability of the entity that this cursor refers to,
24490b57cec5SDimitry Andric  * taking the current target platform into account.
24500b57cec5SDimitry Andric  *
24510b57cec5SDimitry Andric  * \param cursor The cursor to query.
24520b57cec5SDimitry Andric  *
24530b57cec5SDimitry Andric  * \returns The availability of the cursor.
24540b57cec5SDimitry Andric  */
24550b57cec5SDimitry Andric CINDEX_LINKAGE enum CXAvailabilityKind
24560b57cec5SDimitry Andric clang_getCursorAvailability(CXCursor cursor);
24570b57cec5SDimitry Andric 
24580b57cec5SDimitry Andric /**
24590b57cec5SDimitry Andric  * Describes the availability of a given entity on a particular platform, e.g.,
24600b57cec5SDimitry Andric  * a particular class might only be available on Mac OS 10.7 or newer.
24610b57cec5SDimitry Andric  */
24620b57cec5SDimitry Andric typedef struct CXPlatformAvailability {
24630b57cec5SDimitry Andric   /**
24640b57cec5SDimitry Andric    * A string that describes the platform for which this structure
24650b57cec5SDimitry Andric    * provides availability information.
24660b57cec5SDimitry Andric    *
24670b57cec5SDimitry Andric    * Possible values are "ios" or "macos".
24680b57cec5SDimitry Andric    */
24690b57cec5SDimitry Andric   CXString Platform;
24700b57cec5SDimitry Andric   /**
24710b57cec5SDimitry Andric    * The version number in which this entity was introduced.
24720b57cec5SDimitry Andric    */
24730b57cec5SDimitry Andric   CXVersion Introduced;
24740b57cec5SDimitry Andric   /**
24750b57cec5SDimitry Andric    * The version number in which this entity was deprecated (but is
24760b57cec5SDimitry Andric    * still available).
24770b57cec5SDimitry Andric    */
24780b57cec5SDimitry Andric   CXVersion Deprecated;
24790b57cec5SDimitry Andric   /**
24800b57cec5SDimitry Andric    * The version number in which this entity was obsoleted, and therefore
24810b57cec5SDimitry Andric    * is no longer available.
24820b57cec5SDimitry Andric    */
24830b57cec5SDimitry Andric   CXVersion Obsoleted;
24840b57cec5SDimitry Andric   /**
24850b57cec5SDimitry Andric    * Whether the entity is unconditionally unavailable on this platform.
24860b57cec5SDimitry Andric    */
24870b57cec5SDimitry Andric   int Unavailable;
24880b57cec5SDimitry Andric   /**
24890b57cec5SDimitry Andric    * An optional message to provide to a user of this API, e.g., to
24900b57cec5SDimitry Andric    * suggest replacement APIs.
24910b57cec5SDimitry Andric    */
24920b57cec5SDimitry Andric   CXString Message;
24930b57cec5SDimitry Andric } CXPlatformAvailability;
24940b57cec5SDimitry Andric 
24950b57cec5SDimitry Andric /**
24960b57cec5SDimitry Andric  * Determine the availability of the entity that this cursor refers to
24970b57cec5SDimitry Andric  * on any platforms for which availability information is known.
24980b57cec5SDimitry Andric  *
24990b57cec5SDimitry Andric  * \param cursor The cursor to query.
25000b57cec5SDimitry Andric  *
25010b57cec5SDimitry Andric  * \param always_deprecated If non-NULL, will be set to indicate whether the
25020b57cec5SDimitry Andric  * entity is deprecated on all platforms.
25030b57cec5SDimitry Andric  *
25040b57cec5SDimitry Andric  * \param deprecated_message If non-NULL, will be set to the message text
25050b57cec5SDimitry Andric  * provided along with the unconditional deprecation of this entity. The client
25060b57cec5SDimitry Andric  * is responsible for deallocating this string.
25070b57cec5SDimitry Andric  *
25080b57cec5SDimitry Andric  * \param always_unavailable If non-NULL, will be set to indicate whether the
25090b57cec5SDimitry Andric  * entity is unavailable on all platforms.
25100b57cec5SDimitry Andric  *
25110b57cec5SDimitry Andric  * \param unavailable_message If non-NULL, will be set to the message text
25120b57cec5SDimitry Andric  * provided along with the unconditional unavailability of this entity. The
25130b57cec5SDimitry Andric  * client is responsible for deallocating this string.
25140b57cec5SDimitry Andric  *
25150b57cec5SDimitry Andric  * \param availability If non-NULL, an array of CXPlatformAvailability instances
25160b57cec5SDimitry Andric  * that will be populated with platform availability information, up to either
25170b57cec5SDimitry Andric  * the number of platforms for which availability information is available (as
25180b57cec5SDimitry Andric  * returned by this function) or \c availability_size, whichever is smaller.
25190b57cec5SDimitry Andric  *
25200b57cec5SDimitry Andric  * \param availability_size The number of elements available in the
25210b57cec5SDimitry Andric  * \c availability array.
25220b57cec5SDimitry Andric  *
25230b57cec5SDimitry Andric  * \returns The number of platforms (N) for which availability information is
25240b57cec5SDimitry Andric  * available (which is unrelated to \c availability_size).
25250b57cec5SDimitry Andric  *
25260b57cec5SDimitry Andric  * Note that the client is responsible for calling
25270b57cec5SDimitry Andric  * \c clang_disposeCXPlatformAvailability to free each of the
25280b57cec5SDimitry Andric  * platform-availability structures returned. There are
25290b57cec5SDimitry Andric  * \c min(N, availability_size) such structures.
25300b57cec5SDimitry Andric  */
25315ffd83dbSDimitry Andric CINDEX_LINKAGE int clang_getCursorPlatformAvailability(
25325ffd83dbSDimitry Andric     CXCursor cursor, int *always_deprecated, CXString *deprecated_message,
25335ffd83dbSDimitry Andric     int *always_unavailable, CXString *unavailable_message,
25345ffd83dbSDimitry Andric     CXPlatformAvailability *availability, int availability_size);
25350b57cec5SDimitry Andric 
25360b57cec5SDimitry Andric /**
25370b57cec5SDimitry Andric  * Free the memory associated with a \c CXPlatformAvailability structure.
25380b57cec5SDimitry Andric  */
25390b57cec5SDimitry Andric CINDEX_LINKAGE void
25400b57cec5SDimitry Andric clang_disposeCXPlatformAvailability(CXPlatformAvailability *availability);
25410b57cec5SDimitry Andric 
25420b57cec5SDimitry Andric /**
2543e8d8bef9SDimitry Andric  * If cursor refers to a variable declaration and it has initializer returns
2544e8d8bef9SDimitry Andric  * cursor referring to the initializer otherwise return null cursor.
2545e8d8bef9SDimitry Andric  */
2546e8d8bef9SDimitry Andric CINDEX_LINKAGE CXCursor clang_Cursor_getVarDeclInitializer(CXCursor cursor);
2547e8d8bef9SDimitry Andric 
2548e8d8bef9SDimitry Andric /**
2549e8d8bef9SDimitry Andric  * If cursor refers to a variable declaration that has global storage returns 1.
2550e8d8bef9SDimitry Andric  * If cursor refers to a variable declaration that doesn't have global storage
2551e8d8bef9SDimitry Andric  * returns 0. Otherwise returns -1.
2552e8d8bef9SDimitry Andric  */
2553e8d8bef9SDimitry Andric CINDEX_LINKAGE int clang_Cursor_hasVarDeclGlobalStorage(CXCursor cursor);
2554e8d8bef9SDimitry Andric 
2555e8d8bef9SDimitry Andric /**
2556e8d8bef9SDimitry Andric  * If cursor refers to a variable declaration that has external storage
2557e8d8bef9SDimitry Andric  * returns 1. If cursor refers to a variable declaration that doesn't have
2558e8d8bef9SDimitry Andric  * external storage returns 0. Otherwise returns -1.
2559e8d8bef9SDimitry Andric  */
2560e8d8bef9SDimitry Andric CINDEX_LINKAGE int clang_Cursor_hasVarDeclExternalStorage(CXCursor cursor);
2561e8d8bef9SDimitry Andric 
2562e8d8bef9SDimitry Andric /**
25630b57cec5SDimitry Andric  * Describe the "language" of the entity referred to by a cursor.
25640b57cec5SDimitry Andric  */
25650b57cec5SDimitry Andric enum CXLanguageKind {
25660b57cec5SDimitry Andric   CXLanguage_Invalid = 0,
25670b57cec5SDimitry Andric   CXLanguage_C,
25680b57cec5SDimitry Andric   CXLanguage_ObjC,
25690b57cec5SDimitry Andric   CXLanguage_CPlusPlus
25700b57cec5SDimitry Andric };
25710b57cec5SDimitry Andric 
25720b57cec5SDimitry Andric /**
25730b57cec5SDimitry Andric  * Determine the "language" of the entity referred to by a given cursor.
25740b57cec5SDimitry Andric  */
25750b57cec5SDimitry Andric CINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor);
25760b57cec5SDimitry Andric 
25770b57cec5SDimitry Andric /**
25780b57cec5SDimitry Andric  * Describe the "thread-local storage (TLS) kind" of the declaration
25790b57cec5SDimitry Andric  * referred to by a cursor.
25800b57cec5SDimitry Andric  */
25815ffd83dbSDimitry Andric enum CXTLSKind { CXTLS_None = 0, CXTLS_Dynamic, CXTLS_Static };
25820b57cec5SDimitry Andric 
25830b57cec5SDimitry Andric /**
25840b57cec5SDimitry Andric  * Determine the "thread-local storage (TLS) kind" of the declaration
25850b57cec5SDimitry Andric  * referred to by a cursor.
25860b57cec5SDimitry Andric  */
25870b57cec5SDimitry Andric CINDEX_LINKAGE enum CXTLSKind clang_getCursorTLSKind(CXCursor cursor);
25880b57cec5SDimitry Andric 
25890b57cec5SDimitry Andric /**
25900b57cec5SDimitry Andric  * Returns the translation unit that a cursor originated from.
25910b57cec5SDimitry Andric  */
25920b57cec5SDimitry Andric CINDEX_LINKAGE CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor);
25930b57cec5SDimitry Andric 
25940b57cec5SDimitry Andric /**
25950b57cec5SDimitry Andric  * A fast container representing a set of CXCursors.
25960b57cec5SDimitry Andric  */
25970b57cec5SDimitry Andric typedef struct CXCursorSetImpl *CXCursorSet;
25980b57cec5SDimitry Andric 
25990b57cec5SDimitry Andric /**
26000b57cec5SDimitry Andric  * Creates an empty CXCursorSet.
26010b57cec5SDimitry Andric  */
26020b57cec5SDimitry Andric CINDEX_LINKAGE CXCursorSet clang_createCXCursorSet(void);
26030b57cec5SDimitry Andric 
26040b57cec5SDimitry Andric /**
26050b57cec5SDimitry Andric  * Disposes a CXCursorSet and releases its associated memory.
26060b57cec5SDimitry Andric  */
26070b57cec5SDimitry Andric CINDEX_LINKAGE void clang_disposeCXCursorSet(CXCursorSet cset);
26080b57cec5SDimitry Andric 
26090b57cec5SDimitry Andric /**
26100b57cec5SDimitry Andric  * Queries a CXCursorSet to see if it contains a specific CXCursor.
26110b57cec5SDimitry Andric  *
26120b57cec5SDimitry Andric  * \returns non-zero if the set contains the specified cursor.
26130b57cec5SDimitry Andric  */
26140b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_CXCursorSet_contains(CXCursorSet cset,
26150b57cec5SDimitry Andric                                                    CXCursor cursor);
26160b57cec5SDimitry Andric 
26170b57cec5SDimitry Andric /**
26180b57cec5SDimitry Andric  * Inserts a CXCursor into a CXCursorSet.
26190b57cec5SDimitry Andric  *
26200b57cec5SDimitry Andric  * \returns zero if the CXCursor was already in the set, and non-zero otherwise.
26210b57cec5SDimitry Andric  */
26220b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_CXCursorSet_insert(CXCursorSet cset,
26230b57cec5SDimitry Andric                                                  CXCursor cursor);
26240b57cec5SDimitry Andric 
26250b57cec5SDimitry Andric /**
26260b57cec5SDimitry Andric  * Determine the semantic parent of the given cursor.
26270b57cec5SDimitry Andric  *
26280b57cec5SDimitry Andric  * The semantic parent of a cursor is the cursor that semantically contains
26290b57cec5SDimitry Andric  * the given \p cursor. For many declarations, the lexical and semantic parents
26300b57cec5SDimitry Andric  * are equivalent (the lexical parent is returned by
26310b57cec5SDimitry Andric  * \c clang_getCursorLexicalParent()). They diverge when declarations or
26320b57cec5SDimitry Andric  * definitions are provided out-of-line. For example:
26330b57cec5SDimitry Andric  *
26340b57cec5SDimitry Andric  * \code
26350b57cec5SDimitry Andric  * class C {
26360b57cec5SDimitry Andric  *  void f();
26370b57cec5SDimitry Andric  * };
26380b57cec5SDimitry Andric  *
26390b57cec5SDimitry Andric  * void C::f() { }
26400b57cec5SDimitry Andric  * \endcode
26410b57cec5SDimitry Andric  *
26420b57cec5SDimitry Andric  * In the out-of-line definition of \c C::f, the semantic parent is
26430b57cec5SDimitry Andric  * the class \c C, of which this function is a member. The lexical parent is
26440b57cec5SDimitry Andric  * the place where the declaration actually occurs in the source code; in this
26450b57cec5SDimitry Andric  * case, the definition occurs in the translation unit. In general, the
26460b57cec5SDimitry Andric  * lexical parent for a given entity can change without affecting the semantics
26470b57cec5SDimitry Andric  * of the program, and the lexical parent of different declarations of the
26480b57cec5SDimitry Andric  * same entity may be different. Changing the semantic parent of a declaration,
26490b57cec5SDimitry Andric  * on the other hand, can have a major impact on semantics, and redeclarations
26500b57cec5SDimitry Andric  * of a particular entity should all have the same semantic context.
26510b57cec5SDimitry Andric  *
26520b57cec5SDimitry Andric  * In the example above, both declarations of \c C::f have \c C as their
26530b57cec5SDimitry Andric  * semantic context, while the lexical context of the first \c C::f is \c C
26540b57cec5SDimitry Andric  * and the lexical context of the second \c C::f is the translation unit.
26550b57cec5SDimitry Andric  *
26560b57cec5SDimitry Andric  * For global declarations, the semantic parent is the translation unit.
26570b57cec5SDimitry Andric  */
26580b57cec5SDimitry Andric CINDEX_LINKAGE CXCursor clang_getCursorSemanticParent(CXCursor cursor);
26590b57cec5SDimitry Andric 
26600b57cec5SDimitry Andric /**
26610b57cec5SDimitry Andric  * Determine the lexical parent of the given cursor.
26620b57cec5SDimitry Andric  *
26630b57cec5SDimitry Andric  * The lexical parent of a cursor is the cursor in which the given \p cursor
26640b57cec5SDimitry Andric  * was actually written. For many declarations, the lexical and semantic parents
26650b57cec5SDimitry Andric  * are equivalent (the semantic parent is returned by
26660b57cec5SDimitry Andric  * \c clang_getCursorSemanticParent()). They diverge when declarations or
26670b57cec5SDimitry Andric  * definitions are provided out-of-line. For example:
26680b57cec5SDimitry Andric  *
26690b57cec5SDimitry Andric  * \code
26700b57cec5SDimitry Andric  * class C {
26710b57cec5SDimitry Andric  *  void f();
26720b57cec5SDimitry Andric  * };
26730b57cec5SDimitry Andric  *
26740b57cec5SDimitry Andric  * void C::f() { }
26750b57cec5SDimitry Andric  * \endcode
26760b57cec5SDimitry Andric  *
26770b57cec5SDimitry Andric  * In the out-of-line definition of \c C::f, the semantic parent is
26780b57cec5SDimitry Andric  * the class \c C, of which this function is a member. The lexical parent is
26790b57cec5SDimitry Andric  * the place where the declaration actually occurs in the source code; in this
26800b57cec5SDimitry Andric  * case, the definition occurs in the translation unit. In general, the
26810b57cec5SDimitry Andric  * lexical parent for a given entity can change without affecting the semantics
26820b57cec5SDimitry Andric  * of the program, and the lexical parent of different declarations of the
26830b57cec5SDimitry Andric  * same entity may be different. Changing the semantic parent of a declaration,
26840b57cec5SDimitry Andric  * on the other hand, can have a major impact on semantics, and redeclarations
26850b57cec5SDimitry Andric  * of a particular entity should all have the same semantic context.
26860b57cec5SDimitry Andric  *
26870b57cec5SDimitry Andric  * In the example above, both declarations of \c C::f have \c C as their
26880b57cec5SDimitry Andric  * semantic context, while the lexical context of the first \c C::f is \c C
26890b57cec5SDimitry Andric  * and the lexical context of the second \c C::f is the translation unit.
26900b57cec5SDimitry Andric  *
26910b57cec5SDimitry Andric  * For declarations written in the global scope, the lexical parent is
26920b57cec5SDimitry Andric  * the translation unit.
26930b57cec5SDimitry Andric  */
26940b57cec5SDimitry Andric CINDEX_LINKAGE CXCursor clang_getCursorLexicalParent(CXCursor cursor);
26950b57cec5SDimitry Andric 
26960b57cec5SDimitry Andric /**
26970b57cec5SDimitry Andric  * Determine the set of methods that are overridden by the given
26980b57cec5SDimitry Andric  * method.
26990b57cec5SDimitry Andric  *
27000b57cec5SDimitry Andric  * In both Objective-C and C++, a method (aka virtual member function,
27010b57cec5SDimitry Andric  * in C++) can override a virtual method in a base class. For
27020b57cec5SDimitry Andric  * Objective-C, a method is said to override any method in the class's
27030b57cec5SDimitry Andric  * base class, its protocols, or its categories' protocols, that has the same
27040b57cec5SDimitry Andric  * selector and is of the same kind (class or instance).
27050b57cec5SDimitry Andric  * If no such method exists, the search continues to the class's superclass,
27060b57cec5SDimitry Andric  * its protocols, and its categories, and so on. A method from an Objective-C
27070b57cec5SDimitry Andric  * implementation is considered to override the same methods as its
27080b57cec5SDimitry Andric  * corresponding method in the interface.
27090b57cec5SDimitry Andric  *
27100b57cec5SDimitry Andric  * For C++, a virtual member function overrides any virtual member
27110b57cec5SDimitry Andric  * function with the same signature that occurs in its base
27120b57cec5SDimitry Andric  * classes. With multiple inheritance, a virtual member function can
27130b57cec5SDimitry Andric  * override several virtual member functions coming from different
27140b57cec5SDimitry Andric  * base classes.
27150b57cec5SDimitry Andric  *
27160b57cec5SDimitry Andric  * In all cases, this function determines the immediate overridden
27170b57cec5SDimitry Andric  * method, rather than all of the overridden methods. For example, if
27180b57cec5SDimitry Andric  * a method is originally declared in a class A, then overridden in B
27190b57cec5SDimitry Andric  * (which in inherits from A) and also in C (which inherited from B),
27200b57cec5SDimitry Andric  * then the only overridden method returned from this function when
27210b57cec5SDimitry Andric  * invoked on C's method will be B's method. The client may then
27220b57cec5SDimitry Andric  * invoke this function again, given the previously-found overridden
27230b57cec5SDimitry Andric  * methods, to map out the complete method-override set.
27240b57cec5SDimitry Andric  *
27250b57cec5SDimitry Andric  * \param cursor A cursor representing an Objective-C or C++
27260b57cec5SDimitry Andric  * method. This routine will compute the set of methods that this
27270b57cec5SDimitry Andric  * method overrides.
27280b57cec5SDimitry Andric  *
27290b57cec5SDimitry Andric  * \param overridden A pointer whose pointee will be replaced with a
27300b57cec5SDimitry Andric  * pointer to an array of cursors, representing the set of overridden
27310b57cec5SDimitry Andric  * methods. If there are no overridden methods, the pointee will be
27320b57cec5SDimitry Andric  * set to NULL. The pointee must be freed via a call to
27330b57cec5SDimitry Andric  * \c clang_disposeOverriddenCursors().
27340b57cec5SDimitry Andric  *
27350b57cec5SDimitry Andric  * \param num_overridden A pointer to the number of overridden
27360b57cec5SDimitry Andric  * functions, will be set to the number of overridden functions in the
27370b57cec5SDimitry Andric  * array pointed to by \p overridden.
27380b57cec5SDimitry Andric  */
27390b57cec5SDimitry Andric CINDEX_LINKAGE void clang_getOverriddenCursors(CXCursor cursor,
27400b57cec5SDimitry Andric                                                CXCursor **overridden,
27410b57cec5SDimitry Andric                                                unsigned *num_overridden);
27420b57cec5SDimitry Andric 
27430b57cec5SDimitry Andric /**
27440b57cec5SDimitry Andric  * Free the set of overridden cursors returned by \c
27450b57cec5SDimitry Andric  * clang_getOverriddenCursors().
27460b57cec5SDimitry Andric  */
27470b57cec5SDimitry Andric CINDEX_LINKAGE void clang_disposeOverriddenCursors(CXCursor *overridden);
27480b57cec5SDimitry Andric 
27490b57cec5SDimitry Andric /**
27500b57cec5SDimitry Andric  * Retrieve the file that is included by the given inclusion directive
27510b57cec5SDimitry Andric  * cursor.
27520b57cec5SDimitry Andric  */
27530b57cec5SDimitry Andric CINDEX_LINKAGE CXFile clang_getIncludedFile(CXCursor cursor);
27540b57cec5SDimitry Andric 
27550b57cec5SDimitry Andric /**
27560b57cec5SDimitry Andric  * @}
27570b57cec5SDimitry Andric  */
27580b57cec5SDimitry Andric 
27590b57cec5SDimitry Andric /**
27600b57cec5SDimitry Andric  * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code
27610b57cec5SDimitry Andric  *
27620b57cec5SDimitry Andric  * Cursors represent a location within the Abstract Syntax Tree (AST). These
27630b57cec5SDimitry Andric  * routines help map between cursors and the physical locations where the
27640b57cec5SDimitry Andric  * described entities occur in the source code. The mapping is provided in
27650b57cec5SDimitry Andric  * both directions, so one can map from source code to the AST and back.
27660b57cec5SDimitry Andric  *
27670b57cec5SDimitry Andric  * @{
27680b57cec5SDimitry Andric  */
27690b57cec5SDimitry Andric 
27700b57cec5SDimitry Andric /**
27710b57cec5SDimitry Andric  * Map a source location to the cursor that describes the entity at that
27720b57cec5SDimitry Andric  * location in the source code.
27730b57cec5SDimitry Andric  *
27740b57cec5SDimitry Andric  * clang_getCursor() maps an arbitrary source location within a translation
27750b57cec5SDimitry Andric  * unit down to the most specific cursor that describes the entity at that
27760b57cec5SDimitry Andric  * location. For example, given an expression \c x + y, invoking
27770b57cec5SDimitry Andric  * clang_getCursor() with a source location pointing to "x" will return the
27780b57cec5SDimitry Andric  * cursor for "x"; similarly for "y". If the cursor points anywhere between
27790b57cec5SDimitry Andric  * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor()
27800b57cec5SDimitry Andric  * will return a cursor referring to the "+" expression.
27810b57cec5SDimitry Andric  *
27820b57cec5SDimitry Andric  * \returns a cursor representing the entity at the given source location, or
27830b57cec5SDimitry Andric  * a NULL cursor if no such entity can be found.
27840b57cec5SDimitry Andric  */
27850b57cec5SDimitry Andric CINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, CXSourceLocation);
27860b57cec5SDimitry Andric 
27870b57cec5SDimitry Andric /**
27880b57cec5SDimitry Andric  * Retrieve the physical location of the source constructor referenced
27890b57cec5SDimitry Andric  * by the given cursor.
27900b57cec5SDimitry Andric  *
27910b57cec5SDimitry Andric  * The location of a declaration is typically the location of the name of that
27920b57cec5SDimitry Andric  * declaration, where the name of that declaration would occur if it is
27930b57cec5SDimitry Andric  * unnamed, or some keyword that introduces that particular declaration.
27940b57cec5SDimitry Andric  * The location of a reference is where that reference occurs within the
27950b57cec5SDimitry Andric  * source code.
27960b57cec5SDimitry Andric  */
27970b57cec5SDimitry Andric CINDEX_LINKAGE CXSourceLocation clang_getCursorLocation(CXCursor);
27980b57cec5SDimitry Andric 
27990b57cec5SDimitry Andric /**
28000b57cec5SDimitry Andric  * Retrieve the physical extent of the source construct referenced by
28010b57cec5SDimitry Andric  * the given cursor.
28020b57cec5SDimitry Andric  *
28030b57cec5SDimitry Andric  * The extent of a cursor starts with the file/line/column pointing at the
28040b57cec5SDimitry Andric  * first character within the source construct that the cursor refers to and
28050b57cec5SDimitry Andric  * ends with the last character within that source construct. For a
28060b57cec5SDimitry Andric  * declaration, the extent covers the declaration itself. For a reference,
28070b57cec5SDimitry Andric  * the extent covers the location of the reference (e.g., where the referenced
28080b57cec5SDimitry Andric  * entity was actually used).
28090b57cec5SDimitry Andric  */
28100b57cec5SDimitry Andric CINDEX_LINKAGE CXSourceRange clang_getCursorExtent(CXCursor);
28110b57cec5SDimitry Andric 
28120b57cec5SDimitry Andric /**
28130b57cec5SDimitry Andric  * @}
28140b57cec5SDimitry Andric  */
28150b57cec5SDimitry Andric 
28160b57cec5SDimitry Andric /**
28170b57cec5SDimitry Andric  * \defgroup CINDEX_TYPES Type information for CXCursors
28180b57cec5SDimitry Andric  *
28190b57cec5SDimitry Andric  * @{
28200b57cec5SDimitry Andric  */
28210b57cec5SDimitry Andric 
28220b57cec5SDimitry Andric /**
28230b57cec5SDimitry Andric  * Describes the kind of type
28240b57cec5SDimitry Andric  */
28250b57cec5SDimitry Andric enum CXTypeKind {
28260b57cec5SDimitry Andric   /**
28270b57cec5SDimitry Andric    * Represents an invalid type (e.g., where no type is available).
28280b57cec5SDimitry Andric    */
28290b57cec5SDimitry Andric   CXType_Invalid = 0,
28300b57cec5SDimitry Andric 
28310b57cec5SDimitry Andric   /**
28320b57cec5SDimitry Andric    * A type whose specific kind is not exposed via this
28330b57cec5SDimitry Andric    * interface.
28340b57cec5SDimitry Andric    */
28350b57cec5SDimitry Andric   CXType_Unexposed = 1,
28360b57cec5SDimitry Andric 
28370b57cec5SDimitry Andric   /* Builtin types */
28380b57cec5SDimitry Andric   CXType_Void = 2,
28390b57cec5SDimitry Andric   CXType_Bool = 3,
28400b57cec5SDimitry Andric   CXType_Char_U = 4,
28410b57cec5SDimitry Andric   CXType_UChar = 5,
28420b57cec5SDimitry Andric   CXType_Char16 = 6,
28430b57cec5SDimitry Andric   CXType_Char32 = 7,
28440b57cec5SDimitry Andric   CXType_UShort = 8,
28450b57cec5SDimitry Andric   CXType_UInt = 9,
28460b57cec5SDimitry Andric   CXType_ULong = 10,
28470b57cec5SDimitry Andric   CXType_ULongLong = 11,
28480b57cec5SDimitry Andric   CXType_UInt128 = 12,
28490b57cec5SDimitry Andric   CXType_Char_S = 13,
28500b57cec5SDimitry Andric   CXType_SChar = 14,
28510b57cec5SDimitry Andric   CXType_WChar = 15,
28520b57cec5SDimitry Andric   CXType_Short = 16,
28530b57cec5SDimitry Andric   CXType_Int = 17,
28540b57cec5SDimitry Andric   CXType_Long = 18,
28550b57cec5SDimitry Andric   CXType_LongLong = 19,
28560b57cec5SDimitry Andric   CXType_Int128 = 20,
28570b57cec5SDimitry Andric   CXType_Float = 21,
28580b57cec5SDimitry Andric   CXType_Double = 22,
28590b57cec5SDimitry Andric   CXType_LongDouble = 23,
28600b57cec5SDimitry Andric   CXType_NullPtr = 24,
28610b57cec5SDimitry Andric   CXType_Overload = 25,
28620b57cec5SDimitry Andric   CXType_Dependent = 26,
28630b57cec5SDimitry Andric   CXType_ObjCId = 27,
28640b57cec5SDimitry Andric   CXType_ObjCClass = 28,
28650b57cec5SDimitry Andric   CXType_ObjCSel = 29,
28660b57cec5SDimitry Andric   CXType_Float128 = 30,
28670b57cec5SDimitry Andric   CXType_Half = 31,
28680b57cec5SDimitry Andric   CXType_Float16 = 32,
28690b57cec5SDimitry Andric   CXType_ShortAccum = 33,
28700b57cec5SDimitry Andric   CXType_Accum = 34,
28710b57cec5SDimitry Andric   CXType_LongAccum = 35,
28720b57cec5SDimitry Andric   CXType_UShortAccum = 36,
28730b57cec5SDimitry Andric   CXType_UAccum = 37,
28740b57cec5SDimitry Andric   CXType_ULongAccum = 38,
28755ffd83dbSDimitry Andric   CXType_BFloat16 = 39,
2876349cc55cSDimitry Andric   CXType_Ibm128 = 40,
28770b57cec5SDimitry Andric   CXType_FirstBuiltin = CXType_Void,
2878349cc55cSDimitry Andric   CXType_LastBuiltin = CXType_Ibm128,
28790b57cec5SDimitry Andric 
28800b57cec5SDimitry Andric   CXType_Complex = 100,
28810b57cec5SDimitry Andric   CXType_Pointer = 101,
28820b57cec5SDimitry Andric   CXType_BlockPointer = 102,
28830b57cec5SDimitry Andric   CXType_LValueReference = 103,
28840b57cec5SDimitry Andric   CXType_RValueReference = 104,
28850b57cec5SDimitry Andric   CXType_Record = 105,
28860b57cec5SDimitry Andric   CXType_Enum = 106,
28870b57cec5SDimitry Andric   CXType_Typedef = 107,
28880b57cec5SDimitry Andric   CXType_ObjCInterface = 108,
28890b57cec5SDimitry Andric   CXType_ObjCObjectPointer = 109,
28900b57cec5SDimitry Andric   CXType_FunctionNoProto = 110,
28910b57cec5SDimitry Andric   CXType_FunctionProto = 111,
28920b57cec5SDimitry Andric   CXType_ConstantArray = 112,
28930b57cec5SDimitry Andric   CXType_Vector = 113,
28940b57cec5SDimitry Andric   CXType_IncompleteArray = 114,
28950b57cec5SDimitry Andric   CXType_VariableArray = 115,
28960b57cec5SDimitry Andric   CXType_DependentSizedArray = 116,
28970b57cec5SDimitry Andric   CXType_MemberPointer = 117,
28980b57cec5SDimitry Andric   CXType_Auto = 118,
28990b57cec5SDimitry Andric 
29000b57cec5SDimitry Andric   /**
29010b57cec5SDimitry Andric    * Represents a type that was referred to using an elaborated type keyword.
29020b57cec5SDimitry Andric    *
29030b57cec5SDimitry Andric    * E.g., struct S, or via a qualified name, e.g., N::M::type, or both.
29040b57cec5SDimitry Andric    */
29050b57cec5SDimitry Andric   CXType_Elaborated = 119,
29060b57cec5SDimitry Andric 
29070b57cec5SDimitry Andric   /* OpenCL PipeType. */
29080b57cec5SDimitry Andric   CXType_Pipe = 120,
29090b57cec5SDimitry Andric 
29100b57cec5SDimitry Andric   /* OpenCL builtin types. */
29110b57cec5SDimitry Andric   CXType_OCLImage1dRO = 121,
29120b57cec5SDimitry Andric   CXType_OCLImage1dArrayRO = 122,
29130b57cec5SDimitry Andric   CXType_OCLImage1dBufferRO = 123,
29140b57cec5SDimitry Andric   CXType_OCLImage2dRO = 124,
29150b57cec5SDimitry Andric   CXType_OCLImage2dArrayRO = 125,
29160b57cec5SDimitry Andric   CXType_OCLImage2dDepthRO = 126,
29170b57cec5SDimitry Andric   CXType_OCLImage2dArrayDepthRO = 127,
29180b57cec5SDimitry Andric   CXType_OCLImage2dMSAARO = 128,
29190b57cec5SDimitry Andric   CXType_OCLImage2dArrayMSAARO = 129,
29200b57cec5SDimitry Andric   CXType_OCLImage2dMSAADepthRO = 130,
29210b57cec5SDimitry Andric   CXType_OCLImage2dArrayMSAADepthRO = 131,
29220b57cec5SDimitry Andric   CXType_OCLImage3dRO = 132,
29230b57cec5SDimitry Andric   CXType_OCLImage1dWO = 133,
29240b57cec5SDimitry Andric   CXType_OCLImage1dArrayWO = 134,
29250b57cec5SDimitry Andric   CXType_OCLImage1dBufferWO = 135,
29260b57cec5SDimitry Andric   CXType_OCLImage2dWO = 136,
29270b57cec5SDimitry Andric   CXType_OCLImage2dArrayWO = 137,
29280b57cec5SDimitry Andric   CXType_OCLImage2dDepthWO = 138,
29290b57cec5SDimitry Andric   CXType_OCLImage2dArrayDepthWO = 139,
29300b57cec5SDimitry Andric   CXType_OCLImage2dMSAAWO = 140,
29310b57cec5SDimitry Andric   CXType_OCLImage2dArrayMSAAWO = 141,
29320b57cec5SDimitry Andric   CXType_OCLImage2dMSAADepthWO = 142,
29330b57cec5SDimitry Andric   CXType_OCLImage2dArrayMSAADepthWO = 143,
29340b57cec5SDimitry Andric   CXType_OCLImage3dWO = 144,
29350b57cec5SDimitry Andric   CXType_OCLImage1dRW = 145,
29360b57cec5SDimitry Andric   CXType_OCLImage1dArrayRW = 146,
29370b57cec5SDimitry Andric   CXType_OCLImage1dBufferRW = 147,
29380b57cec5SDimitry Andric   CXType_OCLImage2dRW = 148,
29390b57cec5SDimitry Andric   CXType_OCLImage2dArrayRW = 149,
29400b57cec5SDimitry Andric   CXType_OCLImage2dDepthRW = 150,
29410b57cec5SDimitry Andric   CXType_OCLImage2dArrayDepthRW = 151,
29420b57cec5SDimitry Andric   CXType_OCLImage2dMSAARW = 152,
29430b57cec5SDimitry Andric   CXType_OCLImage2dArrayMSAARW = 153,
29440b57cec5SDimitry Andric   CXType_OCLImage2dMSAADepthRW = 154,
29450b57cec5SDimitry Andric   CXType_OCLImage2dArrayMSAADepthRW = 155,
29460b57cec5SDimitry Andric   CXType_OCLImage3dRW = 156,
29470b57cec5SDimitry Andric   CXType_OCLSampler = 157,
29480b57cec5SDimitry Andric   CXType_OCLEvent = 158,
29490b57cec5SDimitry Andric   CXType_OCLQueue = 159,
29500b57cec5SDimitry Andric   CXType_OCLReserveID = 160,
29510b57cec5SDimitry Andric 
29520b57cec5SDimitry Andric   CXType_ObjCObject = 161,
29530b57cec5SDimitry Andric   CXType_ObjCTypeParam = 162,
29540b57cec5SDimitry Andric   CXType_Attributed = 163,
29550b57cec5SDimitry Andric 
29560b57cec5SDimitry Andric   CXType_OCLIntelSubgroupAVCMcePayload = 164,
29570b57cec5SDimitry Andric   CXType_OCLIntelSubgroupAVCImePayload = 165,
29580b57cec5SDimitry Andric   CXType_OCLIntelSubgroupAVCRefPayload = 166,
29590b57cec5SDimitry Andric   CXType_OCLIntelSubgroupAVCSicPayload = 167,
29600b57cec5SDimitry Andric   CXType_OCLIntelSubgroupAVCMceResult = 168,
29610b57cec5SDimitry Andric   CXType_OCLIntelSubgroupAVCImeResult = 169,
29620b57cec5SDimitry Andric   CXType_OCLIntelSubgroupAVCRefResult = 170,
29630b57cec5SDimitry Andric   CXType_OCLIntelSubgroupAVCSicResult = 171,
296406c3fb27SDimitry Andric   CXType_OCLIntelSubgroupAVCImeResultSingleReferenceStreamout = 172,
296506c3fb27SDimitry Andric   CXType_OCLIntelSubgroupAVCImeResultDualReferenceStreamout = 173,
296606c3fb27SDimitry Andric   CXType_OCLIntelSubgroupAVCImeSingleReferenceStreamin = 174,
296706c3fb27SDimitry Andric   CXType_OCLIntelSubgroupAVCImeDualReferenceStreamin = 175,
296806c3fb27SDimitry Andric 
296906c3fb27SDimitry Andric   /* Old aliases for AVC OpenCL extension types. */
29700b57cec5SDimitry Andric   CXType_OCLIntelSubgroupAVCImeResultSingleRefStreamout = 172,
29710b57cec5SDimitry Andric   CXType_OCLIntelSubgroupAVCImeResultDualRefStreamout = 173,
29720b57cec5SDimitry Andric   CXType_OCLIntelSubgroupAVCImeSingleRefStreamin = 174,
29730b57cec5SDimitry Andric   CXType_OCLIntelSubgroupAVCImeDualRefStreamin = 175,
29740b57cec5SDimitry Andric 
29755ffd83dbSDimitry Andric   CXType_ExtVector = 176,
297681ad6265SDimitry Andric   CXType_Atomic = 177,
297781ad6265SDimitry Andric   CXType_BTFTagAttributed = 178
29780b57cec5SDimitry Andric };
29790b57cec5SDimitry Andric 
29800b57cec5SDimitry Andric /**
29810b57cec5SDimitry Andric  * Describes the calling convention of a function type
29820b57cec5SDimitry Andric  */
29830b57cec5SDimitry Andric enum CXCallingConv {
29840b57cec5SDimitry Andric   CXCallingConv_Default = 0,
29850b57cec5SDimitry Andric   CXCallingConv_C = 1,
29860b57cec5SDimitry Andric   CXCallingConv_X86StdCall = 2,
29870b57cec5SDimitry Andric   CXCallingConv_X86FastCall = 3,
29880b57cec5SDimitry Andric   CXCallingConv_X86ThisCall = 4,
29890b57cec5SDimitry Andric   CXCallingConv_X86Pascal = 5,
29900b57cec5SDimitry Andric   CXCallingConv_AAPCS = 6,
29910b57cec5SDimitry Andric   CXCallingConv_AAPCS_VFP = 7,
29920b57cec5SDimitry Andric   CXCallingConv_X86RegCall = 8,
29930b57cec5SDimitry Andric   CXCallingConv_IntelOclBicc = 9,
29940b57cec5SDimitry Andric   CXCallingConv_Win64 = 10,
29950b57cec5SDimitry Andric   /* Alias for compatibility with older versions of API. */
29960b57cec5SDimitry Andric   CXCallingConv_X86_64Win64 = CXCallingConv_Win64,
29970b57cec5SDimitry Andric   CXCallingConv_X86_64SysV = 11,
29980b57cec5SDimitry Andric   CXCallingConv_X86VectorCall = 12,
29990b57cec5SDimitry Andric   CXCallingConv_Swift = 13,
30000b57cec5SDimitry Andric   CXCallingConv_PreserveMost = 14,
30010b57cec5SDimitry Andric   CXCallingConv_PreserveAll = 15,
30020b57cec5SDimitry Andric   CXCallingConv_AArch64VectorCall = 16,
3003fe6060f1SDimitry Andric   CXCallingConv_SwiftAsync = 17,
300481ad6265SDimitry Andric   CXCallingConv_AArch64SVEPCS = 18,
30055f757f3fSDimitry Andric   CXCallingConv_M68kRTD = 19,
3006*0fca6ea1SDimitry Andric   CXCallingConv_PreserveNone = 20,
3007*0fca6ea1SDimitry Andric   CXCallingConv_RISCVVectorCall = 21,
30080b57cec5SDimitry Andric 
30090b57cec5SDimitry Andric   CXCallingConv_Invalid = 100,
30100b57cec5SDimitry Andric   CXCallingConv_Unexposed = 200
30110b57cec5SDimitry Andric };
30120b57cec5SDimitry Andric 
30130b57cec5SDimitry Andric /**
30140b57cec5SDimitry Andric  * The type of an element in the abstract syntax tree.
30150b57cec5SDimitry Andric  *
30160b57cec5SDimitry Andric  */
30170b57cec5SDimitry Andric typedef struct {
30180b57cec5SDimitry Andric   enum CXTypeKind kind;
30190b57cec5SDimitry Andric   void *data[2];
30200b57cec5SDimitry Andric } CXType;
30210b57cec5SDimitry Andric 
30220b57cec5SDimitry Andric /**
30230b57cec5SDimitry Andric  * Retrieve the type of a CXCursor (if any).
30240b57cec5SDimitry Andric  */
30250b57cec5SDimitry Andric CINDEX_LINKAGE CXType clang_getCursorType(CXCursor C);
30260b57cec5SDimitry Andric 
30270b57cec5SDimitry Andric /**
30280b57cec5SDimitry Andric  * Pretty-print the underlying type using the rules of the
30290b57cec5SDimitry Andric  * language of the translation unit from which it came.
30300b57cec5SDimitry Andric  *
30310b57cec5SDimitry Andric  * If the type is invalid, an empty string is returned.
30320b57cec5SDimitry Andric  */
30330b57cec5SDimitry Andric CINDEX_LINKAGE CXString clang_getTypeSpelling(CXType CT);
30340b57cec5SDimitry Andric 
30350b57cec5SDimitry Andric /**
30360b57cec5SDimitry Andric  * Retrieve the underlying type of a typedef declaration.
30370b57cec5SDimitry Andric  *
30380b57cec5SDimitry Andric  * If the cursor does not reference a typedef declaration, an invalid type is
30390b57cec5SDimitry Andric  * returned.
30400b57cec5SDimitry Andric  */
30410b57cec5SDimitry Andric CINDEX_LINKAGE CXType clang_getTypedefDeclUnderlyingType(CXCursor C);
30420b57cec5SDimitry Andric 
30430b57cec5SDimitry Andric /**
30440b57cec5SDimitry Andric  * Retrieve the integer type of an enum declaration.
30450b57cec5SDimitry Andric  *
30460b57cec5SDimitry Andric  * If the cursor does not reference an enum declaration, an invalid type is
30470b57cec5SDimitry Andric  * returned.
30480b57cec5SDimitry Andric  */
30490b57cec5SDimitry Andric CINDEX_LINKAGE CXType clang_getEnumDeclIntegerType(CXCursor C);
30500b57cec5SDimitry Andric 
30510b57cec5SDimitry Andric /**
30520b57cec5SDimitry Andric  * Retrieve the integer value of an enum constant declaration as a signed
30530b57cec5SDimitry Andric  *  long long.
30540b57cec5SDimitry Andric  *
30555ffd83dbSDimitry Andric  * If the cursor does not reference an enum constant declaration, LLONG_MIN is
30565ffd83dbSDimitry Andric  * returned. Since this is also potentially a valid constant value, the kind of
30575ffd83dbSDimitry Andric  * the cursor must be verified before calling this function.
30580b57cec5SDimitry Andric  */
30590b57cec5SDimitry Andric CINDEX_LINKAGE long long clang_getEnumConstantDeclValue(CXCursor C);
30600b57cec5SDimitry Andric 
30610b57cec5SDimitry Andric /**
30620b57cec5SDimitry Andric  * Retrieve the integer value of an enum constant declaration as an unsigned
30630b57cec5SDimitry Andric  *  long long.
30640b57cec5SDimitry Andric  *
30655ffd83dbSDimitry Andric  * If the cursor does not reference an enum constant declaration, ULLONG_MAX is
30665ffd83dbSDimitry Andric  * returned. Since this is also potentially a valid constant value, the kind of
30675ffd83dbSDimitry Andric  * the cursor must be verified before calling this function.
30680b57cec5SDimitry Andric  */
30695ffd83dbSDimitry Andric CINDEX_LINKAGE unsigned long long
30705ffd83dbSDimitry Andric clang_getEnumConstantDeclUnsignedValue(CXCursor C);
30710b57cec5SDimitry Andric 
30720b57cec5SDimitry Andric /**
307306c3fb27SDimitry Andric  * Returns non-zero if the cursor specifies a Record member that is a bit-field.
307406c3fb27SDimitry Andric  */
307506c3fb27SDimitry Andric CINDEX_LINKAGE unsigned clang_Cursor_isBitField(CXCursor C);
307606c3fb27SDimitry Andric 
307706c3fb27SDimitry Andric /**
307806c3fb27SDimitry Andric  * Retrieve the bit width of a bit-field declaration as an integer.
30790b57cec5SDimitry Andric  *
308006c3fb27SDimitry Andric  * If the cursor does not reference a bit-field, or if the bit-field's width
308106c3fb27SDimitry Andric  * expression cannot be evaluated, -1 is returned.
308206c3fb27SDimitry Andric  *
308306c3fb27SDimitry Andric  * For example:
308406c3fb27SDimitry Andric  * \code
308506c3fb27SDimitry Andric  * if (clang_Cursor_isBitField(Cursor)) {
308606c3fb27SDimitry Andric  *   int Width = clang_getFieldDeclBitWidth(Cursor);
308706c3fb27SDimitry Andric  *   if (Width != -1) {
308806c3fb27SDimitry Andric  *     // The bit-field width is not value-dependent.
308906c3fb27SDimitry Andric  *   }
309006c3fb27SDimitry Andric  * }
309106c3fb27SDimitry Andric  * \endcode
30920b57cec5SDimitry Andric  */
30930b57cec5SDimitry Andric CINDEX_LINKAGE int clang_getFieldDeclBitWidth(CXCursor C);
30940b57cec5SDimitry Andric 
30950b57cec5SDimitry Andric /**
30960b57cec5SDimitry Andric  * Retrieve the number of non-variadic arguments associated with a given
30970b57cec5SDimitry Andric  * cursor.
30980b57cec5SDimitry Andric  *
30990b57cec5SDimitry Andric  * The number of arguments can be determined for calls as well as for
31000b57cec5SDimitry Andric  * declarations of functions or methods. For other cursors -1 is returned.
31010b57cec5SDimitry Andric  */
31020b57cec5SDimitry Andric CINDEX_LINKAGE int clang_Cursor_getNumArguments(CXCursor C);
31030b57cec5SDimitry Andric 
31040b57cec5SDimitry Andric /**
31050b57cec5SDimitry Andric  * Retrieve the argument cursor of a function or method.
31060b57cec5SDimitry Andric  *
31070b57cec5SDimitry Andric  * The argument cursor can be determined for calls as well as for declarations
31080b57cec5SDimitry Andric  * of functions or methods. For other cursors and for invalid indices, an
31090b57cec5SDimitry Andric  * invalid cursor is returned.
31100b57cec5SDimitry Andric  */
31110b57cec5SDimitry Andric CINDEX_LINKAGE CXCursor clang_Cursor_getArgument(CXCursor C, unsigned i);
31120b57cec5SDimitry Andric 
31130b57cec5SDimitry Andric /**
31140b57cec5SDimitry Andric  * Describes the kind of a template argument.
31150b57cec5SDimitry Andric  *
31160b57cec5SDimitry Andric  * See the definition of llvm::clang::TemplateArgument::ArgKind for full
31170b57cec5SDimitry Andric  * element descriptions.
31180b57cec5SDimitry Andric  */
31190b57cec5SDimitry Andric enum CXTemplateArgumentKind {
31200b57cec5SDimitry Andric   CXTemplateArgumentKind_Null,
31210b57cec5SDimitry Andric   CXTemplateArgumentKind_Type,
31220b57cec5SDimitry Andric   CXTemplateArgumentKind_Declaration,
31230b57cec5SDimitry Andric   CXTemplateArgumentKind_NullPtr,
31240b57cec5SDimitry Andric   CXTemplateArgumentKind_Integral,
31250b57cec5SDimitry Andric   CXTemplateArgumentKind_Template,
31260b57cec5SDimitry Andric   CXTemplateArgumentKind_TemplateExpansion,
31270b57cec5SDimitry Andric   CXTemplateArgumentKind_Expression,
31280b57cec5SDimitry Andric   CXTemplateArgumentKind_Pack,
31290b57cec5SDimitry Andric   /* Indicates an error case, preventing the kind from being deduced. */
31300b57cec5SDimitry Andric   CXTemplateArgumentKind_Invalid
31310b57cec5SDimitry Andric };
31320b57cec5SDimitry Andric 
31330b57cec5SDimitry Andric /**
3134bdd1243dSDimitry Andric  * Returns the number of template args of a function, struct, or class decl
3135bdd1243dSDimitry Andric  * representing a template specialization.
31360b57cec5SDimitry Andric  *
31370b57cec5SDimitry Andric  * If the argument cursor cannot be converted into a template function
31380b57cec5SDimitry Andric  * declaration, -1 is returned.
31390b57cec5SDimitry Andric  *
31400b57cec5SDimitry Andric  * For example, for the following declaration and specialization:
31410b57cec5SDimitry Andric  *   template <typename T, int kInt, bool kBool>
31420b57cec5SDimitry Andric  *   void foo() { ... }
31430b57cec5SDimitry Andric  *
31440b57cec5SDimitry Andric  *   template <>
31450b57cec5SDimitry Andric  *   void foo<float, -7, true>();
31460b57cec5SDimitry Andric  *
31470b57cec5SDimitry Andric  * The value 3 would be returned from this call.
31480b57cec5SDimitry Andric  */
31490b57cec5SDimitry Andric CINDEX_LINKAGE int clang_Cursor_getNumTemplateArguments(CXCursor C);
31500b57cec5SDimitry Andric 
31510b57cec5SDimitry Andric /**
31520b57cec5SDimitry Andric  * Retrieve the kind of the I'th template argument of the CXCursor C.
31530b57cec5SDimitry Andric  *
3154bdd1243dSDimitry Andric  * If the argument CXCursor does not represent a FunctionDecl, StructDecl, or
3155bdd1243dSDimitry Andric  * ClassTemplatePartialSpecialization, an invalid template argument kind is
3156bdd1243dSDimitry Andric  * returned.
31570b57cec5SDimitry Andric  *
31580b57cec5SDimitry Andric  * For example, for the following declaration and specialization:
31590b57cec5SDimitry Andric  *   template <typename T, int kInt, bool kBool>
31600b57cec5SDimitry Andric  *   void foo() { ... }
31610b57cec5SDimitry Andric  *
31620b57cec5SDimitry Andric  *   template <>
31630b57cec5SDimitry Andric  *   void foo<float, -7, true>();
31640b57cec5SDimitry Andric  *
31650b57cec5SDimitry Andric  * For I = 0, 1, and 2, Type, Integral, and Integral will be returned,
31660b57cec5SDimitry Andric  * respectively.
31670b57cec5SDimitry Andric  */
31685ffd83dbSDimitry Andric CINDEX_LINKAGE enum CXTemplateArgumentKind
31695ffd83dbSDimitry Andric clang_Cursor_getTemplateArgumentKind(CXCursor C, unsigned I);
31700b57cec5SDimitry Andric 
31710b57cec5SDimitry Andric /**
31720b57cec5SDimitry Andric  * Retrieve a CXType representing the type of a TemplateArgument of a
31730b57cec5SDimitry Andric  *  function decl representing a template specialization.
31740b57cec5SDimitry Andric  *
3175bdd1243dSDimitry Andric  * If the argument CXCursor does not represent a FunctionDecl, StructDecl,
3176bdd1243dSDimitry Andric  * ClassDecl or ClassTemplatePartialSpecialization whose I'th template argument
3177bdd1243dSDimitry Andric  * has a kind of CXTemplateArgKind_Integral, an invalid type is returned.
31780b57cec5SDimitry Andric  *
31790b57cec5SDimitry Andric  * For example, for the following declaration and specialization:
31800b57cec5SDimitry Andric  *   template <typename T, int kInt, bool kBool>
31810b57cec5SDimitry Andric  *   void foo() { ... }
31820b57cec5SDimitry Andric  *
31830b57cec5SDimitry Andric  *   template <>
31840b57cec5SDimitry Andric  *   void foo<float, -7, true>();
31850b57cec5SDimitry Andric  *
31860b57cec5SDimitry Andric  * If called with I = 0, "float", will be returned.
31870b57cec5SDimitry Andric  * Invalid types will be returned for I == 1 or 2.
31880b57cec5SDimitry Andric  */
31890b57cec5SDimitry Andric CINDEX_LINKAGE CXType clang_Cursor_getTemplateArgumentType(CXCursor C,
31900b57cec5SDimitry Andric                                                            unsigned I);
31910b57cec5SDimitry Andric 
31920b57cec5SDimitry Andric /**
31930b57cec5SDimitry Andric  * Retrieve the value of an Integral TemplateArgument (of a function
31940b57cec5SDimitry Andric  *  decl representing a template specialization) as a signed long long.
31950b57cec5SDimitry Andric  *
31960b57cec5SDimitry Andric  * It is undefined to call this function on a CXCursor that does not represent a
3197bdd1243dSDimitry Andric  * FunctionDecl, StructDecl, ClassDecl or ClassTemplatePartialSpecialization
3198bdd1243dSDimitry Andric  * whose I'th template argument is not an integral value.
31990b57cec5SDimitry Andric  *
32000b57cec5SDimitry Andric  * For example, for the following declaration and specialization:
32010b57cec5SDimitry Andric  *   template <typename T, int kInt, bool kBool>
32020b57cec5SDimitry Andric  *   void foo() { ... }
32030b57cec5SDimitry Andric  *
32040b57cec5SDimitry Andric  *   template <>
32050b57cec5SDimitry Andric  *   void foo<float, -7, true>();
32060b57cec5SDimitry Andric  *
32070b57cec5SDimitry Andric  * If called with I = 1 or 2, -7 or true will be returned, respectively.
32080b57cec5SDimitry Andric  * For I == 0, this function's behavior is undefined.
32090b57cec5SDimitry Andric  */
32100b57cec5SDimitry Andric CINDEX_LINKAGE long long clang_Cursor_getTemplateArgumentValue(CXCursor C,
32110b57cec5SDimitry Andric                                                                unsigned I);
32120b57cec5SDimitry Andric 
32130b57cec5SDimitry Andric /**
32140b57cec5SDimitry Andric  * Retrieve the value of an Integral TemplateArgument (of a function
32150b57cec5SDimitry Andric  *  decl representing a template specialization) as an unsigned long long.
32160b57cec5SDimitry Andric  *
32170b57cec5SDimitry Andric  * It is undefined to call this function on a CXCursor that does not represent a
3218bdd1243dSDimitry Andric  * FunctionDecl, StructDecl, ClassDecl or ClassTemplatePartialSpecialization or
3219bdd1243dSDimitry Andric  * whose I'th template argument is not an integral value.
32200b57cec5SDimitry Andric  *
32210b57cec5SDimitry Andric  * For example, for the following declaration and specialization:
32220b57cec5SDimitry Andric  *   template <typename T, int kInt, bool kBool>
32230b57cec5SDimitry Andric  *   void foo() { ... }
32240b57cec5SDimitry Andric  *
32250b57cec5SDimitry Andric  *   template <>
32260b57cec5SDimitry Andric  *   void foo<float, 2147483649, true>();
32270b57cec5SDimitry Andric  *
32280b57cec5SDimitry Andric  * If called with I = 1 or 2, 2147483649 or true will be returned, respectively.
32290b57cec5SDimitry Andric  * For I == 0, this function's behavior is undefined.
32300b57cec5SDimitry Andric  */
32315ffd83dbSDimitry Andric CINDEX_LINKAGE unsigned long long
32325ffd83dbSDimitry Andric clang_Cursor_getTemplateArgumentUnsignedValue(CXCursor C, unsigned I);
32330b57cec5SDimitry Andric 
32340b57cec5SDimitry Andric /**
32350b57cec5SDimitry Andric  * Determine whether two CXTypes represent the same type.
32360b57cec5SDimitry Andric  *
32370b57cec5SDimitry Andric  * \returns non-zero if the CXTypes represent the same type and
32380b57cec5SDimitry Andric  *          zero otherwise.
32390b57cec5SDimitry Andric  */
32400b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_equalTypes(CXType A, CXType B);
32410b57cec5SDimitry Andric 
32420b57cec5SDimitry Andric /**
32430b57cec5SDimitry Andric  * Return the canonical type for a CXType.
32440b57cec5SDimitry Andric  *
32450b57cec5SDimitry Andric  * Clang's type system explicitly models typedefs and all the ways
32460b57cec5SDimitry Andric  * a specific type can be represented.  The canonical type is the underlying
32470b57cec5SDimitry Andric  * type with all the "sugar" removed.  For example, if 'T' is a typedef
32480b57cec5SDimitry Andric  * for 'int', the canonical type for 'T' would be 'int'.
32490b57cec5SDimitry Andric  */
32500b57cec5SDimitry Andric CINDEX_LINKAGE CXType clang_getCanonicalType(CXType T);
32510b57cec5SDimitry Andric 
32520b57cec5SDimitry Andric /**
32530b57cec5SDimitry Andric  * Determine whether a CXType has the "const" qualifier set,
32540b57cec5SDimitry Andric  * without looking through typedefs that may have added "const" at a
32550b57cec5SDimitry Andric  * different level.
32560b57cec5SDimitry Andric  */
32570b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_isConstQualifiedType(CXType T);
32580b57cec5SDimitry Andric 
32590b57cec5SDimitry Andric /**
32600b57cec5SDimitry Andric  * Determine whether a  CXCursor that is a macro, is
32610b57cec5SDimitry Andric  * function like.
32620b57cec5SDimitry Andric  */
32630b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_Cursor_isMacroFunctionLike(CXCursor C);
32640b57cec5SDimitry Andric 
32650b57cec5SDimitry Andric /**
32660b57cec5SDimitry Andric  * Determine whether a  CXCursor that is a macro, is a
32670b57cec5SDimitry Andric  * builtin one.
32680b57cec5SDimitry Andric  */
32690b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_Cursor_isMacroBuiltin(CXCursor C);
32700b57cec5SDimitry Andric 
32710b57cec5SDimitry Andric /**
32720b57cec5SDimitry Andric  * Determine whether a  CXCursor that is a function declaration, is an
32730b57cec5SDimitry Andric  * inline declaration.
32740b57cec5SDimitry Andric  */
32750b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_Cursor_isFunctionInlined(CXCursor C);
32760b57cec5SDimitry Andric 
32770b57cec5SDimitry Andric /**
32780b57cec5SDimitry Andric  * Determine whether a CXType has the "volatile" qualifier set,
32790b57cec5SDimitry Andric  * without looking through typedefs that may have added "volatile" at
32800b57cec5SDimitry Andric  * a different level.
32810b57cec5SDimitry Andric  */
32820b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_isVolatileQualifiedType(CXType T);
32830b57cec5SDimitry Andric 
32840b57cec5SDimitry Andric /**
32850b57cec5SDimitry Andric  * Determine whether a CXType has the "restrict" qualifier set,
32860b57cec5SDimitry Andric  * without looking through typedefs that may have added "restrict" at a
32870b57cec5SDimitry Andric  * different level.
32880b57cec5SDimitry Andric  */
32890b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_isRestrictQualifiedType(CXType T);
32900b57cec5SDimitry Andric 
32910b57cec5SDimitry Andric /**
32920b57cec5SDimitry Andric  * Returns the address space of the given type.
32930b57cec5SDimitry Andric  */
32940b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_getAddressSpace(CXType T);
32950b57cec5SDimitry Andric 
32960b57cec5SDimitry Andric /**
32970b57cec5SDimitry Andric  * Returns the typedef name of the given type.
32980b57cec5SDimitry Andric  */
32990b57cec5SDimitry Andric CINDEX_LINKAGE CXString clang_getTypedefName(CXType CT);
33000b57cec5SDimitry Andric 
33010b57cec5SDimitry Andric /**
33020b57cec5SDimitry Andric  * For pointer types, returns the type of the pointee.
33030b57cec5SDimitry Andric  */
33040b57cec5SDimitry Andric CINDEX_LINKAGE CXType clang_getPointeeType(CXType T);
33050b57cec5SDimitry Andric 
33060b57cec5SDimitry Andric /**
3307bdd1243dSDimitry Andric  * Retrieve the unqualified variant of the given type, removing as
3308bdd1243dSDimitry Andric  * little sugar as possible.
3309bdd1243dSDimitry Andric  *
3310bdd1243dSDimitry Andric  * For example, given the following series of typedefs:
3311bdd1243dSDimitry Andric  *
3312bdd1243dSDimitry Andric  * \code
3313bdd1243dSDimitry Andric  * typedef int Integer;
3314bdd1243dSDimitry Andric  * typedef const Integer CInteger;
3315bdd1243dSDimitry Andric  * typedef CInteger DifferenceType;
3316bdd1243dSDimitry Andric  * \endcode
3317bdd1243dSDimitry Andric  *
3318bdd1243dSDimitry Andric  * Executing \c clang_getUnqualifiedType() on a \c CXType that
3319bdd1243dSDimitry Andric  * represents \c DifferenceType, will desugar to a type representing
3320bdd1243dSDimitry Andric  * \c Integer, that has no qualifiers.
3321bdd1243dSDimitry Andric  *
3322bdd1243dSDimitry Andric  * And, executing \c clang_getUnqualifiedType() on the type of the
3323bdd1243dSDimitry Andric  * first argument of the following function declaration:
3324bdd1243dSDimitry Andric  *
3325bdd1243dSDimitry Andric  * \code
3326bdd1243dSDimitry Andric  * void foo(const int);
3327bdd1243dSDimitry Andric  * \endcode
3328bdd1243dSDimitry Andric  *
3329bdd1243dSDimitry Andric  * Will return a type representing \c int, removing the \c const
3330bdd1243dSDimitry Andric  * qualifier.
3331bdd1243dSDimitry Andric  *
3332bdd1243dSDimitry Andric  * Sugar over array types is not desugared.
3333bdd1243dSDimitry Andric  *
3334bdd1243dSDimitry Andric  * A type can be checked for qualifiers with \c
3335bdd1243dSDimitry Andric  * clang_isConstQualifiedType(), \c clang_isVolatileQualifiedType()
3336bdd1243dSDimitry Andric  * and \c clang_isRestrictQualifiedType().
3337bdd1243dSDimitry Andric  *
3338bdd1243dSDimitry Andric  * A type that resulted from a call to \c clang_getUnqualifiedType
3339bdd1243dSDimitry Andric  * will return \c false for all of the above calls.
3340bdd1243dSDimitry Andric  */
3341bdd1243dSDimitry Andric CINDEX_LINKAGE CXType clang_getUnqualifiedType(CXType CT);
3342bdd1243dSDimitry Andric 
3343bdd1243dSDimitry Andric /**
3344bdd1243dSDimitry Andric  * For reference types (e.g., "const int&"), returns the type that the
3345bdd1243dSDimitry Andric  * reference refers to (e.g "const int").
3346bdd1243dSDimitry Andric  *
3347bdd1243dSDimitry Andric  * Otherwise, returns the type itself.
3348bdd1243dSDimitry Andric  *
3349bdd1243dSDimitry Andric  * A type that has kind \c CXType_LValueReference or
3350bdd1243dSDimitry Andric  * \c CXType_RValueReference is a reference type.
3351bdd1243dSDimitry Andric  */
3352bdd1243dSDimitry Andric CINDEX_LINKAGE CXType clang_getNonReferenceType(CXType CT);
3353bdd1243dSDimitry Andric 
3354bdd1243dSDimitry Andric /**
33550b57cec5SDimitry Andric  * Return the cursor for the declaration of the given type.
33560b57cec5SDimitry Andric  */
33570b57cec5SDimitry Andric CINDEX_LINKAGE CXCursor clang_getTypeDeclaration(CXType T);
33580b57cec5SDimitry Andric 
33590b57cec5SDimitry Andric /**
33600b57cec5SDimitry Andric  * Returns the Objective-C type encoding for the specified declaration.
33610b57cec5SDimitry Andric  */
33620b57cec5SDimitry Andric CINDEX_LINKAGE CXString clang_getDeclObjCTypeEncoding(CXCursor C);
33630b57cec5SDimitry Andric 
33640b57cec5SDimitry Andric /**
33650b57cec5SDimitry Andric  * Returns the Objective-C type encoding for the specified CXType.
33660b57cec5SDimitry Andric  */
33670b57cec5SDimitry Andric CINDEX_LINKAGE CXString clang_Type_getObjCEncoding(CXType type);
33680b57cec5SDimitry Andric 
33690b57cec5SDimitry Andric /**
33700b57cec5SDimitry Andric  * Retrieve the spelling of a given CXTypeKind.
33710b57cec5SDimitry Andric  */
33720b57cec5SDimitry Andric CINDEX_LINKAGE CXString clang_getTypeKindSpelling(enum CXTypeKind K);
33730b57cec5SDimitry Andric 
33740b57cec5SDimitry Andric /**
33750b57cec5SDimitry Andric  * Retrieve the calling convention associated with a function type.
33760b57cec5SDimitry Andric  *
33770b57cec5SDimitry Andric  * If a non-function type is passed in, CXCallingConv_Invalid is returned.
33780b57cec5SDimitry Andric  */
33790b57cec5SDimitry Andric CINDEX_LINKAGE enum CXCallingConv clang_getFunctionTypeCallingConv(CXType T);
33800b57cec5SDimitry Andric 
33810b57cec5SDimitry Andric /**
33820b57cec5SDimitry Andric  * Retrieve the return type associated with a function type.
33830b57cec5SDimitry Andric  *
33840b57cec5SDimitry Andric  * If a non-function type is passed in, an invalid type is returned.
33850b57cec5SDimitry Andric  */
33860b57cec5SDimitry Andric CINDEX_LINKAGE CXType clang_getResultType(CXType T);
33870b57cec5SDimitry Andric 
33880b57cec5SDimitry Andric /**
33890b57cec5SDimitry Andric  * Retrieve the exception specification type associated with a function type.
33900b57cec5SDimitry Andric  * This is a value of type CXCursor_ExceptionSpecificationKind.
33910b57cec5SDimitry Andric  *
33920b57cec5SDimitry Andric  * If a non-function type is passed in, an error code of -1 is returned.
33930b57cec5SDimitry Andric  */
33940b57cec5SDimitry Andric CINDEX_LINKAGE int clang_getExceptionSpecificationType(CXType T);
33950b57cec5SDimitry Andric 
33960b57cec5SDimitry Andric /**
33970b57cec5SDimitry Andric  * Retrieve the number of non-variadic parameters associated with a
33980b57cec5SDimitry Andric  * function type.
33990b57cec5SDimitry Andric  *
34000b57cec5SDimitry Andric  * If a non-function type is passed in, -1 is returned.
34010b57cec5SDimitry Andric  */
34020b57cec5SDimitry Andric CINDEX_LINKAGE int clang_getNumArgTypes(CXType T);
34030b57cec5SDimitry Andric 
34040b57cec5SDimitry Andric /**
34050b57cec5SDimitry Andric  * Retrieve the type of a parameter of a function type.
34060b57cec5SDimitry Andric  *
34070b57cec5SDimitry Andric  * If a non-function type is passed in or the function does not have enough
34080b57cec5SDimitry Andric  * parameters, an invalid type is returned.
34090b57cec5SDimitry Andric  */
34100b57cec5SDimitry Andric CINDEX_LINKAGE CXType clang_getArgType(CXType T, unsigned i);
34110b57cec5SDimitry Andric 
34120b57cec5SDimitry Andric /**
34130b57cec5SDimitry Andric  * Retrieves the base type of the ObjCObjectType.
34140b57cec5SDimitry Andric  *
34150b57cec5SDimitry Andric  * If the type is not an ObjC object, an invalid type is returned.
34160b57cec5SDimitry Andric  */
34170b57cec5SDimitry Andric CINDEX_LINKAGE CXType clang_Type_getObjCObjectBaseType(CXType T);
34180b57cec5SDimitry Andric 
34190b57cec5SDimitry Andric /**
34200b57cec5SDimitry Andric  * Retrieve the number of protocol references associated with an ObjC object/id.
34210b57cec5SDimitry Andric  *
34220b57cec5SDimitry Andric  * If the type is not an ObjC object, 0 is returned.
34230b57cec5SDimitry Andric  */
34240b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_Type_getNumObjCProtocolRefs(CXType T);
34250b57cec5SDimitry Andric 
34260b57cec5SDimitry Andric /**
34270b57cec5SDimitry Andric  * Retrieve the decl for a protocol reference for an ObjC object/id.
34280b57cec5SDimitry Andric  *
34290b57cec5SDimitry Andric  * If the type is not an ObjC object or there are not enough protocol
34300b57cec5SDimitry Andric  * references, an invalid cursor is returned.
34310b57cec5SDimitry Andric  */
34320b57cec5SDimitry Andric CINDEX_LINKAGE CXCursor clang_Type_getObjCProtocolDecl(CXType T, unsigned i);
34330b57cec5SDimitry Andric 
34340b57cec5SDimitry Andric /**
34355ffd83dbSDimitry Andric  * Retrieve the number of type arguments associated with an ObjC object.
34360b57cec5SDimitry Andric  *
34370b57cec5SDimitry Andric  * If the type is not an ObjC object, 0 is returned.
34380b57cec5SDimitry Andric  */
34390b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_Type_getNumObjCTypeArgs(CXType T);
34400b57cec5SDimitry Andric 
34410b57cec5SDimitry Andric /**
34420b57cec5SDimitry Andric  * Retrieve a type argument associated with an ObjC object.
34430b57cec5SDimitry Andric  *
34440b57cec5SDimitry Andric  * If the type is not an ObjC or the index is not valid,
34450b57cec5SDimitry Andric  * an invalid type is returned.
34460b57cec5SDimitry Andric  */
34470b57cec5SDimitry Andric CINDEX_LINKAGE CXType clang_Type_getObjCTypeArg(CXType T, unsigned i);
34480b57cec5SDimitry Andric 
34490b57cec5SDimitry Andric /**
34500b57cec5SDimitry Andric  * Return 1 if the CXType is a variadic function type, and 0 otherwise.
34510b57cec5SDimitry Andric  */
34520b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_isFunctionTypeVariadic(CXType T);
34530b57cec5SDimitry Andric 
34540b57cec5SDimitry Andric /**
34550b57cec5SDimitry Andric  * Retrieve the return type associated with a given cursor.
34560b57cec5SDimitry Andric  *
34570b57cec5SDimitry Andric  * This only returns a valid type if the cursor refers to a function or method.
34580b57cec5SDimitry Andric  */
34590b57cec5SDimitry Andric CINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C);
34600b57cec5SDimitry Andric 
34610b57cec5SDimitry Andric /**
34620b57cec5SDimitry Andric  * Retrieve the exception specification type associated with a given cursor.
34630b57cec5SDimitry Andric  * This is a value of type CXCursor_ExceptionSpecificationKind.
34640b57cec5SDimitry Andric  *
34655ffd83dbSDimitry Andric  * This only returns a valid result if the cursor refers to a function or
34665ffd83dbSDimitry Andric  * method.
34670b57cec5SDimitry Andric  */
34680b57cec5SDimitry Andric CINDEX_LINKAGE int clang_getCursorExceptionSpecificationType(CXCursor C);
34690b57cec5SDimitry Andric 
34700b57cec5SDimitry Andric /**
34710b57cec5SDimitry Andric  * Return 1 if the CXType is a POD (plain old data) type, and 0
34720b57cec5SDimitry Andric  *  otherwise.
34730b57cec5SDimitry Andric  */
34740b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_isPODType(CXType T);
34750b57cec5SDimitry Andric 
34760b57cec5SDimitry Andric /**
34770b57cec5SDimitry Andric  * Return the element type of an array, complex, or vector type.
34780b57cec5SDimitry Andric  *
34790b57cec5SDimitry Andric  * If a type is passed in that is not an array, complex, or vector type,
34800b57cec5SDimitry Andric  * an invalid type is returned.
34810b57cec5SDimitry Andric  */
34820b57cec5SDimitry Andric CINDEX_LINKAGE CXType clang_getElementType(CXType T);
34830b57cec5SDimitry Andric 
34840b57cec5SDimitry Andric /**
34850b57cec5SDimitry Andric  * Return the number of elements of an array or vector type.
34860b57cec5SDimitry Andric  *
34870b57cec5SDimitry Andric  * If a type is passed in that is not an array or vector type,
34880b57cec5SDimitry Andric  * -1 is returned.
34890b57cec5SDimitry Andric  */
34900b57cec5SDimitry Andric CINDEX_LINKAGE long long clang_getNumElements(CXType T);
34910b57cec5SDimitry Andric 
34920b57cec5SDimitry Andric /**
34930b57cec5SDimitry Andric  * Return the element type of an array type.
34940b57cec5SDimitry Andric  *
34950b57cec5SDimitry Andric  * If a non-array type is passed in, an invalid type is returned.
34960b57cec5SDimitry Andric  */
34970b57cec5SDimitry Andric CINDEX_LINKAGE CXType clang_getArrayElementType(CXType T);
34980b57cec5SDimitry Andric 
34990b57cec5SDimitry Andric /**
35000b57cec5SDimitry Andric  * Return the array size of a constant array.
35010b57cec5SDimitry Andric  *
35020b57cec5SDimitry Andric  * If a non-array type is passed in, -1 is returned.
35030b57cec5SDimitry Andric  */
35040b57cec5SDimitry Andric CINDEX_LINKAGE long long clang_getArraySize(CXType T);
35050b57cec5SDimitry Andric 
35060b57cec5SDimitry Andric /**
35070b57cec5SDimitry Andric  * Retrieve the type named by the qualified-id.
35080b57cec5SDimitry Andric  *
35090b57cec5SDimitry Andric  * If a non-elaborated type is passed in, an invalid type is returned.
35100b57cec5SDimitry Andric  */
35110b57cec5SDimitry Andric CINDEX_LINKAGE CXType clang_Type_getNamedType(CXType T);
35120b57cec5SDimitry Andric 
35130b57cec5SDimitry Andric /**
35140b57cec5SDimitry Andric  * Determine if a typedef is 'transparent' tag.
35150b57cec5SDimitry Andric  *
35160b57cec5SDimitry Andric  * A typedef is considered 'transparent' if it shares a name and spelling
35170b57cec5SDimitry Andric  * location with its underlying tag type, as is the case with the NS_ENUM macro.
35180b57cec5SDimitry Andric  *
35190b57cec5SDimitry Andric  * \returns non-zero if transparent and zero otherwise.
35200b57cec5SDimitry Andric  */
35210b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_Type_isTransparentTagTypedef(CXType T);
35220b57cec5SDimitry Andric 
35230b57cec5SDimitry Andric enum CXTypeNullabilityKind {
35240b57cec5SDimitry Andric   /**
35250b57cec5SDimitry Andric    * Values of this type can never be null.
35260b57cec5SDimitry Andric    */
35270b57cec5SDimitry Andric   CXTypeNullability_NonNull = 0,
35280b57cec5SDimitry Andric   /**
35290b57cec5SDimitry Andric    * Values of this type can be null.
35300b57cec5SDimitry Andric    */
35310b57cec5SDimitry Andric   CXTypeNullability_Nullable = 1,
35320b57cec5SDimitry Andric   /**
35330b57cec5SDimitry Andric    * Whether values of this type can be null is (explicitly)
35340b57cec5SDimitry Andric    * unspecified. This captures a (fairly rare) case where we
35350b57cec5SDimitry Andric    * can't conclude anything about the nullability of the type even
35360b57cec5SDimitry Andric    * though it has been considered.
35370b57cec5SDimitry Andric    */
35380b57cec5SDimitry Andric   CXTypeNullability_Unspecified = 2,
35390b57cec5SDimitry Andric   /**
35400b57cec5SDimitry Andric    * Nullability is not applicable to this type.
35410b57cec5SDimitry Andric    */
3542e8d8bef9SDimitry Andric   CXTypeNullability_Invalid = 3,
3543e8d8bef9SDimitry Andric 
3544e8d8bef9SDimitry Andric   /**
3545e8d8bef9SDimitry Andric    * Generally behaves like Nullable, except when used in a block parameter that
3546e8d8bef9SDimitry Andric    * was imported into a swift async method. There, swift will assume that the
354781ad6265SDimitry Andric    * parameter can get null even if no error occurred. _Nullable parameters are
3548e8d8bef9SDimitry Andric    * assumed to only get null on error.
3549e8d8bef9SDimitry Andric    */
3550e8d8bef9SDimitry Andric   CXTypeNullability_NullableResult = 4
35510b57cec5SDimitry Andric };
35520b57cec5SDimitry Andric 
35530b57cec5SDimitry Andric /**
35540b57cec5SDimitry Andric  * Retrieve the nullability kind of a pointer type.
35550b57cec5SDimitry Andric  */
35560b57cec5SDimitry Andric CINDEX_LINKAGE enum CXTypeNullabilityKind clang_Type_getNullability(CXType T);
35570b57cec5SDimitry Andric 
35580b57cec5SDimitry Andric /**
35590b57cec5SDimitry Andric  * List the possible error codes for \c clang_Type_getSizeOf,
35600b57cec5SDimitry Andric  *   \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf and
35610b57cec5SDimitry Andric  *   \c clang_Cursor_getOffsetOf.
35620b57cec5SDimitry Andric  *
35630b57cec5SDimitry Andric  * A value of this enumeration type can be returned if the target type is not
35640b57cec5SDimitry Andric  * a valid argument to sizeof, alignof or offsetof.
35650b57cec5SDimitry Andric  */
35660b57cec5SDimitry Andric enum CXTypeLayoutError {
35670b57cec5SDimitry Andric   /**
35680b57cec5SDimitry Andric    * Type is of kind CXType_Invalid.
35690b57cec5SDimitry Andric    */
35700b57cec5SDimitry Andric   CXTypeLayoutError_Invalid = -1,
35710b57cec5SDimitry Andric   /**
35720b57cec5SDimitry Andric    * The type is an incomplete Type.
35730b57cec5SDimitry Andric    */
35740b57cec5SDimitry Andric   CXTypeLayoutError_Incomplete = -2,
35750b57cec5SDimitry Andric   /**
35760b57cec5SDimitry Andric    * The type is a dependent Type.
35770b57cec5SDimitry Andric    */
35780b57cec5SDimitry Andric   CXTypeLayoutError_Dependent = -3,
35790b57cec5SDimitry Andric   /**
35800b57cec5SDimitry Andric    * The type is not a constant size type.
35810b57cec5SDimitry Andric    */
35820b57cec5SDimitry Andric   CXTypeLayoutError_NotConstantSize = -4,
35830b57cec5SDimitry Andric   /**
35840b57cec5SDimitry Andric    * The Field name is not valid for this record.
35850b57cec5SDimitry Andric    */
35860b57cec5SDimitry Andric   CXTypeLayoutError_InvalidFieldName = -5,
35870b57cec5SDimitry Andric   /**
35880b57cec5SDimitry Andric    * The type is undeduced.
35890b57cec5SDimitry Andric    */
35900b57cec5SDimitry Andric   CXTypeLayoutError_Undeduced = -6
35910b57cec5SDimitry Andric };
35920b57cec5SDimitry Andric 
35930b57cec5SDimitry Andric /**
35940b57cec5SDimitry Andric  * Return the alignment of a type in bytes as per C++[expr.alignof]
35950b57cec5SDimitry Andric  *   standard.
35960b57cec5SDimitry Andric  *
35970b57cec5SDimitry Andric  * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
35980b57cec5SDimitry Andric  * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
35990b57cec5SDimitry Andric  *   is returned.
36000b57cec5SDimitry Andric  * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
36010b57cec5SDimitry Andric  *   returned.
36020b57cec5SDimitry Andric  * If the type declaration is not a constant size type,
36030b57cec5SDimitry Andric  *   CXTypeLayoutError_NotConstantSize is returned.
36040b57cec5SDimitry Andric  */
36050b57cec5SDimitry Andric CINDEX_LINKAGE long long clang_Type_getAlignOf(CXType T);
36060b57cec5SDimitry Andric 
36070b57cec5SDimitry Andric /**
36080b57cec5SDimitry Andric  * Return the class type of an member pointer type.
36090b57cec5SDimitry Andric  *
36100b57cec5SDimitry Andric  * If a non-member-pointer type is passed in, an invalid type is returned.
36110b57cec5SDimitry Andric  */
36120b57cec5SDimitry Andric CINDEX_LINKAGE CXType clang_Type_getClassType(CXType T);
36130b57cec5SDimitry Andric 
36140b57cec5SDimitry Andric /**
36150b57cec5SDimitry Andric  * Return the size of a type in bytes as per C++[expr.sizeof] standard.
36160b57cec5SDimitry Andric  *
36170b57cec5SDimitry Andric  * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
36180b57cec5SDimitry Andric  * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
36190b57cec5SDimitry Andric  *   is returned.
36200b57cec5SDimitry Andric  * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
36210b57cec5SDimitry Andric  *   returned.
36220b57cec5SDimitry Andric  */
36230b57cec5SDimitry Andric CINDEX_LINKAGE long long clang_Type_getSizeOf(CXType T);
36240b57cec5SDimitry Andric 
36250b57cec5SDimitry Andric /**
36260b57cec5SDimitry Andric  * Return the offset of a field named S in a record of type T in bits
36270b57cec5SDimitry Andric  *   as it would be returned by __offsetof__ as per C++11[18.2p4]
36280b57cec5SDimitry Andric  *
36290b57cec5SDimitry Andric  * If the cursor is not a record field declaration, CXTypeLayoutError_Invalid
36300b57cec5SDimitry Andric  *   is returned.
36310b57cec5SDimitry Andric  * If the field's type declaration is an incomplete type,
36320b57cec5SDimitry Andric  *   CXTypeLayoutError_Incomplete is returned.
36330b57cec5SDimitry Andric  * If the field's type declaration is a dependent type,
36340b57cec5SDimitry Andric  *   CXTypeLayoutError_Dependent is returned.
36350b57cec5SDimitry Andric  * If the field's name S is not found,
36360b57cec5SDimitry Andric  *   CXTypeLayoutError_InvalidFieldName is returned.
36370b57cec5SDimitry Andric  */
36380b57cec5SDimitry Andric CINDEX_LINKAGE long long clang_Type_getOffsetOf(CXType T, const char *S);
36390b57cec5SDimitry Andric 
36400b57cec5SDimitry Andric /**
36410b57cec5SDimitry Andric  * Return the type that was modified by this attributed type.
36420b57cec5SDimitry Andric  *
36430b57cec5SDimitry Andric  * If the type is not an attributed type, an invalid type is returned.
36440b57cec5SDimitry Andric  */
36450b57cec5SDimitry Andric CINDEX_LINKAGE CXType clang_Type_getModifiedType(CXType T);
36460b57cec5SDimitry Andric 
36470b57cec5SDimitry Andric /**
36485ffd83dbSDimitry Andric  * Gets the type contained by this atomic type.
36495ffd83dbSDimitry Andric  *
36505ffd83dbSDimitry Andric  * If a non-atomic type is passed in, an invalid type is returned.
36515ffd83dbSDimitry Andric  */
36525ffd83dbSDimitry Andric CINDEX_LINKAGE CXType clang_Type_getValueType(CXType CT);
36535ffd83dbSDimitry Andric 
36545ffd83dbSDimitry Andric /**
36550b57cec5SDimitry Andric  * Return the offset of the field represented by the Cursor.
36560b57cec5SDimitry Andric  *
36570b57cec5SDimitry Andric  * If the cursor is not a field declaration, -1 is returned.
36580b57cec5SDimitry Andric  * If the cursor semantic parent is not a record field declaration,
36590b57cec5SDimitry Andric  *   CXTypeLayoutError_Invalid is returned.
36600b57cec5SDimitry Andric  * If the field's type declaration is an incomplete type,
36610b57cec5SDimitry Andric  *   CXTypeLayoutError_Incomplete is returned.
36620b57cec5SDimitry Andric  * If the field's type declaration is a dependent type,
36630b57cec5SDimitry Andric  *   CXTypeLayoutError_Dependent is returned.
36640b57cec5SDimitry Andric  * If the field's name S is not found,
36650b57cec5SDimitry Andric  *   CXTypeLayoutError_InvalidFieldName is returned.
36660b57cec5SDimitry Andric  */
36670b57cec5SDimitry Andric CINDEX_LINKAGE long long clang_Cursor_getOffsetOfField(CXCursor C);
36680b57cec5SDimitry Andric 
36690b57cec5SDimitry Andric /**
36700b57cec5SDimitry Andric  * Determine whether the given cursor represents an anonymous
36710b57cec5SDimitry Andric  * tag or namespace
36720b57cec5SDimitry Andric  */
36730b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_Cursor_isAnonymous(CXCursor C);
36740b57cec5SDimitry Andric 
36750b57cec5SDimitry Andric /**
36760b57cec5SDimitry Andric  * Determine whether the given cursor represents an anonymous record
36770b57cec5SDimitry Andric  * declaration.
36780b57cec5SDimitry Andric  */
36790b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_Cursor_isAnonymousRecordDecl(CXCursor C);
36800b57cec5SDimitry Andric 
36810b57cec5SDimitry Andric /**
36820b57cec5SDimitry Andric  * Determine whether the given cursor represents an inline namespace
36830b57cec5SDimitry Andric  * declaration.
36840b57cec5SDimitry Andric  */
36850b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_Cursor_isInlineNamespace(CXCursor C);
36860b57cec5SDimitry Andric 
36870b57cec5SDimitry Andric enum CXRefQualifierKind {
36880b57cec5SDimitry Andric   /** No ref-qualifier was provided. */
36890b57cec5SDimitry Andric   CXRefQualifier_None = 0,
36900b57cec5SDimitry Andric   /** An lvalue ref-qualifier was provided (\c &). */
36910b57cec5SDimitry Andric   CXRefQualifier_LValue,
36920b57cec5SDimitry Andric   /** An rvalue ref-qualifier was provided (\c &&). */
36930b57cec5SDimitry Andric   CXRefQualifier_RValue
36940b57cec5SDimitry Andric };
36950b57cec5SDimitry Andric 
36960b57cec5SDimitry Andric /**
36970b57cec5SDimitry Andric  * Returns the number of template arguments for given template
36980b57cec5SDimitry Andric  * specialization, or -1 if type \c T is not a template specialization.
36990b57cec5SDimitry Andric  */
37000b57cec5SDimitry Andric CINDEX_LINKAGE int clang_Type_getNumTemplateArguments(CXType T);
37010b57cec5SDimitry Andric 
37020b57cec5SDimitry Andric /**
37030b57cec5SDimitry Andric  * Returns the type template argument of a template class specialization
37040b57cec5SDimitry Andric  * at given index.
37050b57cec5SDimitry Andric  *
37060b57cec5SDimitry Andric  * This function only returns template type arguments and does not handle
37070b57cec5SDimitry Andric  * template template arguments or variadic packs.
37080b57cec5SDimitry Andric  */
37095ffd83dbSDimitry Andric CINDEX_LINKAGE CXType clang_Type_getTemplateArgumentAsType(CXType T,
37105ffd83dbSDimitry Andric                                                            unsigned i);
37110b57cec5SDimitry Andric 
37120b57cec5SDimitry Andric /**
37130b57cec5SDimitry Andric  * Retrieve the ref-qualifier kind of a function or method.
37140b57cec5SDimitry Andric  *
37150b57cec5SDimitry Andric  * The ref-qualifier is returned for C++ functions or methods. For other types
37160b57cec5SDimitry Andric  * or non-C++ declarations, CXRefQualifier_None is returned.
37170b57cec5SDimitry Andric  */
37180b57cec5SDimitry Andric CINDEX_LINKAGE enum CXRefQualifierKind clang_Type_getCXXRefQualifier(CXType T);
37190b57cec5SDimitry Andric 
37200b57cec5SDimitry Andric /**
37210b57cec5SDimitry Andric  * Returns 1 if the base class specified by the cursor with kind
37220b57cec5SDimitry Andric  *   CX_CXXBaseSpecifier is virtual.
37230b57cec5SDimitry Andric  */
37240b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_isVirtualBase(CXCursor);
37250b57cec5SDimitry Andric 
37260b57cec5SDimitry Andric /**
37270b57cec5SDimitry Andric  * Represents the C++ access control level to a base class for a
37280b57cec5SDimitry Andric  * cursor with kind CX_CXXBaseSpecifier.
37290b57cec5SDimitry Andric  */
37300b57cec5SDimitry Andric enum CX_CXXAccessSpecifier {
37310b57cec5SDimitry Andric   CX_CXXInvalidAccessSpecifier,
37320b57cec5SDimitry Andric   CX_CXXPublic,
37330b57cec5SDimitry Andric   CX_CXXProtected,
37340b57cec5SDimitry Andric   CX_CXXPrivate
37350b57cec5SDimitry Andric };
37360b57cec5SDimitry Andric 
37370b57cec5SDimitry Andric /**
37380b57cec5SDimitry Andric  * Returns the access control level for the referenced object.
37390b57cec5SDimitry Andric  *
37405ffd83dbSDimitry Andric  * If the cursor refers to a C++ declaration, its access control level within
37415ffd83dbSDimitry Andric  * its parent scope is returned. Otherwise, if the cursor refers to a base
37425ffd83dbSDimitry Andric  * specifier or access specifier, the specifier itself is returned.
37430b57cec5SDimitry Andric  */
37440b57cec5SDimitry Andric CINDEX_LINKAGE enum CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor);
37450b57cec5SDimitry Andric 
37460b57cec5SDimitry Andric /**
37470b57cec5SDimitry Andric  * Represents the storage classes as declared in the source. CX_SC_Invalid
37480b57cec5SDimitry Andric  * was added for the case that the passed cursor in not a declaration.
37490b57cec5SDimitry Andric  */
37500b57cec5SDimitry Andric enum CX_StorageClass {
37510b57cec5SDimitry Andric   CX_SC_Invalid,
37520b57cec5SDimitry Andric   CX_SC_None,
37530b57cec5SDimitry Andric   CX_SC_Extern,
37540b57cec5SDimitry Andric   CX_SC_Static,
37550b57cec5SDimitry Andric   CX_SC_PrivateExtern,
37560b57cec5SDimitry Andric   CX_SC_OpenCLWorkGroupLocal,
37570b57cec5SDimitry Andric   CX_SC_Auto,
37580b57cec5SDimitry Andric   CX_SC_Register
37590b57cec5SDimitry Andric };
37600b57cec5SDimitry Andric 
37610b57cec5SDimitry Andric /**
3762*0fca6ea1SDimitry Andric  * Represents a specific kind of binary operator which can appear at a cursor.
3763*0fca6ea1SDimitry Andric  */
3764*0fca6ea1SDimitry Andric enum CX_BinaryOperatorKind {
3765*0fca6ea1SDimitry Andric   CX_BO_Invalid = 0,
3766*0fca6ea1SDimitry Andric   CX_BO_PtrMemD = 1,
3767*0fca6ea1SDimitry Andric   CX_BO_PtrMemI = 2,
3768*0fca6ea1SDimitry Andric   CX_BO_Mul = 3,
3769*0fca6ea1SDimitry Andric   CX_BO_Div = 4,
3770*0fca6ea1SDimitry Andric   CX_BO_Rem = 5,
3771*0fca6ea1SDimitry Andric   CX_BO_Add = 6,
3772*0fca6ea1SDimitry Andric   CX_BO_Sub = 7,
3773*0fca6ea1SDimitry Andric   CX_BO_Shl = 8,
3774*0fca6ea1SDimitry Andric   CX_BO_Shr = 9,
3775*0fca6ea1SDimitry Andric   CX_BO_Cmp = 10,
3776*0fca6ea1SDimitry Andric   CX_BO_LT = 11,
3777*0fca6ea1SDimitry Andric   CX_BO_GT = 12,
3778*0fca6ea1SDimitry Andric   CX_BO_LE = 13,
3779*0fca6ea1SDimitry Andric   CX_BO_GE = 14,
3780*0fca6ea1SDimitry Andric   CX_BO_EQ = 15,
3781*0fca6ea1SDimitry Andric   CX_BO_NE = 16,
3782*0fca6ea1SDimitry Andric   CX_BO_And = 17,
3783*0fca6ea1SDimitry Andric   CX_BO_Xor = 18,
3784*0fca6ea1SDimitry Andric   CX_BO_Or = 19,
3785*0fca6ea1SDimitry Andric   CX_BO_LAnd = 20,
3786*0fca6ea1SDimitry Andric   CX_BO_LOr = 21,
3787*0fca6ea1SDimitry Andric   CX_BO_Assign = 22,
3788*0fca6ea1SDimitry Andric   CX_BO_MulAssign = 23,
3789*0fca6ea1SDimitry Andric   CX_BO_DivAssign = 24,
3790*0fca6ea1SDimitry Andric   CX_BO_RemAssign = 25,
3791*0fca6ea1SDimitry Andric   CX_BO_AddAssign = 26,
3792*0fca6ea1SDimitry Andric   CX_BO_SubAssign = 27,
3793*0fca6ea1SDimitry Andric   CX_BO_ShlAssign = 28,
3794*0fca6ea1SDimitry Andric   CX_BO_ShrAssign = 29,
3795*0fca6ea1SDimitry Andric   CX_BO_AndAssign = 30,
3796*0fca6ea1SDimitry Andric   CX_BO_XorAssign = 31,
3797*0fca6ea1SDimitry Andric   CX_BO_OrAssign = 32,
3798*0fca6ea1SDimitry Andric   CX_BO_Comma = 33,
3799*0fca6ea1SDimitry Andric   CX_BO_LAST = CX_BO_Comma
3800*0fca6ea1SDimitry Andric };
3801*0fca6ea1SDimitry Andric 
3802*0fca6ea1SDimitry Andric /**
3803*0fca6ea1SDimitry Andric  * \brief Returns the operator code for the binary operator.
3804*0fca6ea1SDimitry Andric  */
3805*0fca6ea1SDimitry Andric CINDEX_LINKAGE enum CX_BinaryOperatorKind
3806*0fca6ea1SDimitry Andric clang_Cursor_getBinaryOpcode(CXCursor C);
3807*0fca6ea1SDimitry Andric 
3808*0fca6ea1SDimitry Andric /**
3809*0fca6ea1SDimitry Andric  * \brief Returns a string containing the spelling of the binary operator.
3810*0fca6ea1SDimitry Andric  */
3811*0fca6ea1SDimitry Andric CINDEX_LINKAGE CXString
3812*0fca6ea1SDimitry Andric clang_Cursor_getBinaryOpcodeStr(enum CX_BinaryOperatorKind Op);
3813*0fca6ea1SDimitry Andric 
3814*0fca6ea1SDimitry Andric /**
38150b57cec5SDimitry Andric  * Returns the storage class for a function or variable declaration.
38160b57cec5SDimitry Andric  *
38170b57cec5SDimitry Andric  * If the passed in Cursor is not a function or variable declaration,
38180b57cec5SDimitry Andric  * CX_SC_Invalid is returned else the storage class.
38190b57cec5SDimitry Andric  */
38200b57cec5SDimitry Andric CINDEX_LINKAGE enum CX_StorageClass clang_Cursor_getStorageClass(CXCursor);
38210b57cec5SDimitry Andric 
38220b57cec5SDimitry Andric /**
38230b57cec5SDimitry Andric  * Determine the number of overloaded declarations referenced by a
38240b57cec5SDimitry Andric  * \c CXCursor_OverloadedDeclRef cursor.
38250b57cec5SDimitry Andric  *
38260b57cec5SDimitry Andric  * \param cursor The cursor whose overloaded declarations are being queried.
38270b57cec5SDimitry Andric  *
38280b57cec5SDimitry Andric  * \returns The number of overloaded declarations referenced by \c cursor. If it
38290b57cec5SDimitry Andric  * is not a \c CXCursor_OverloadedDeclRef cursor, returns 0.
38300b57cec5SDimitry Andric  */
38310b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_getNumOverloadedDecls(CXCursor cursor);
38320b57cec5SDimitry Andric 
38330b57cec5SDimitry Andric /**
38340b57cec5SDimitry Andric  * Retrieve a cursor for one of the overloaded declarations referenced
38350b57cec5SDimitry Andric  * by a \c CXCursor_OverloadedDeclRef cursor.
38360b57cec5SDimitry Andric  *
38370b57cec5SDimitry Andric  * \param cursor The cursor whose overloaded declarations are being queried.
38380b57cec5SDimitry Andric  *
38390b57cec5SDimitry Andric  * \param index The zero-based index into the set of overloaded declarations in
38400b57cec5SDimitry Andric  * the cursor.
38410b57cec5SDimitry Andric  *
38420b57cec5SDimitry Andric  * \returns A cursor representing the declaration referenced by the given
38430b57cec5SDimitry Andric  * \c cursor at the specified \c index. If the cursor does not have an
38440b57cec5SDimitry Andric  * associated set of overloaded declarations, or if the index is out of bounds,
38450b57cec5SDimitry Andric  * returns \c clang_getNullCursor();
38460b57cec5SDimitry Andric  */
38470b57cec5SDimitry Andric CINDEX_LINKAGE CXCursor clang_getOverloadedDecl(CXCursor cursor,
38480b57cec5SDimitry Andric                                                 unsigned index);
38490b57cec5SDimitry Andric 
38500b57cec5SDimitry Andric /**
38510b57cec5SDimitry Andric  * @}
38520b57cec5SDimitry Andric  */
38530b57cec5SDimitry Andric 
38540b57cec5SDimitry Andric /**
38550b57cec5SDimitry Andric  * \defgroup CINDEX_ATTRIBUTES Information for attributes
38560b57cec5SDimitry Andric  *
38570b57cec5SDimitry Andric  * @{
38580b57cec5SDimitry Andric  */
38590b57cec5SDimitry Andric 
38600b57cec5SDimitry Andric /**
38610b57cec5SDimitry Andric  * For cursors representing an iboutletcollection attribute,
38620b57cec5SDimitry Andric  *  this function returns the collection element type.
38630b57cec5SDimitry Andric  *
38640b57cec5SDimitry Andric  */
38650b57cec5SDimitry Andric CINDEX_LINKAGE CXType clang_getIBOutletCollectionType(CXCursor);
38660b57cec5SDimitry Andric 
38670b57cec5SDimitry Andric /**
38680b57cec5SDimitry Andric  * @}
38690b57cec5SDimitry Andric  */
38700b57cec5SDimitry Andric 
38710b57cec5SDimitry Andric /**
38720b57cec5SDimitry Andric  * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors
38730b57cec5SDimitry Andric  *
38740b57cec5SDimitry Andric  * These routines provide the ability to traverse the abstract syntax tree
38750b57cec5SDimitry Andric  * using cursors.
38760b57cec5SDimitry Andric  *
38770b57cec5SDimitry Andric  * @{
38780b57cec5SDimitry Andric  */
38790b57cec5SDimitry Andric 
38800b57cec5SDimitry Andric /**
38810b57cec5SDimitry Andric  * Describes how the traversal of the children of a particular
38820b57cec5SDimitry Andric  * cursor should proceed after visiting a particular child cursor.
38830b57cec5SDimitry Andric  *
38840b57cec5SDimitry Andric  * A value of this enumeration type should be returned by each
38850b57cec5SDimitry Andric  * \c CXCursorVisitor to indicate how clang_visitChildren() proceed.
38860b57cec5SDimitry Andric  */
38870b57cec5SDimitry Andric enum CXChildVisitResult {
38880b57cec5SDimitry Andric   /**
38890b57cec5SDimitry Andric    * Terminates the cursor traversal.
38900b57cec5SDimitry Andric    */
38910b57cec5SDimitry Andric   CXChildVisit_Break,
38920b57cec5SDimitry Andric   /**
38930b57cec5SDimitry Andric    * Continues the cursor traversal with the next sibling of
38940b57cec5SDimitry Andric    * the cursor just visited, without visiting its children.
38950b57cec5SDimitry Andric    */
38960b57cec5SDimitry Andric   CXChildVisit_Continue,
38970b57cec5SDimitry Andric   /**
38980b57cec5SDimitry Andric    * Recursively traverse the children of this cursor, using
38990b57cec5SDimitry Andric    * the same visitor and client data.
39000b57cec5SDimitry Andric    */
39010b57cec5SDimitry Andric   CXChildVisit_Recurse
39020b57cec5SDimitry Andric };
39030b57cec5SDimitry Andric 
39040b57cec5SDimitry Andric /**
39050b57cec5SDimitry Andric  * Visitor invoked for each cursor found by a traversal.
39060b57cec5SDimitry Andric  *
39070b57cec5SDimitry Andric  * This visitor function will be invoked for each cursor found by
39080b57cec5SDimitry Andric  * clang_visitCursorChildren(). Its first argument is the cursor being
39090b57cec5SDimitry Andric  * visited, its second argument is the parent visitor for that cursor,
39100b57cec5SDimitry Andric  * and its third argument is the client data provided to
39110b57cec5SDimitry Andric  * clang_visitCursorChildren().
39120b57cec5SDimitry Andric  *
39130b57cec5SDimitry Andric  * The visitor should return one of the \c CXChildVisitResult values
39140b57cec5SDimitry Andric  * to direct clang_visitCursorChildren().
39150b57cec5SDimitry Andric  */
39160b57cec5SDimitry Andric typedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor,
39170b57cec5SDimitry Andric                                                    CXCursor parent,
39180b57cec5SDimitry Andric                                                    CXClientData client_data);
39190b57cec5SDimitry Andric 
39200b57cec5SDimitry Andric /**
39210b57cec5SDimitry Andric  * Visit the children of a particular cursor.
39220b57cec5SDimitry Andric  *
39230b57cec5SDimitry Andric  * This function visits all the direct children of the given cursor,
39240b57cec5SDimitry Andric  * invoking the given \p visitor function with the cursors of each
39250b57cec5SDimitry Andric  * visited child. The traversal may be recursive, if the visitor returns
39260b57cec5SDimitry Andric  * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if
39270b57cec5SDimitry Andric  * the visitor returns \c CXChildVisit_Break.
39280b57cec5SDimitry Andric  *
39290b57cec5SDimitry Andric  * \param parent the cursor whose child may be visited. All kinds of
39300b57cec5SDimitry Andric  * cursors can be visited, including invalid cursors (which, by
39310b57cec5SDimitry Andric  * definition, have no children).
39320b57cec5SDimitry Andric  *
39330b57cec5SDimitry Andric  * \param visitor the visitor function that will be invoked for each
39340b57cec5SDimitry Andric  * child of \p parent.
39350b57cec5SDimitry Andric  *
39360b57cec5SDimitry Andric  * \param client_data pointer data supplied by the client, which will
39370b57cec5SDimitry Andric  * be passed to the visitor each time it is invoked.
39380b57cec5SDimitry Andric  *
39390b57cec5SDimitry Andric  * \returns a non-zero value if the traversal was terminated
39400b57cec5SDimitry Andric  * prematurely by the visitor returning \c CXChildVisit_Break.
39410b57cec5SDimitry Andric  */
39420b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent,
39430b57cec5SDimitry Andric                                             CXCursorVisitor visitor,
39440b57cec5SDimitry Andric                                             CXClientData client_data);
39450b57cec5SDimitry Andric /**
39460b57cec5SDimitry Andric  * Visitor invoked for each cursor found by a traversal.
39470b57cec5SDimitry Andric  *
39480b57cec5SDimitry Andric  * This visitor block will be invoked for each cursor found by
39490b57cec5SDimitry Andric  * clang_visitChildrenWithBlock(). Its first argument is the cursor being
39500b57cec5SDimitry Andric  * visited, its second argument is the parent visitor for that cursor.
39510b57cec5SDimitry Andric  *
39520b57cec5SDimitry Andric  * The visitor should return one of the \c CXChildVisitResult values
39530b57cec5SDimitry Andric  * to direct clang_visitChildrenWithBlock().
39540b57cec5SDimitry Andric  */
395506c3fb27SDimitry Andric #if __has_feature(blocks)
39565ffd83dbSDimitry Andric typedef enum CXChildVisitResult (^CXCursorVisitorBlock)(CXCursor cursor,
39575ffd83dbSDimitry Andric                                                         CXCursor parent);
395806c3fb27SDimitry Andric #else
395906c3fb27SDimitry Andric typedef struct _CXChildVisitResult *CXCursorVisitorBlock;
396006c3fb27SDimitry Andric #endif
39610b57cec5SDimitry Andric 
39620b57cec5SDimitry Andric /**
39630b57cec5SDimitry Andric  * Visits the children of a cursor using the specified block.  Behaves
39640b57cec5SDimitry Andric  * identically to clang_visitChildren() in all other respects.
39650b57cec5SDimitry Andric  */
39665ffd83dbSDimitry Andric CINDEX_LINKAGE unsigned
39675ffd83dbSDimitry Andric clang_visitChildrenWithBlock(CXCursor parent, CXCursorVisitorBlock block);
39680b57cec5SDimitry Andric 
39690b57cec5SDimitry Andric /**
39700b57cec5SDimitry Andric  * @}
39710b57cec5SDimitry Andric  */
39720b57cec5SDimitry Andric 
39730b57cec5SDimitry Andric /**
39740b57cec5SDimitry Andric  * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST
39750b57cec5SDimitry Andric  *
39760b57cec5SDimitry Andric  * These routines provide the ability to determine references within and
39770b57cec5SDimitry Andric  * across translation units, by providing the names of the entities referenced
39780b57cec5SDimitry Andric  * by cursors, follow reference cursors to the declarations they reference,
39790b57cec5SDimitry Andric  * and associate declarations with their definitions.
39800b57cec5SDimitry Andric  *
39810b57cec5SDimitry Andric  * @{
39820b57cec5SDimitry Andric  */
39830b57cec5SDimitry Andric 
39840b57cec5SDimitry Andric /**
39850b57cec5SDimitry Andric  * Retrieve a Unified Symbol Resolution (USR) for the entity referenced
39860b57cec5SDimitry Andric  * by the given cursor.
39870b57cec5SDimitry Andric  *
39880b57cec5SDimitry Andric  * A Unified Symbol Resolution (USR) is a string that identifies a particular
39890b57cec5SDimitry Andric  * entity (function, class, variable, etc.) within a program. USRs can be
39900b57cec5SDimitry Andric  * compared across translation units to determine, e.g., when references in
39910b57cec5SDimitry Andric  * one translation refer to an entity defined in another translation unit.
39920b57cec5SDimitry Andric  */
39930b57cec5SDimitry Andric CINDEX_LINKAGE CXString clang_getCursorUSR(CXCursor);
39940b57cec5SDimitry Andric 
39950b57cec5SDimitry Andric /**
39960b57cec5SDimitry Andric  * Construct a USR for a specified Objective-C class.
39970b57cec5SDimitry Andric  */
39980b57cec5SDimitry Andric CINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name);
39990b57cec5SDimitry Andric 
40000b57cec5SDimitry Andric /**
40010b57cec5SDimitry Andric  * Construct a USR for a specified Objective-C category.
40020b57cec5SDimitry Andric  */
40035ffd83dbSDimitry Andric CINDEX_LINKAGE CXString clang_constructUSR_ObjCCategory(
40045ffd83dbSDimitry Andric     const char *class_name, const char *category_name);
40050b57cec5SDimitry Andric 
40060b57cec5SDimitry Andric /**
40070b57cec5SDimitry Andric  * Construct a USR for a specified Objective-C protocol.
40080b57cec5SDimitry Andric  */
40090b57cec5SDimitry Andric CINDEX_LINKAGE CXString
40100b57cec5SDimitry Andric clang_constructUSR_ObjCProtocol(const char *protocol_name);
40110b57cec5SDimitry Andric 
40120b57cec5SDimitry Andric /**
40130b57cec5SDimitry Andric  * Construct a USR for a specified Objective-C instance variable and
40140b57cec5SDimitry Andric  *   the USR for its containing class.
40150b57cec5SDimitry Andric  */
40160b57cec5SDimitry Andric CINDEX_LINKAGE CXString clang_constructUSR_ObjCIvar(const char *name,
40170b57cec5SDimitry Andric                                                     CXString classUSR);
40180b57cec5SDimitry Andric 
40190b57cec5SDimitry Andric /**
40200b57cec5SDimitry Andric  * Construct a USR for a specified Objective-C method and
40210b57cec5SDimitry Andric  *   the USR for its containing class.
40220b57cec5SDimitry Andric  */
40230b57cec5SDimitry Andric CINDEX_LINKAGE CXString clang_constructUSR_ObjCMethod(const char *name,
40240b57cec5SDimitry Andric                                                       unsigned isInstanceMethod,
40250b57cec5SDimitry Andric                                                       CXString classUSR);
40260b57cec5SDimitry Andric 
40270b57cec5SDimitry Andric /**
40280b57cec5SDimitry Andric  * Construct a USR for a specified Objective-C property and the USR
40290b57cec5SDimitry Andric  *  for its containing class.
40300b57cec5SDimitry Andric  */
40310b57cec5SDimitry Andric CINDEX_LINKAGE CXString clang_constructUSR_ObjCProperty(const char *property,
40320b57cec5SDimitry Andric                                                         CXString classUSR);
40330b57cec5SDimitry Andric 
40340b57cec5SDimitry Andric /**
40350b57cec5SDimitry Andric  * Retrieve a name for the entity referenced by this cursor.
40360b57cec5SDimitry Andric  */
40370b57cec5SDimitry Andric CINDEX_LINKAGE CXString clang_getCursorSpelling(CXCursor);
40380b57cec5SDimitry Andric 
40390b57cec5SDimitry Andric /**
40400b57cec5SDimitry Andric  * Retrieve a range for a piece that forms the cursors spelling name.
40410b57cec5SDimitry Andric  * Most of the times there is only one range for the complete spelling but for
40420b57cec5SDimitry Andric  * Objective-C methods and Objective-C message expressions, there are multiple
40430b57cec5SDimitry Andric  * pieces for each selector identifier.
40440b57cec5SDimitry Andric  *
40450b57cec5SDimitry Andric  * \param pieceIndex the index of the spelling name piece. If this is greater
40460b57cec5SDimitry Andric  * than the actual number of pieces, it will return a NULL (invalid) range.
40470b57cec5SDimitry Andric  *
40480b57cec5SDimitry Andric  * \param options Reserved.
40490b57cec5SDimitry Andric  */
40505ffd83dbSDimitry Andric CINDEX_LINKAGE CXSourceRange clang_Cursor_getSpellingNameRange(
40515ffd83dbSDimitry Andric     CXCursor, unsigned pieceIndex, unsigned options);
40520b57cec5SDimitry Andric 
40530b57cec5SDimitry Andric /**
40540b57cec5SDimitry Andric  * Opaque pointer representing a policy that controls pretty printing
40550b57cec5SDimitry Andric  * for \c clang_getCursorPrettyPrinted.
40560b57cec5SDimitry Andric  */
40570b57cec5SDimitry Andric typedef void *CXPrintingPolicy;
40580b57cec5SDimitry Andric 
40590b57cec5SDimitry Andric /**
40600b57cec5SDimitry Andric  * Properties for the printing policy.
40610b57cec5SDimitry Andric  *
40620b57cec5SDimitry Andric  * See \c clang::PrintingPolicy for more information.
40630b57cec5SDimitry Andric  */
40640b57cec5SDimitry Andric enum CXPrintingPolicyProperty {
40650b57cec5SDimitry Andric   CXPrintingPolicy_Indentation,
40660b57cec5SDimitry Andric   CXPrintingPolicy_SuppressSpecifiers,
40670b57cec5SDimitry Andric   CXPrintingPolicy_SuppressTagKeyword,
40680b57cec5SDimitry Andric   CXPrintingPolicy_IncludeTagDefinition,
40690b57cec5SDimitry Andric   CXPrintingPolicy_SuppressScope,
40700b57cec5SDimitry Andric   CXPrintingPolicy_SuppressUnwrittenScope,
40710b57cec5SDimitry Andric   CXPrintingPolicy_SuppressInitializers,
40720b57cec5SDimitry Andric   CXPrintingPolicy_ConstantArraySizeAsWritten,
40730b57cec5SDimitry Andric   CXPrintingPolicy_AnonymousTagLocations,
40740b57cec5SDimitry Andric   CXPrintingPolicy_SuppressStrongLifetime,
40750b57cec5SDimitry Andric   CXPrintingPolicy_SuppressLifetimeQualifiers,
40760b57cec5SDimitry Andric   CXPrintingPolicy_SuppressTemplateArgsInCXXConstructors,
40770b57cec5SDimitry Andric   CXPrintingPolicy_Bool,
40780b57cec5SDimitry Andric   CXPrintingPolicy_Restrict,
40790b57cec5SDimitry Andric   CXPrintingPolicy_Alignof,
40800b57cec5SDimitry Andric   CXPrintingPolicy_UnderscoreAlignof,
40810b57cec5SDimitry Andric   CXPrintingPolicy_UseVoidForZeroParams,
40820b57cec5SDimitry Andric   CXPrintingPolicy_TerseOutput,
40830b57cec5SDimitry Andric   CXPrintingPolicy_PolishForDeclaration,
40840b57cec5SDimitry Andric   CXPrintingPolicy_Half,
40850b57cec5SDimitry Andric   CXPrintingPolicy_MSWChar,
40860b57cec5SDimitry Andric   CXPrintingPolicy_IncludeNewlines,
40870b57cec5SDimitry Andric   CXPrintingPolicy_MSVCFormatting,
40880b57cec5SDimitry Andric   CXPrintingPolicy_ConstantsAsWritten,
40890b57cec5SDimitry Andric   CXPrintingPolicy_SuppressImplicitBase,
40900b57cec5SDimitry Andric   CXPrintingPolicy_FullyQualifiedName,
40910b57cec5SDimitry Andric 
40920b57cec5SDimitry Andric   CXPrintingPolicy_LastProperty = CXPrintingPolicy_FullyQualifiedName
40930b57cec5SDimitry Andric };
40940b57cec5SDimitry Andric 
40950b57cec5SDimitry Andric /**
40960b57cec5SDimitry Andric  * Get a property value for the given printing policy.
40970b57cec5SDimitry Andric  */
40980b57cec5SDimitry Andric CINDEX_LINKAGE unsigned
40990b57cec5SDimitry Andric clang_PrintingPolicy_getProperty(CXPrintingPolicy Policy,
41000b57cec5SDimitry Andric                                  enum CXPrintingPolicyProperty Property);
41010b57cec5SDimitry Andric 
41020b57cec5SDimitry Andric /**
41030b57cec5SDimitry Andric  * Set a property value for the given printing policy.
41040b57cec5SDimitry Andric  */
41055ffd83dbSDimitry Andric CINDEX_LINKAGE void
41065ffd83dbSDimitry Andric clang_PrintingPolicy_setProperty(CXPrintingPolicy Policy,
41070b57cec5SDimitry Andric                                  enum CXPrintingPolicyProperty Property,
41080b57cec5SDimitry Andric                                  unsigned Value);
41090b57cec5SDimitry Andric 
41100b57cec5SDimitry Andric /**
41110b57cec5SDimitry Andric  * Retrieve the default policy for the cursor.
41120b57cec5SDimitry Andric  *
41130b57cec5SDimitry Andric  * The policy should be released after use with \c
41140b57cec5SDimitry Andric  * clang_PrintingPolicy_dispose.
41150b57cec5SDimitry Andric  */
41160b57cec5SDimitry Andric CINDEX_LINKAGE CXPrintingPolicy clang_getCursorPrintingPolicy(CXCursor);
41170b57cec5SDimitry Andric 
41180b57cec5SDimitry Andric /**
41190b57cec5SDimitry Andric  * Release a printing policy.
41200b57cec5SDimitry Andric  */
41210b57cec5SDimitry Andric CINDEX_LINKAGE void clang_PrintingPolicy_dispose(CXPrintingPolicy Policy);
41220b57cec5SDimitry Andric 
41230b57cec5SDimitry Andric /**
41240b57cec5SDimitry Andric  * Pretty print declarations.
41250b57cec5SDimitry Andric  *
41260b57cec5SDimitry Andric  * \param Cursor The cursor representing a declaration.
41270b57cec5SDimitry Andric  *
41280b57cec5SDimitry Andric  * \param Policy The policy to control the entities being printed. If
41290b57cec5SDimitry Andric  * NULL, a default policy is used.
41300b57cec5SDimitry Andric  *
41310b57cec5SDimitry Andric  * \returns The pretty printed declaration or the empty string for
41320b57cec5SDimitry Andric  * other cursors.
41330b57cec5SDimitry Andric  */
41340b57cec5SDimitry Andric CINDEX_LINKAGE CXString clang_getCursorPrettyPrinted(CXCursor Cursor,
41350b57cec5SDimitry Andric                                                      CXPrintingPolicy Policy);
41360b57cec5SDimitry Andric 
41370b57cec5SDimitry Andric /**
41380b57cec5SDimitry Andric  * Retrieve the display name for the entity referenced by this cursor.
41390b57cec5SDimitry Andric  *
41400b57cec5SDimitry Andric  * The display name contains extra information that helps identify the cursor,
41410b57cec5SDimitry Andric  * such as the parameters of a function or template or the arguments of a
41420b57cec5SDimitry Andric  * class template specialization.
41430b57cec5SDimitry Andric  */
41440b57cec5SDimitry Andric CINDEX_LINKAGE CXString clang_getCursorDisplayName(CXCursor);
41450b57cec5SDimitry Andric 
41460b57cec5SDimitry Andric /** For a cursor that is a reference, retrieve a cursor representing the
41470b57cec5SDimitry Andric  * entity that it references.
41480b57cec5SDimitry Andric  *
41490b57cec5SDimitry Andric  * Reference cursors refer to other entities in the AST. For example, an
41500b57cec5SDimitry Andric  * Objective-C superclass reference cursor refers to an Objective-C class.
41510b57cec5SDimitry Andric  * This function produces the cursor for the Objective-C class from the
41520b57cec5SDimitry Andric  * cursor for the superclass reference. If the input cursor is a declaration or
41530b57cec5SDimitry Andric  * definition, it returns that declaration or definition unchanged.
41540b57cec5SDimitry Andric  * Otherwise, returns the NULL cursor.
41550b57cec5SDimitry Andric  */
41560b57cec5SDimitry Andric CINDEX_LINKAGE CXCursor clang_getCursorReferenced(CXCursor);
41570b57cec5SDimitry Andric 
41580b57cec5SDimitry Andric /**
41590b57cec5SDimitry Andric  *  For a cursor that is either a reference to or a declaration
41600b57cec5SDimitry Andric  *  of some entity, retrieve a cursor that describes the definition of
41610b57cec5SDimitry Andric  *  that entity.
41620b57cec5SDimitry Andric  *
41630b57cec5SDimitry Andric  *  Some entities can be declared multiple times within a translation
41640b57cec5SDimitry Andric  *  unit, but only one of those declarations can also be a
41650b57cec5SDimitry Andric  *  definition. For example, given:
41660b57cec5SDimitry Andric  *
41670b57cec5SDimitry Andric  *  \code
41680b57cec5SDimitry Andric  *  int f(int, int);
41690b57cec5SDimitry Andric  *  int g(int x, int y) { return f(x, y); }
41700b57cec5SDimitry Andric  *  int f(int a, int b) { return a + b; }
41710b57cec5SDimitry Andric  *  int f(int, int);
41720b57cec5SDimitry Andric  *  \endcode
41730b57cec5SDimitry Andric  *
41740b57cec5SDimitry Andric  *  there are three declarations of the function "f", but only the
41750b57cec5SDimitry Andric  *  second one is a definition. The clang_getCursorDefinition()
41760b57cec5SDimitry Andric  *  function will take any cursor pointing to a declaration of "f"
41770b57cec5SDimitry Andric  *  (the first or fourth lines of the example) or a cursor referenced
41780b57cec5SDimitry Andric  *  that uses "f" (the call to "f' inside "g") and will return a
41790b57cec5SDimitry Andric  *  declaration cursor pointing to the definition (the second "f"
41800b57cec5SDimitry Andric  *  declaration).
41810b57cec5SDimitry Andric  *
41820b57cec5SDimitry Andric  *  If given a cursor for which there is no corresponding definition,
41830b57cec5SDimitry Andric  *  e.g., because there is no definition of that entity within this
41840b57cec5SDimitry Andric  *  translation unit, returns a NULL cursor.
41850b57cec5SDimitry Andric  */
41860b57cec5SDimitry Andric CINDEX_LINKAGE CXCursor clang_getCursorDefinition(CXCursor);
41870b57cec5SDimitry Andric 
41880b57cec5SDimitry Andric /**
41890b57cec5SDimitry Andric  * Determine whether the declaration pointed to by this cursor
41900b57cec5SDimitry Andric  * is also a definition of that entity.
41910b57cec5SDimitry Andric  */
41920b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_isCursorDefinition(CXCursor);
41930b57cec5SDimitry Andric 
41940b57cec5SDimitry Andric /**
41950b57cec5SDimitry Andric  * Retrieve the canonical cursor corresponding to the given cursor.
41960b57cec5SDimitry Andric  *
41970b57cec5SDimitry Andric  * In the C family of languages, many kinds of entities can be declared several
41980b57cec5SDimitry Andric  * times within a single translation unit. For example, a structure type can
41990b57cec5SDimitry Andric  * be forward-declared (possibly multiple times) and later defined:
42000b57cec5SDimitry Andric  *
42010b57cec5SDimitry Andric  * \code
42020b57cec5SDimitry Andric  * struct X;
42030b57cec5SDimitry Andric  * struct X;
42040b57cec5SDimitry Andric  * struct X {
42050b57cec5SDimitry Andric  *   int member;
42060b57cec5SDimitry Andric  * };
42070b57cec5SDimitry Andric  * \endcode
42080b57cec5SDimitry Andric  *
42090b57cec5SDimitry Andric  * The declarations and the definition of \c X are represented by three
42100b57cec5SDimitry Andric  * different cursors, all of which are declarations of the same underlying
42110b57cec5SDimitry Andric  * entity. One of these cursor is considered the "canonical" cursor, which
42120b57cec5SDimitry Andric  * is effectively the representative for the underlying entity. One can
42130b57cec5SDimitry Andric  * determine if two cursors are declarations of the same underlying entity by
42140b57cec5SDimitry Andric  * comparing their canonical cursors.
42150b57cec5SDimitry Andric  *
42160b57cec5SDimitry Andric  * \returns The canonical cursor for the entity referred to by the given cursor.
42170b57cec5SDimitry Andric  */
42180b57cec5SDimitry Andric CINDEX_LINKAGE CXCursor clang_getCanonicalCursor(CXCursor);
42190b57cec5SDimitry Andric 
42200b57cec5SDimitry Andric /**
42210b57cec5SDimitry Andric  * If the cursor points to a selector identifier in an Objective-C
42220b57cec5SDimitry Andric  * method or message expression, this returns the selector index.
42230b57cec5SDimitry Andric  *
42240b57cec5SDimitry Andric  * After getting a cursor with #clang_getCursor, this can be called to
42250b57cec5SDimitry Andric  * determine if the location points to a selector identifier.
42260b57cec5SDimitry Andric  *
42270b57cec5SDimitry Andric  * \returns The selector index if the cursor is an Objective-C method or message
42280b57cec5SDimitry Andric  * expression and the cursor is pointing to a selector identifier, or -1
42290b57cec5SDimitry Andric  * otherwise.
42300b57cec5SDimitry Andric  */
42310b57cec5SDimitry Andric CINDEX_LINKAGE int clang_Cursor_getObjCSelectorIndex(CXCursor);
42320b57cec5SDimitry Andric 
42330b57cec5SDimitry Andric /**
42340b57cec5SDimitry Andric  * Given a cursor pointing to a C++ method call or an Objective-C
42350b57cec5SDimitry Andric  * message, returns non-zero if the method/message is "dynamic", meaning:
42360b57cec5SDimitry Andric  *
42370b57cec5SDimitry Andric  * For a C++ method: the call is virtual.
42380b57cec5SDimitry Andric  * For an Objective-C message: the receiver is an object instance, not 'super'
42390b57cec5SDimitry Andric  * or a specific class.
42400b57cec5SDimitry Andric  *
42410b57cec5SDimitry Andric  * If the method/message is "static" or the cursor does not point to a
42420b57cec5SDimitry Andric  * method/message, it will return zero.
42430b57cec5SDimitry Andric  */
42440b57cec5SDimitry Andric CINDEX_LINKAGE int clang_Cursor_isDynamicCall(CXCursor C);
42450b57cec5SDimitry Andric 
42460b57cec5SDimitry Andric /**
42470b57cec5SDimitry Andric  * Given a cursor pointing to an Objective-C message or property
42480b57cec5SDimitry Andric  * reference, or C++ method call, returns the CXType of the receiver.
42490b57cec5SDimitry Andric  */
42500b57cec5SDimitry Andric CINDEX_LINKAGE CXType clang_Cursor_getReceiverType(CXCursor C);
42510b57cec5SDimitry Andric 
42520b57cec5SDimitry Andric /**
42530b57cec5SDimitry Andric  * Property attributes for a \c CXCursor_ObjCPropertyDecl.
42540b57cec5SDimitry Andric  */
42550b57cec5SDimitry Andric typedef enum {
42560b57cec5SDimitry Andric   CXObjCPropertyAttr_noattr = 0x00,
42570b57cec5SDimitry Andric   CXObjCPropertyAttr_readonly = 0x01,
42580b57cec5SDimitry Andric   CXObjCPropertyAttr_getter = 0x02,
42590b57cec5SDimitry Andric   CXObjCPropertyAttr_assign = 0x04,
42600b57cec5SDimitry Andric   CXObjCPropertyAttr_readwrite = 0x08,
42610b57cec5SDimitry Andric   CXObjCPropertyAttr_retain = 0x10,
42620b57cec5SDimitry Andric   CXObjCPropertyAttr_copy = 0x20,
42630b57cec5SDimitry Andric   CXObjCPropertyAttr_nonatomic = 0x40,
42640b57cec5SDimitry Andric   CXObjCPropertyAttr_setter = 0x80,
42650b57cec5SDimitry Andric   CXObjCPropertyAttr_atomic = 0x100,
42660b57cec5SDimitry Andric   CXObjCPropertyAttr_weak = 0x200,
42670b57cec5SDimitry Andric   CXObjCPropertyAttr_strong = 0x400,
42680b57cec5SDimitry Andric   CXObjCPropertyAttr_unsafe_unretained = 0x800,
42690b57cec5SDimitry Andric   CXObjCPropertyAttr_class = 0x1000
42700b57cec5SDimitry Andric } CXObjCPropertyAttrKind;
42710b57cec5SDimitry Andric 
42720b57cec5SDimitry Andric /**
42730b57cec5SDimitry Andric  * Given a cursor that represents a property declaration, return the
42740b57cec5SDimitry Andric  * associated property attributes. The bits are formed from
42750b57cec5SDimitry Andric  * \c CXObjCPropertyAttrKind.
42760b57cec5SDimitry Andric  *
42770b57cec5SDimitry Andric  * \param reserved Reserved for future use, pass 0.
42780b57cec5SDimitry Andric  */
42795ffd83dbSDimitry Andric CINDEX_LINKAGE unsigned
42805ffd83dbSDimitry Andric clang_Cursor_getObjCPropertyAttributes(CXCursor C, unsigned reserved);
42810b57cec5SDimitry Andric 
42820b57cec5SDimitry Andric /**
42830b57cec5SDimitry Andric  * Given a cursor that represents a property declaration, return the
42840b57cec5SDimitry Andric  * name of the method that implements the getter.
42850b57cec5SDimitry Andric  */
42860b57cec5SDimitry Andric CINDEX_LINKAGE CXString clang_Cursor_getObjCPropertyGetterName(CXCursor C);
42870b57cec5SDimitry Andric 
42880b57cec5SDimitry Andric /**
42890b57cec5SDimitry Andric  * Given a cursor that represents a property declaration, return the
42900b57cec5SDimitry Andric  * name of the method that implements the setter, if any.
42910b57cec5SDimitry Andric  */
42920b57cec5SDimitry Andric CINDEX_LINKAGE CXString clang_Cursor_getObjCPropertySetterName(CXCursor C);
42930b57cec5SDimitry Andric 
42940b57cec5SDimitry Andric /**
42950b57cec5SDimitry Andric  * 'Qualifiers' written next to the return and parameter types in
42960b57cec5SDimitry Andric  * Objective-C method declarations.
42970b57cec5SDimitry Andric  */
42980b57cec5SDimitry Andric typedef enum {
42990b57cec5SDimitry Andric   CXObjCDeclQualifier_None = 0x0,
43000b57cec5SDimitry Andric   CXObjCDeclQualifier_In = 0x1,
43010b57cec5SDimitry Andric   CXObjCDeclQualifier_Inout = 0x2,
43020b57cec5SDimitry Andric   CXObjCDeclQualifier_Out = 0x4,
43030b57cec5SDimitry Andric   CXObjCDeclQualifier_Bycopy = 0x8,
43040b57cec5SDimitry Andric   CXObjCDeclQualifier_Byref = 0x10,
43050b57cec5SDimitry Andric   CXObjCDeclQualifier_Oneway = 0x20
43060b57cec5SDimitry Andric } CXObjCDeclQualifierKind;
43070b57cec5SDimitry Andric 
43080b57cec5SDimitry Andric /**
43090b57cec5SDimitry Andric  * Given a cursor that represents an Objective-C method or parameter
43100b57cec5SDimitry Andric  * declaration, return the associated Objective-C qualifiers for the return
43110b57cec5SDimitry Andric  * type or the parameter respectively. The bits are formed from
43120b57cec5SDimitry Andric  * CXObjCDeclQualifierKind.
43130b57cec5SDimitry Andric  */
43140b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_Cursor_getObjCDeclQualifiers(CXCursor C);
43150b57cec5SDimitry Andric 
43160b57cec5SDimitry Andric /**
43170b57cec5SDimitry Andric  * Given a cursor that represents an Objective-C method or property
43180b57cec5SDimitry Andric  * declaration, return non-zero if the declaration was affected by "\@optional".
43190b57cec5SDimitry Andric  * Returns zero if the cursor is not such a declaration or it is "\@required".
43200b57cec5SDimitry Andric  */
43210b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_Cursor_isObjCOptional(CXCursor C);
43220b57cec5SDimitry Andric 
43230b57cec5SDimitry Andric /**
43240b57cec5SDimitry Andric  * Returns non-zero if the given cursor is a variadic function or method.
43250b57cec5SDimitry Andric  */
43260b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_Cursor_isVariadic(CXCursor C);
43270b57cec5SDimitry Andric 
43280b57cec5SDimitry Andric /**
43290b57cec5SDimitry Andric  * Returns non-zero if the given cursor points to a symbol marked with
43300b57cec5SDimitry Andric  * external_source_symbol attribute.
43310b57cec5SDimitry Andric  *
43320b57cec5SDimitry Andric  * \param language If non-NULL, and the attribute is present, will be set to
43330b57cec5SDimitry Andric  * the 'language' string from the attribute.
43340b57cec5SDimitry Andric  *
43350b57cec5SDimitry Andric  * \param definedIn If non-NULL, and the attribute is present, will be set to
43360b57cec5SDimitry Andric  * the 'definedIn' string from the attribute.
43370b57cec5SDimitry Andric  *
43380b57cec5SDimitry Andric  * \param isGenerated If non-NULL, and the attribute is present, will be set to
43390b57cec5SDimitry Andric  * non-zero if the 'generated_declaration' is set in the attribute.
43400b57cec5SDimitry Andric  */
43410b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_Cursor_isExternalSymbol(CXCursor C,
43425ffd83dbSDimitry Andric                                                       CXString *language,
43435ffd83dbSDimitry Andric                                                       CXString *definedIn,
43440b57cec5SDimitry Andric                                                       unsigned *isGenerated);
43450b57cec5SDimitry Andric 
43460b57cec5SDimitry Andric /**
43470b57cec5SDimitry Andric  * Given a cursor that represents a declaration, return the associated
43480b57cec5SDimitry Andric  * comment's source range.  The range may include multiple consecutive comments
43490b57cec5SDimitry Andric  * with whitespace in between.
43500b57cec5SDimitry Andric  */
43510b57cec5SDimitry Andric CINDEX_LINKAGE CXSourceRange clang_Cursor_getCommentRange(CXCursor C);
43520b57cec5SDimitry Andric 
43530b57cec5SDimitry Andric /**
43540b57cec5SDimitry Andric  * Given a cursor that represents a declaration, return the associated
43550b57cec5SDimitry Andric  * comment text, including comment markers.
43560b57cec5SDimitry Andric  */
43570b57cec5SDimitry Andric CINDEX_LINKAGE CXString clang_Cursor_getRawCommentText(CXCursor C);
43580b57cec5SDimitry Andric 
43590b57cec5SDimitry Andric /**
43600b57cec5SDimitry Andric  * Given a cursor that represents a documentable entity (e.g.,
43610b57cec5SDimitry Andric  * declaration), return the associated \paragraph; otherwise return the
43620b57cec5SDimitry Andric  * first paragraph.
43630b57cec5SDimitry Andric  */
43640b57cec5SDimitry Andric CINDEX_LINKAGE CXString clang_Cursor_getBriefCommentText(CXCursor C);
43650b57cec5SDimitry Andric 
43660b57cec5SDimitry Andric /**
43670b57cec5SDimitry Andric  * @}
43680b57cec5SDimitry Andric  */
43690b57cec5SDimitry Andric 
43700b57cec5SDimitry Andric /** \defgroup CINDEX_MANGLE Name Mangling API Functions
43710b57cec5SDimitry Andric  *
43720b57cec5SDimitry Andric  * @{
43730b57cec5SDimitry Andric  */
43740b57cec5SDimitry Andric 
43750b57cec5SDimitry Andric /**
43760b57cec5SDimitry Andric  * Retrieve the CXString representing the mangled name of the cursor.
43770b57cec5SDimitry Andric  */
43780b57cec5SDimitry Andric CINDEX_LINKAGE CXString clang_Cursor_getMangling(CXCursor);
43790b57cec5SDimitry Andric 
43800b57cec5SDimitry Andric /**
43810b57cec5SDimitry Andric  * Retrieve the CXStrings representing the mangled symbols of the C++
43820b57cec5SDimitry Andric  * constructor or destructor at the cursor.
43830b57cec5SDimitry Andric  */
43840b57cec5SDimitry Andric CINDEX_LINKAGE CXStringSet *clang_Cursor_getCXXManglings(CXCursor);
43850b57cec5SDimitry Andric 
43860b57cec5SDimitry Andric /**
43870b57cec5SDimitry Andric  * Retrieve the CXStrings representing the mangled symbols of the ObjC
43880b57cec5SDimitry Andric  * class interface or implementation at the cursor.
43890b57cec5SDimitry Andric  */
43900b57cec5SDimitry Andric CINDEX_LINKAGE CXStringSet *clang_Cursor_getObjCManglings(CXCursor);
43910b57cec5SDimitry Andric 
43920b57cec5SDimitry Andric /**
43930b57cec5SDimitry Andric  * @}
43940b57cec5SDimitry Andric  */
43950b57cec5SDimitry Andric 
43960b57cec5SDimitry Andric /**
43970b57cec5SDimitry Andric  * \defgroup CINDEX_MODULE Module introspection
43980b57cec5SDimitry Andric  *
43990b57cec5SDimitry Andric  * The functions in this group provide access to information about modules.
44000b57cec5SDimitry Andric  *
44010b57cec5SDimitry Andric  * @{
44020b57cec5SDimitry Andric  */
44030b57cec5SDimitry Andric 
44040b57cec5SDimitry Andric typedef void *CXModule;
44050b57cec5SDimitry Andric 
44060b57cec5SDimitry Andric /**
44070b57cec5SDimitry Andric  * Given a CXCursor_ModuleImportDecl cursor, return the associated module.
44080b57cec5SDimitry Andric  */
44090b57cec5SDimitry Andric CINDEX_LINKAGE CXModule clang_Cursor_getModule(CXCursor C);
44100b57cec5SDimitry Andric 
44110b57cec5SDimitry Andric /**
44120b57cec5SDimitry Andric  * Given a CXFile header file, return the module that contains it, if one
44130b57cec5SDimitry Andric  * exists.
44140b57cec5SDimitry Andric  */
44150b57cec5SDimitry Andric CINDEX_LINKAGE CXModule clang_getModuleForFile(CXTranslationUnit, CXFile);
44160b57cec5SDimitry Andric 
44170b57cec5SDimitry Andric /**
44180b57cec5SDimitry Andric  * \param Module a module object.
44190b57cec5SDimitry Andric  *
44200b57cec5SDimitry Andric  * \returns the module file where the provided module object came from.
44210b57cec5SDimitry Andric  */
44220b57cec5SDimitry Andric CINDEX_LINKAGE CXFile clang_Module_getASTFile(CXModule Module);
44230b57cec5SDimitry Andric 
44240b57cec5SDimitry Andric /**
44250b57cec5SDimitry Andric  * \param Module a module object.
44260b57cec5SDimitry Andric  *
44270b57cec5SDimitry Andric  * \returns the parent of a sub-module or NULL if the given module is top-level,
44280b57cec5SDimitry Andric  * e.g. for 'std.vector' it will return the 'std' module.
44290b57cec5SDimitry Andric  */
44300b57cec5SDimitry Andric CINDEX_LINKAGE CXModule clang_Module_getParent(CXModule Module);
44310b57cec5SDimitry Andric 
44320b57cec5SDimitry Andric /**
44330b57cec5SDimitry Andric  * \param Module a module object.
44340b57cec5SDimitry Andric  *
44350b57cec5SDimitry Andric  * \returns the name of the module, e.g. for the 'std.vector' sub-module it
44360b57cec5SDimitry Andric  * will return "vector".
44370b57cec5SDimitry Andric  */
44380b57cec5SDimitry Andric CINDEX_LINKAGE CXString clang_Module_getName(CXModule Module);
44390b57cec5SDimitry Andric 
44400b57cec5SDimitry Andric /**
44410b57cec5SDimitry Andric  * \param Module a module object.
44420b57cec5SDimitry Andric  *
44430b57cec5SDimitry Andric  * \returns the full name of the module, e.g. "std.vector".
44440b57cec5SDimitry Andric  */
44450b57cec5SDimitry Andric CINDEX_LINKAGE CXString clang_Module_getFullName(CXModule Module);
44460b57cec5SDimitry Andric 
44470b57cec5SDimitry Andric /**
44480b57cec5SDimitry Andric  * \param Module a module object.
44490b57cec5SDimitry Andric  *
44500b57cec5SDimitry Andric  * \returns non-zero if the module is a system one.
44510b57cec5SDimitry Andric  */
44520b57cec5SDimitry Andric CINDEX_LINKAGE int clang_Module_isSystem(CXModule Module);
44530b57cec5SDimitry Andric 
44540b57cec5SDimitry Andric /**
44550b57cec5SDimitry Andric  * \param Module a module object.
44560b57cec5SDimitry Andric  *
44570b57cec5SDimitry Andric  * \returns the number of top level headers associated with this module.
44580b57cec5SDimitry Andric  */
44590b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_Module_getNumTopLevelHeaders(CXTranslationUnit,
44600b57cec5SDimitry Andric                                                            CXModule Module);
44610b57cec5SDimitry Andric 
44620b57cec5SDimitry Andric /**
44630b57cec5SDimitry Andric  * \param Module a module object.
44640b57cec5SDimitry Andric  *
44650b57cec5SDimitry Andric  * \param Index top level header index (zero-based).
44660b57cec5SDimitry Andric  *
44670b57cec5SDimitry Andric  * \returns the specified top level header associated with the module.
44680b57cec5SDimitry Andric  */
44690b57cec5SDimitry Andric CINDEX_LINKAGE
44705ffd83dbSDimitry Andric CXFile clang_Module_getTopLevelHeader(CXTranslationUnit, CXModule Module,
44715ffd83dbSDimitry Andric                                       unsigned Index);
44720b57cec5SDimitry Andric 
44730b57cec5SDimitry Andric /**
44740b57cec5SDimitry Andric  * @}
44750b57cec5SDimitry Andric  */
44760b57cec5SDimitry Andric 
44770b57cec5SDimitry Andric /**
44780b57cec5SDimitry Andric  * \defgroup CINDEX_CPP C++ AST introspection
44790b57cec5SDimitry Andric  *
44800b57cec5SDimitry Andric  * The routines in this group provide access information in the ASTs specific
44810b57cec5SDimitry Andric  * to C++ language features.
44820b57cec5SDimitry Andric  *
44830b57cec5SDimitry Andric  * @{
44840b57cec5SDimitry Andric  */
44850b57cec5SDimitry Andric 
44860b57cec5SDimitry Andric /**
44870b57cec5SDimitry Andric  * Determine if a C++ constructor is a converting constructor.
44880b57cec5SDimitry Andric  */
44895ffd83dbSDimitry Andric CINDEX_LINKAGE unsigned
44905ffd83dbSDimitry Andric clang_CXXConstructor_isConvertingConstructor(CXCursor C);
44910b57cec5SDimitry Andric 
44920b57cec5SDimitry Andric /**
44930b57cec5SDimitry Andric  * Determine if a C++ constructor is a copy constructor.
44940b57cec5SDimitry Andric  */
44950b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_CXXConstructor_isCopyConstructor(CXCursor C);
44960b57cec5SDimitry Andric 
44970b57cec5SDimitry Andric /**
44980b57cec5SDimitry Andric  * Determine if a C++ constructor is the default constructor.
44990b57cec5SDimitry Andric  */
45000b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_CXXConstructor_isDefaultConstructor(CXCursor C);
45010b57cec5SDimitry Andric 
45020b57cec5SDimitry Andric /**
45030b57cec5SDimitry Andric  * Determine if a C++ constructor is a move constructor.
45040b57cec5SDimitry Andric  */
45050b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_CXXConstructor_isMoveConstructor(CXCursor C);
45060b57cec5SDimitry Andric 
45070b57cec5SDimitry Andric /**
45080b57cec5SDimitry Andric  * Determine if a C++ field is declared 'mutable'.
45090b57cec5SDimitry Andric  */
45100b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_CXXField_isMutable(CXCursor C);
45110b57cec5SDimitry Andric 
45120b57cec5SDimitry Andric /**
45130b57cec5SDimitry Andric  * Determine if a C++ method is declared '= default'.
45140b57cec5SDimitry Andric  */
45150b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_CXXMethod_isDefaulted(CXCursor C);
45160b57cec5SDimitry Andric 
45170b57cec5SDimitry Andric /**
4518bdd1243dSDimitry Andric  * Determine if a C++ method is declared '= delete'.
4519bdd1243dSDimitry Andric  */
4520bdd1243dSDimitry Andric CINDEX_LINKAGE unsigned clang_CXXMethod_isDeleted(CXCursor C);
4521bdd1243dSDimitry Andric 
4522bdd1243dSDimitry Andric /**
45230b57cec5SDimitry Andric  * Determine if a C++ member function or member function template is
45240b57cec5SDimitry Andric  * pure virtual.
45250b57cec5SDimitry Andric  */
45260b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_CXXMethod_isPureVirtual(CXCursor C);
45270b57cec5SDimitry Andric 
45280b57cec5SDimitry Andric /**
45290b57cec5SDimitry Andric  * Determine if a C++ member function or member function template is
45300b57cec5SDimitry Andric  * declared 'static'.
45310b57cec5SDimitry Andric  */
45320b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C);
45330b57cec5SDimitry Andric 
45340b57cec5SDimitry Andric /**
45350b57cec5SDimitry Andric  * Determine if a C++ member function or member function template is
45360b57cec5SDimitry Andric  * explicitly declared 'virtual' or if it overrides a virtual method from
45370b57cec5SDimitry Andric  * one of the base classes.
45380b57cec5SDimitry Andric  */
45390b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual(CXCursor C);
45400b57cec5SDimitry Andric 
45410b57cec5SDimitry Andric /**
4542bdd1243dSDimitry Andric  * Determine if a C++ member function is a copy-assignment operator,
4543bdd1243dSDimitry Andric  * returning 1 if such is the case and 0 otherwise.
4544bdd1243dSDimitry Andric  *
4545bdd1243dSDimitry Andric  * > A copy-assignment operator `X::operator=` is a non-static,
4546bdd1243dSDimitry Andric  * > non-template member function of _class_ `X` with exactly one
4547bdd1243dSDimitry Andric  * > parameter of type `X`, `X&`, `const X&`, `volatile X&` or `const
4548bdd1243dSDimitry Andric  * > volatile X&`.
4549bdd1243dSDimitry Andric  *
4550bdd1243dSDimitry Andric  * That is, for example, the `operator=` in:
4551bdd1243dSDimitry Andric  *
4552bdd1243dSDimitry Andric  *    class Foo {
4553bdd1243dSDimitry Andric  *        bool operator=(const volatile Foo&);
4554bdd1243dSDimitry Andric  *    };
4555bdd1243dSDimitry Andric  *
4556bdd1243dSDimitry Andric  * Is a copy-assignment operator, while the `operator=` in:
4557bdd1243dSDimitry Andric  *
4558bdd1243dSDimitry Andric  *    class Bar {
4559bdd1243dSDimitry Andric  *        bool operator=(const int&);
4560bdd1243dSDimitry Andric  *    };
4561bdd1243dSDimitry Andric  *
4562bdd1243dSDimitry Andric  * Is not.
4563bdd1243dSDimitry Andric  */
4564bdd1243dSDimitry Andric CINDEX_LINKAGE unsigned clang_CXXMethod_isCopyAssignmentOperator(CXCursor C);
4565bdd1243dSDimitry Andric 
4566bdd1243dSDimitry Andric /**
4567bdd1243dSDimitry Andric  * Determine if a C++ member function is a move-assignment operator,
4568bdd1243dSDimitry Andric  * returning 1 if such is the case and 0 otherwise.
4569bdd1243dSDimitry Andric  *
4570bdd1243dSDimitry Andric  * > A move-assignment operator `X::operator=` is a non-static,
4571bdd1243dSDimitry Andric  * > non-template member function of _class_ `X` with exactly one
4572bdd1243dSDimitry Andric  * > parameter of type `X&&`, `const X&&`, `volatile X&&` or `const
4573bdd1243dSDimitry Andric  * > volatile X&&`.
4574bdd1243dSDimitry Andric  *
4575bdd1243dSDimitry Andric  * That is, for example, the `operator=` in:
4576bdd1243dSDimitry Andric  *
4577bdd1243dSDimitry Andric  *    class Foo {
4578bdd1243dSDimitry Andric  *        bool operator=(const volatile Foo&&);
4579bdd1243dSDimitry Andric  *    };
4580bdd1243dSDimitry Andric  *
4581bdd1243dSDimitry Andric  * Is a move-assignment operator, while the `operator=` in:
4582bdd1243dSDimitry Andric  *
4583bdd1243dSDimitry Andric  *    class Bar {
4584bdd1243dSDimitry Andric  *        bool operator=(const int&&);
4585bdd1243dSDimitry Andric  *    };
4586bdd1243dSDimitry Andric  *
4587bdd1243dSDimitry Andric  * Is not.
4588bdd1243dSDimitry Andric  */
4589bdd1243dSDimitry Andric CINDEX_LINKAGE unsigned clang_CXXMethod_isMoveAssignmentOperator(CXCursor C);
4590bdd1243dSDimitry Andric 
4591bdd1243dSDimitry Andric /**
459206c3fb27SDimitry Andric  * Determines if a C++ constructor or conversion function was declared
459306c3fb27SDimitry Andric  * explicit, returning 1 if such is the case and 0 otherwise.
459406c3fb27SDimitry Andric  *
459506c3fb27SDimitry Andric  * Constructors or conversion functions are declared explicit through
459606c3fb27SDimitry Andric  * the use of the explicit specifier.
459706c3fb27SDimitry Andric  *
459806c3fb27SDimitry Andric  * For example, the following constructor and conversion function are
459906c3fb27SDimitry Andric  * not explicit as they lack the explicit specifier:
460006c3fb27SDimitry Andric  *
460106c3fb27SDimitry Andric  *     class Foo {
460206c3fb27SDimitry Andric  *         Foo();
460306c3fb27SDimitry Andric  *         operator int();
460406c3fb27SDimitry Andric  *     };
460506c3fb27SDimitry Andric  *
460606c3fb27SDimitry Andric  * While the following constructor and conversion function are
460706c3fb27SDimitry Andric  * explicit as they are declared with the explicit specifier.
460806c3fb27SDimitry Andric  *
460906c3fb27SDimitry Andric  *     class Foo {
461006c3fb27SDimitry Andric  *         explicit Foo();
461106c3fb27SDimitry Andric  *         explicit operator int();
461206c3fb27SDimitry Andric  *     };
461306c3fb27SDimitry Andric  *
461406c3fb27SDimitry Andric  * This function will return 0 when given a cursor pointing to one of
461506c3fb27SDimitry Andric  * the former declarations and it will return 1 for a cursor pointing
461606c3fb27SDimitry Andric  * to the latter declarations.
461706c3fb27SDimitry Andric  *
461806c3fb27SDimitry Andric  * The explicit specifier allows the user to specify a
461906c3fb27SDimitry Andric  * conditional compile-time expression whose value decides
462006c3fb27SDimitry Andric  * whether the marked element is explicit or not.
462106c3fb27SDimitry Andric  *
462206c3fb27SDimitry Andric  * For example:
462306c3fb27SDimitry Andric  *
462406c3fb27SDimitry Andric  *     constexpr bool foo(int i) { return i % 2 == 0; }
462506c3fb27SDimitry Andric  *
462606c3fb27SDimitry Andric  *     class Foo {
462706c3fb27SDimitry Andric  *          explicit(foo(1)) Foo();
462806c3fb27SDimitry Andric  *          explicit(foo(2)) operator int();
462906c3fb27SDimitry Andric  *     }
463006c3fb27SDimitry Andric  *
463106c3fb27SDimitry Andric  * This function will return 0 for the constructor and 1 for
463206c3fb27SDimitry Andric  * the conversion function.
463306c3fb27SDimitry Andric  */
463406c3fb27SDimitry Andric CINDEX_LINKAGE unsigned clang_CXXMethod_isExplicit(CXCursor C);
463506c3fb27SDimitry Andric 
463606c3fb27SDimitry Andric /**
46370b57cec5SDimitry Andric  * Determine if a C++ record is abstract, i.e. whether a class or struct
46380b57cec5SDimitry Andric  * has a pure virtual member function.
46390b57cec5SDimitry Andric  */
46400b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_CXXRecord_isAbstract(CXCursor C);
46410b57cec5SDimitry Andric 
46420b57cec5SDimitry Andric /**
46430b57cec5SDimitry Andric  * Determine if an enum declaration refers to a scoped enum.
46440b57cec5SDimitry Andric  */
46450b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_EnumDecl_isScoped(CXCursor C);
46460b57cec5SDimitry Andric 
46470b57cec5SDimitry Andric /**
46480b57cec5SDimitry Andric  * Determine if a C++ member function or member function template is
46490b57cec5SDimitry Andric  * declared 'const'.
46500b57cec5SDimitry Andric  */
46510b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_CXXMethod_isConst(CXCursor C);
46520b57cec5SDimitry Andric 
46530b57cec5SDimitry Andric /**
46540b57cec5SDimitry Andric  * Given a cursor that represents a template, determine
46550b57cec5SDimitry Andric  * the cursor kind of the specializations would be generated by instantiating
46560b57cec5SDimitry Andric  * the template.
46570b57cec5SDimitry Andric  *
46580b57cec5SDimitry Andric  * This routine can be used to determine what flavor of function template,
46590b57cec5SDimitry Andric  * class template, or class template partial specialization is stored in the
46600b57cec5SDimitry Andric  * cursor. For example, it can describe whether a class template cursor is
46610b57cec5SDimitry Andric  * declared with "struct", "class" or "union".
46620b57cec5SDimitry Andric  *
46630b57cec5SDimitry Andric  * \param C The cursor to query. This cursor should represent a template
46640b57cec5SDimitry Andric  * declaration.
46650b57cec5SDimitry Andric  *
46660b57cec5SDimitry Andric  * \returns The cursor kind of the specializations that would be generated
46670b57cec5SDimitry Andric  * by instantiating the template \p C. If \p C is not a template, returns
46680b57cec5SDimitry Andric  * \c CXCursor_NoDeclFound.
46690b57cec5SDimitry Andric  */
46700b57cec5SDimitry Andric CINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind(CXCursor C);
46710b57cec5SDimitry Andric 
46720b57cec5SDimitry Andric /**
46730b57cec5SDimitry Andric  * Given a cursor that may represent a specialization or instantiation
46740b57cec5SDimitry Andric  * of a template, retrieve the cursor that represents the template that it
46750b57cec5SDimitry Andric  * specializes or from which it was instantiated.
46760b57cec5SDimitry Andric  *
46770b57cec5SDimitry Andric  * This routine determines the template involved both for explicit
46780b57cec5SDimitry Andric  * specializations of templates and for implicit instantiations of the template,
46790b57cec5SDimitry Andric  * both of which are referred to as "specializations". For a class template
46800b57cec5SDimitry Andric  * specialization (e.g., \c std::vector<bool>), this routine will return
46810b57cec5SDimitry Andric  * either the primary template (\c std::vector) or, if the specialization was
46820b57cec5SDimitry Andric  * instantiated from a class template partial specialization, the class template
46830b57cec5SDimitry Andric  * partial specialization. For a class template partial specialization and a
46840b57cec5SDimitry Andric  * function template specialization (including instantiations), this
46850b57cec5SDimitry Andric  * this routine will return the specialized template.
46860b57cec5SDimitry Andric  *
46870b57cec5SDimitry Andric  * For members of a class template (e.g., member functions, member classes, or
46880b57cec5SDimitry Andric  * static data members), returns the specialized or instantiated member.
46890b57cec5SDimitry Andric  * Although not strictly "templates" in the C++ language, members of class
46900b57cec5SDimitry Andric  * templates have the same notions of specializations and instantiations that
46910b57cec5SDimitry Andric  * templates do, so this routine treats them similarly.
46920b57cec5SDimitry Andric  *
46930b57cec5SDimitry Andric  * \param C A cursor that may be a specialization of a template or a member
46940b57cec5SDimitry Andric  * of a template.
46950b57cec5SDimitry Andric  *
46960b57cec5SDimitry Andric  * \returns If the given cursor is a specialization or instantiation of a
46970b57cec5SDimitry Andric  * template or a member thereof, the template or member that it specializes or
46980b57cec5SDimitry Andric  * from which it was instantiated. Otherwise, returns a NULL cursor.
46990b57cec5SDimitry Andric  */
47000b57cec5SDimitry Andric CINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate(CXCursor C);
47010b57cec5SDimitry Andric 
47020b57cec5SDimitry Andric /**
47030b57cec5SDimitry Andric  * Given a cursor that references something else, return the source range
47040b57cec5SDimitry Andric  * covering that reference.
47050b57cec5SDimitry Andric  *
47060b57cec5SDimitry Andric  * \param C A cursor pointing to a member reference, a declaration reference, or
47070b57cec5SDimitry Andric  * an operator call.
47080b57cec5SDimitry Andric  * \param NameFlags A bitset with three independent flags:
47090b57cec5SDimitry Andric  * CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and
47100b57cec5SDimitry Andric  * CXNameRange_WantSinglePiece.
47110b57cec5SDimitry Andric  * \param PieceIndex For contiguous names or when passing the flag
47120b57cec5SDimitry Andric  * CXNameRange_WantSinglePiece, only one piece with index 0 is
47130b57cec5SDimitry Andric  * available. When the CXNameRange_WantSinglePiece flag is not passed for a
47140b57cec5SDimitry Andric  * non-contiguous names, this index can be used to retrieve the individual
47150b57cec5SDimitry Andric  * pieces of the name. See also CXNameRange_WantSinglePiece.
47160b57cec5SDimitry Andric  *
47170b57cec5SDimitry Andric  * \returns The piece of the name pointed to by the given cursor. If there is no
47180b57cec5SDimitry Andric  * name, or if the PieceIndex is out-of-range, a null-cursor will be returned.
47190b57cec5SDimitry Andric  */
47205ffd83dbSDimitry Andric CINDEX_LINKAGE CXSourceRange clang_getCursorReferenceNameRange(
47215ffd83dbSDimitry Andric     CXCursor C, unsigned NameFlags, unsigned PieceIndex);
47220b57cec5SDimitry Andric 
47230b57cec5SDimitry Andric enum CXNameRefFlags {
47240b57cec5SDimitry Andric   /**
47250b57cec5SDimitry Andric    * Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the
47260b57cec5SDimitry Andric    * range.
47270b57cec5SDimitry Andric    */
47280b57cec5SDimitry Andric   CXNameRange_WantQualifier = 0x1,
47290b57cec5SDimitry Andric 
47300b57cec5SDimitry Andric   /**
47310b57cec5SDimitry Andric    * Include the explicit template arguments, e.g. \<int> in x.f<int>,
47320b57cec5SDimitry Andric    * in the range.
47330b57cec5SDimitry Andric    */
47340b57cec5SDimitry Andric   CXNameRange_WantTemplateArgs = 0x2,
47350b57cec5SDimitry Andric 
47360b57cec5SDimitry Andric   /**
47370b57cec5SDimitry Andric    * If the name is non-contiguous, return the full spanning range.
47380b57cec5SDimitry Andric    *
47390b57cec5SDimitry Andric    * Non-contiguous names occur in Objective-C when a selector with two or more
47400b57cec5SDimitry Andric    * parameters is used, or in C++ when using an operator:
47410b57cec5SDimitry Andric    * \code
47420b57cec5SDimitry Andric    * [object doSomething:here withValue:there]; // Objective-C
47430b57cec5SDimitry Andric    * return some_vector[1]; // C++
47440b57cec5SDimitry Andric    * \endcode
47450b57cec5SDimitry Andric    */
47460b57cec5SDimitry Andric   CXNameRange_WantSinglePiece = 0x4
47470b57cec5SDimitry Andric };
47480b57cec5SDimitry Andric 
47490b57cec5SDimitry Andric /**
47500b57cec5SDimitry Andric  * @}
47510b57cec5SDimitry Andric  */
47520b57cec5SDimitry Andric 
47530b57cec5SDimitry Andric /**
47540b57cec5SDimitry Andric  * \defgroup CINDEX_LEX Token extraction and manipulation
47550b57cec5SDimitry Andric  *
47560b57cec5SDimitry Andric  * The routines in this group provide access to the tokens within a
47570b57cec5SDimitry Andric  * translation unit, along with a semantic mapping of those tokens to
47580b57cec5SDimitry Andric  * their corresponding cursors.
47590b57cec5SDimitry Andric  *
47600b57cec5SDimitry Andric  * @{
47610b57cec5SDimitry Andric  */
47620b57cec5SDimitry Andric 
47630b57cec5SDimitry Andric /**
47640b57cec5SDimitry Andric  * Describes a kind of token.
47650b57cec5SDimitry Andric  */
47660b57cec5SDimitry Andric typedef enum CXTokenKind {
47670b57cec5SDimitry Andric   /**
47680b57cec5SDimitry Andric    * A token that contains some kind of punctuation.
47690b57cec5SDimitry Andric    */
47700b57cec5SDimitry Andric   CXToken_Punctuation,
47710b57cec5SDimitry Andric 
47720b57cec5SDimitry Andric   /**
47730b57cec5SDimitry Andric    * A language keyword.
47740b57cec5SDimitry Andric    */
47750b57cec5SDimitry Andric   CXToken_Keyword,
47760b57cec5SDimitry Andric 
47770b57cec5SDimitry Andric   /**
47780b57cec5SDimitry Andric    * An identifier (that is not a keyword).
47790b57cec5SDimitry Andric    */
47800b57cec5SDimitry Andric   CXToken_Identifier,
47810b57cec5SDimitry Andric 
47820b57cec5SDimitry Andric   /**
47830b57cec5SDimitry Andric    * A numeric, string, or character literal.
47840b57cec5SDimitry Andric    */
47850b57cec5SDimitry Andric   CXToken_Literal,
47860b57cec5SDimitry Andric 
47870b57cec5SDimitry Andric   /**
47880b57cec5SDimitry Andric    * A comment.
47890b57cec5SDimitry Andric    */
47900b57cec5SDimitry Andric   CXToken_Comment
47910b57cec5SDimitry Andric } CXTokenKind;
47920b57cec5SDimitry Andric 
47930b57cec5SDimitry Andric /**
47940b57cec5SDimitry Andric  * Describes a single preprocessing token.
47950b57cec5SDimitry Andric  */
47960b57cec5SDimitry Andric typedef struct {
47970b57cec5SDimitry Andric   unsigned int_data[4];
47980b57cec5SDimitry Andric   void *ptr_data;
47990b57cec5SDimitry Andric } CXToken;
48000b57cec5SDimitry Andric 
48010b57cec5SDimitry Andric /**
48020b57cec5SDimitry Andric  * Get the raw lexical token starting with the given location.
48030b57cec5SDimitry Andric  *
48040b57cec5SDimitry Andric  * \param TU the translation unit whose text is being tokenized.
48050b57cec5SDimitry Andric  *
48060b57cec5SDimitry Andric  * \param Location the source location with which the token starts.
48070b57cec5SDimitry Andric  *
48080b57cec5SDimitry Andric  * \returns The token starting with the given location or NULL if no such token
48090b57cec5SDimitry Andric  * exist. The returned pointer must be freed with clang_disposeTokens before the
48100b57cec5SDimitry Andric  * translation unit is destroyed.
48110b57cec5SDimitry Andric  */
48120b57cec5SDimitry Andric CINDEX_LINKAGE CXToken *clang_getToken(CXTranslationUnit TU,
48130b57cec5SDimitry Andric                                        CXSourceLocation Location);
48140b57cec5SDimitry Andric 
48150b57cec5SDimitry Andric /**
48160b57cec5SDimitry Andric  * Determine the kind of the given token.
48170b57cec5SDimitry Andric  */
48180b57cec5SDimitry Andric CINDEX_LINKAGE CXTokenKind clang_getTokenKind(CXToken);
48190b57cec5SDimitry Andric 
48200b57cec5SDimitry Andric /**
48210b57cec5SDimitry Andric  * Determine the spelling of the given token.
48220b57cec5SDimitry Andric  *
48230b57cec5SDimitry Andric  * The spelling of a token is the textual representation of that token, e.g.,
48240b57cec5SDimitry Andric  * the text of an identifier or keyword.
48250b57cec5SDimitry Andric  */
48260b57cec5SDimitry Andric CINDEX_LINKAGE CXString clang_getTokenSpelling(CXTranslationUnit, CXToken);
48270b57cec5SDimitry Andric 
48280b57cec5SDimitry Andric /**
48290b57cec5SDimitry Andric  * Retrieve the source location of the given token.
48300b57cec5SDimitry Andric  */
48310b57cec5SDimitry Andric CINDEX_LINKAGE CXSourceLocation clang_getTokenLocation(CXTranslationUnit,
48320b57cec5SDimitry Andric                                                        CXToken);
48330b57cec5SDimitry Andric 
48340b57cec5SDimitry Andric /**
48350b57cec5SDimitry Andric  * Retrieve a source range that covers the given token.
48360b57cec5SDimitry Andric  */
48370b57cec5SDimitry Andric CINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken);
48380b57cec5SDimitry Andric 
48390b57cec5SDimitry Andric /**
48400b57cec5SDimitry Andric  * Tokenize the source code described by the given range into raw
48410b57cec5SDimitry Andric  * lexical tokens.
48420b57cec5SDimitry Andric  *
48430b57cec5SDimitry Andric  * \param TU the translation unit whose text is being tokenized.
48440b57cec5SDimitry Andric  *
48450b57cec5SDimitry Andric  * \param Range the source range in which text should be tokenized. All of the
48460b57cec5SDimitry Andric  * tokens produced by tokenization will fall within this source range,
48470b57cec5SDimitry Andric  *
48480b57cec5SDimitry Andric  * \param Tokens this pointer will be set to point to the array of tokens
48490b57cec5SDimitry Andric  * that occur within the given source range. The returned pointer must be
48500b57cec5SDimitry Andric  * freed with clang_disposeTokens() before the translation unit is destroyed.
48510b57cec5SDimitry Andric  *
48520b57cec5SDimitry Andric  * \param NumTokens will be set to the number of tokens in the \c *Tokens
48530b57cec5SDimitry Andric  * array.
48540b57cec5SDimitry Andric  *
48550b57cec5SDimitry Andric  */
48560b57cec5SDimitry Andric CINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
48570b57cec5SDimitry Andric                                    CXToken **Tokens, unsigned *NumTokens);
48580b57cec5SDimitry Andric 
48590b57cec5SDimitry Andric /**
48600b57cec5SDimitry Andric  * Annotate the given set of tokens by providing cursors for each token
48610b57cec5SDimitry Andric  * that can be mapped to a specific entity within the abstract syntax tree.
48620b57cec5SDimitry Andric  *
48630b57cec5SDimitry Andric  * This token-annotation routine is equivalent to invoking
48640b57cec5SDimitry Andric  * clang_getCursor() for the source locations of each of the
48650b57cec5SDimitry Andric  * tokens. The cursors provided are filtered, so that only those
48660b57cec5SDimitry Andric  * cursors that have a direct correspondence to the token are
48670b57cec5SDimitry Andric  * accepted. For example, given a function call \c f(x),
48680b57cec5SDimitry Andric  * clang_getCursor() would provide the following cursors:
48690b57cec5SDimitry Andric  *
48700b57cec5SDimitry Andric  *   * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'.
48710b57cec5SDimitry Andric  *   * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'.
48720b57cec5SDimitry Andric  *   * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'.
48730b57cec5SDimitry Andric  *
48740b57cec5SDimitry Andric  * Only the first and last of these cursors will occur within the
48750b57cec5SDimitry Andric  * annotate, since the tokens "f" and "x' directly refer to a function
48760b57cec5SDimitry Andric  * and a variable, respectively, but the parentheses are just a small
48770b57cec5SDimitry Andric  * part of the full syntax of the function call expression, which is
48780b57cec5SDimitry Andric  * not provided as an annotation.
48790b57cec5SDimitry Andric  *
48800b57cec5SDimitry Andric  * \param TU the translation unit that owns the given tokens.
48810b57cec5SDimitry Andric  *
48820b57cec5SDimitry Andric  * \param Tokens the set of tokens to annotate.
48830b57cec5SDimitry Andric  *
48840b57cec5SDimitry Andric  * \param NumTokens the number of tokens in \p Tokens.
48850b57cec5SDimitry Andric  *
48860b57cec5SDimitry Andric  * \param Cursors an array of \p NumTokens cursors, whose contents will be
48870b57cec5SDimitry Andric  * replaced with the cursors corresponding to each token.
48880b57cec5SDimitry Andric  */
48895ffd83dbSDimitry Andric CINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU, CXToken *Tokens,
48905ffd83dbSDimitry Andric                                          unsigned NumTokens, CXCursor *Cursors);
48910b57cec5SDimitry Andric 
48920b57cec5SDimitry Andric /**
48930b57cec5SDimitry Andric  * Free the given set of tokens.
48940b57cec5SDimitry Andric  */
48955ffd83dbSDimitry Andric CINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU, CXToken *Tokens,
48965ffd83dbSDimitry Andric                                         unsigned NumTokens);
48970b57cec5SDimitry Andric 
48980b57cec5SDimitry Andric /**
48990b57cec5SDimitry Andric  * @}
49000b57cec5SDimitry Andric  */
49010b57cec5SDimitry Andric 
49020b57cec5SDimitry Andric /**
49030b57cec5SDimitry Andric  * \defgroup CINDEX_DEBUG Debugging facilities
49040b57cec5SDimitry Andric  *
49050b57cec5SDimitry Andric  * These routines are used for testing and debugging, only, and should not
49060b57cec5SDimitry Andric  * be relied upon.
49070b57cec5SDimitry Andric  *
49080b57cec5SDimitry Andric  * @{
49090b57cec5SDimitry Andric  */
49100b57cec5SDimitry Andric 
49110b57cec5SDimitry Andric /* for debug/testing */
49120b57cec5SDimitry Andric CINDEX_LINKAGE CXString clang_getCursorKindSpelling(enum CXCursorKind Kind);
49135ffd83dbSDimitry Andric CINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(
49145ffd83dbSDimitry Andric     CXCursor, const char **startBuf, const char **endBuf, unsigned *startLine,
49155ffd83dbSDimitry Andric     unsigned *startColumn, unsigned *endLine, unsigned *endColumn);
49160b57cec5SDimitry Andric CINDEX_LINKAGE void clang_enableStackTraces(void);
49170b57cec5SDimitry Andric CINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void *), void *user_data,
49180b57cec5SDimitry Andric                                           unsigned stack_size);
49190b57cec5SDimitry Andric 
49200b57cec5SDimitry Andric /**
49210b57cec5SDimitry Andric  * @}
49220b57cec5SDimitry Andric  */
49230b57cec5SDimitry Andric 
49240b57cec5SDimitry Andric /**
49250b57cec5SDimitry Andric  * \defgroup CINDEX_CODE_COMPLET Code completion
49260b57cec5SDimitry Andric  *
49270b57cec5SDimitry Andric  * Code completion involves taking an (incomplete) source file, along with
49280b57cec5SDimitry Andric  * knowledge of where the user is actively editing that file, and suggesting
49290b57cec5SDimitry Andric  * syntactically- and semantically-valid constructs that the user might want to
49300b57cec5SDimitry Andric  * use at that particular point in the source code. These data structures and
49310b57cec5SDimitry Andric  * routines provide support for code completion.
49320b57cec5SDimitry Andric  *
49330b57cec5SDimitry Andric  * @{
49340b57cec5SDimitry Andric  */
49350b57cec5SDimitry Andric 
49360b57cec5SDimitry Andric /**
49370b57cec5SDimitry Andric  * A semantic string that describes a code-completion result.
49380b57cec5SDimitry Andric  *
49390b57cec5SDimitry Andric  * A semantic string that describes the formatting of a code-completion
49400b57cec5SDimitry Andric  * result as a single "template" of text that should be inserted into the
49410b57cec5SDimitry Andric  * source buffer when a particular code-completion result is selected.
49420b57cec5SDimitry Andric  * Each semantic string is made up of some number of "chunks", each of which
49430b57cec5SDimitry Andric  * contains some text along with a description of what that text means, e.g.,
49440b57cec5SDimitry Andric  * the name of the entity being referenced, whether the text chunk is part of
49450b57cec5SDimitry Andric  * the template, or whether it is a "placeholder" that the user should replace
49460b57cec5SDimitry Andric  * with actual code,of a specific kind. See \c CXCompletionChunkKind for a
49470b57cec5SDimitry Andric  * description of the different kinds of chunks.
49480b57cec5SDimitry Andric  */
49490b57cec5SDimitry Andric typedef void *CXCompletionString;
49500b57cec5SDimitry Andric 
49510b57cec5SDimitry Andric /**
49520b57cec5SDimitry Andric  * A single result of code completion.
49530b57cec5SDimitry Andric  */
49540b57cec5SDimitry Andric typedef struct {
49550b57cec5SDimitry Andric   /**
49560b57cec5SDimitry Andric    * The kind of entity that this completion refers to.
49570b57cec5SDimitry Andric    *
49580b57cec5SDimitry Andric    * The cursor kind will be a macro, keyword, or a declaration (one of the
49590b57cec5SDimitry Andric    * *Decl cursor kinds), describing the entity that the completion is
49600b57cec5SDimitry Andric    * referring to.
49610b57cec5SDimitry Andric    *
49620b57cec5SDimitry Andric    * \todo In the future, we would like to provide a full cursor, to allow
49630b57cec5SDimitry Andric    * the client to extract additional information from declaration.
49640b57cec5SDimitry Andric    */
49650b57cec5SDimitry Andric   enum CXCursorKind CursorKind;
49660b57cec5SDimitry Andric 
49670b57cec5SDimitry Andric   /**
49680b57cec5SDimitry Andric    * The code-completion string that describes how to insert this
49690b57cec5SDimitry Andric    * code-completion result into the editing buffer.
49700b57cec5SDimitry Andric    */
49710b57cec5SDimitry Andric   CXCompletionString CompletionString;
49720b57cec5SDimitry Andric } CXCompletionResult;
49730b57cec5SDimitry Andric 
49740b57cec5SDimitry Andric /**
49750b57cec5SDimitry Andric  * Describes a single piece of text within a code-completion string.
49760b57cec5SDimitry Andric  *
49770b57cec5SDimitry Andric  * Each "chunk" within a code-completion string (\c CXCompletionString) is
49780b57cec5SDimitry Andric  * either a piece of text with a specific "kind" that describes how that text
49790b57cec5SDimitry Andric  * should be interpreted by the client or is another completion string.
49800b57cec5SDimitry Andric  */
49810b57cec5SDimitry Andric enum CXCompletionChunkKind {
49820b57cec5SDimitry Andric   /**
49830b57cec5SDimitry Andric    * A code-completion string that describes "optional" text that
49840b57cec5SDimitry Andric    * could be a part of the template (but is not required).
49850b57cec5SDimitry Andric    *
49860b57cec5SDimitry Andric    * The Optional chunk is the only kind of chunk that has a code-completion
49870b57cec5SDimitry Andric    * string for its representation, which is accessible via
49880b57cec5SDimitry Andric    * \c clang_getCompletionChunkCompletionString(). The code-completion string
49890b57cec5SDimitry Andric    * describes an additional part of the template that is completely optional.
49900b57cec5SDimitry Andric    * For example, optional chunks can be used to describe the placeholders for
49910b57cec5SDimitry Andric    * arguments that match up with defaulted function parameters, e.g. given:
49920b57cec5SDimitry Andric    *
49930b57cec5SDimitry Andric    * \code
49940b57cec5SDimitry Andric    * void f(int x, float y = 3.14, double z = 2.71828);
49950b57cec5SDimitry Andric    * \endcode
49960b57cec5SDimitry Andric    *
49970b57cec5SDimitry Andric    * The code-completion string for this function would contain:
49980b57cec5SDimitry Andric    *   - a TypedText chunk for "f".
49990b57cec5SDimitry Andric    *   - a LeftParen chunk for "(".
50000b57cec5SDimitry Andric    *   - a Placeholder chunk for "int x"
50010b57cec5SDimitry Andric    *   - an Optional chunk containing the remaining defaulted arguments, e.g.,
50020b57cec5SDimitry Andric    *       - a Comma chunk for ","
50030b57cec5SDimitry Andric    *       - a Placeholder chunk for "float y"
50040b57cec5SDimitry Andric    *       - an Optional chunk containing the last defaulted argument:
50050b57cec5SDimitry Andric    *           - a Comma chunk for ","
50060b57cec5SDimitry Andric    *           - a Placeholder chunk for "double z"
50070b57cec5SDimitry Andric    *   - a RightParen chunk for ")"
50080b57cec5SDimitry Andric    *
50090b57cec5SDimitry Andric    * There are many ways to handle Optional chunks. Two simple approaches are:
50100b57cec5SDimitry Andric    *   - Completely ignore optional chunks, in which case the template for the
50110b57cec5SDimitry Andric    *     function "f" would only include the first parameter ("int x").
50120b57cec5SDimitry Andric    *   - Fully expand all optional chunks, in which case the template for the
50130b57cec5SDimitry Andric    *     function "f" would have all of the parameters.
50140b57cec5SDimitry Andric    */
50150b57cec5SDimitry Andric   CXCompletionChunk_Optional,
50160b57cec5SDimitry Andric   /**
50170b57cec5SDimitry Andric    * Text that a user would be expected to type to get this
50180b57cec5SDimitry Andric    * code-completion result.
50190b57cec5SDimitry Andric    *
50200b57cec5SDimitry Andric    * There will be exactly one "typed text" chunk in a semantic string, which
50210b57cec5SDimitry Andric    * will typically provide the spelling of a keyword or the name of a
50220b57cec5SDimitry Andric    * declaration that could be used at the current code point. Clients are
50230b57cec5SDimitry Andric    * expected to filter the code-completion results based on the text in this
50240b57cec5SDimitry Andric    * chunk.
50250b57cec5SDimitry Andric    */
50260b57cec5SDimitry Andric   CXCompletionChunk_TypedText,
50270b57cec5SDimitry Andric   /**
50280b57cec5SDimitry Andric    * Text that should be inserted as part of a code-completion result.
50290b57cec5SDimitry Andric    *
50300b57cec5SDimitry Andric    * A "text" chunk represents text that is part of the template to be
50310b57cec5SDimitry Andric    * inserted into user code should this particular code-completion result
50320b57cec5SDimitry Andric    * be selected.
50330b57cec5SDimitry Andric    */
50340b57cec5SDimitry Andric   CXCompletionChunk_Text,
50350b57cec5SDimitry Andric   /**
50360b57cec5SDimitry Andric    * Placeholder text that should be replaced by the user.
50370b57cec5SDimitry Andric    *
50380b57cec5SDimitry Andric    * A "placeholder" chunk marks a place where the user should insert text
50390b57cec5SDimitry Andric    * into the code-completion template. For example, placeholders might mark
50400b57cec5SDimitry Andric    * the function parameters for a function declaration, to indicate that the
50410b57cec5SDimitry Andric    * user should provide arguments for each of those parameters. The actual
50420b57cec5SDimitry Andric    * text in a placeholder is a suggestion for the text to display before
50430b57cec5SDimitry Andric    * the user replaces the placeholder with real code.
50440b57cec5SDimitry Andric    */
50450b57cec5SDimitry Andric   CXCompletionChunk_Placeholder,
50460b57cec5SDimitry Andric   /**
50470b57cec5SDimitry Andric    * Informative text that should be displayed but never inserted as
50480b57cec5SDimitry Andric    * part of the template.
50490b57cec5SDimitry Andric    *
50500b57cec5SDimitry Andric    * An "informative" chunk contains annotations that can be displayed to
50510b57cec5SDimitry Andric    * help the user decide whether a particular code-completion result is the
50520b57cec5SDimitry Andric    * right option, but which is not part of the actual template to be inserted
50530b57cec5SDimitry Andric    * by code completion.
50540b57cec5SDimitry Andric    */
50550b57cec5SDimitry Andric   CXCompletionChunk_Informative,
50560b57cec5SDimitry Andric   /**
50570b57cec5SDimitry Andric    * Text that describes the current parameter when code-completion is
50580b57cec5SDimitry Andric    * referring to function call, message send, or template specialization.
50590b57cec5SDimitry Andric    *
50600b57cec5SDimitry Andric    * A "current parameter" chunk occurs when code-completion is providing
50610b57cec5SDimitry Andric    * information about a parameter corresponding to the argument at the
50620b57cec5SDimitry Andric    * code-completion point. For example, given a function
50630b57cec5SDimitry Andric    *
50640b57cec5SDimitry Andric    * \code
50650b57cec5SDimitry Andric    * int add(int x, int y);
50660b57cec5SDimitry Andric    * \endcode
50670b57cec5SDimitry Andric    *
50680b57cec5SDimitry Andric    * and the source code \c add(, where the code-completion point is after the
50690b57cec5SDimitry Andric    * "(", the code-completion string will contain a "current parameter" chunk
50700b57cec5SDimitry Andric    * for "int x", indicating that the current argument will initialize that
50710b57cec5SDimitry Andric    * parameter. After typing further, to \c add(17, (where the code-completion
50720b57cec5SDimitry Andric    * point is after the ","), the code-completion string will contain a
50730b57cec5SDimitry Andric    * "current parameter" chunk to "int y".
50740b57cec5SDimitry Andric    */
50750b57cec5SDimitry Andric   CXCompletionChunk_CurrentParameter,
50760b57cec5SDimitry Andric   /**
50770b57cec5SDimitry Andric    * A left parenthesis ('('), used to initiate a function call or
50780b57cec5SDimitry Andric    * signal the beginning of a function parameter list.
50790b57cec5SDimitry Andric    */
50800b57cec5SDimitry Andric   CXCompletionChunk_LeftParen,
50810b57cec5SDimitry Andric   /**
50820b57cec5SDimitry Andric    * A right parenthesis (')'), used to finish a function call or
50830b57cec5SDimitry Andric    * signal the end of a function parameter list.
50840b57cec5SDimitry Andric    */
50850b57cec5SDimitry Andric   CXCompletionChunk_RightParen,
50860b57cec5SDimitry Andric   /**
50870b57cec5SDimitry Andric    * A left bracket ('[').
50880b57cec5SDimitry Andric    */
50890b57cec5SDimitry Andric   CXCompletionChunk_LeftBracket,
50900b57cec5SDimitry Andric   /**
50910b57cec5SDimitry Andric    * A right bracket (']').
50920b57cec5SDimitry Andric    */
50930b57cec5SDimitry Andric   CXCompletionChunk_RightBracket,
50940b57cec5SDimitry Andric   /**
50950b57cec5SDimitry Andric    * A left brace ('{').
50960b57cec5SDimitry Andric    */
50970b57cec5SDimitry Andric   CXCompletionChunk_LeftBrace,
50980b57cec5SDimitry Andric   /**
50990b57cec5SDimitry Andric    * A right brace ('}').
51000b57cec5SDimitry Andric    */
51010b57cec5SDimitry Andric   CXCompletionChunk_RightBrace,
51020b57cec5SDimitry Andric   /**
51030b57cec5SDimitry Andric    * A left angle bracket ('<').
51040b57cec5SDimitry Andric    */
51050b57cec5SDimitry Andric   CXCompletionChunk_LeftAngle,
51060b57cec5SDimitry Andric   /**
51070b57cec5SDimitry Andric    * A right angle bracket ('>').
51080b57cec5SDimitry Andric    */
51090b57cec5SDimitry Andric   CXCompletionChunk_RightAngle,
51100b57cec5SDimitry Andric   /**
51110b57cec5SDimitry Andric    * A comma separator (',').
51120b57cec5SDimitry Andric    */
51130b57cec5SDimitry Andric   CXCompletionChunk_Comma,
51140b57cec5SDimitry Andric   /**
51150b57cec5SDimitry Andric    * Text that specifies the result type of a given result.
51160b57cec5SDimitry Andric    *
51170b57cec5SDimitry Andric    * This special kind of informative chunk is not meant to be inserted into
51180b57cec5SDimitry Andric    * the text buffer. Rather, it is meant to illustrate the type that an
51190b57cec5SDimitry Andric    * expression using the given completion string would have.
51200b57cec5SDimitry Andric    */
51210b57cec5SDimitry Andric   CXCompletionChunk_ResultType,
51220b57cec5SDimitry Andric   /**
51230b57cec5SDimitry Andric    * A colon (':').
51240b57cec5SDimitry Andric    */
51250b57cec5SDimitry Andric   CXCompletionChunk_Colon,
51260b57cec5SDimitry Andric   /**
51270b57cec5SDimitry Andric    * A semicolon (';').
51280b57cec5SDimitry Andric    */
51290b57cec5SDimitry Andric   CXCompletionChunk_SemiColon,
51300b57cec5SDimitry Andric   /**
51310b57cec5SDimitry Andric    * An '=' sign.
51320b57cec5SDimitry Andric    */
51330b57cec5SDimitry Andric   CXCompletionChunk_Equal,
51340b57cec5SDimitry Andric   /**
51350b57cec5SDimitry Andric    * Horizontal space (' ').
51360b57cec5SDimitry Andric    */
51370b57cec5SDimitry Andric   CXCompletionChunk_HorizontalSpace,
51380b57cec5SDimitry Andric   /**
51390b57cec5SDimitry Andric    * Vertical space ('\\n'), after which it is generally a good idea to
51400b57cec5SDimitry Andric    * perform indentation.
51410b57cec5SDimitry Andric    */
51420b57cec5SDimitry Andric   CXCompletionChunk_VerticalSpace
51430b57cec5SDimitry Andric };
51440b57cec5SDimitry Andric 
51450b57cec5SDimitry Andric /**
51460b57cec5SDimitry Andric  * Determine the kind of a particular chunk within a completion string.
51470b57cec5SDimitry Andric  *
51480b57cec5SDimitry Andric  * \param completion_string the completion string to query.
51490b57cec5SDimitry Andric  *
51500b57cec5SDimitry Andric  * \param chunk_number the 0-based index of the chunk in the completion string.
51510b57cec5SDimitry Andric  *
51520b57cec5SDimitry Andric  * \returns the kind of the chunk at the index \c chunk_number.
51530b57cec5SDimitry Andric  */
51540b57cec5SDimitry Andric CINDEX_LINKAGE enum CXCompletionChunkKind
51550b57cec5SDimitry Andric clang_getCompletionChunkKind(CXCompletionString completion_string,
51560b57cec5SDimitry Andric                              unsigned chunk_number);
51570b57cec5SDimitry Andric 
51580b57cec5SDimitry Andric /**
51590b57cec5SDimitry Andric  * Retrieve the text associated with a particular chunk within a
51600b57cec5SDimitry Andric  * completion string.
51610b57cec5SDimitry Andric  *
51620b57cec5SDimitry Andric  * \param completion_string the completion string to query.
51630b57cec5SDimitry Andric  *
51640b57cec5SDimitry Andric  * \param chunk_number the 0-based index of the chunk in the completion string.
51650b57cec5SDimitry Andric  *
51660b57cec5SDimitry Andric  * \returns the text associated with the chunk at index \c chunk_number.
51670b57cec5SDimitry Andric  */
51685ffd83dbSDimitry Andric CINDEX_LINKAGE CXString clang_getCompletionChunkText(
51695ffd83dbSDimitry Andric     CXCompletionString completion_string, unsigned chunk_number);
51700b57cec5SDimitry Andric 
51710b57cec5SDimitry Andric /**
51720b57cec5SDimitry Andric  * Retrieve the completion string associated with a particular chunk
51730b57cec5SDimitry Andric  * within a completion string.
51740b57cec5SDimitry Andric  *
51750b57cec5SDimitry Andric  * \param completion_string the completion string to query.
51760b57cec5SDimitry Andric  *
51770b57cec5SDimitry Andric  * \param chunk_number the 0-based index of the chunk in the completion string.
51780b57cec5SDimitry Andric  *
51790b57cec5SDimitry Andric  * \returns the completion string associated with the chunk at index
51800b57cec5SDimitry Andric  * \c chunk_number.
51810b57cec5SDimitry Andric  */
51825ffd83dbSDimitry Andric CINDEX_LINKAGE CXCompletionString clang_getCompletionChunkCompletionString(
51835ffd83dbSDimitry Andric     CXCompletionString completion_string, unsigned chunk_number);
51840b57cec5SDimitry Andric 
51850b57cec5SDimitry Andric /**
51860b57cec5SDimitry Andric  * Retrieve the number of chunks in the given code-completion string.
51870b57cec5SDimitry Andric  */
51880b57cec5SDimitry Andric CINDEX_LINKAGE unsigned
51890b57cec5SDimitry Andric clang_getNumCompletionChunks(CXCompletionString completion_string);
51900b57cec5SDimitry Andric 
51910b57cec5SDimitry Andric /**
51920b57cec5SDimitry Andric  * Determine the priority of this code completion.
51930b57cec5SDimitry Andric  *
51940b57cec5SDimitry Andric  * The priority of a code completion indicates how likely it is that this
51950b57cec5SDimitry Andric  * particular completion is the completion that the user will select. The
51960b57cec5SDimitry Andric  * priority is selected by various internal heuristics.
51970b57cec5SDimitry Andric  *
51980b57cec5SDimitry Andric  * \param completion_string The completion string to query.
51990b57cec5SDimitry Andric  *
52000b57cec5SDimitry Andric  * \returns The priority of this completion string. Smaller values indicate
52010b57cec5SDimitry Andric  * higher-priority (more likely) completions.
52020b57cec5SDimitry Andric  */
52030b57cec5SDimitry Andric CINDEX_LINKAGE unsigned
52040b57cec5SDimitry Andric clang_getCompletionPriority(CXCompletionString completion_string);
52050b57cec5SDimitry Andric 
52060b57cec5SDimitry Andric /**
52070b57cec5SDimitry Andric  * Determine the availability of the entity that this code-completion
52080b57cec5SDimitry Andric  * string refers to.
52090b57cec5SDimitry Andric  *
52100b57cec5SDimitry Andric  * \param completion_string The completion string to query.
52110b57cec5SDimitry Andric  *
52120b57cec5SDimitry Andric  * \returns The availability of the completion string.
52130b57cec5SDimitry Andric  */
52140b57cec5SDimitry Andric CINDEX_LINKAGE enum CXAvailabilityKind
52150b57cec5SDimitry Andric clang_getCompletionAvailability(CXCompletionString completion_string);
52160b57cec5SDimitry Andric 
52170b57cec5SDimitry Andric /**
52180b57cec5SDimitry Andric  * Retrieve the number of annotations associated with the given
52190b57cec5SDimitry Andric  * completion string.
52200b57cec5SDimitry Andric  *
52210b57cec5SDimitry Andric  * \param completion_string the completion string to query.
52220b57cec5SDimitry Andric  *
52230b57cec5SDimitry Andric  * \returns the number of annotations associated with the given completion
52240b57cec5SDimitry Andric  * string.
52250b57cec5SDimitry Andric  */
52260b57cec5SDimitry Andric CINDEX_LINKAGE unsigned
52270b57cec5SDimitry Andric clang_getCompletionNumAnnotations(CXCompletionString completion_string);
52280b57cec5SDimitry Andric 
52290b57cec5SDimitry Andric /**
52300b57cec5SDimitry Andric  * Retrieve the annotation associated with the given completion string.
52310b57cec5SDimitry Andric  *
52320b57cec5SDimitry Andric  * \param completion_string the completion string to query.
52330b57cec5SDimitry Andric  *
52340b57cec5SDimitry Andric  * \param annotation_number the 0-based index of the annotation of the
52350b57cec5SDimitry Andric  * completion string.
52360b57cec5SDimitry Andric  *
52370b57cec5SDimitry Andric  * \returns annotation string associated with the completion at index
52380b57cec5SDimitry Andric  * \c annotation_number, or a NULL string if that annotation is not available.
52390b57cec5SDimitry Andric  */
52405ffd83dbSDimitry Andric CINDEX_LINKAGE CXString clang_getCompletionAnnotation(
52415ffd83dbSDimitry Andric     CXCompletionString completion_string, unsigned annotation_number);
52420b57cec5SDimitry Andric 
52430b57cec5SDimitry Andric /**
52440b57cec5SDimitry Andric  * Retrieve the parent context of the given completion string.
52450b57cec5SDimitry Andric  *
52460b57cec5SDimitry Andric  * The parent context of a completion string is the semantic parent of
52470b57cec5SDimitry Andric  * the declaration (if any) that the code completion represents. For example,
52480b57cec5SDimitry Andric  * a code completion for an Objective-C method would have the method's class
52490b57cec5SDimitry Andric  * or protocol as its context.
52500b57cec5SDimitry Andric  *
52510b57cec5SDimitry Andric  * \param completion_string The code completion string whose parent is
52520b57cec5SDimitry Andric  * being queried.
52530b57cec5SDimitry Andric  *
52540b57cec5SDimitry Andric  * \param kind DEPRECATED: always set to CXCursor_NotImplemented if non-NULL.
52550b57cec5SDimitry Andric  *
52560b57cec5SDimitry Andric  * \returns The name of the completion parent, e.g., "NSObject" if
52570b57cec5SDimitry Andric  * the completion string represents a method in the NSObject class.
52580b57cec5SDimitry Andric  */
52595ffd83dbSDimitry Andric CINDEX_LINKAGE CXString clang_getCompletionParent(
52605ffd83dbSDimitry Andric     CXCompletionString completion_string, enum CXCursorKind *kind);
52610b57cec5SDimitry Andric 
52620b57cec5SDimitry Andric /**
52630b57cec5SDimitry Andric  * Retrieve the brief documentation comment attached to the declaration
52640b57cec5SDimitry Andric  * that corresponds to the given completion string.
52650b57cec5SDimitry Andric  */
52660b57cec5SDimitry Andric CINDEX_LINKAGE CXString
52670b57cec5SDimitry Andric clang_getCompletionBriefComment(CXCompletionString completion_string);
52680b57cec5SDimitry Andric 
52690b57cec5SDimitry Andric /**
52700b57cec5SDimitry Andric  * Retrieve a completion string for an arbitrary declaration or macro
52710b57cec5SDimitry Andric  * definition cursor.
52720b57cec5SDimitry Andric  *
52730b57cec5SDimitry Andric  * \param cursor The cursor to query.
52740b57cec5SDimitry Andric  *
52750b57cec5SDimitry Andric  * \returns A non-context-sensitive completion string for declaration and macro
52760b57cec5SDimitry Andric  * definition cursors, or NULL for other kinds of cursors.
52770b57cec5SDimitry Andric  */
52780b57cec5SDimitry Andric CINDEX_LINKAGE CXCompletionString
52790b57cec5SDimitry Andric clang_getCursorCompletionString(CXCursor cursor);
52800b57cec5SDimitry Andric 
52810b57cec5SDimitry Andric /**
52820b57cec5SDimitry Andric  * Contains the results of code-completion.
52830b57cec5SDimitry Andric  *
52840b57cec5SDimitry Andric  * This data structure contains the results of code completion, as
52850b57cec5SDimitry Andric  * produced by \c clang_codeCompleteAt(). Its contents must be freed by
52860b57cec5SDimitry Andric  * \c clang_disposeCodeCompleteResults.
52870b57cec5SDimitry Andric  */
52880b57cec5SDimitry Andric typedef struct {
52890b57cec5SDimitry Andric   /**
52900b57cec5SDimitry Andric    * The code-completion results.
52910b57cec5SDimitry Andric    */
52920b57cec5SDimitry Andric   CXCompletionResult *Results;
52930b57cec5SDimitry Andric 
52940b57cec5SDimitry Andric   /**
52950b57cec5SDimitry Andric    * The number of code-completion results stored in the
52960b57cec5SDimitry Andric    * \c Results array.
52970b57cec5SDimitry Andric    */
52980b57cec5SDimitry Andric   unsigned NumResults;
52990b57cec5SDimitry Andric } CXCodeCompleteResults;
53000b57cec5SDimitry Andric 
53010b57cec5SDimitry Andric /**
53020b57cec5SDimitry Andric  * Retrieve the number of fix-its for the given completion index.
53030b57cec5SDimitry Andric  *
53040b57cec5SDimitry Andric  * Calling this makes sense only if CXCodeComplete_IncludeCompletionsWithFixIts
53050b57cec5SDimitry Andric  * option was set.
53060b57cec5SDimitry Andric  *
53070b57cec5SDimitry Andric  * \param results The structure keeping all completion results
53080b57cec5SDimitry Andric  *
53090b57cec5SDimitry Andric  * \param completion_index The index of the completion
53100b57cec5SDimitry Andric  *
53110b57cec5SDimitry Andric  * \return The number of fix-its which must be applied before the completion at
53120b57cec5SDimitry Andric  * completion_index can be applied
53130b57cec5SDimitry Andric  */
53140b57cec5SDimitry Andric CINDEX_LINKAGE unsigned
53150b57cec5SDimitry Andric clang_getCompletionNumFixIts(CXCodeCompleteResults *results,
53160b57cec5SDimitry Andric                              unsigned completion_index);
53170b57cec5SDimitry Andric 
53180b57cec5SDimitry Andric /**
53190b57cec5SDimitry Andric  * Fix-its that *must* be applied before inserting the text for the
53200b57cec5SDimitry Andric  * corresponding completion.
53210b57cec5SDimitry Andric  *
53220b57cec5SDimitry Andric  * By default, clang_codeCompleteAt() only returns completions with empty
53230b57cec5SDimitry Andric  * fix-its. Extra completions with non-empty fix-its should be explicitly
53240b57cec5SDimitry Andric  * requested by setting CXCodeComplete_IncludeCompletionsWithFixIts.
53250b57cec5SDimitry Andric  *
53260b57cec5SDimitry Andric  * For the clients to be able to compute position of the cursor after applying
53270b57cec5SDimitry Andric  * fix-its, the following conditions are guaranteed to hold for
53280b57cec5SDimitry Andric  * replacement_range of the stored fix-its:
53290b57cec5SDimitry Andric  *  - Ranges in the fix-its are guaranteed to never contain the completion
53300b57cec5SDimitry Andric  *  point (or identifier under completion point, if any) inside them, except
53310b57cec5SDimitry Andric  *  at the start or at the end of the range.
53320b57cec5SDimitry Andric  *  - If a fix-it range starts or ends with completion point (or starts or
53330b57cec5SDimitry Andric  *  ends after the identifier under completion point), it will contain at
53340b57cec5SDimitry Andric  *  least one character. It allows to unambiguously recompute completion
53350b57cec5SDimitry Andric  *  point after applying the fix-it.
53360b57cec5SDimitry Andric  *
53370b57cec5SDimitry Andric  * The intuition is that provided fix-its change code around the identifier we
53380b57cec5SDimitry Andric  * complete, but are not allowed to touch the identifier itself or the
53390b57cec5SDimitry Andric  * completion point. One example of completions with corrections are the ones
53400b57cec5SDimitry Andric  * replacing '.' with '->' and vice versa:
53410b57cec5SDimitry Andric  *
53420b57cec5SDimitry Andric  * std::unique_ptr<std::vector<int>> vec_ptr;
53430b57cec5SDimitry Andric  * In 'vec_ptr.^', one of the completions is 'push_back', it requires
53440b57cec5SDimitry Andric  * replacing '.' with '->'.
53450b57cec5SDimitry Andric  * In 'vec_ptr->^', one of the completions is 'release', it requires
53460b57cec5SDimitry Andric  * replacing '->' with '.'.
53470b57cec5SDimitry Andric  *
53480b57cec5SDimitry Andric  * \param results The structure keeping all completion results
53490b57cec5SDimitry Andric  *
53500b57cec5SDimitry Andric  * \param completion_index The index of the completion
53510b57cec5SDimitry Andric  *
53520b57cec5SDimitry Andric  * \param fixit_index The index of the fix-it for the completion at
53530b57cec5SDimitry Andric  * completion_index
53540b57cec5SDimitry Andric  *
53550b57cec5SDimitry Andric  * \param replacement_range The fix-it range that must be replaced before the
53560b57cec5SDimitry Andric  * completion at completion_index can be applied
53570b57cec5SDimitry Andric  *
53580b57cec5SDimitry Andric  * \returns The fix-it string that must replace the code at replacement_range
53590b57cec5SDimitry Andric  * before the completion at completion_index can be applied
53600b57cec5SDimitry Andric  */
53610b57cec5SDimitry Andric CINDEX_LINKAGE CXString clang_getCompletionFixIt(
53620b57cec5SDimitry Andric     CXCodeCompleteResults *results, unsigned completion_index,
53630b57cec5SDimitry Andric     unsigned fixit_index, CXSourceRange *replacement_range);
53640b57cec5SDimitry Andric 
53650b57cec5SDimitry Andric /**
53660b57cec5SDimitry Andric  * Flags that can be passed to \c clang_codeCompleteAt() to
53670b57cec5SDimitry Andric  * modify its behavior.
53680b57cec5SDimitry Andric  *
53690b57cec5SDimitry Andric  * The enumerators in this enumeration can be bitwise-OR'd together to
53700b57cec5SDimitry Andric  * provide multiple options to \c clang_codeCompleteAt().
53710b57cec5SDimitry Andric  */
53720b57cec5SDimitry Andric enum CXCodeComplete_Flags {
53730b57cec5SDimitry Andric   /**
53740b57cec5SDimitry Andric    * Whether to include macros within the set of code
53750b57cec5SDimitry Andric    * completions returned.
53760b57cec5SDimitry Andric    */
53770b57cec5SDimitry Andric   CXCodeComplete_IncludeMacros = 0x01,
53780b57cec5SDimitry Andric 
53790b57cec5SDimitry Andric   /**
53800b57cec5SDimitry Andric    * Whether to include code patterns for language constructs
53810b57cec5SDimitry Andric    * within the set of code completions, e.g., for loops.
53820b57cec5SDimitry Andric    */
53830b57cec5SDimitry Andric   CXCodeComplete_IncludeCodePatterns = 0x02,
53840b57cec5SDimitry Andric 
53850b57cec5SDimitry Andric   /**
53860b57cec5SDimitry Andric    * Whether to include brief documentation within the set of code
53870b57cec5SDimitry Andric    * completions returned.
53880b57cec5SDimitry Andric    */
53890b57cec5SDimitry Andric   CXCodeComplete_IncludeBriefComments = 0x04,
53900b57cec5SDimitry Andric 
53910b57cec5SDimitry Andric   /**
53920b57cec5SDimitry Andric    * Whether to speed up completion by omitting top- or namespace-level entities
53930b57cec5SDimitry Andric    * defined in the preamble. There's no guarantee any particular entity is
53940b57cec5SDimitry Andric    * omitted. This may be useful if the headers are indexed externally.
53950b57cec5SDimitry Andric    */
53960b57cec5SDimitry Andric   CXCodeComplete_SkipPreamble = 0x08,
53970b57cec5SDimitry Andric 
53980b57cec5SDimitry Andric   /**
53990b57cec5SDimitry Andric    * Whether to include completions with small
54000b57cec5SDimitry Andric    * fix-its, e.g. change '.' to '->' on member access, etc.
54010b57cec5SDimitry Andric    */
54020b57cec5SDimitry Andric   CXCodeComplete_IncludeCompletionsWithFixIts = 0x10
54030b57cec5SDimitry Andric };
54040b57cec5SDimitry Andric 
54050b57cec5SDimitry Andric /**
54060b57cec5SDimitry Andric  * Bits that represent the context under which completion is occurring.
54070b57cec5SDimitry Andric  *
54080b57cec5SDimitry Andric  * The enumerators in this enumeration may be bitwise-OR'd together if multiple
54090b57cec5SDimitry Andric  * contexts are occurring simultaneously.
54100b57cec5SDimitry Andric  */
54110b57cec5SDimitry Andric enum CXCompletionContext {
54120b57cec5SDimitry Andric   /**
54130b57cec5SDimitry Andric    * The context for completions is unexposed, as only Clang results
54140b57cec5SDimitry Andric    * should be included. (This is equivalent to having no context bits set.)
54150b57cec5SDimitry Andric    */
54160b57cec5SDimitry Andric   CXCompletionContext_Unexposed = 0,
54170b57cec5SDimitry Andric 
54180b57cec5SDimitry Andric   /**
54190b57cec5SDimitry Andric    * Completions for any possible type should be included in the results.
54200b57cec5SDimitry Andric    */
54210b57cec5SDimitry Andric   CXCompletionContext_AnyType = 1 << 0,
54220b57cec5SDimitry Andric 
54230b57cec5SDimitry Andric   /**
54240b57cec5SDimitry Andric    * Completions for any possible value (variables, function calls, etc.)
54250b57cec5SDimitry Andric    * should be included in the results.
54260b57cec5SDimitry Andric    */
54270b57cec5SDimitry Andric   CXCompletionContext_AnyValue = 1 << 1,
54280b57cec5SDimitry Andric   /**
54290b57cec5SDimitry Andric    * Completions for values that resolve to an Objective-C object should
54300b57cec5SDimitry Andric    * be included in the results.
54310b57cec5SDimitry Andric    */
54320b57cec5SDimitry Andric   CXCompletionContext_ObjCObjectValue = 1 << 2,
54330b57cec5SDimitry Andric   /**
54340b57cec5SDimitry Andric    * Completions for values that resolve to an Objective-C selector
54350b57cec5SDimitry Andric    * should be included in the results.
54360b57cec5SDimitry Andric    */
54370b57cec5SDimitry Andric   CXCompletionContext_ObjCSelectorValue = 1 << 3,
54380b57cec5SDimitry Andric   /**
54390b57cec5SDimitry Andric    * Completions for values that resolve to a C++ class type should be
54400b57cec5SDimitry Andric    * included in the results.
54410b57cec5SDimitry Andric    */
54420b57cec5SDimitry Andric   CXCompletionContext_CXXClassTypeValue = 1 << 4,
54430b57cec5SDimitry Andric 
54440b57cec5SDimitry Andric   /**
54450b57cec5SDimitry Andric    * Completions for fields of the member being accessed using the dot
54460b57cec5SDimitry Andric    * operator should be included in the results.
54470b57cec5SDimitry Andric    */
54480b57cec5SDimitry Andric   CXCompletionContext_DotMemberAccess = 1 << 5,
54490b57cec5SDimitry Andric   /**
54500b57cec5SDimitry Andric    * Completions for fields of the member being accessed using the arrow
54510b57cec5SDimitry Andric    * operator should be included in the results.
54520b57cec5SDimitry Andric    */
54530b57cec5SDimitry Andric   CXCompletionContext_ArrowMemberAccess = 1 << 6,
54540b57cec5SDimitry Andric   /**
54550b57cec5SDimitry Andric    * Completions for properties of the Objective-C object being accessed
54560b57cec5SDimitry Andric    * using the dot operator should be included in the results.
54570b57cec5SDimitry Andric    */
54580b57cec5SDimitry Andric   CXCompletionContext_ObjCPropertyAccess = 1 << 7,
54590b57cec5SDimitry Andric 
54600b57cec5SDimitry Andric   /**
54610b57cec5SDimitry Andric    * Completions for enum tags should be included in the results.
54620b57cec5SDimitry Andric    */
54630b57cec5SDimitry Andric   CXCompletionContext_EnumTag = 1 << 8,
54640b57cec5SDimitry Andric   /**
54650b57cec5SDimitry Andric    * Completions for union tags should be included in the results.
54660b57cec5SDimitry Andric    */
54670b57cec5SDimitry Andric   CXCompletionContext_UnionTag = 1 << 9,
54680b57cec5SDimitry Andric   /**
54690b57cec5SDimitry Andric    * Completions for struct tags should be included in the results.
54700b57cec5SDimitry Andric    */
54710b57cec5SDimitry Andric   CXCompletionContext_StructTag = 1 << 10,
54720b57cec5SDimitry Andric 
54730b57cec5SDimitry Andric   /**
54740b57cec5SDimitry Andric    * Completions for C++ class names should be included in the results.
54750b57cec5SDimitry Andric    */
54760b57cec5SDimitry Andric   CXCompletionContext_ClassTag = 1 << 11,
54770b57cec5SDimitry Andric   /**
54780b57cec5SDimitry Andric    * Completions for C++ namespaces and namespace aliases should be
54790b57cec5SDimitry Andric    * included in the results.
54800b57cec5SDimitry Andric    */
54810b57cec5SDimitry Andric   CXCompletionContext_Namespace = 1 << 12,
54820b57cec5SDimitry Andric   /**
54830b57cec5SDimitry Andric    * Completions for C++ nested name specifiers should be included in
54840b57cec5SDimitry Andric    * the results.
54850b57cec5SDimitry Andric    */
54860b57cec5SDimitry Andric   CXCompletionContext_NestedNameSpecifier = 1 << 13,
54870b57cec5SDimitry Andric 
54880b57cec5SDimitry Andric   /**
54890b57cec5SDimitry Andric    * Completions for Objective-C interfaces (classes) should be included
54900b57cec5SDimitry Andric    * in the results.
54910b57cec5SDimitry Andric    */
54920b57cec5SDimitry Andric   CXCompletionContext_ObjCInterface = 1 << 14,
54930b57cec5SDimitry Andric   /**
54940b57cec5SDimitry Andric    * Completions for Objective-C protocols should be included in
54950b57cec5SDimitry Andric    * the results.
54960b57cec5SDimitry Andric    */
54970b57cec5SDimitry Andric   CXCompletionContext_ObjCProtocol = 1 << 15,
54980b57cec5SDimitry Andric   /**
54990b57cec5SDimitry Andric    * Completions for Objective-C categories should be included in
55000b57cec5SDimitry Andric    * the results.
55010b57cec5SDimitry Andric    */
55020b57cec5SDimitry Andric   CXCompletionContext_ObjCCategory = 1 << 16,
55030b57cec5SDimitry Andric   /**
55040b57cec5SDimitry Andric    * Completions for Objective-C instance messages should be included
55050b57cec5SDimitry Andric    * in the results.
55060b57cec5SDimitry Andric    */
55070b57cec5SDimitry Andric   CXCompletionContext_ObjCInstanceMessage = 1 << 17,
55080b57cec5SDimitry Andric   /**
55090b57cec5SDimitry Andric    * Completions for Objective-C class messages should be included in
55100b57cec5SDimitry Andric    * the results.
55110b57cec5SDimitry Andric    */
55120b57cec5SDimitry Andric   CXCompletionContext_ObjCClassMessage = 1 << 18,
55130b57cec5SDimitry Andric   /**
55140b57cec5SDimitry Andric    * Completions for Objective-C selector names should be included in
55150b57cec5SDimitry Andric    * the results.
55160b57cec5SDimitry Andric    */
55170b57cec5SDimitry Andric   CXCompletionContext_ObjCSelectorName = 1 << 19,
55180b57cec5SDimitry Andric 
55190b57cec5SDimitry Andric   /**
55200b57cec5SDimitry Andric    * Completions for preprocessor macro names should be included in
55210b57cec5SDimitry Andric    * the results.
55220b57cec5SDimitry Andric    */
55230b57cec5SDimitry Andric   CXCompletionContext_MacroName = 1 << 20,
55240b57cec5SDimitry Andric 
55250b57cec5SDimitry Andric   /**
55260b57cec5SDimitry Andric    * Natural language completions should be included in the results.
55270b57cec5SDimitry Andric    */
55280b57cec5SDimitry Andric   CXCompletionContext_NaturalLanguage = 1 << 21,
55290b57cec5SDimitry Andric 
55300b57cec5SDimitry Andric   /**
55310b57cec5SDimitry Andric    * #include file completions should be included in the results.
55320b57cec5SDimitry Andric    */
55330b57cec5SDimitry Andric   CXCompletionContext_IncludedFile = 1 << 22,
55340b57cec5SDimitry Andric 
55350b57cec5SDimitry Andric   /**
55360b57cec5SDimitry Andric    * The current context is unknown, so set all contexts.
55370b57cec5SDimitry Andric    */
55380b57cec5SDimitry Andric   CXCompletionContext_Unknown = ((1 << 23) - 1)
55390b57cec5SDimitry Andric };
55400b57cec5SDimitry Andric 
55410b57cec5SDimitry Andric /**
55420b57cec5SDimitry Andric  * Returns a default set of code-completion options that can be
55430b57cec5SDimitry Andric  * passed to\c clang_codeCompleteAt().
55440b57cec5SDimitry Andric  */
55450b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_defaultCodeCompleteOptions(void);
55460b57cec5SDimitry Andric 
55470b57cec5SDimitry Andric /**
55480b57cec5SDimitry Andric  * Perform code completion at a given location in a translation unit.
55490b57cec5SDimitry Andric  *
55500b57cec5SDimitry Andric  * This function performs code completion at a particular file, line, and
55510b57cec5SDimitry Andric  * column within source code, providing results that suggest potential
55520b57cec5SDimitry Andric  * code snippets based on the context of the completion. The basic model
55530b57cec5SDimitry Andric  * for code completion is that Clang will parse a complete source file,
55540b57cec5SDimitry Andric  * performing syntax checking up to the location where code-completion has
55550b57cec5SDimitry Andric  * been requested. At that point, a special code-completion token is passed
55560b57cec5SDimitry Andric  * to the parser, which recognizes this token and determines, based on the
55570b57cec5SDimitry Andric  * current location in the C/Objective-C/C++ grammar and the state of
55580b57cec5SDimitry Andric  * semantic analysis, what completions to provide. These completions are
55590b57cec5SDimitry Andric  * returned via a new \c CXCodeCompleteResults structure.
55600b57cec5SDimitry Andric  *
55610b57cec5SDimitry Andric  * Code completion itself is meant to be triggered by the client when the
55620b57cec5SDimitry Andric  * user types punctuation characters or whitespace, at which point the
55630b57cec5SDimitry Andric  * code-completion location will coincide with the cursor. For example, if \c p
55640b57cec5SDimitry Andric  * is a pointer, code-completion might be triggered after the "-" and then
55650b57cec5SDimitry Andric  * after the ">" in \c p->. When the code-completion location is after the ">",
55660b57cec5SDimitry Andric  * the completion results will provide, e.g., the members of the struct that
55670b57cec5SDimitry Andric  * "p" points to. The client is responsible for placing the cursor at the
55680b57cec5SDimitry Andric  * beginning of the token currently being typed, then filtering the results
55690b57cec5SDimitry Andric  * based on the contents of the token. For example, when code-completing for
55700b57cec5SDimitry Andric  * the expression \c p->get, the client should provide the location just after
55710b57cec5SDimitry Andric  * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the
55720b57cec5SDimitry Andric  * client can filter the results based on the current token text ("get"), only
55730b57cec5SDimitry Andric  * showing those results that start with "get". The intent of this interface
55740b57cec5SDimitry Andric  * is to separate the relatively high-latency acquisition of code-completion
55750b57cec5SDimitry Andric  * results from the filtering of results on a per-character basis, which must
55760b57cec5SDimitry Andric  * have a lower latency.
55770b57cec5SDimitry Andric  *
55780b57cec5SDimitry Andric  * \param TU The translation unit in which code-completion should
55790b57cec5SDimitry Andric  * occur. The source files for this translation unit need not be
55800b57cec5SDimitry Andric  * completely up-to-date (and the contents of those source files may
55810b57cec5SDimitry Andric  * be overridden via \p unsaved_files). Cursors referring into the
55820b57cec5SDimitry Andric  * translation unit may be invalidated by this invocation.
55830b57cec5SDimitry Andric  *
55840b57cec5SDimitry Andric  * \param complete_filename The name of the source file where code
55850b57cec5SDimitry Andric  * completion should be performed. This filename may be any file
55860b57cec5SDimitry Andric  * included in the translation unit.
55870b57cec5SDimitry Andric  *
55880b57cec5SDimitry Andric  * \param complete_line The line at which code-completion should occur.
55890b57cec5SDimitry Andric  *
55900b57cec5SDimitry Andric  * \param complete_column The column at which code-completion should occur.
55910b57cec5SDimitry Andric  * Note that the column should point just after the syntactic construct that
55920b57cec5SDimitry Andric  * initiated code completion, and not in the middle of a lexical token.
55930b57cec5SDimitry Andric  *
55940b57cec5SDimitry Andric  * \param unsaved_files the Files that have not yet been saved to disk
55950b57cec5SDimitry Andric  * but may be required for parsing or code completion, including the
55960b57cec5SDimitry Andric  * contents of those files.  The contents and name of these files (as
55970b57cec5SDimitry Andric  * specified by CXUnsavedFile) are copied when necessary, so the
55980b57cec5SDimitry Andric  * client only needs to guarantee their validity until the call to
55990b57cec5SDimitry Andric  * this function returns.
56000b57cec5SDimitry Andric  *
56010b57cec5SDimitry Andric  * \param num_unsaved_files The number of unsaved file entries in \p
56020b57cec5SDimitry Andric  * unsaved_files.
56030b57cec5SDimitry Andric  *
56040b57cec5SDimitry Andric  * \param options Extra options that control the behavior of code
56050b57cec5SDimitry Andric  * completion, expressed as a bitwise OR of the enumerators of the
56060b57cec5SDimitry Andric  * CXCodeComplete_Flags enumeration. The
56070b57cec5SDimitry Andric  * \c clang_defaultCodeCompleteOptions() function returns a default set
56080b57cec5SDimitry Andric  * of code-completion options.
56090b57cec5SDimitry Andric  *
56100b57cec5SDimitry Andric  * \returns If successful, a new \c CXCodeCompleteResults structure
56110b57cec5SDimitry Andric  * containing code-completion results, which should eventually be
56120b57cec5SDimitry Andric  * freed with \c clang_disposeCodeCompleteResults(). If code
56130b57cec5SDimitry Andric  * completion fails, returns NULL.
56140b57cec5SDimitry Andric  */
56150b57cec5SDimitry Andric CINDEX_LINKAGE
56165ffd83dbSDimitry Andric CXCodeCompleteResults *
56175ffd83dbSDimitry Andric clang_codeCompleteAt(CXTranslationUnit TU, const char *complete_filename,
56185ffd83dbSDimitry Andric                      unsigned complete_line, unsigned complete_column,
56190b57cec5SDimitry Andric                      struct CXUnsavedFile *unsaved_files,
56205ffd83dbSDimitry Andric                      unsigned num_unsaved_files, unsigned options);
56210b57cec5SDimitry Andric 
56220b57cec5SDimitry Andric /**
56230b57cec5SDimitry Andric  * Sort the code-completion results in case-insensitive alphabetical
56240b57cec5SDimitry Andric  * order.
56250b57cec5SDimitry Andric  *
56260b57cec5SDimitry Andric  * \param Results The set of results to sort.
56270b57cec5SDimitry Andric  * \param NumResults The number of results in \p Results.
56280b57cec5SDimitry Andric  */
56290b57cec5SDimitry Andric CINDEX_LINKAGE
56300b57cec5SDimitry Andric void clang_sortCodeCompletionResults(CXCompletionResult *Results,
56310b57cec5SDimitry Andric                                      unsigned NumResults);
56320b57cec5SDimitry Andric 
56330b57cec5SDimitry Andric /**
56340b57cec5SDimitry Andric  * Free the given set of code-completion results.
56350b57cec5SDimitry Andric  */
56360b57cec5SDimitry Andric CINDEX_LINKAGE
56370b57cec5SDimitry Andric void clang_disposeCodeCompleteResults(CXCodeCompleteResults *Results);
56380b57cec5SDimitry Andric 
56390b57cec5SDimitry Andric /**
56400b57cec5SDimitry Andric  * Determine the number of diagnostics produced prior to the
56410b57cec5SDimitry Andric  * location where code completion was performed.
56420b57cec5SDimitry Andric  */
56430b57cec5SDimitry Andric CINDEX_LINKAGE
56440b57cec5SDimitry Andric unsigned clang_codeCompleteGetNumDiagnostics(CXCodeCompleteResults *Results);
56450b57cec5SDimitry Andric 
56460b57cec5SDimitry Andric /**
56470b57cec5SDimitry Andric  * Retrieve a diagnostic associated with the given code completion.
56480b57cec5SDimitry Andric  *
56490b57cec5SDimitry Andric  * \param Results the code completion results to query.
56500b57cec5SDimitry Andric  * \param Index the zero-based diagnostic number to retrieve.
56510b57cec5SDimitry Andric  *
56520b57cec5SDimitry Andric  * \returns the requested diagnostic. This diagnostic must be freed
56530b57cec5SDimitry Andric  * via a call to \c clang_disposeDiagnostic().
56540b57cec5SDimitry Andric  */
56550b57cec5SDimitry Andric CINDEX_LINKAGE
56560b57cec5SDimitry Andric CXDiagnostic clang_codeCompleteGetDiagnostic(CXCodeCompleteResults *Results,
56570b57cec5SDimitry Andric                                              unsigned Index);
56580b57cec5SDimitry Andric 
56590b57cec5SDimitry Andric /**
56600b57cec5SDimitry Andric  * Determines what completions are appropriate for the context
56610b57cec5SDimitry Andric  * the given code completion.
56620b57cec5SDimitry Andric  *
56630b57cec5SDimitry Andric  * \param Results the code completion results to query
56640b57cec5SDimitry Andric  *
56650b57cec5SDimitry Andric  * \returns the kinds of completions that are appropriate for use
56660b57cec5SDimitry Andric  * along with the given code completion results.
56670b57cec5SDimitry Andric  */
56680b57cec5SDimitry Andric CINDEX_LINKAGE
56695ffd83dbSDimitry Andric unsigned long long
56705ffd83dbSDimitry Andric clang_codeCompleteGetContexts(CXCodeCompleteResults *Results);
56710b57cec5SDimitry Andric 
56720b57cec5SDimitry Andric /**
56730b57cec5SDimitry Andric  * Returns the cursor kind for the container for the current code
56740b57cec5SDimitry Andric  * completion context. The container is only guaranteed to be set for
56750b57cec5SDimitry Andric  * contexts where a container exists (i.e. member accesses or Objective-C
56760b57cec5SDimitry Andric  * message sends); if there is not a container, this function will return
56770b57cec5SDimitry Andric  * CXCursor_InvalidCode.
56780b57cec5SDimitry Andric  *
56790b57cec5SDimitry Andric  * \param Results the code completion results to query
56800b57cec5SDimitry Andric  *
56810b57cec5SDimitry Andric  * \param IsIncomplete on return, this value will be false if Clang has complete
56820b57cec5SDimitry Andric  * information about the container. If Clang does not have complete
56830b57cec5SDimitry Andric  * information, this value will be true.
56840b57cec5SDimitry Andric  *
56850b57cec5SDimitry Andric  * \returns the container kind, or CXCursor_InvalidCode if there is not a
56860b57cec5SDimitry Andric  * container
56870b57cec5SDimitry Andric  */
56880b57cec5SDimitry Andric CINDEX_LINKAGE
56895ffd83dbSDimitry Andric enum CXCursorKind
56905ffd83dbSDimitry Andric clang_codeCompleteGetContainerKind(CXCodeCompleteResults *Results,
56910b57cec5SDimitry Andric                                    unsigned *IsIncomplete);
56920b57cec5SDimitry Andric 
56930b57cec5SDimitry Andric /**
56940b57cec5SDimitry Andric  * Returns the USR for the container for the current code completion
56950b57cec5SDimitry Andric  * context. If there is not a container for the current context, this
56960b57cec5SDimitry Andric  * function will return the empty string.
56970b57cec5SDimitry Andric  *
56980b57cec5SDimitry Andric  * \param Results the code completion results to query
56990b57cec5SDimitry Andric  *
57000b57cec5SDimitry Andric  * \returns the USR for the container
57010b57cec5SDimitry Andric  */
57020b57cec5SDimitry Andric CINDEX_LINKAGE
57030b57cec5SDimitry Andric CXString clang_codeCompleteGetContainerUSR(CXCodeCompleteResults *Results);
57040b57cec5SDimitry Andric 
57050b57cec5SDimitry Andric /**
57060b57cec5SDimitry Andric  * Returns the currently-entered selector for an Objective-C message
57070b57cec5SDimitry Andric  * send, formatted like "initWithFoo:bar:". Only guaranteed to return a
57080b57cec5SDimitry Andric  * non-empty string for CXCompletionContext_ObjCInstanceMessage and
57090b57cec5SDimitry Andric  * CXCompletionContext_ObjCClassMessage.
57100b57cec5SDimitry Andric  *
57110b57cec5SDimitry Andric  * \param Results the code completion results to query
57120b57cec5SDimitry Andric  *
57130b57cec5SDimitry Andric  * \returns the selector (or partial selector) that has been entered thus far
57140b57cec5SDimitry Andric  * for an Objective-C message send.
57150b57cec5SDimitry Andric  */
57160b57cec5SDimitry Andric CINDEX_LINKAGE
57170b57cec5SDimitry Andric CXString clang_codeCompleteGetObjCSelector(CXCodeCompleteResults *Results);
57180b57cec5SDimitry Andric 
57190b57cec5SDimitry Andric /**
57200b57cec5SDimitry Andric  * @}
57210b57cec5SDimitry Andric  */
57220b57cec5SDimitry Andric 
57230b57cec5SDimitry Andric /**
57240b57cec5SDimitry Andric  * \defgroup CINDEX_MISC Miscellaneous utility functions
57250b57cec5SDimitry Andric  *
57260b57cec5SDimitry Andric  * @{
57270b57cec5SDimitry Andric  */
57280b57cec5SDimitry Andric 
57290b57cec5SDimitry Andric /**
57300b57cec5SDimitry Andric  * Return a version string, suitable for showing to a user, but not
57310b57cec5SDimitry Andric  *        intended to be parsed (the format is not guaranteed to be stable).
57320b57cec5SDimitry Andric  */
57330b57cec5SDimitry Andric CINDEX_LINKAGE CXString clang_getClangVersion(void);
57340b57cec5SDimitry Andric 
57350b57cec5SDimitry Andric /**
57360b57cec5SDimitry Andric  * Enable/disable crash recovery.
57370b57cec5SDimitry Andric  *
57380b57cec5SDimitry Andric  * \param isEnabled Flag to indicate if crash recovery is enabled.  A non-zero
57390b57cec5SDimitry Andric  *        value enables crash recovery, while 0 disables it.
57400b57cec5SDimitry Andric  */
57410b57cec5SDimitry Andric CINDEX_LINKAGE void clang_toggleCrashRecovery(unsigned isEnabled);
57420b57cec5SDimitry Andric 
57430b57cec5SDimitry Andric /**
57440b57cec5SDimitry Andric  * Visitor invoked for each file in a translation unit
57450b57cec5SDimitry Andric  *        (used with clang_getInclusions()).
57460b57cec5SDimitry Andric  *
57470b57cec5SDimitry Andric  * This visitor function will be invoked by clang_getInclusions() for each
57480b57cec5SDimitry Andric  * file included (either at the top-level or by \#include directives) within
57490b57cec5SDimitry Andric  * a translation unit.  The first argument is the file being included, and
57500b57cec5SDimitry Andric  * the second and third arguments provide the inclusion stack.  The
57510b57cec5SDimitry Andric  * array is sorted in order of immediate inclusion.  For example,
57520b57cec5SDimitry Andric  * the first element refers to the location that included 'included_file'.
57530b57cec5SDimitry Andric  */
57540b57cec5SDimitry Andric typedef void (*CXInclusionVisitor)(CXFile included_file,
57550b57cec5SDimitry Andric                                    CXSourceLocation *inclusion_stack,
57560b57cec5SDimitry Andric                                    unsigned include_len,
57570b57cec5SDimitry Andric                                    CXClientData client_data);
57580b57cec5SDimitry Andric 
57590b57cec5SDimitry Andric /**
57600b57cec5SDimitry Andric  * Visit the set of preprocessor inclusions in a translation unit.
57610b57cec5SDimitry Andric  *   The visitor function is called with the provided data for every included
57620b57cec5SDimitry Andric  *   file.  This does not include headers included by the PCH file (unless one
57630b57cec5SDimitry Andric  *   is inspecting the inclusions in the PCH file itself).
57640b57cec5SDimitry Andric  */
57650b57cec5SDimitry Andric CINDEX_LINKAGE void clang_getInclusions(CXTranslationUnit tu,
57660b57cec5SDimitry Andric                                         CXInclusionVisitor visitor,
57670b57cec5SDimitry Andric                                         CXClientData client_data);
57680b57cec5SDimitry Andric 
57690b57cec5SDimitry Andric typedef enum {
57700b57cec5SDimitry Andric   CXEval_Int = 1,
57710b57cec5SDimitry Andric   CXEval_Float = 2,
57720b57cec5SDimitry Andric   CXEval_ObjCStrLiteral = 3,
57730b57cec5SDimitry Andric   CXEval_StrLiteral = 4,
57740b57cec5SDimitry Andric   CXEval_CFStr = 5,
57750b57cec5SDimitry Andric   CXEval_Other = 6,
57760b57cec5SDimitry Andric 
57770b57cec5SDimitry Andric   CXEval_UnExposed = 0
57780b57cec5SDimitry Andric 
57790b57cec5SDimitry Andric } CXEvalResultKind;
57800b57cec5SDimitry Andric 
57810b57cec5SDimitry Andric /**
57820b57cec5SDimitry Andric  * Evaluation result of a cursor
57830b57cec5SDimitry Andric  */
57840b57cec5SDimitry Andric typedef void *CXEvalResult;
57850b57cec5SDimitry Andric 
57860b57cec5SDimitry Andric /**
57870b57cec5SDimitry Andric  * If cursor is a statement declaration tries to evaluate the
57880b57cec5SDimitry Andric  * statement and if its variable, tries to evaluate its initializer,
57890b57cec5SDimitry Andric  * into its corresponding type.
57905ffd83dbSDimitry Andric  * If it's an expression, tries to evaluate the expression.
57910b57cec5SDimitry Andric  */
57920b57cec5SDimitry Andric CINDEX_LINKAGE CXEvalResult clang_Cursor_Evaluate(CXCursor C);
57930b57cec5SDimitry Andric 
57940b57cec5SDimitry Andric /**
57950b57cec5SDimitry Andric  * Returns the kind of the evaluated result.
57960b57cec5SDimitry Andric  */
57970b57cec5SDimitry Andric CINDEX_LINKAGE CXEvalResultKind clang_EvalResult_getKind(CXEvalResult E);
57980b57cec5SDimitry Andric 
57990b57cec5SDimitry Andric /**
58000b57cec5SDimitry Andric  * Returns the evaluation result as integer if the
58010b57cec5SDimitry Andric  * kind is Int.
58020b57cec5SDimitry Andric  */
58030b57cec5SDimitry Andric CINDEX_LINKAGE int clang_EvalResult_getAsInt(CXEvalResult E);
58040b57cec5SDimitry Andric 
58050b57cec5SDimitry Andric /**
58060b57cec5SDimitry Andric  * Returns the evaluation result as a long long integer if the
58070b57cec5SDimitry Andric  * kind is Int. This prevents overflows that may happen if the result is
58080b57cec5SDimitry Andric  * returned with clang_EvalResult_getAsInt.
58090b57cec5SDimitry Andric  */
58100b57cec5SDimitry Andric CINDEX_LINKAGE long long clang_EvalResult_getAsLongLong(CXEvalResult E);
58110b57cec5SDimitry Andric 
58120b57cec5SDimitry Andric /**
58130b57cec5SDimitry Andric  * Returns a non-zero value if the kind is Int and the evaluation
58140b57cec5SDimitry Andric  * result resulted in an unsigned integer.
58150b57cec5SDimitry Andric  */
58160b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_EvalResult_isUnsignedInt(CXEvalResult E);
58170b57cec5SDimitry Andric 
58180b57cec5SDimitry Andric /**
58190b57cec5SDimitry Andric  * Returns the evaluation result as an unsigned integer if
58200b57cec5SDimitry Andric  * the kind is Int and clang_EvalResult_isUnsignedInt is non-zero.
58210b57cec5SDimitry Andric  */
58225ffd83dbSDimitry Andric CINDEX_LINKAGE unsigned long long
58235ffd83dbSDimitry Andric clang_EvalResult_getAsUnsigned(CXEvalResult E);
58240b57cec5SDimitry Andric 
58250b57cec5SDimitry Andric /**
58260b57cec5SDimitry Andric  * Returns the evaluation result as double if the
58270b57cec5SDimitry Andric  * kind is double.
58280b57cec5SDimitry Andric  */
58290b57cec5SDimitry Andric CINDEX_LINKAGE double clang_EvalResult_getAsDouble(CXEvalResult E);
58300b57cec5SDimitry Andric 
58310b57cec5SDimitry Andric /**
58320b57cec5SDimitry Andric  * Returns the evaluation result as a constant string if the
58330b57cec5SDimitry Andric  * kind is other than Int or float. User must not free this pointer,
58340b57cec5SDimitry Andric  * instead call clang_EvalResult_dispose on the CXEvalResult returned
58350b57cec5SDimitry Andric  * by clang_Cursor_Evaluate.
58360b57cec5SDimitry Andric  */
58370b57cec5SDimitry Andric CINDEX_LINKAGE const char *clang_EvalResult_getAsStr(CXEvalResult E);
58380b57cec5SDimitry Andric 
58390b57cec5SDimitry Andric /**
58400b57cec5SDimitry Andric  * Disposes the created Eval memory.
58410b57cec5SDimitry Andric  */
58420b57cec5SDimitry Andric CINDEX_LINKAGE void clang_EvalResult_dispose(CXEvalResult E);
58430b57cec5SDimitry Andric /**
58440b57cec5SDimitry Andric  * @}
58450b57cec5SDimitry Andric  */
58460b57cec5SDimitry Andric 
58470b57cec5SDimitry Andric /** \defgroup CINDEX_REMAPPING Remapping functions
58480b57cec5SDimitry Andric  *
58490b57cec5SDimitry Andric  * @{
58500b57cec5SDimitry Andric  */
58510b57cec5SDimitry Andric 
58520b57cec5SDimitry Andric /**
58530b57cec5SDimitry Andric  * A remapping of original source files and their translated files.
58540b57cec5SDimitry Andric  */
58550b57cec5SDimitry Andric typedef void *CXRemapping;
58560b57cec5SDimitry Andric 
58570b57cec5SDimitry Andric /**
58580b57cec5SDimitry Andric  * Retrieve a remapping.
58590b57cec5SDimitry Andric  *
58600b57cec5SDimitry Andric  * \param path the path that contains metadata about remappings.
58610b57cec5SDimitry Andric  *
58620b57cec5SDimitry Andric  * \returns the requested remapping. This remapping must be freed
58630b57cec5SDimitry Andric  * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
58640b57cec5SDimitry Andric  */
58650b57cec5SDimitry Andric CINDEX_LINKAGE CXRemapping clang_getRemappings(const char *path);
58660b57cec5SDimitry Andric 
58670b57cec5SDimitry Andric /**
58680b57cec5SDimitry Andric  * Retrieve a remapping.
58690b57cec5SDimitry Andric  *
58700b57cec5SDimitry Andric  * \param filePaths pointer to an array of file paths containing remapping info.
58710b57cec5SDimitry Andric  *
58720b57cec5SDimitry Andric  * \param numFiles number of file paths.
58730b57cec5SDimitry Andric  *
58740b57cec5SDimitry Andric  * \returns the requested remapping. This remapping must be freed
58750b57cec5SDimitry Andric  * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
58760b57cec5SDimitry Andric  */
58770b57cec5SDimitry Andric CINDEX_LINKAGE
58780b57cec5SDimitry Andric CXRemapping clang_getRemappingsFromFileList(const char **filePaths,
58790b57cec5SDimitry Andric                                             unsigned numFiles);
58800b57cec5SDimitry Andric 
58810b57cec5SDimitry Andric /**
58820b57cec5SDimitry Andric  * Determine the number of remappings.
58830b57cec5SDimitry Andric  */
58840b57cec5SDimitry Andric CINDEX_LINKAGE unsigned clang_remap_getNumFiles(CXRemapping);
58850b57cec5SDimitry Andric 
58860b57cec5SDimitry Andric /**
58870b57cec5SDimitry Andric  * Get the original and the associated filename from the remapping.
58880b57cec5SDimitry Andric  *
58890b57cec5SDimitry Andric  * \param original If non-NULL, will be set to the original filename.
58900b57cec5SDimitry Andric  *
58910b57cec5SDimitry Andric  * \param transformed If non-NULL, will be set to the filename that the original
58920b57cec5SDimitry Andric  * is associated with.
58930b57cec5SDimitry Andric  */
58940b57cec5SDimitry Andric CINDEX_LINKAGE void clang_remap_getFilenames(CXRemapping, unsigned index,
58955ffd83dbSDimitry Andric                                              CXString *original,
58965ffd83dbSDimitry Andric                                              CXString *transformed);
58970b57cec5SDimitry Andric 
58980b57cec5SDimitry Andric /**
58990b57cec5SDimitry Andric  * Dispose the remapping.
59000b57cec5SDimitry Andric  */
59010b57cec5SDimitry Andric CINDEX_LINKAGE void clang_remap_dispose(CXRemapping);
59020b57cec5SDimitry Andric 
59030b57cec5SDimitry Andric /**
59040b57cec5SDimitry Andric  * @}
59050b57cec5SDimitry Andric  */
59060b57cec5SDimitry Andric 
59070b57cec5SDimitry Andric /** \defgroup CINDEX_HIGH Higher level API functions
59080b57cec5SDimitry Andric  *
59090b57cec5SDimitry Andric  * @{
59100b57cec5SDimitry Andric  */
59110b57cec5SDimitry Andric 
59125ffd83dbSDimitry Andric enum CXVisitorResult { CXVisit_Break, CXVisit_Continue };
59130b57cec5SDimitry Andric 
59140b57cec5SDimitry Andric typedef struct CXCursorAndRangeVisitor {
59150b57cec5SDimitry Andric   void *context;
59160b57cec5SDimitry Andric   enum CXVisitorResult (*visit)(void *context, CXCursor, CXSourceRange);
59170b57cec5SDimitry Andric } CXCursorAndRangeVisitor;
59180b57cec5SDimitry Andric 
59190b57cec5SDimitry Andric typedef enum {
59200b57cec5SDimitry Andric   /**
59210b57cec5SDimitry Andric    * Function returned successfully.
59220b57cec5SDimitry Andric    */
59230b57cec5SDimitry Andric   CXResult_Success = 0,
59240b57cec5SDimitry Andric   /**
59250b57cec5SDimitry Andric    * One of the parameters was invalid for the function.
59260b57cec5SDimitry Andric    */
59270b57cec5SDimitry Andric   CXResult_Invalid = 1,
59280b57cec5SDimitry Andric   /**
59290b57cec5SDimitry Andric    * The function was terminated by a callback (e.g. it returned
59300b57cec5SDimitry Andric    * CXVisit_Break)
59310b57cec5SDimitry Andric    */
59320b57cec5SDimitry Andric   CXResult_VisitBreak = 2
59330b57cec5SDimitry Andric 
59340b57cec5SDimitry Andric } CXResult;
59350b57cec5SDimitry Andric 
59360b57cec5SDimitry Andric /**
59370b57cec5SDimitry Andric  * Find references of a declaration in a specific file.
59380b57cec5SDimitry Andric  *
59390b57cec5SDimitry Andric  * \param cursor pointing to a declaration or a reference of one.
59400b57cec5SDimitry Andric  *
59410b57cec5SDimitry Andric  * \param file to search for references.
59420b57cec5SDimitry Andric  *
59430b57cec5SDimitry Andric  * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
59440b57cec5SDimitry Andric  * each reference found.
59450b57cec5SDimitry Andric  * The CXSourceRange will point inside the file; if the reference is inside
59460b57cec5SDimitry Andric  * a macro (and not a macro argument) the CXSourceRange will be invalid.
59470b57cec5SDimitry Andric  *
59480b57cec5SDimitry Andric  * \returns one of the CXResult enumerators.
59490b57cec5SDimitry Andric  */
59505ffd83dbSDimitry Andric CINDEX_LINKAGE CXResult clang_findReferencesInFile(
59515ffd83dbSDimitry Andric     CXCursor cursor, CXFile file, CXCursorAndRangeVisitor visitor);
59520b57cec5SDimitry Andric 
59530b57cec5SDimitry Andric /**
59540b57cec5SDimitry Andric  * Find #import/#include directives in a specific file.
59550b57cec5SDimitry Andric  *
59560b57cec5SDimitry Andric  * \param TU translation unit containing the file to query.
59570b57cec5SDimitry Andric  *
59580b57cec5SDimitry Andric  * \param file to search for #import/#include directives.
59590b57cec5SDimitry Andric  *
59600b57cec5SDimitry Andric  * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
59610b57cec5SDimitry Andric  * each directive found.
59620b57cec5SDimitry Andric  *
59630b57cec5SDimitry Andric  * \returns one of the CXResult enumerators.
59640b57cec5SDimitry Andric  */
59655ffd83dbSDimitry Andric CINDEX_LINKAGE CXResult clang_findIncludesInFile(
59665ffd83dbSDimitry Andric     CXTranslationUnit TU, CXFile file, CXCursorAndRangeVisitor visitor);
59670b57cec5SDimitry Andric 
59680b57cec5SDimitry Andric #if __has_feature(blocks)
59695ffd83dbSDimitry Andric typedef enum CXVisitorResult (^CXCursorAndRangeVisitorBlock)(CXCursor,
59705ffd83dbSDimitry Andric                                                              CXSourceRange);
597106c3fb27SDimitry Andric #else
597206c3fb27SDimitry Andric typedef struct _CXCursorAndRangeVisitorBlock *CXCursorAndRangeVisitorBlock;
597306c3fb27SDimitry Andric #endif
59740b57cec5SDimitry Andric 
59750b57cec5SDimitry Andric CINDEX_LINKAGE
59760b57cec5SDimitry Andric CXResult clang_findReferencesInFileWithBlock(CXCursor, CXFile,
59770b57cec5SDimitry Andric                                              CXCursorAndRangeVisitorBlock);
59780b57cec5SDimitry Andric 
59790b57cec5SDimitry Andric CINDEX_LINKAGE
59800b57cec5SDimitry Andric CXResult clang_findIncludesInFileWithBlock(CXTranslationUnit, CXFile,
59810b57cec5SDimitry Andric                                            CXCursorAndRangeVisitorBlock);
59820b57cec5SDimitry Andric 
59830b57cec5SDimitry Andric /**
59840b57cec5SDimitry Andric  * The client's data object that is associated with a CXFile.
59850b57cec5SDimitry Andric  */
59860b57cec5SDimitry Andric typedef void *CXIdxClientFile;
59870b57cec5SDimitry Andric 
59880b57cec5SDimitry Andric /**
59890b57cec5SDimitry Andric  * The client's data object that is associated with a semantic entity.
59900b57cec5SDimitry Andric  */
59910b57cec5SDimitry Andric typedef void *CXIdxClientEntity;
59920b57cec5SDimitry Andric 
59930b57cec5SDimitry Andric /**
59940b57cec5SDimitry Andric  * The client's data object that is associated with a semantic container
59950b57cec5SDimitry Andric  * of entities.
59960b57cec5SDimitry Andric  */
59970b57cec5SDimitry Andric typedef void *CXIdxClientContainer;
59980b57cec5SDimitry Andric 
59990b57cec5SDimitry Andric /**
60000b57cec5SDimitry Andric  * The client's data object that is associated with an AST file (PCH
60010b57cec5SDimitry Andric  * or module).
60020b57cec5SDimitry Andric  */
60030b57cec5SDimitry Andric typedef void *CXIdxClientASTFile;
60040b57cec5SDimitry Andric 
60050b57cec5SDimitry Andric /**
60060b57cec5SDimitry Andric  * Source location passed to index callbacks.
60070b57cec5SDimitry Andric  */
60080b57cec5SDimitry Andric typedef struct {
60090b57cec5SDimitry Andric   void *ptr_data[2];
60100b57cec5SDimitry Andric   unsigned int_data;
60110b57cec5SDimitry Andric } CXIdxLoc;
60120b57cec5SDimitry Andric 
60130b57cec5SDimitry Andric /**
60140b57cec5SDimitry Andric  * Data for ppIncludedFile callback.
60150b57cec5SDimitry Andric  */
60160b57cec5SDimitry Andric typedef struct {
60170b57cec5SDimitry Andric   /**
60180b57cec5SDimitry Andric    * Location of '#' in the \#include/\#import directive.
60190b57cec5SDimitry Andric    */
60200b57cec5SDimitry Andric   CXIdxLoc hashLoc;
60210b57cec5SDimitry Andric   /**
60220b57cec5SDimitry Andric    * Filename as written in the \#include/\#import directive.
60230b57cec5SDimitry Andric    */
60240b57cec5SDimitry Andric   const char *filename;
60250b57cec5SDimitry Andric   /**
60260b57cec5SDimitry Andric    * The actual file that the \#include/\#import directive resolved to.
60270b57cec5SDimitry Andric    */
60280b57cec5SDimitry Andric   CXFile file;
60290b57cec5SDimitry Andric   int isImport;
60300b57cec5SDimitry Andric   int isAngled;
60310b57cec5SDimitry Andric   /**
60320b57cec5SDimitry Andric    * Non-zero if the directive was automatically turned into a module
60330b57cec5SDimitry Andric    * import.
60340b57cec5SDimitry Andric    */
60350b57cec5SDimitry Andric   int isModuleImport;
60360b57cec5SDimitry Andric } CXIdxIncludedFileInfo;
60370b57cec5SDimitry Andric 
60380b57cec5SDimitry Andric /**
60390b57cec5SDimitry Andric  * Data for IndexerCallbacks#importedASTFile.
60400b57cec5SDimitry Andric  */
60410b57cec5SDimitry Andric typedef struct {
60420b57cec5SDimitry Andric   /**
60430b57cec5SDimitry Andric    * Top level AST file containing the imported PCH, module or submodule.
60440b57cec5SDimitry Andric    */
60450b57cec5SDimitry Andric   CXFile file;
60460b57cec5SDimitry Andric   /**
60470b57cec5SDimitry Andric    * The imported module or NULL if the AST file is a PCH.
60480b57cec5SDimitry Andric    */
60490b57cec5SDimitry Andric   CXModule module;
60500b57cec5SDimitry Andric   /**
60510b57cec5SDimitry Andric    * Location where the file is imported. Applicable only for modules.
60520b57cec5SDimitry Andric    */
60530b57cec5SDimitry Andric   CXIdxLoc loc;
60540b57cec5SDimitry Andric   /**
60550b57cec5SDimitry Andric    * Non-zero if an inclusion directive was automatically turned into
60560b57cec5SDimitry Andric    * a module import. Applicable only for modules.
60570b57cec5SDimitry Andric    */
60580b57cec5SDimitry Andric   int isImplicit;
60590b57cec5SDimitry Andric 
60600b57cec5SDimitry Andric } CXIdxImportedASTFileInfo;
60610b57cec5SDimitry Andric 
60620b57cec5SDimitry Andric typedef enum {
60630b57cec5SDimitry Andric   CXIdxEntity_Unexposed = 0,
60640b57cec5SDimitry Andric   CXIdxEntity_Typedef = 1,
60650b57cec5SDimitry Andric   CXIdxEntity_Function = 2,
60660b57cec5SDimitry Andric   CXIdxEntity_Variable = 3,
60670b57cec5SDimitry Andric   CXIdxEntity_Field = 4,
60680b57cec5SDimitry Andric   CXIdxEntity_EnumConstant = 5,
60690b57cec5SDimitry Andric 
60700b57cec5SDimitry Andric   CXIdxEntity_ObjCClass = 6,
60710b57cec5SDimitry Andric   CXIdxEntity_ObjCProtocol = 7,
60720b57cec5SDimitry Andric   CXIdxEntity_ObjCCategory = 8,
60730b57cec5SDimitry Andric 
60740b57cec5SDimitry Andric   CXIdxEntity_ObjCInstanceMethod = 9,
60750b57cec5SDimitry Andric   CXIdxEntity_ObjCClassMethod = 10,
60760b57cec5SDimitry Andric   CXIdxEntity_ObjCProperty = 11,
60770b57cec5SDimitry Andric   CXIdxEntity_ObjCIvar = 12,
60780b57cec5SDimitry Andric 
60790b57cec5SDimitry Andric   CXIdxEntity_Enum = 13,
60800b57cec5SDimitry Andric   CXIdxEntity_Struct = 14,
60810b57cec5SDimitry Andric   CXIdxEntity_Union = 15,
60820b57cec5SDimitry Andric 
60830b57cec5SDimitry Andric   CXIdxEntity_CXXClass = 16,
60840b57cec5SDimitry Andric   CXIdxEntity_CXXNamespace = 17,
60850b57cec5SDimitry Andric   CXIdxEntity_CXXNamespaceAlias = 18,
60860b57cec5SDimitry Andric   CXIdxEntity_CXXStaticVariable = 19,
60870b57cec5SDimitry Andric   CXIdxEntity_CXXStaticMethod = 20,
60880b57cec5SDimitry Andric   CXIdxEntity_CXXInstanceMethod = 21,
60890b57cec5SDimitry Andric   CXIdxEntity_CXXConstructor = 22,
60900b57cec5SDimitry Andric   CXIdxEntity_CXXDestructor = 23,
60910b57cec5SDimitry Andric   CXIdxEntity_CXXConversionFunction = 24,
60920b57cec5SDimitry Andric   CXIdxEntity_CXXTypeAlias = 25,
609381ad6265SDimitry Andric   CXIdxEntity_CXXInterface = 26,
609481ad6265SDimitry Andric   CXIdxEntity_CXXConcept = 27
60950b57cec5SDimitry Andric 
60960b57cec5SDimitry Andric } CXIdxEntityKind;
60970b57cec5SDimitry Andric 
60980b57cec5SDimitry Andric typedef enum {
60990b57cec5SDimitry Andric   CXIdxEntityLang_None = 0,
61000b57cec5SDimitry Andric   CXIdxEntityLang_C = 1,
61010b57cec5SDimitry Andric   CXIdxEntityLang_ObjC = 2,
61020b57cec5SDimitry Andric   CXIdxEntityLang_CXX = 3,
61030b57cec5SDimitry Andric   CXIdxEntityLang_Swift = 4
61040b57cec5SDimitry Andric } CXIdxEntityLanguage;
61050b57cec5SDimitry Andric 
61060b57cec5SDimitry Andric /**
61070b57cec5SDimitry Andric  * Extra C++ template information for an entity. This can apply to:
61080b57cec5SDimitry Andric  * CXIdxEntity_Function
61090b57cec5SDimitry Andric  * CXIdxEntity_CXXClass
61100b57cec5SDimitry Andric  * CXIdxEntity_CXXStaticMethod
61110b57cec5SDimitry Andric  * CXIdxEntity_CXXInstanceMethod
61120b57cec5SDimitry Andric  * CXIdxEntity_CXXConstructor
61130b57cec5SDimitry Andric  * CXIdxEntity_CXXConversionFunction
61140b57cec5SDimitry Andric  * CXIdxEntity_CXXTypeAlias
61150b57cec5SDimitry Andric  */
61160b57cec5SDimitry Andric typedef enum {
61170b57cec5SDimitry Andric   CXIdxEntity_NonTemplate = 0,
61180b57cec5SDimitry Andric   CXIdxEntity_Template = 1,
61190b57cec5SDimitry Andric   CXIdxEntity_TemplatePartialSpecialization = 2,
61200b57cec5SDimitry Andric   CXIdxEntity_TemplateSpecialization = 3
61210b57cec5SDimitry Andric } CXIdxEntityCXXTemplateKind;
61220b57cec5SDimitry Andric 
61230b57cec5SDimitry Andric typedef enum {
61240b57cec5SDimitry Andric   CXIdxAttr_Unexposed = 0,
61250b57cec5SDimitry Andric   CXIdxAttr_IBAction = 1,
61260b57cec5SDimitry Andric   CXIdxAttr_IBOutlet = 2,
61270b57cec5SDimitry Andric   CXIdxAttr_IBOutletCollection = 3
61280b57cec5SDimitry Andric } CXIdxAttrKind;
61290b57cec5SDimitry Andric 
61300b57cec5SDimitry Andric typedef struct {
61310b57cec5SDimitry Andric   CXIdxAttrKind kind;
61320b57cec5SDimitry Andric   CXCursor cursor;
61330b57cec5SDimitry Andric   CXIdxLoc loc;
61340b57cec5SDimitry Andric } CXIdxAttrInfo;
61350b57cec5SDimitry Andric 
61360b57cec5SDimitry Andric typedef struct {
61370b57cec5SDimitry Andric   CXIdxEntityKind kind;
61380b57cec5SDimitry Andric   CXIdxEntityCXXTemplateKind templateKind;
61390b57cec5SDimitry Andric   CXIdxEntityLanguage lang;
61400b57cec5SDimitry Andric   const char *name;
61410b57cec5SDimitry Andric   const char *USR;
61420b57cec5SDimitry Andric   CXCursor cursor;
61430b57cec5SDimitry Andric   const CXIdxAttrInfo *const *attributes;
61440b57cec5SDimitry Andric   unsigned numAttributes;
61450b57cec5SDimitry Andric } CXIdxEntityInfo;
61460b57cec5SDimitry Andric 
61470b57cec5SDimitry Andric typedef struct {
61480b57cec5SDimitry Andric   CXCursor cursor;
61490b57cec5SDimitry Andric } CXIdxContainerInfo;
61500b57cec5SDimitry Andric 
61510b57cec5SDimitry Andric typedef struct {
61520b57cec5SDimitry Andric   const CXIdxAttrInfo *attrInfo;
61530b57cec5SDimitry Andric   const CXIdxEntityInfo *objcClass;
61540b57cec5SDimitry Andric   CXCursor classCursor;
61550b57cec5SDimitry Andric   CXIdxLoc classLoc;
61560b57cec5SDimitry Andric } CXIdxIBOutletCollectionAttrInfo;
61570b57cec5SDimitry Andric 
61585ffd83dbSDimitry Andric typedef enum { CXIdxDeclFlag_Skipped = 0x1 } CXIdxDeclInfoFlags;
61590b57cec5SDimitry Andric 
61600b57cec5SDimitry Andric typedef struct {
61610b57cec5SDimitry Andric   const CXIdxEntityInfo *entityInfo;
61620b57cec5SDimitry Andric   CXCursor cursor;
61630b57cec5SDimitry Andric   CXIdxLoc loc;
61640b57cec5SDimitry Andric   const CXIdxContainerInfo *semanticContainer;
61650b57cec5SDimitry Andric   /**
61660b57cec5SDimitry Andric    * Generally same as #semanticContainer but can be different in
61670b57cec5SDimitry Andric    * cases like out-of-line C++ member functions.
61680b57cec5SDimitry Andric    */
61690b57cec5SDimitry Andric   const CXIdxContainerInfo *lexicalContainer;
61700b57cec5SDimitry Andric   int isRedeclaration;
61710b57cec5SDimitry Andric   int isDefinition;
61720b57cec5SDimitry Andric   int isContainer;
61730b57cec5SDimitry Andric   const CXIdxContainerInfo *declAsContainer;
61740b57cec5SDimitry Andric   /**
61750b57cec5SDimitry Andric    * Whether the declaration exists in code or was created implicitly
61760b57cec5SDimitry Andric    * by the compiler, e.g. implicit Objective-C methods for properties.
61770b57cec5SDimitry Andric    */
61780b57cec5SDimitry Andric   int isImplicit;
61790b57cec5SDimitry Andric   const CXIdxAttrInfo *const *attributes;
61800b57cec5SDimitry Andric   unsigned numAttributes;
61810b57cec5SDimitry Andric 
61820b57cec5SDimitry Andric   unsigned flags;
61830b57cec5SDimitry Andric 
61840b57cec5SDimitry Andric } CXIdxDeclInfo;
61850b57cec5SDimitry Andric 
61860b57cec5SDimitry Andric typedef enum {
61870b57cec5SDimitry Andric   CXIdxObjCContainer_ForwardRef = 0,
61880b57cec5SDimitry Andric   CXIdxObjCContainer_Interface = 1,
61890b57cec5SDimitry Andric   CXIdxObjCContainer_Implementation = 2
61900b57cec5SDimitry Andric } CXIdxObjCContainerKind;
61910b57cec5SDimitry Andric 
61920b57cec5SDimitry Andric typedef struct {
61930b57cec5SDimitry Andric   const CXIdxDeclInfo *declInfo;
61940b57cec5SDimitry Andric   CXIdxObjCContainerKind kind;
61950b57cec5SDimitry Andric } CXIdxObjCContainerDeclInfo;
61960b57cec5SDimitry Andric 
61970b57cec5SDimitry Andric typedef struct {
61980b57cec5SDimitry Andric   const CXIdxEntityInfo *base;
61990b57cec5SDimitry Andric   CXCursor cursor;
62000b57cec5SDimitry Andric   CXIdxLoc loc;
62010b57cec5SDimitry Andric } CXIdxBaseClassInfo;
62020b57cec5SDimitry Andric 
62030b57cec5SDimitry Andric typedef struct {
62040b57cec5SDimitry Andric   const CXIdxEntityInfo *protocol;
62050b57cec5SDimitry Andric   CXCursor cursor;
62060b57cec5SDimitry Andric   CXIdxLoc loc;
62070b57cec5SDimitry Andric } CXIdxObjCProtocolRefInfo;
62080b57cec5SDimitry Andric 
62090b57cec5SDimitry Andric typedef struct {
62100b57cec5SDimitry Andric   const CXIdxObjCProtocolRefInfo *const *protocols;
62110b57cec5SDimitry Andric   unsigned numProtocols;
62120b57cec5SDimitry Andric } CXIdxObjCProtocolRefListInfo;
62130b57cec5SDimitry Andric 
62140b57cec5SDimitry Andric typedef struct {
62150b57cec5SDimitry Andric   const CXIdxObjCContainerDeclInfo *containerInfo;
62160b57cec5SDimitry Andric   const CXIdxBaseClassInfo *superInfo;
62170b57cec5SDimitry Andric   const CXIdxObjCProtocolRefListInfo *protocols;
62180b57cec5SDimitry Andric } CXIdxObjCInterfaceDeclInfo;
62190b57cec5SDimitry Andric 
62200b57cec5SDimitry Andric typedef struct {
62210b57cec5SDimitry Andric   const CXIdxObjCContainerDeclInfo *containerInfo;
62220b57cec5SDimitry Andric   const CXIdxEntityInfo *objcClass;
62230b57cec5SDimitry Andric   CXCursor classCursor;
62240b57cec5SDimitry Andric   CXIdxLoc classLoc;
62250b57cec5SDimitry Andric   const CXIdxObjCProtocolRefListInfo *protocols;
62260b57cec5SDimitry Andric } CXIdxObjCCategoryDeclInfo;
62270b57cec5SDimitry Andric 
62280b57cec5SDimitry Andric typedef struct {
62290b57cec5SDimitry Andric   const CXIdxDeclInfo *declInfo;
62300b57cec5SDimitry Andric   const CXIdxEntityInfo *getter;
62310b57cec5SDimitry Andric   const CXIdxEntityInfo *setter;
62320b57cec5SDimitry Andric } CXIdxObjCPropertyDeclInfo;
62330b57cec5SDimitry Andric 
62340b57cec5SDimitry Andric typedef struct {
62350b57cec5SDimitry Andric   const CXIdxDeclInfo *declInfo;
62360b57cec5SDimitry Andric   const CXIdxBaseClassInfo *const *bases;
62370b57cec5SDimitry Andric   unsigned numBases;
62380b57cec5SDimitry Andric } CXIdxCXXClassDeclInfo;
62390b57cec5SDimitry Andric 
62400b57cec5SDimitry Andric /**
62410b57cec5SDimitry Andric  * Data for IndexerCallbacks#indexEntityReference.
62420b57cec5SDimitry Andric  *
62430b57cec5SDimitry Andric  * This may be deprecated in a future version as this duplicates
62440b57cec5SDimitry Andric  * the \c CXSymbolRole_Implicit bit in \c CXSymbolRole.
62450b57cec5SDimitry Andric  */
62460b57cec5SDimitry Andric typedef enum {
62470b57cec5SDimitry Andric   /**
62480b57cec5SDimitry Andric    * The entity is referenced directly in user's code.
62490b57cec5SDimitry Andric    */
62500b57cec5SDimitry Andric   CXIdxEntityRef_Direct = 1,
62510b57cec5SDimitry Andric   /**
62520b57cec5SDimitry Andric    * An implicit reference, e.g. a reference of an Objective-C method
62530b57cec5SDimitry Andric    * via the dot syntax.
62540b57cec5SDimitry Andric    */
62550b57cec5SDimitry Andric   CXIdxEntityRef_Implicit = 2
62560b57cec5SDimitry Andric } CXIdxEntityRefKind;
62570b57cec5SDimitry Andric 
62580b57cec5SDimitry Andric /**
62590b57cec5SDimitry Andric  * Roles that are attributed to symbol occurrences.
62600b57cec5SDimitry Andric  *
62610b57cec5SDimitry Andric  * Internal: this currently mirrors low 9 bits of clang::index::SymbolRole with
62620b57cec5SDimitry Andric  * higher bits zeroed. These high bits may be exposed in the future.
62630b57cec5SDimitry Andric  */
62640b57cec5SDimitry Andric typedef enum {
62650b57cec5SDimitry Andric   CXSymbolRole_None = 0,
62660b57cec5SDimitry Andric   CXSymbolRole_Declaration = 1 << 0,
62670b57cec5SDimitry Andric   CXSymbolRole_Definition = 1 << 1,
62680b57cec5SDimitry Andric   CXSymbolRole_Reference = 1 << 2,
62690b57cec5SDimitry Andric   CXSymbolRole_Read = 1 << 3,
62700b57cec5SDimitry Andric   CXSymbolRole_Write = 1 << 4,
62710b57cec5SDimitry Andric   CXSymbolRole_Call = 1 << 5,
62720b57cec5SDimitry Andric   CXSymbolRole_Dynamic = 1 << 6,
62730b57cec5SDimitry Andric   CXSymbolRole_AddressOf = 1 << 7,
62740b57cec5SDimitry Andric   CXSymbolRole_Implicit = 1 << 8
62750b57cec5SDimitry Andric } CXSymbolRole;
62760b57cec5SDimitry Andric 
62770b57cec5SDimitry Andric /**
62780b57cec5SDimitry Andric  * Data for IndexerCallbacks#indexEntityReference.
62790b57cec5SDimitry Andric  */
62800b57cec5SDimitry Andric typedef struct {
62810b57cec5SDimitry Andric   CXIdxEntityRefKind kind;
62820b57cec5SDimitry Andric   /**
62830b57cec5SDimitry Andric    * Reference cursor.
62840b57cec5SDimitry Andric    */
62850b57cec5SDimitry Andric   CXCursor cursor;
62860b57cec5SDimitry Andric   CXIdxLoc loc;
62870b57cec5SDimitry Andric   /**
62880b57cec5SDimitry Andric    * The entity that gets referenced.
62890b57cec5SDimitry Andric    */
62900b57cec5SDimitry Andric   const CXIdxEntityInfo *referencedEntity;
62910b57cec5SDimitry Andric   /**
62920b57cec5SDimitry Andric    * Immediate "parent" of the reference. For example:
62930b57cec5SDimitry Andric    *
62940b57cec5SDimitry Andric    * \code
62950b57cec5SDimitry Andric    * Foo *var;
62960b57cec5SDimitry Andric    * \endcode
62970b57cec5SDimitry Andric    *
62980b57cec5SDimitry Andric    * The parent of reference of type 'Foo' is the variable 'var'.
62990b57cec5SDimitry Andric    * For references inside statement bodies of functions/methods,
63000b57cec5SDimitry Andric    * the parentEntity will be the function/method.
63010b57cec5SDimitry Andric    */
63020b57cec5SDimitry Andric   const CXIdxEntityInfo *parentEntity;
63030b57cec5SDimitry Andric   /**
63040b57cec5SDimitry Andric    * Lexical container context of the reference.
63050b57cec5SDimitry Andric    */
63060b57cec5SDimitry Andric   const CXIdxContainerInfo *container;
63070b57cec5SDimitry Andric   /**
63080b57cec5SDimitry Andric    * Sets of symbol roles of the reference.
63090b57cec5SDimitry Andric    */
63100b57cec5SDimitry Andric   CXSymbolRole role;
63110b57cec5SDimitry Andric } CXIdxEntityRefInfo;
63120b57cec5SDimitry Andric 
63130b57cec5SDimitry Andric /**
63140b57cec5SDimitry Andric  * A group of callbacks used by #clang_indexSourceFile and
63150b57cec5SDimitry Andric  * #clang_indexTranslationUnit.
63160b57cec5SDimitry Andric  */
63170b57cec5SDimitry Andric typedef struct {
63180b57cec5SDimitry Andric   /**
63190b57cec5SDimitry Andric    * Called periodically to check whether indexing should be aborted.
63200b57cec5SDimitry Andric    * Should return 0 to continue, and non-zero to abort.
63210b57cec5SDimitry Andric    */
63220b57cec5SDimitry Andric   int (*abortQuery)(CXClientData client_data, void *reserved);
63230b57cec5SDimitry Andric 
63240b57cec5SDimitry Andric   /**
63250b57cec5SDimitry Andric    * Called at the end of indexing; passes the complete diagnostic set.
63260b57cec5SDimitry Andric    */
63275ffd83dbSDimitry Andric   void (*diagnostic)(CXClientData client_data, CXDiagnosticSet, void *reserved);
63280b57cec5SDimitry Andric 
63295ffd83dbSDimitry Andric   CXIdxClientFile (*enteredMainFile)(CXClientData client_data, CXFile mainFile,
63305ffd83dbSDimitry Andric                                      void *reserved);
63310b57cec5SDimitry Andric 
63320b57cec5SDimitry Andric   /**
63330b57cec5SDimitry Andric    * Called when a file gets \#included/\#imported.
63340b57cec5SDimitry Andric    */
63350b57cec5SDimitry Andric   CXIdxClientFile (*ppIncludedFile)(CXClientData client_data,
63360b57cec5SDimitry Andric                                     const CXIdxIncludedFileInfo *);
63370b57cec5SDimitry Andric 
63380b57cec5SDimitry Andric   /**
63390b57cec5SDimitry Andric    * Called when a AST file (PCH or module) gets imported.
63400b57cec5SDimitry Andric    *
63410b57cec5SDimitry Andric    * AST files will not get indexed (there will not be callbacks to index all
63420b57cec5SDimitry Andric    * the entities in an AST file). The recommended action is that, if the AST
63430b57cec5SDimitry Andric    * file is not already indexed, to initiate a new indexing job specific to
63440b57cec5SDimitry Andric    * the AST file.
63450b57cec5SDimitry Andric    */
63460b57cec5SDimitry Andric   CXIdxClientASTFile (*importedASTFile)(CXClientData client_data,
63470b57cec5SDimitry Andric                                         const CXIdxImportedASTFileInfo *);
63480b57cec5SDimitry Andric 
63490b57cec5SDimitry Andric   /**
63500b57cec5SDimitry Andric    * Called at the beginning of indexing a translation unit.
63510b57cec5SDimitry Andric    */
63520b57cec5SDimitry Andric   CXIdxClientContainer (*startedTranslationUnit)(CXClientData client_data,
63530b57cec5SDimitry Andric                                                  void *reserved);
63540b57cec5SDimitry Andric 
63555ffd83dbSDimitry Andric   void (*indexDeclaration)(CXClientData client_data, const CXIdxDeclInfo *);
63560b57cec5SDimitry Andric 
63570b57cec5SDimitry Andric   /**
63580b57cec5SDimitry Andric    * Called to index a reference of an entity.
63590b57cec5SDimitry Andric    */
63600b57cec5SDimitry Andric   void (*indexEntityReference)(CXClientData client_data,
63610b57cec5SDimitry Andric                                const CXIdxEntityRefInfo *);
63620b57cec5SDimitry Andric 
63630b57cec5SDimitry Andric } IndexerCallbacks;
63640b57cec5SDimitry Andric 
63650b57cec5SDimitry Andric CINDEX_LINKAGE int clang_index_isEntityObjCContainerKind(CXIdxEntityKind);
63660b57cec5SDimitry Andric CINDEX_LINKAGE const CXIdxObjCContainerDeclInfo *
63670b57cec5SDimitry Andric clang_index_getObjCContainerDeclInfo(const CXIdxDeclInfo *);
63680b57cec5SDimitry Andric 
63690b57cec5SDimitry Andric CINDEX_LINKAGE const CXIdxObjCInterfaceDeclInfo *
63700b57cec5SDimitry Andric clang_index_getObjCInterfaceDeclInfo(const CXIdxDeclInfo *);
63710b57cec5SDimitry Andric 
63720b57cec5SDimitry Andric CINDEX_LINKAGE
63730b57cec5SDimitry Andric const CXIdxObjCCategoryDeclInfo *
63740b57cec5SDimitry Andric clang_index_getObjCCategoryDeclInfo(const CXIdxDeclInfo *);
63750b57cec5SDimitry Andric 
63760b57cec5SDimitry Andric CINDEX_LINKAGE const CXIdxObjCProtocolRefListInfo *
63770b57cec5SDimitry Andric clang_index_getObjCProtocolRefListInfo(const CXIdxDeclInfo *);
63780b57cec5SDimitry Andric 
63790b57cec5SDimitry Andric CINDEX_LINKAGE const CXIdxObjCPropertyDeclInfo *
63800b57cec5SDimitry Andric clang_index_getObjCPropertyDeclInfo(const CXIdxDeclInfo *);
63810b57cec5SDimitry Andric 
63820b57cec5SDimitry Andric CINDEX_LINKAGE const CXIdxIBOutletCollectionAttrInfo *
63830b57cec5SDimitry Andric clang_index_getIBOutletCollectionAttrInfo(const CXIdxAttrInfo *);
63840b57cec5SDimitry Andric 
63850b57cec5SDimitry Andric CINDEX_LINKAGE const CXIdxCXXClassDeclInfo *
63860b57cec5SDimitry Andric clang_index_getCXXClassDeclInfo(const CXIdxDeclInfo *);
63870b57cec5SDimitry Andric 
63880b57cec5SDimitry Andric /**
63890b57cec5SDimitry Andric  * For retrieving a custom CXIdxClientContainer attached to a
63900b57cec5SDimitry Andric  * container.
63910b57cec5SDimitry Andric  */
63920b57cec5SDimitry Andric CINDEX_LINKAGE CXIdxClientContainer
63930b57cec5SDimitry Andric clang_index_getClientContainer(const CXIdxContainerInfo *);
63940b57cec5SDimitry Andric 
63950b57cec5SDimitry Andric /**
63960b57cec5SDimitry Andric  * For setting a custom CXIdxClientContainer attached to a
63970b57cec5SDimitry Andric  * container.
63980b57cec5SDimitry Andric  */
63995ffd83dbSDimitry Andric CINDEX_LINKAGE void clang_index_setClientContainer(const CXIdxContainerInfo *,
64005ffd83dbSDimitry Andric                                                    CXIdxClientContainer);
64010b57cec5SDimitry Andric 
64020b57cec5SDimitry Andric /**
64030b57cec5SDimitry Andric  * For retrieving a custom CXIdxClientEntity attached to an entity.
64040b57cec5SDimitry Andric  */
64050b57cec5SDimitry Andric CINDEX_LINKAGE CXIdxClientEntity
64060b57cec5SDimitry Andric clang_index_getClientEntity(const CXIdxEntityInfo *);
64070b57cec5SDimitry Andric 
64080b57cec5SDimitry Andric /**
64090b57cec5SDimitry Andric  * For setting a custom CXIdxClientEntity attached to an entity.
64100b57cec5SDimitry Andric  */
64115ffd83dbSDimitry Andric CINDEX_LINKAGE void clang_index_setClientEntity(const CXIdxEntityInfo *,
64125ffd83dbSDimitry Andric                                                 CXIdxClientEntity);
64130b57cec5SDimitry Andric 
64140b57cec5SDimitry Andric /**
64150b57cec5SDimitry Andric  * An indexing action/session, to be applied to one or multiple
64160b57cec5SDimitry Andric  * translation units.
64170b57cec5SDimitry Andric  */
64180b57cec5SDimitry Andric typedef void *CXIndexAction;
64190b57cec5SDimitry Andric 
64200b57cec5SDimitry Andric /**
64210b57cec5SDimitry Andric  * An indexing action/session, to be applied to one or multiple
64220b57cec5SDimitry Andric  * translation units.
64230b57cec5SDimitry Andric  *
64240b57cec5SDimitry Andric  * \param CIdx The index object with which the index action will be associated.
64250b57cec5SDimitry Andric  */
64260b57cec5SDimitry Andric CINDEX_LINKAGE CXIndexAction clang_IndexAction_create(CXIndex CIdx);
64270b57cec5SDimitry Andric 
64280b57cec5SDimitry Andric /**
64290b57cec5SDimitry Andric  * Destroy the given index action.
64300b57cec5SDimitry Andric  *
64310b57cec5SDimitry Andric  * The index action must not be destroyed until all of the translation units
64320b57cec5SDimitry Andric  * created within that index action have been destroyed.
64330b57cec5SDimitry Andric  */
64340b57cec5SDimitry Andric CINDEX_LINKAGE void clang_IndexAction_dispose(CXIndexAction);
64350b57cec5SDimitry Andric 
64360b57cec5SDimitry Andric typedef enum {
64370b57cec5SDimitry Andric   /**
64380b57cec5SDimitry Andric    * Used to indicate that no special indexing options are needed.
64390b57cec5SDimitry Andric    */
64400b57cec5SDimitry Andric   CXIndexOpt_None = 0x0,
64410b57cec5SDimitry Andric 
64420b57cec5SDimitry Andric   /**
64430b57cec5SDimitry Andric    * Used to indicate that IndexerCallbacks#indexEntityReference should
64440b57cec5SDimitry Andric    * be invoked for only one reference of an entity per source file that does
64450b57cec5SDimitry Andric    * not also include a declaration/definition of the entity.
64460b57cec5SDimitry Andric    */
64470b57cec5SDimitry Andric   CXIndexOpt_SuppressRedundantRefs = 0x1,
64480b57cec5SDimitry Andric 
64490b57cec5SDimitry Andric   /**
64500b57cec5SDimitry Andric    * Function-local symbols should be indexed. If this is not set
64510b57cec5SDimitry Andric    * function-local symbols will be ignored.
64520b57cec5SDimitry Andric    */
64530b57cec5SDimitry Andric   CXIndexOpt_IndexFunctionLocalSymbols = 0x2,
64540b57cec5SDimitry Andric 
64550b57cec5SDimitry Andric   /**
64560b57cec5SDimitry Andric    * Implicit function/class template instantiations should be indexed.
64570b57cec5SDimitry Andric    * If this is not set, implicit instantiations will be ignored.
64580b57cec5SDimitry Andric    */
64590b57cec5SDimitry Andric   CXIndexOpt_IndexImplicitTemplateInstantiations = 0x4,
64600b57cec5SDimitry Andric 
64610b57cec5SDimitry Andric   /**
64620b57cec5SDimitry Andric    * Suppress all compiler warnings when parsing for indexing.
64630b57cec5SDimitry Andric    */
64640b57cec5SDimitry Andric   CXIndexOpt_SuppressWarnings = 0x8,
64650b57cec5SDimitry Andric 
64660b57cec5SDimitry Andric   /**
64670b57cec5SDimitry Andric    * Skip a function/method body that was already parsed during an
64680b57cec5SDimitry Andric    * indexing session associated with a \c CXIndexAction object.
64690b57cec5SDimitry Andric    * Bodies in system headers are always skipped.
64700b57cec5SDimitry Andric    */
64710b57cec5SDimitry Andric   CXIndexOpt_SkipParsedBodiesInSession = 0x10
64720b57cec5SDimitry Andric 
64730b57cec5SDimitry Andric } CXIndexOptFlags;
64740b57cec5SDimitry Andric 
64750b57cec5SDimitry Andric /**
64760b57cec5SDimitry Andric  * Index the given source file and the translation unit corresponding
64770b57cec5SDimitry Andric  * to that file via callbacks implemented through #IndexerCallbacks.
64780b57cec5SDimitry Andric  *
64790b57cec5SDimitry Andric  * \param client_data pointer data supplied by the client, which will
64800b57cec5SDimitry Andric  * be passed to the invoked callbacks.
64810b57cec5SDimitry Andric  *
64820b57cec5SDimitry Andric  * \param index_callbacks Pointer to indexing callbacks that the client
64830b57cec5SDimitry Andric  * implements.
64840b57cec5SDimitry Andric  *
64850b57cec5SDimitry Andric  * \param index_callbacks_size Size of #IndexerCallbacks structure that gets
64860b57cec5SDimitry Andric  * passed in index_callbacks.
64870b57cec5SDimitry Andric  *
64880b57cec5SDimitry Andric  * \param index_options A bitmask of options that affects how indexing is
64890b57cec5SDimitry Andric  * performed. This should be a bitwise OR of the CXIndexOpt_XXX flags.
64900b57cec5SDimitry Andric  *
64910b57cec5SDimitry Andric  * \param[out] out_TU pointer to store a \c CXTranslationUnit that can be
64920b57cec5SDimitry Andric  * reused after indexing is finished. Set to \c NULL if you do not require it.
64930b57cec5SDimitry Andric  *
64940b57cec5SDimitry Andric  * \returns 0 on success or if there were errors from which the compiler could
64950b57cec5SDimitry Andric  * recover.  If there is a failure from which there is no recovery, returns
64960b57cec5SDimitry Andric  * a non-zero \c CXErrorCode.
64970b57cec5SDimitry Andric  *
64980b57cec5SDimitry Andric  * The rest of the parameters are the same as #clang_parseTranslationUnit.
64990b57cec5SDimitry Andric  */
65005ffd83dbSDimitry Andric CINDEX_LINKAGE int clang_indexSourceFile(
65015ffd83dbSDimitry Andric     CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks,
65025ffd83dbSDimitry Andric     unsigned index_callbacks_size, unsigned index_options,
65035ffd83dbSDimitry Andric     const char *source_filename, const char *const *command_line_args,
65045ffd83dbSDimitry Andric     int num_command_line_args, struct CXUnsavedFile *unsaved_files,
65055ffd83dbSDimitry Andric     unsigned num_unsaved_files, CXTranslationUnit *out_TU, unsigned TU_options);
65060b57cec5SDimitry Andric 
65070b57cec5SDimitry Andric /**
65080b57cec5SDimitry Andric  * Same as clang_indexSourceFile but requires a full command line
65090b57cec5SDimitry Andric  * for \c command_line_args including argv[0]. This is useful if the standard
65100b57cec5SDimitry Andric  * library paths are relative to the binary.
65110b57cec5SDimitry Andric  */
65120b57cec5SDimitry Andric CINDEX_LINKAGE int clang_indexSourceFileFullArgv(
65130b57cec5SDimitry Andric     CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks,
65140b57cec5SDimitry Andric     unsigned index_callbacks_size, unsigned index_options,
65150b57cec5SDimitry Andric     const char *source_filename, const char *const *command_line_args,
65160b57cec5SDimitry Andric     int num_command_line_args, struct CXUnsavedFile *unsaved_files,
65170b57cec5SDimitry Andric     unsigned num_unsaved_files, CXTranslationUnit *out_TU, unsigned TU_options);
65180b57cec5SDimitry Andric 
65190b57cec5SDimitry Andric /**
65200b57cec5SDimitry Andric  * Index the given translation unit via callbacks implemented through
65210b57cec5SDimitry Andric  * #IndexerCallbacks.
65220b57cec5SDimitry Andric  *
65230b57cec5SDimitry Andric  * The order of callback invocations is not guaranteed to be the same as
65240b57cec5SDimitry Andric  * when indexing a source file. The high level order will be:
65250b57cec5SDimitry Andric  *
65260b57cec5SDimitry Andric  *   -Preprocessor callbacks invocations
65270b57cec5SDimitry Andric  *   -Declaration/reference callbacks invocations
65280b57cec5SDimitry Andric  *   -Diagnostic callback invocations
65290b57cec5SDimitry Andric  *
65300b57cec5SDimitry Andric  * The parameters are the same as #clang_indexSourceFile.
65310b57cec5SDimitry Andric  *
65320b57cec5SDimitry Andric  * \returns If there is a failure from which there is no recovery, returns
65330b57cec5SDimitry Andric  * non-zero, otherwise returns 0.
65340b57cec5SDimitry Andric  */
65355ffd83dbSDimitry Andric CINDEX_LINKAGE int clang_indexTranslationUnit(
65365ffd83dbSDimitry Andric     CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks,
65375ffd83dbSDimitry Andric     unsigned index_callbacks_size, unsigned index_options, CXTranslationUnit);
65380b57cec5SDimitry Andric 
65390b57cec5SDimitry Andric /**
65400b57cec5SDimitry Andric  * Retrieve the CXIdxFile, file, line, column, and offset represented by
65410b57cec5SDimitry Andric  * the given CXIdxLoc.
65420b57cec5SDimitry Andric  *
65430b57cec5SDimitry Andric  * If the location refers into a macro expansion, retrieves the
65440b57cec5SDimitry Andric  * location of the macro expansion and if it refers into a macro argument
65450b57cec5SDimitry Andric  * retrieves the location of the argument.
65460b57cec5SDimitry Andric  */
65470b57cec5SDimitry Andric CINDEX_LINKAGE void clang_indexLoc_getFileLocation(CXIdxLoc loc,
65480b57cec5SDimitry Andric                                                    CXIdxClientFile *indexFile,
65495ffd83dbSDimitry Andric                                                    CXFile *file, unsigned *line,
65500b57cec5SDimitry Andric                                                    unsigned *column,
65510b57cec5SDimitry Andric                                                    unsigned *offset);
65520b57cec5SDimitry Andric 
65530b57cec5SDimitry Andric /**
65540b57cec5SDimitry Andric  * Retrieve the CXSourceLocation represented by the given CXIdxLoc.
65550b57cec5SDimitry Andric  */
65560b57cec5SDimitry Andric CINDEX_LINKAGE
65570b57cec5SDimitry Andric CXSourceLocation clang_indexLoc_getCXSourceLocation(CXIdxLoc loc);
65580b57cec5SDimitry Andric 
65590b57cec5SDimitry Andric /**
65600b57cec5SDimitry Andric  * Visitor invoked for each field found by a traversal.
65610b57cec5SDimitry Andric  *
65620b57cec5SDimitry Andric  * This visitor function will be invoked for each field found by
65630b57cec5SDimitry Andric  * \c clang_Type_visitFields. Its first argument is the cursor being
65640b57cec5SDimitry Andric  * visited, its second argument is the client data provided to
65650b57cec5SDimitry Andric  * \c clang_Type_visitFields.
65660b57cec5SDimitry Andric  *
65670b57cec5SDimitry Andric  * The visitor should return one of the \c CXVisitorResult values
65680b57cec5SDimitry Andric  * to direct \c clang_Type_visitFields.
65690b57cec5SDimitry Andric  */
65700b57cec5SDimitry Andric typedef enum CXVisitorResult (*CXFieldVisitor)(CXCursor C,
65710b57cec5SDimitry Andric                                                CXClientData client_data);
65720b57cec5SDimitry Andric 
65730b57cec5SDimitry Andric /**
65740b57cec5SDimitry Andric  * Visit the fields of a particular type.
65750b57cec5SDimitry Andric  *
65760b57cec5SDimitry Andric  * This function visits all the direct fields of the given cursor,
65770b57cec5SDimitry Andric  * invoking the given \p visitor function with the cursors of each
65780b57cec5SDimitry Andric  * visited field. The traversal may be ended prematurely, if
65790b57cec5SDimitry Andric  * the visitor returns \c CXFieldVisit_Break.
65800b57cec5SDimitry Andric  *
65810b57cec5SDimitry Andric  * \param T the record type whose field may be visited.
65820b57cec5SDimitry Andric  *
65830b57cec5SDimitry Andric  * \param visitor the visitor function that will be invoked for each
65840b57cec5SDimitry Andric  * field of \p T.
65850b57cec5SDimitry Andric  *
65860b57cec5SDimitry Andric  * \param client_data pointer data supplied by the client, which will
65870b57cec5SDimitry Andric  * be passed to the visitor each time it is invoked.
65880b57cec5SDimitry Andric  *
65890b57cec5SDimitry Andric  * \returns a non-zero value if the traversal was terminated
65900b57cec5SDimitry Andric  * prematurely by the visitor returning \c CXFieldVisit_Break.
65910b57cec5SDimitry Andric  */
65925ffd83dbSDimitry Andric CINDEX_LINKAGE unsigned clang_Type_visitFields(CXType T, CXFieldVisitor visitor,
65930b57cec5SDimitry Andric                                                CXClientData client_data);
65940b57cec5SDimitry Andric 
65950b57cec5SDimitry Andric /**
659606c3fb27SDimitry Andric  * Describes the kind of binary operators.
659706c3fb27SDimitry Andric  */
659806c3fb27SDimitry Andric enum CXBinaryOperatorKind {
659906c3fb27SDimitry Andric   /** This value describes cursors which are not binary operators. */
660006c3fb27SDimitry Andric   CXBinaryOperator_Invalid,
660106c3fb27SDimitry Andric   /** C++ Pointer - to - member operator. */
660206c3fb27SDimitry Andric   CXBinaryOperator_PtrMemD,
660306c3fb27SDimitry Andric   /** C++ Pointer - to - member operator. */
660406c3fb27SDimitry Andric   CXBinaryOperator_PtrMemI,
660506c3fb27SDimitry Andric   /** Multiplication operator. */
660606c3fb27SDimitry Andric   CXBinaryOperator_Mul,
660706c3fb27SDimitry Andric   /** Division operator. */
660806c3fb27SDimitry Andric   CXBinaryOperator_Div,
660906c3fb27SDimitry Andric   /** Remainder operator. */
661006c3fb27SDimitry Andric   CXBinaryOperator_Rem,
661106c3fb27SDimitry Andric   /** Addition operator. */
661206c3fb27SDimitry Andric   CXBinaryOperator_Add,
661306c3fb27SDimitry Andric   /** Subtraction operator. */
661406c3fb27SDimitry Andric   CXBinaryOperator_Sub,
661506c3fb27SDimitry Andric   /** Bitwise shift left operator. */
661606c3fb27SDimitry Andric   CXBinaryOperator_Shl,
661706c3fb27SDimitry Andric   /** Bitwise shift right operator. */
661806c3fb27SDimitry Andric   CXBinaryOperator_Shr,
661906c3fb27SDimitry Andric   /** C++ three-way comparison (spaceship) operator. */
662006c3fb27SDimitry Andric   CXBinaryOperator_Cmp,
662106c3fb27SDimitry Andric   /** Less than operator. */
662206c3fb27SDimitry Andric   CXBinaryOperator_LT,
662306c3fb27SDimitry Andric   /** Greater than operator. */
662406c3fb27SDimitry Andric   CXBinaryOperator_GT,
662506c3fb27SDimitry Andric   /** Less or equal operator. */
662606c3fb27SDimitry Andric   CXBinaryOperator_LE,
662706c3fb27SDimitry Andric   /** Greater or equal operator. */
662806c3fb27SDimitry Andric   CXBinaryOperator_GE,
662906c3fb27SDimitry Andric   /** Equal operator. */
663006c3fb27SDimitry Andric   CXBinaryOperator_EQ,
663106c3fb27SDimitry Andric   /** Not equal operator. */
663206c3fb27SDimitry Andric   CXBinaryOperator_NE,
663306c3fb27SDimitry Andric   /** Bitwise AND operator. */
663406c3fb27SDimitry Andric   CXBinaryOperator_And,
663506c3fb27SDimitry Andric   /** Bitwise XOR operator. */
663606c3fb27SDimitry Andric   CXBinaryOperator_Xor,
663706c3fb27SDimitry Andric   /** Bitwise OR operator. */
663806c3fb27SDimitry Andric   CXBinaryOperator_Or,
663906c3fb27SDimitry Andric   /** Logical AND operator. */
664006c3fb27SDimitry Andric   CXBinaryOperator_LAnd,
664106c3fb27SDimitry Andric   /** Logical OR operator. */
664206c3fb27SDimitry Andric   CXBinaryOperator_LOr,
664306c3fb27SDimitry Andric   /** Assignment operator. */
664406c3fb27SDimitry Andric   CXBinaryOperator_Assign,
664506c3fb27SDimitry Andric   /** Multiplication assignment operator. */
664606c3fb27SDimitry Andric   CXBinaryOperator_MulAssign,
664706c3fb27SDimitry Andric   /** Division assignment operator. */
664806c3fb27SDimitry Andric   CXBinaryOperator_DivAssign,
664906c3fb27SDimitry Andric   /** Remainder assignment operator. */
665006c3fb27SDimitry Andric   CXBinaryOperator_RemAssign,
665106c3fb27SDimitry Andric   /** Addition assignment operator. */
665206c3fb27SDimitry Andric   CXBinaryOperator_AddAssign,
665306c3fb27SDimitry Andric   /** Subtraction assignment operator. */
665406c3fb27SDimitry Andric   CXBinaryOperator_SubAssign,
665506c3fb27SDimitry Andric   /** Bitwise shift left assignment operator. */
665606c3fb27SDimitry Andric   CXBinaryOperator_ShlAssign,
665706c3fb27SDimitry Andric   /** Bitwise shift right assignment operator. */
665806c3fb27SDimitry Andric   CXBinaryOperator_ShrAssign,
665906c3fb27SDimitry Andric   /** Bitwise AND assignment operator. */
666006c3fb27SDimitry Andric   CXBinaryOperator_AndAssign,
666106c3fb27SDimitry Andric   /** Bitwise XOR assignment operator. */
666206c3fb27SDimitry Andric   CXBinaryOperator_XorAssign,
666306c3fb27SDimitry Andric   /** Bitwise OR assignment operator. */
666406c3fb27SDimitry Andric   CXBinaryOperator_OrAssign,
666506c3fb27SDimitry Andric   /** Comma operator. */
666606c3fb27SDimitry Andric   CXBinaryOperator_Comma
666706c3fb27SDimitry Andric };
666806c3fb27SDimitry Andric 
666906c3fb27SDimitry Andric /**
667006c3fb27SDimitry Andric  * Retrieve the spelling of a given CXBinaryOperatorKind.
667106c3fb27SDimitry Andric  */
667206c3fb27SDimitry Andric CINDEX_LINKAGE CXString
667306c3fb27SDimitry Andric clang_getBinaryOperatorKindSpelling(enum CXBinaryOperatorKind kind);
667406c3fb27SDimitry Andric 
667506c3fb27SDimitry Andric /**
667606c3fb27SDimitry Andric  * Retrieve the binary operator kind of this cursor.
667706c3fb27SDimitry Andric  *
667806c3fb27SDimitry Andric  * If this cursor is not a binary operator then returns Invalid.
667906c3fb27SDimitry Andric  */
668006c3fb27SDimitry Andric CINDEX_LINKAGE enum CXBinaryOperatorKind
668106c3fb27SDimitry Andric clang_getCursorBinaryOperatorKind(CXCursor cursor);
668206c3fb27SDimitry Andric 
668306c3fb27SDimitry Andric /**
668406c3fb27SDimitry Andric  * Describes the kind of unary operators.
668506c3fb27SDimitry Andric  */
668606c3fb27SDimitry Andric enum CXUnaryOperatorKind {
668706c3fb27SDimitry Andric   /** This value describes cursors which are not unary operators. */
668806c3fb27SDimitry Andric   CXUnaryOperator_Invalid,
668906c3fb27SDimitry Andric   /** Postfix increment operator. */
669006c3fb27SDimitry Andric   CXUnaryOperator_PostInc,
669106c3fb27SDimitry Andric   /** Postfix decrement operator. */
669206c3fb27SDimitry Andric   CXUnaryOperator_PostDec,
669306c3fb27SDimitry Andric   /** Prefix increment operator. */
669406c3fb27SDimitry Andric   CXUnaryOperator_PreInc,
669506c3fb27SDimitry Andric   /** Prefix decrement operator. */
669606c3fb27SDimitry Andric   CXUnaryOperator_PreDec,
669706c3fb27SDimitry Andric   /** Address of operator. */
669806c3fb27SDimitry Andric   CXUnaryOperator_AddrOf,
669906c3fb27SDimitry Andric   /** Dereference operator. */
670006c3fb27SDimitry Andric   CXUnaryOperator_Deref,
670106c3fb27SDimitry Andric   /** Plus operator. */
670206c3fb27SDimitry Andric   CXUnaryOperator_Plus,
670306c3fb27SDimitry Andric   /** Minus operator. */
670406c3fb27SDimitry Andric   CXUnaryOperator_Minus,
670506c3fb27SDimitry Andric   /** Not operator. */
670606c3fb27SDimitry Andric   CXUnaryOperator_Not,
670706c3fb27SDimitry Andric   /** LNot operator. */
670806c3fb27SDimitry Andric   CXUnaryOperator_LNot,
670906c3fb27SDimitry Andric   /** "__real expr" operator. */
671006c3fb27SDimitry Andric   CXUnaryOperator_Real,
671106c3fb27SDimitry Andric   /** "__imag expr" operator. */
671206c3fb27SDimitry Andric   CXUnaryOperator_Imag,
671306c3fb27SDimitry Andric   /** __extension__ marker operator. */
671406c3fb27SDimitry Andric   CXUnaryOperator_Extension,
671506c3fb27SDimitry Andric   /** C++ co_await operator. */
671606c3fb27SDimitry Andric   CXUnaryOperator_Coawait
671706c3fb27SDimitry Andric };
671806c3fb27SDimitry Andric 
671906c3fb27SDimitry Andric /**
672006c3fb27SDimitry Andric  * Retrieve the spelling of a given CXUnaryOperatorKind.
672106c3fb27SDimitry Andric  */
672206c3fb27SDimitry Andric CINDEX_LINKAGE CXString
672306c3fb27SDimitry Andric clang_getUnaryOperatorKindSpelling(enum CXUnaryOperatorKind kind);
672406c3fb27SDimitry Andric 
672506c3fb27SDimitry Andric /**
672606c3fb27SDimitry Andric  * Retrieve the unary operator kind of this cursor.
672706c3fb27SDimitry Andric  *
672806c3fb27SDimitry Andric  * If this cursor is not a unary operator then returns Invalid.
672906c3fb27SDimitry Andric  */
673006c3fb27SDimitry Andric CINDEX_LINKAGE enum CXUnaryOperatorKind
673106c3fb27SDimitry Andric clang_getCursorUnaryOperatorKind(CXCursor cursor);
673206c3fb27SDimitry Andric 
673306c3fb27SDimitry Andric /**
67340b57cec5SDimitry Andric  * @}
67350b57cec5SDimitry Andric  */
67360b57cec5SDimitry Andric 
67370b57cec5SDimitry Andric /**
67380b57cec5SDimitry Andric  * @}
67390b57cec5SDimitry Andric  */
67400b57cec5SDimitry Andric 
6741480093f4SDimitry Andric LLVM_CLANG_C_EXTERN_C_END
6742480093f4SDimitry Andric 
67430b57cec5SDimitry Andric #endif
6744