106f32e7eSjoerg /*===-- clang-c/Index.h - Indexing Public C Interface -------------*- C -*-===*\ 206f32e7eSjoerg |* *| 306f32e7eSjoerg |* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| 406f32e7eSjoerg |* Exceptions. *| 506f32e7eSjoerg |* See https://llvm.org/LICENSE.txt for license information. *| 606f32e7eSjoerg |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| 706f32e7eSjoerg |* *| 806f32e7eSjoerg |*===----------------------------------------------------------------------===*| 906f32e7eSjoerg |* *| 1006f32e7eSjoerg |* This header provides a public interface to a Clang library for extracting *| 1106f32e7eSjoerg |* high-level symbol information from source files without exposing the full *| 1206f32e7eSjoerg |* Clang C++ API. *| 1306f32e7eSjoerg |* *| 1406f32e7eSjoerg \*===----------------------------------------------------------------------===*/ 1506f32e7eSjoerg 1606f32e7eSjoerg #ifndef LLVM_CLANG_C_INDEX_H 1706f32e7eSjoerg #define LLVM_CLANG_C_INDEX_H 1806f32e7eSjoerg 1906f32e7eSjoerg #include <time.h> 2006f32e7eSjoerg 21*13fbcb42Sjoerg #include "clang-c/BuildSystem.h" 2206f32e7eSjoerg #include "clang-c/CXErrorCode.h" 2306f32e7eSjoerg #include "clang-c/CXString.h" 24*13fbcb42Sjoerg #include "clang-c/ExternC.h" 25*13fbcb42Sjoerg #include "clang-c/Platform.h" 2606f32e7eSjoerg 2706f32e7eSjoerg /** 2806f32e7eSjoerg * The version constants for the libclang API. 2906f32e7eSjoerg * CINDEX_VERSION_MINOR should increase when there are API additions. 3006f32e7eSjoerg * CINDEX_VERSION_MAJOR is intended for "major" source/ABI breaking changes. 3106f32e7eSjoerg * 3206f32e7eSjoerg * The policy about the libclang API was always to keep it source and ABI 3306f32e7eSjoerg * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable. 3406f32e7eSjoerg */ 3506f32e7eSjoerg #define CINDEX_VERSION_MAJOR 0 36*13fbcb42Sjoerg #define CINDEX_VERSION_MINOR 61 3706f32e7eSjoerg 38*13fbcb42Sjoerg #define CINDEX_VERSION_ENCODE(major, minor) (((major)*10000) + ((minor)*1)) 3906f32e7eSjoerg 40*13fbcb42Sjoerg #define CINDEX_VERSION \ 41*13fbcb42Sjoerg CINDEX_VERSION_ENCODE(CINDEX_VERSION_MAJOR, CINDEX_VERSION_MINOR) 4206f32e7eSjoerg 43*13fbcb42Sjoerg #define CINDEX_VERSION_STRINGIZE_(major, minor) #major "." #minor 4406f32e7eSjoerg #define CINDEX_VERSION_STRINGIZE(major, minor) \ 4506f32e7eSjoerg CINDEX_VERSION_STRINGIZE_(major, minor) 4606f32e7eSjoerg 47*13fbcb42Sjoerg #define CINDEX_VERSION_STRING \ 48*13fbcb42Sjoerg CINDEX_VERSION_STRINGIZE(CINDEX_VERSION_MAJOR, CINDEX_VERSION_MINOR) 4906f32e7eSjoerg 50*13fbcb42Sjoerg LLVM_CLANG_C_EXTERN_C_BEGIN 5106f32e7eSjoerg 5206f32e7eSjoerg /** \defgroup CINDEX libclang: C Interface to Clang 5306f32e7eSjoerg * 5406f32e7eSjoerg * The C Interface to Clang provides a relatively small API that exposes 5506f32e7eSjoerg * facilities for parsing source code into an abstract syntax tree (AST), 5606f32e7eSjoerg * loading already-parsed ASTs, traversing the AST, associating 5706f32e7eSjoerg * physical source locations with elements within the AST, and other 5806f32e7eSjoerg * facilities that support Clang-based development tools. 5906f32e7eSjoerg * 6006f32e7eSjoerg * This C interface to Clang will never provide all of the information 6106f32e7eSjoerg * representation stored in Clang's C++ AST, nor should it: the intent is to 6206f32e7eSjoerg * maintain an API that is relatively stable from one release to the next, 6306f32e7eSjoerg * providing only the basic functionality needed to support development tools. 6406f32e7eSjoerg * 6506f32e7eSjoerg * To avoid namespace pollution, data types are prefixed with "CX" and 6606f32e7eSjoerg * functions are prefixed with "clang_". 6706f32e7eSjoerg * 6806f32e7eSjoerg * @{ 6906f32e7eSjoerg */ 7006f32e7eSjoerg 7106f32e7eSjoerg /** 7206f32e7eSjoerg * An "index" that consists of a set of translation units that would 7306f32e7eSjoerg * typically be linked together into an executable or library. 7406f32e7eSjoerg */ 7506f32e7eSjoerg typedef void *CXIndex; 7606f32e7eSjoerg 7706f32e7eSjoerg /** 7806f32e7eSjoerg * An opaque type representing target information for a given translation 7906f32e7eSjoerg * unit. 8006f32e7eSjoerg */ 8106f32e7eSjoerg typedef struct CXTargetInfoImpl *CXTargetInfo; 8206f32e7eSjoerg 8306f32e7eSjoerg /** 8406f32e7eSjoerg * A single translation unit, which resides in an index. 8506f32e7eSjoerg */ 8606f32e7eSjoerg typedef struct CXTranslationUnitImpl *CXTranslationUnit; 8706f32e7eSjoerg 8806f32e7eSjoerg /** 8906f32e7eSjoerg * Opaque pointer representing client data that will be passed through 9006f32e7eSjoerg * to various callbacks and visitors. 9106f32e7eSjoerg */ 9206f32e7eSjoerg typedef void *CXClientData; 9306f32e7eSjoerg 9406f32e7eSjoerg /** 9506f32e7eSjoerg * Provides the contents of a file that has not yet been saved to disk. 9606f32e7eSjoerg * 9706f32e7eSjoerg * Each CXUnsavedFile instance provides the name of a file on the 9806f32e7eSjoerg * system along with the current contents of that file that have not 9906f32e7eSjoerg * yet been saved to disk. 10006f32e7eSjoerg */ 10106f32e7eSjoerg struct CXUnsavedFile { 10206f32e7eSjoerg /** 10306f32e7eSjoerg * The file whose contents have not yet been saved. 10406f32e7eSjoerg * 10506f32e7eSjoerg * This file must already exist in the file system. 10606f32e7eSjoerg */ 10706f32e7eSjoerg const char *Filename; 10806f32e7eSjoerg 10906f32e7eSjoerg /** 11006f32e7eSjoerg * A buffer containing the unsaved contents of this file. 11106f32e7eSjoerg */ 11206f32e7eSjoerg const char *Contents; 11306f32e7eSjoerg 11406f32e7eSjoerg /** 11506f32e7eSjoerg * The length of the unsaved contents of this buffer. 11606f32e7eSjoerg */ 11706f32e7eSjoerg unsigned long Length; 11806f32e7eSjoerg }; 11906f32e7eSjoerg 12006f32e7eSjoerg /** 12106f32e7eSjoerg * Describes the availability of a particular entity, which indicates 12206f32e7eSjoerg * whether the use of this entity will result in a warning or error due to 12306f32e7eSjoerg * it being deprecated or unavailable. 12406f32e7eSjoerg */ 12506f32e7eSjoerg enum CXAvailabilityKind { 12606f32e7eSjoerg /** 12706f32e7eSjoerg * The entity is available. 12806f32e7eSjoerg */ 12906f32e7eSjoerg CXAvailability_Available, 13006f32e7eSjoerg /** 13106f32e7eSjoerg * The entity is available, but has been deprecated (and its use is 13206f32e7eSjoerg * not recommended). 13306f32e7eSjoerg */ 13406f32e7eSjoerg CXAvailability_Deprecated, 13506f32e7eSjoerg /** 13606f32e7eSjoerg * The entity is not available; any use of it will be an error. 13706f32e7eSjoerg */ 13806f32e7eSjoerg CXAvailability_NotAvailable, 13906f32e7eSjoerg /** 14006f32e7eSjoerg * The entity is available, but not accessible; any use of it will be 14106f32e7eSjoerg * an error. 14206f32e7eSjoerg */ 14306f32e7eSjoerg CXAvailability_NotAccessible 14406f32e7eSjoerg }; 14506f32e7eSjoerg 14606f32e7eSjoerg /** 14706f32e7eSjoerg * Describes a version number of the form major.minor.subminor. 14806f32e7eSjoerg */ 14906f32e7eSjoerg typedef struct CXVersion { 15006f32e7eSjoerg /** 15106f32e7eSjoerg * The major version number, e.g., the '10' in '10.7.3'. A negative 15206f32e7eSjoerg * value indicates that there is no version number at all. 15306f32e7eSjoerg */ 15406f32e7eSjoerg int Major; 15506f32e7eSjoerg /** 15606f32e7eSjoerg * The minor version number, e.g., the '7' in '10.7.3'. This value 15706f32e7eSjoerg * will be negative if no minor version number was provided, e.g., for 15806f32e7eSjoerg * version '10'. 15906f32e7eSjoerg */ 16006f32e7eSjoerg int Minor; 16106f32e7eSjoerg /** 16206f32e7eSjoerg * The subminor version number, e.g., the '3' in '10.7.3'. This value 16306f32e7eSjoerg * will be negative if no minor or subminor version number was provided, 16406f32e7eSjoerg * e.g., in version '10' or '10.7'. 16506f32e7eSjoerg */ 16606f32e7eSjoerg int Subminor; 16706f32e7eSjoerg } CXVersion; 16806f32e7eSjoerg 16906f32e7eSjoerg /** 17006f32e7eSjoerg * Describes the exception specification of a cursor. 17106f32e7eSjoerg * 17206f32e7eSjoerg * A negative value indicates that the cursor is not a function declaration. 17306f32e7eSjoerg */ 17406f32e7eSjoerg enum CXCursor_ExceptionSpecificationKind { 17506f32e7eSjoerg /** 17606f32e7eSjoerg * The cursor has no exception specification. 17706f32e7eSjoerg */ 17806f32e7eSjoerg CXCursor_ExceptionSpecificationKind_None, 17906f32e7eSjoerg 18006f32e7eSjoerg /** 18106f32e7eSjoerg * The cursor has exception specification throw() 18206f32e7eSjoerg */ 18306f32e7eSjoerg CXCursor_ExceptionSpecificationKind_DynamicNone, 18406f32e7eSjoerg 18506f32e7eSjoerg /** 18606f32e7eSjoerg * The cursor has exception specification throw(T1, T2) 18706f32e7eSjoerg */ 18806f32e7eSjoerg CXCursor_ExceptionSpecificationKind_Dynamic, 18906f32e7eSjoerg 19006f32e7eSjoerg /** 19106f32e7eSjoerg * The cursor has exception specification throw(...). 19206f32e7eSjoerg */ 19306f32e7eSjoerg CXCursor_ExceptionSpecificationKind_MSAny, 19406f32e7eSjoerg 19506f32e7eSjoerg /** 19606f32e7eSjoerg * The cursor has exception specification basic noexcept. 19706f32e7eSjoerg */ 19806f32e7eSjoerg CXCursor_ExceptionSpecificationKind_BasicNoexcept, 19906f32e7eSjoerg 20006f32e7eSjoerg /** 20106f32e7eSjoerg * The cursor has exception specification computed noexcept. 20206f32e7eSjoerg */ 20306f32e7eSjoerg CXCursor_ExceptionSpecificationKind_ComputedNoexcept, 20406f32e7eSjoerg 20506f32e7eSjoerg /** 20606f32e7eSjoerg * The exception specification has not yet been evaluated. 20706f32e7eSjoerg */ 20806f32e7eSjoerg CXCursor_ExceptionSpecificationKind_Unevaluated, 20906f32e7eSjoerg 21006f32e7eSjoerg /** 21106f32e7eSjoerg * The exception specification has not yet been instantiated. 21206f32e7eSjoerg */ 21306f32e7eSjoerg CXCursor_ExceptionSpecificationKind_Uninstantiated, 21406f32e7eSjoerg 21506f32e7eSjoerg /** 21606f32e7eSjoerg * The exception specification has not been parsed yet. 21706f32e7eSjoerg */ 21806f32e7eSjoerg CXCursor_ExceptionSpecificationKind_Unparsed, 21906f32e7eSjoerg 22006f32e7eSjoerg /** 22106f32e7eSjoerg * The cursor has a __declspec(nothrow) exception specification. 22206f32e7eSjoerg */ 22306f32e7eSjoerg CXCursor_ExceptionSpecificationKind_NoThrow 22406f32e7eSjoerg }; 22506f32e7eSjoerg 22606f32e7eSjoerg /** 22706f32e7eSjoerg * Provides a shared context for creating translation units. 22806f32e7eSjoerg * 22906f32e7eSjoerg * It provides two options: 23006f32e7eSjoerg * 23106f32e7eSjoerg * - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local" 23206f32e7eSjoerg * declarations (when loading any new translation units). A "local" declaration 23306f32e7eSjoerg * is one that belongs in the translation unit itself and not in a precompiled 23406f32e7eSjoerg * header that was used by the translation unit. If zero, all declarations 23506f32e7eSjoerg * will be enumerated. 23606f32e7eSjoerg * 23706f32e7eSjoerg * Here is an example: 23806f32e7eSjoerg * 23906f32e7eSjoerg * \code 24006f32e7eSjoerg * // excludeDeclsFromPCH = 1, displayDiagnostics=1 24106f32e7eSjoerg * Idx = clang_createIndex(1, 1); 24206f32e7eSjoerg * 24306f32e7eSjoerg * // IndexTest.pch was produced with the following command: 24406f32e7eSjoerg * // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch" 24506f32e7eSjoerg * TU = clang_createTranslationUnit(Idx, "IndexTest.pch"); 24606f32e7eSjoerg * 24706f32e7eSjoerg * // This will load all the symbols from 'IndexTest.pch' 24806f32e7eSjoerg * clang_visitChildren(clang_getTranslationUnitCursor(TU), 24906f32e7eSjoerg * TranslationUnitVisitor, 0); 25006f32e7eSjoerg * clang_disposeTranslationUnit(TU); 25106f32e7eSjoerg * 25206f32e7eSjoerg * // This will load all the symbols from 'IndexTest.c', excluding symbols 25306f32e7eSjoerg * // from 'IndexTest.pch'. 25406f32e7eSjoerg * char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" }; 25506f32e7eSjoerg * TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args, 25606f32e7eSjoerg * 0, 0); 25706f32e7eSjoerg * clang_visitChildren(clang_getTranslationUnitCursor(TU), 25806f32e7eSjoerg * TranslationUnitVisitor, 0); 25906f32e7eSjoerg * clang_disposeTranslationUnit(TU); 26006f32e7eSjoerg * \endcode 26106f32e7eSjoerg * 26206f32e7eSjoerg * This process of creating the 'pch', loading it separately, and using it (via 26306f32e7eSjoerg * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks 26406f32e7eSjoerg * (which gives the indexer the same performance benefit as the compiler). 26506f32e7eSjoerg */ 26606f32e7eSjoerg CINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH, 26706f32e7eSjoerg int displayDiagnostics); 26806f32e7eSjoerg 26906f32e7eSjoerg /** 27006f32e7eSjoerg * Destroy the given index. 27106f32e7eSjoerg * 27206f32e7eSjoerg * The index must not be destroyed until all of the translation units created 27306f32e7eSjoerg * within that index have been destroyed. 27406f32e7eSjoerg */ 27506f32e7eSjoerg CINDEX_LINKAGE void clang_disposeIndex(CXIndex index); 27606f32e7eSjoerg 27706f32e7eSjoerg typedef enum { 27806f32e7eSjoerg /** 27906f32e7eSjoerg * Used to indicate that no special CXIndex options are needed. 28006f32e7eSjoerg */ 28106f32e7eSjoerg CXGlobalOpt_None = 0x0, 28206f32e7eSjoerg 28306f32e7eSjoerg /** 28406f32e7eSjoerg * Used to indicate that threads that libclang creates for indexing 28506f32e7eSjoerg * purposes should use background priority. 28606f32e7eSjoerg * 28706f32e7eSjoerg * Affects #clang_indexSourceFile, #clang_indexTranslationUnit, 28806f32e7eSjoerg * #clang_parseTranslationUnit, #clang_saveTranslationUnit. 28906f32e7eSjoerg */ 29006f32e7eSjoerg CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1, 29106f32e7eSjoerg 29206f32e7eSjoerg /** 29306f32e7eSjoerg * Used to indicate that threads that libclang creates for editing 29406f32e7eSjoerg * purposes should use background priority. 29506f32e7eSjoerg * 29606f32e7eSjoerg * Affects #clang_reparseTranslationUnit, #clang_codeCompleteAt, 29706f32e7eSjoerg * #clang_annotateTokens 29806f32e7eSjoerg */ 29906f32e7eSjoerg CXGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2, 30006f32e7eSjoerg 30106f32e7eSjoerg /** 30206f32e7eSjoerg * Used to indicate that all threads that libclang creates should use 30306f32e7eSjoerg * background priority. 30406f32e7eSjoerg */ 30506f32e7eSjoerg CXGlobalOpt_ThreadBackgroundPriorityForAll = 30606f32e7eSjoerg CXGlobalOpt_ThreadBackgroundPriorityForIndexing | 30706f32e7eSjoerg CXGlobalOpt_ThreadBackgroundPriorityForEditing 30806f32e7eSjoerg 30906f32e7eSjoerg } CXGlobalOptFlags; 31006f32e7eSjoerg 31106f32e7eSjoerg /** 31206f32e7eSjoerg * Sets general options associated with a CXIndex. 31306f32e7eSjoerg * 31406f32e7eSjoerg * For example: 31506f32e7eSjoerg * \code 31606f32e7eSjoerg * CXIndex idx = ...; 31706f32e7eSjoerg * clang_CXIndex_setGlobalOptions(idx, 31806f32e7eSjoerg * clang_CXIndex_getGlobalOptions(idx) | 31906f32e7eSjoerg * CXGlobalOpt_ThreadBackgroundPriorityForIndexing); 32006f32e7eSjoerg * \endcode 32106f32e7eSjoerg * 32206f32e7eSjoerg * \param options A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags. 32306f32e7eSjoerg */ 32406f32e7eSjoerg CINDEX_LINKAGE void clang_CXIndex_setGlobalOptions(CXIndex, unsigned options); 32506f32e7eSjoerg 32606f32e7eSjoerg /** 32706f32e7eSjoerg * Gets the general options associated with a CXIndex. 32806f32e7eSjoerg * 32906f32e7eSjoerg * \returns A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags that 33006f32e7eSjoerg * are associated with the given CXIndex object. 33106f32e7eSjoerg */ 33206f32e7eSjoerg CINDEX_LINKAGE unsigned clang_CXIndex_getGlobalOptions(CXIndex); 33306f32e7eSjoerg 33406f32e7eSjoerg /** 33506f32e7eSjoerg * Sets the invocation emission path option in a CXIndex. 33606f32e7eSjoerg * 33706f32e7eSjoerg * The invocation emission path specifies a path which will contain log 33806f32e7eSjoerg * files for certain libclang invocations. A null value (default) implies that 33906f32e7eSjoerg * libclang invocations are not logged.. 34006f32e7eSjoerg */ 34106f32e7eSjoerg CINDEX_LINKAGE void 34206f32e7eSjoerg clang_CXIndex_setInvocationEmissionPathOption(CXIndex, const char *Path); 34306f32e7eSjoerg 34406f32e7eSjoerg /** 34506f32e7eSjoerg * \defgroup CINDEX_FILES File manipulation routines 34606f32e7eSjoerg * 34706f32e7eSjoerg * @{ 34806f32e7eSjoerg */ 34906f32e7eSjoerg 35006f32e7eSjoerg /** 35106f32e7eSjoerg * A particular source file that is part of a translation unit. 35206f32e7eSjoerg */ 35306f32e7eSjoerg typedef void *CXFile; 35406f32e7eSjoerg 35506f32e7eSjoerg /** 35606f32e7eSjoerg * Retrieve the complete file and path name of the given file. 35706f32e7eSjoerg */ 35806f32e7eSjoerg CINDEX_LINKAGE CXString clang_getFileName(CXFile SFile); 35906f32e7eSjoerg 36006f32e7eSjoerg /** 36106f32e7eSjoerg * Retrieve the last modification time of the given file. 36206f32e7eSjoerg */ 36306f32e7eSjoerg CINDEX_LINKAGE time_t clang_getFileTime(CXFile SFile); 36406f32e7eSjoerg 36506f32e7eSjoerg /** 36606f32e7eSjoerg * Uniquely identifies a CXFile, that refers to the same underlying file, 36706f32e7eSjoerg * across an indexing session. 36806f32e7eSjoerg */ 36906f32e7eSjoerg typedef struct { 37006f32e7eSjoerg unsigned long long data[3]; 37106f32e7eSjoerg } CXFileUniqueID; 37206f32e7eSjoerg 37306f32e7eSjoerg /** 37406f32e7eSjoerg * Retrieve the unique ID for the given \c file. 37506f32e7eSjoerg * 37606f32e7eSjoerg * \param file the file to get the ID for. 37706f32e7eSjoerg * \param outID stores the returned CXFileUniqueID. 37806f32e7eSjoerg * \returns If there was a failure getting the unique ID, returns non-zero, 37906f32e7eSjoerg * otherwise returns 0. 38006f32e7eSjoerg */ 38106f32e7eSjoerg CINDEX_LINKAGE int clang_getFileUniqueID(CXFile file, CXFileUniqueID *outID); 38206f32e7eSjoerg 38306f32e7eSjoerg /** 38406f32e7eSjoerg * Determine whether the given header is guarded against 38506f32e7eSjoerg * multiple inclusions, either with the conventional 38606f32e7eSjoerg * \#ifndef/\#define/\#endif macro guards or with \#pragma once. 38706f32e7eSjoerg */ 388*13fbcb42Sjoerg CINDEX_LINKAGE unsigned clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu, 389*13fbcb42Sjoerg CXFile file); 39006f32e7eSjoerg 39106f32e7eSjoerg /** 39206f32e7eSjoerg * Retrieve a file handle within the given translation unit. 39306f32e7eSjoerg * 39406f32e7eSjoerg * \param tu the translation unit 39506f32e7eSjoerg * 39606f32e7eSjoerg * \param file_name the name of the file. 39706f32e7eSjoerg * 39806f32e7eSjoerg * \returns the file handle for the named file in the translation unit \p tu, 39906f32e7eSjoerg * or a NULL file handle if the file was not a part of this translation unit. 40006f32e7eSjoerg */ 40106f32e7eSjoerg CINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu, 40206f32e7eSjoerg const char *file_name); 40306f32e7eSjoerg 40406f32e7eSjoerg /** 40506f32e7eSjoerg * Retrieve the buffer associated with the given file. 40606f32e7eSjoerg * 40706f32e7eSjoerg * \param tu the translation unit 40806f32e7eSjoerg * 40906f32e7eSjoerg * \param file the file for which to retrieve the buffer. 41006f32e7eSjoerg * 41106f32e7eSjoerg * \param size [out] if non-NULL, will be set to the size of the buffer. 41206f32e7eSjoerg * 41306f32e7eSjoerg * \returns a pointer to the buffer in memory that holds the contents of 41406f32e7eSjoerg * \p file, or a NULL pointer when the file is not loaded. 41506f32e7eSjoerg */ 41606f32e7eSjoerg CINDEX_LINKAGE const char *clang_getFileContents(CXTranslationUnit tu, 41706f32e7eSjoerg CXFile file, size_t *size); 41806f32e7eSjoerg 41906f32e7eSjoerg /** 42006f32e7eSjoerg * Returns non-zero if the \c file1 and \c file2 point to the same file, 42106f32e7eSjoerg * or they are both NULL. 42206f32e7eSjoerg */ 42306f32e7eSjoerg CINDEX_LINKAGE int clang_File_isEqual(CXFile file1, CXFile file2); 42406f32e7eSjoerg 42506f32e7eSjoerg /** 42606f32e7eSjoerg * Returns the real path name of \c file. 42706f32e7eSjoerg * 42806f32e7eSjoerg * An empty string may be returned. Use \c clang_getFileName() in that case. 42906f32e7eSjoerg */ 43006f32e7eSjoerg CINDEX_LINKAGE CXString clang_File_tryGetRealPathName(CXFile file); 43106f32e7eSjoerg 43206f32e7eSjoerg /** 43306f32e7eSjoerg * @} 43406f32e7eSjoerg */ 43506f32e7eSjoerg 43606f32e7eSjoerg /** 43706f32e7eSjoerg * \defgroup CINDEX_LOCATIONS Physical source locations 43806f32e7eSjoerg * 43906f32e7eSjoerg * Clang represents physical source locations in its abstract syntax tree in 44006f32e7eSjoerg * great detail, with file, line, and column information for the majority of 44106f32e7eSjoerg * the tokens parsed in the source code. These data types and functions are 44206f32e7eSjoerg * used to represent source location information, either for a particular 44306f32e7eSjoerg * point in the program or for a range of points in the program, and extract 44406f32e7eSjoerg * specific location information from those data types. 44506f32e7eSjoerg * 44606f32e7eSjoerg * @{ 44706f32e7eSjoerg */ 44806f32e7eSjoerg 44906f32e7eSjoerg /** 45006f32e7eSjoerg * Identifies a specific source location within a translation 45106f32e7eSjoerg * unit. 45206f32e7eSjoerg * 45306f32e7eSjoerg * Use clang_getExpansionLocation() or clang_getSpellingLocation() 45406f32e7eSjoerg * to map a source location to a particular file, line, and column. 45506f32e7eSjoerg */ 45606f32e7eSjoerg typedef struct { 45706f32e7eSjoerg const void *ptr_data[2]; 45806f32e7eSjoerg unsigned int_data; 45906f32e7eSjoerg } CXSourceLocation; 46006f32e7eSjoerg 46106f32e7eSjoerg /** 46206f32e7eSjoerg * Identifies a half-open character range in the source code. 46306f32e7eSjoerg * 46406f32e7eSjoerg * Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the 46506f32e7eSjoerg * starting and end locations from a source range, respectively. 46606f32e7eSjoerg */ 46706f32e7eSjoerg typedef struct { 46806f32e7eSjoerg const void *ptr_data[2]; 46906f32e7eSjoerg unsigned begin_int_data; 47006f32e7eSjoerg unsigned end_int_data; 47106f32e7eSjoerg } CXSourceRange; 47206f32e7eSjoerg 47306f32e7eSjoerg /** 47406f32e7eSjoerg * Retrieve a NULL (invalid) source location. 47506f32e7eSjoerg */ 47606f32e7eSjoerg CINDEX_LINKAGE CXSourceLocation clang_getNullLocation(void); 47706f32e7eSjoerg 47806f32e7eSjoerg /** 47906f32e7eSjoerg * Determine whether two source locations, which must refer into 48006f32e7eSjoerg * the same translation unit, refer to exactly the same point in the source 48106f32e7eSjoerg * code. 48206f32e7eSjoerg * 48306f32e7eSjoerg * \returns non-zero if the source locations refer to the same location, zero 48406f32e7eSjoerg * if they refer to different locations. 48506f32e7eSjoerg */ 48606f32e7eSjoerg CINDEX_LINKAGE unsigned clang_equalLocations(CXSourceLocation loc1, 48706f32e7eSjoerg CXSourceLocation loc2); 48806f32e7eSjoerg 48906f32e7eSjoerg /** 49006f32e7eSjoerg * Retrieves the source location associated with a given file/line/column 49106f32e7eSjoerg * in a particular translation unit. 49206f32e7eSjoerg */ 49306f32e7eSjoerg CINDEX_LINKAGE CXSourceLocation clang_getLocation(CXTranslationUnit tu, 494*13fbcb42Sjoerg CXFile file, unsigned line, 49506f32e7eSjoerg unsigned column); 49606f32e7eSjoerg /** 49706f32e7eSjoerg * Retrieves the source location associated with a given character offset 49806f32e7eSjoerg * in a particular translation unit. 49906f32e7eSjoerg */ 50006f32e7eSjoerg CINDEX_LINKAGE CXSourceLocation clang_getLocationForOffset(CXTranslationUnit tu, 50106f32e7eSjoerg CXFile file, 50206f32e7eSjoerg unsigned offset); 50306f32e7eSjoerg 50406f32e7eSjoerg /** 50506f32e7eSjoerg * Returns non-zero if the given source location is in a system header. 50606f32e7eSjoerg */ 50706f32e7eSjoerg CINDEX_LINKAGE int clang_Location_isInSystemHeader(CXSourceLocation location); 50806f32e7eSjoerg 50906f32e7eSjoerg /** 51006f32e7eSjoerg * Returns non-zero if the given source location is in the main file of 51106f32e7eSjoerg * the corresponding translation unit. 51206f32e7eSjoerg */ 51306f32e7eSjoerg CINDEX_LINKAGE int clang_Location_isFromMainFile(CXSourceLocation location); 51406f32e7eSjoerg 51506f32e7eSjoerg /** 51606f32e7eSjoerg * Retrieve a NULL (invalid) source range. 51706f32e7eSjoerg */ 51806f32e7eSjoerg CINDEX_LINKAGE CXSourceRange clang_getNullRange(void); 51906f32e7eSjoerg 52006f32e7eSjoerg /** 52106f32e7eSjoerg * Retrieve a source range given the beginning and ending source 52206f32e7eSjoerg * locations. 52306f32e7eSjoerg */ 52406f32e7eSjoerg CINDEX_LINKAGE CXSourceRange clang_getRange(CXSourceLocation begin, 52506f32e7eSjoerg CXSourceLocation end); 52606f32e7eSjoerg 52706f32e7eSjoerg /** 52806f32e7eSjoerg * Determine whether two ranges are equivalent. 52906f32e7eSjoerg * 53006f32e7eSjoerg * \returns non-zero if the ranges are the same, zero if they differ. 53106f32e7eSjoerg */ 53206f32e7eSjoerg CINDEX_LINKAGE unsigned clang_equalRanges(CXSourceRange range1, 53306f32e7eSjoerg CXSourceRange range2); 53406f32e7eSjoerg 53506f32e7eSjoerg /** 53606f32e7eSjoerg * Returns non-zero if \p range is null. 53706f32e7eSjoerg */ 53806f32e7eSjoerg CINDEX_LINKAGE int clang_Range_isNull(CXSourceRange range); 53906f32e7eSjoerg 54006f32e7eSjoerg /** 54106f32e7eSjoerg * Retrieve the file, line, column, and offset represented by 54206f32e7eSjoerg * the given source location. 54306f32e7eSjoerg * 54406f32e7eSjoerg * If the location refers into a macro expansion, retrieves the 54506f32e7eSjoerg * location of the macro expansion. 54606f32e7eSjoerg * 54706f32e7eSjoerg * \param location the location within a source file that will be decomposed 54806f32e7eSjoerg * into its parts. 54906f32e7eSjoerg * 55006f32e7eSjoerg * \param file [out] if non-NULL, will be set to the file to which the given 55106f32e7eSjoerg * source location points. 55206f32e7eSjoerg * 55306f32e7eSjoerg * \param line [out] if non-NULL, will be set to the line to which the given 55406f32e7eSjoerg * source location points. 55506f32e7eSjoerg * 55606f32e7eSjoerg * \param column [out] if non-NULL, will be set to the column to which the given 55706f32e7eSjoerg * source location points. 55806f32e7eSjoerg * 55906f32e7eSjoerg * \param offset [out] if non-NULL, will be set to the offset into the 56006f32e7eSjoerg * buffer to which the given source location points. 56106f32e7eSjoerg */ 56206f32e7eSjoerg CINDEX_LINKAGE void clang_getExpansionLocation(CXSourceLocation location, 563*13fbcb42Sjoerg CXFile *file, unsigned *line, 56406f32e7eSjoerg unsigned *column, 56506f32e7eSjoerg unsigned *offset); 56606f32e7eSjoerg 56706f32e7eSjoerg /** 56806f32e7eSjoerg * Retrieve the file, line and column represented by the given source 56906f32e7eSjoerg * location, as specified in a # line directive. 57006f32e7eSjoerg * 57106f32e7eSjoerg * Example: given the following source code in a file somefile.c 57206f32e7eSjoerg * 57306f32e7eSjoerg * \code 57406f32e7eSjoerg * #123 "dummy.c" 1 57506f32e7eSjoerg * 57606f32e7eSjoerg * static int func(void) 57706f32e7eSjoerg * { 57806f32e7eSjoerg * return 0; 57906f32e7eSjoerg * } 58006f32e7eSjoerg * \endcode 58106f32e7eSjoerg * 58206f32e7eSjoerg * the location information returned by this function would be 58306f32e7eSjoerg * 58406f32e7eSjoerg * File: dummy.c Line: 124 Column: 12 58506f32e7eSjoerg * 58606f32e7eSjoerg * whereas clang_getExpansionLocation would have returned 58706f32e7eSjoerg * 58806f32e7eSjoerg * File: somefile.c Line: 3 Column: 12 58906f32e7eSjoerg * 59006f32e7eSjoerg * \param location the location within a source file that will be decomposed 59106f32e7eSjoerg * into its parts. 59206f32e7eSjoerg * 59306f32e7eSjoerg * \param filename [out] if non-NULL, will be set to the filename of the 59406f32e7eSjoerg * source location. Note that filenames returned will be for "virtual" files, 59506f32e7eSjoerg * which don't necessarily exist on the machine running clang - e.g. when 59606f32e7eSjoerg * parsing preprocessed output obtained from a different environment. If 59706f32e7eSjoerg * a non-NULL value is passed in, remember to dispose of the returned value 59806f32e7eSjoerg * using \c clang_disposeString() once you've finished with it. For an invalid 59906f32e7eSjoerg * source location, an empty string is returned. 60006f32e7eSjoerg * 60106f32e7eSjoerg * \param line [out] if non-NULL, will be set to the line number of the 60206f32e7eSjoerg * source location. For an invalid source location, zero is returned. 60306f32e7eSjoerg * 60406f32e7eSjoerg * \param column [out] if non-NULL, will be set to the column number of the 60506f32e7eSjoerg * source location. For an invalid source location, zero is returned. 60606f32e7eSjoerg */ 60706f32e7eSjoerg CINDEX_LINKAGE void clang_getPresumedLocation(CXSourceLocation location, 60806f32e7eSjoerg CXString *filename, 609*13fbcb42Sjoerg unsigned *line, unsigned *column); 61006f32e7eSjoerg 61106f32e7eSjoerg /** 61206f32e7eSjoerg * Legacy API to retrieve the file, line, column, and offset represented 61306f32e7eSjoerg * by the given source location. 61406f32e7eSjoerg * 61506f32e7eSjoerg * This interface has been replaced by the newer interface 61606f32e7eSjoerg * #clang_getExpansionLocation(). See that interface's documentation for 61706f32e7eSjoerg * details. 61806f32e7eSjoerg */ 61906f32e7eSjoerg CINDEX_LINKAGE void clang_getInstantiationLocation(CXSourceLocation location, 620*13fbcb42Sjoerg CXFile *file, unsigned *line, 62106f32e7eSjoerg unsigned *column, 62206f32e7eSjoerg unsigned *offset); 62306f32e7eSjoerg 62406f32e7eSjoerg /** 62506f32e7eSjoerg * Retrieve the file, line, column, and offset represented by 62606f32e7eSjoerg * the given source location. 62706f32e7eSjoerg * 62806f32e7eSjoerg * If the location refers into a macro instantiation, return where the 62906f32e7eSjoerg * location was originally spelled in the source file. 63006f32e7eSjoerg * 63106f32e7eSjoerg * \param location the location within a source file that will be decomposed 63206f32e7eSjoerg * into its parts. 63306f32e7eSjoerg * 63406f32e7eSjoerg * \param file [out] if non-NULL, will be set to the file to which the given 63506f32e7eSjoerg * source location points. 63606f32e7eSjoerg * 63706f32e7eSjoerg * \param line [out] if non-NULL, will be set to the line to which the given 63806f32e7eSjoerg * source location points. 63906f32e7eSjoerg * 64006f32e7eSjoerg * \param column [out] if non-NULL, will be set to the column to which the given 64106f32e7eSjoerg * source location points. 64206f32e7eSjoerg * 64306f32e7eSjoerg * \param offset [out] if non-NULL, will be set to the offset into the 64406f32e7eSjoerg * buffer to which the given source location points. 64506f32e7eSjoerg */ 64606f32e7eSjoerg CINDEX_LINKAGE void clang_getSpellingLocation(CXSourceLocation location, 647*13fbcb42Sjoerg CXFile *file, unsigned *line, 64806f32e7eSjoerg unsigned *column, 64906f32e7eSjoerg unsigned *offset); 65006f32e7eSjoerg 65106f32e7eSjoerg /** 65206f32e7eSjoerg * Retrieve the file, line, column, and offset represented by 65306f32e7eSjoerg * the given source location. 65406f32e7eSjoerg * 65506f32e7eSjoerg * If the location refers into a macro expansion, return where the macro was 65606f32e7eSjoerg * expanded or where the macro argument was written, if the location points at 65706f32e7eSjoerg * a macro argument. 65806f32e7eSjoerg * 65906f32e7eSjoerg * \param location the location within a source file that will be decomposed 66006f32e7eSjoerg * into its parts. 66106f32e7eSjoerg * 66206f32e7eSjoerg * \param file [out] if non-NULL, will be set to the file to which the given 66306f32e7eSjoerg * source location points. 66406f32e7eSjoerg * 66506f32e7eSjoerg * \param line [out] if non-NULL, will be set to the line to which the given 66606f32e7eSjoerg * source location points. 66706f32e7eSjoerg * 66806f32e7eSjoerg * \param column [out] if non-NULL, will be set to the column to which the given 66906f32e7eSjoerg * source location points. 67006f32e7eSjoerg * 67106f32e7eSjoerg * \param offset [out] if non-NULL, will be set to the offset into the 67206f32e7eSjoerg * buffer to which the given source location points. 67306f32e7eSjoerg */ 67406f32e7eSjoerg CINDEX_LINKAGE void clang_getFileLocation(CXSourceLocation location, 675*13fbcb42Sjoerg CXFile *file, unsigned *line, 676*13fbcb42Sjoerg unsigned *column, unsigned *offset); 67706f32e7eSjoerg 67806f32e7eSjoerg /** 67906f32e7eSjoerg * Retrieve a source location representing the first character within a 68006f32e7eSjoerg * source range. 68106f32e7eSjoerg */ 68206f32e7eSjoerg CINDEX_LINKAGE CXSourceLocation clang_getRangeStart(CXSourceRange range); 68306f32e7eSjoerg 68406f32e7eSjoerg /** 68506f32e7eSjoerg * Retrieve a source location representing the last character within a 68606f32e7eSjoerg * source range. 68706f32e7eSjoerg */ 68806f32e7eSjoerg CINDEX_LINKAGE CXSourceLocation clang_getRangeEnd(CXSourceRange range); 68906f32e7eSjoerg 69006f32e7eSjoerg /** 69106f32e7eSjoerg * Identifies an array of ranges. 69206f32e7eSjoerg */ 69306f32e7eSjoerg typedef struct { 69406f32e7eSjoerg /** The number of ranges in the \c ranges array. */ 69506f32e7eSjoerg unsigned count; 69606f32e7eSjoerg /** 69706f32e7eSjoerg * An array of \c CXSourceRanges. 69806f32e7eSjoerg */ 69906f32e7eSjoerg CXSourceRange *ranges; 70006f32e7eSjoerg } CXSourceRangeList; 70106f32e7eSjoerg 70206f32e7eSjoerg /** 70306f32e7eSjoerg * Retrieve all ranges that were skipped by the preprocessor. 70406f32e7eSjoerg * 70506f32e7eSjoerg * The preprocessor will skip lines when they are surrounded by an 70606f32e7eSjoerg * if/ifdef/ifndef directive whose condition does not evaluate to true. 70706f32e7eSjoerg */ 70806f32e7eSjoerg CINDEX_LINKAGE CXSourceRangeList *clang_getSkippedRanges(CXTranslationUnit tu, 70906f32e7eSjoerg CXFile file); 71006f32e7eSjoerg 71106f32e7eSjoerg /** 71206f32e7eSjoerg * Retrieve all ranges from all files that were skipped by the 71306f32e7eSjoerg * preprocessor. 71406f32e7eSjoerg * 71506f32e7eSjoerg * The preprocessor will skip lines when they are surrounded by an 71606f32e7eSjoerg * if/ifdef/ifndef directive whose condition does not evaluate to true. 71706f32e7eSjoerg */ 718*13fbcb42Sjoerg CINDEX_LINKAGE CXSourceRangeList * 719*13fbcb42Sjoerg clang_getAllSkippedRanges(CXTranslationUnit tu); 72006f32e7eSjoerg 72106f32e7eSjoerg /** 72206f32e7eSjoerg * Destroy the given \c CXSourceRangeList. 72306f32e7eSjoerg */ 72406f32e7eSjoerg CINDEX_LINKAGE void clang_disposeSourceRangeList(CXSourceRangeList *ranges); 72506f32e7eSjoerg 72606f32e7eSjoerg /** 72706f32e7eSjoerg * @} 72806f32e7eSjoerg */ 72906f32e7eSjoerg 73006f32e7eSjoerg /** 73106f32e7eSjoerg * \defgroup CINDEX_DIAG Diagnostic reporting 73206f32e7eSjoerg * 73306f32e7eSjoerg * @{ 73406f32e7eSjoerg */ 73506f32e7eSjoerg 73606f32e7eSjoerg /** 73706f32e7eSjoerg * Describes the severity of a particular diagnostic. 73806f32e7eSjoerg */ 73906f32e7eSjoerg enum CXDiagnosticSeverity { 74006f32e7eSjoerg /** 74106f32e7eSjoerg * A diagnostic that has been suppressed, e.g., by a command-line 74206f32e7eSjoerg * option. 74306f32e7eSjoerg */ 74406f32e7eSjoerg CXDiagnostic_Ignored = 0, 74506f32e7eSjoerg 74606f32e7eSjoerg /** 74706f32e7eSjoerg * This diagnostic is a note that should be attached to the 74806f32e7eSjoerg * previous (non-note) diagnostic. 74906f32e7eSjoerg */ 75006f32e7eSjoerg CXDiagnostic_Note = 1, 75106f32e7eSjoerg 75206f32e7eSjoerg /** 75306f32e7eSjoerg * This diagnostic indicates suspicious code that may not be 75406f32e7eSjoerg * wrong. 75506f32e7eSjoerg */ 75606f32e7eSjoerg CXDiagnostic_Warning = 2, 75706f32e7eSjoerg 75806f32e7eSjoerg /** 75906f32e7eSjoerg * This diagnostic indicates that the code is ill-formed. 76006f32e7eSjoerg */ 76106f32e7eSjoerg CXDiagnostic_Error = 3, 76206f32e7eSjoerg 76306f32e7eSjoerg /** 76406f32e7eSjoerg * This diagnostic indicates that the code is ill-formed such 76506f32e7eSjoerg * that future parser recovery is unlikely to produce useful 76606f32e7eSjoerg * results. 76706f32e7eSjoerg */ 76806f32e7eSjoerg CXDiagnostic_Fatal = 4 76906f32e7eSjoerg }; 77006f32e7eSjoerg 77106f32e7eSjoerg /** 77206f32e7eSjoerg * A single diagnostic, containing the diagnostic's severity, 77306f32e7eSjoerg * location, text, source ranges, and fix-it hints. 77406f32e7eSjoerg */ 77506f32e7eSjoerg typedef void *CXDiagnostic; 77606f32e7eSjoerg 77706f32e7eSjoerg /** 77806f32e7eSjoerg * A group of CXDiagnostics. 77906f32e7eSjoerg */ 78006f32e7eSjoerg typedef void *CXDiagnosticSet; 78106f32e7eSjoerg 78206f32e7eSjoerg /** 78306f32e7eSjoerg * Determine the number of diagnostics in a CXDiagnosticSet. 78406f32e7eSjoerg */ 78506f32e7eSjoerg CINDEX_LINKAGE unsigned clang_getNumDiagnosticsInSet(CXDiagnosticSet Diags); 78606f32e7eSjoerg 78706f32e7eSjoerg /** 78806f32e7eSjoerg * Retrieve a diagnostic associated with the given CXDiagnosticSet. 78906f32e7eSjoerg * 79006f32e7eSjoerg * \param Diags the CXDiagnosticSet to query. 79106f32e7eSjoerg * \param Index the zero-based diagnostic number to retrieve. 79206f32e7eSjoerg * 79306f32e7eSjoerg * \returns the requested diagnostic. This diagnostic must be freed 79406f32e7eSjoerg * via a call to \c clang_disposeDiagnostic(). 79506f32e7eSjoerg */ 79606f32e7eSjoerg CINDEX_LINKAGE CXDiagnostic clang_getDiagnosticInSet(CXDiagnosticSet Diags, 79706f32e7eSjoerg unsigned Index); 79806f32e7eSjoerg 79906f32e7eSjoerg /** 80006f32e7eSjoerg * Describes the kind of error that occurred (if any) in a call to 80106f32e7eSjoerg * \c clang_loadDiagnostics. 80206f32e7eSjoerg */ 80306f32e7eSjoerg enum CXLoadDiag_Error { 80406f32e7eSjoerg /** 80506f32e7eSjoerg * Indicates that no error occurred. 80606f32e7eSjoerg */ 80706f32e7eSjoerg CXLoadDiag_None = 0, 80806f32e7eSjoerg 80906f32e7eSjoerg /** 81006f32e7eSjoerg * Indicates that an unknown error occurred while attempting to 81106f32e7eSjoerg * deserialize diagnostics. 81206f32e7eSjoerg */ 81306f32e7eSjoerg CXLoadDiag_Unknown = 1, 81406f32e7eSjoerg 81506f32e7eSjoerg /** 81606f32e7eSjoerg * Indicates that the file containing the serialized diagnostics 81706f32e7eSjoerg * could not be opened. 81806f32e7eSjoerg */ 81906f32e7eSjoerg CXLoadDiag_CannotLoad = 2, 82006f32e7eSjoerg 82106f32e7eSjoerg /** 82206f32e7eSjoerg * Indicates that the serialized diagnostics file is invalid or 82306f32e7eSjoerg * corrupt. 82406f32e7eSjoerg */ 82506f32e7eSjoerg CXLoadDiag_InvalidFile = 3 82606f32e7eSjoerg }; 82706f32e7eSjoerg 82806f32e7eSjoerg /** 82906f32e7eSjoerg * Deserialize a set of diagnostics from a Clang diagnostics bitcode 83006f32e7eSjoerg * file. 83106f32e7eSjoerg * 83206f32e7eSjoerg * \param file The name of the file to deserialize. 83306f32e7eSjoerg * \param error A pointer to a enum value recording if there was a problem 83406f32e7eSjoerg * deserializing the diagnostics. 83506f32e7eSjoerg * \param errorString A pointer to a CXString for recording the error string 83606f32e7eSjoerg * if the file was not successfully loaded. 83706f32e7eSjoerg * 83806f32e7eSjoerg * \returns A loaded CXDiagnosticSet if successful, and NULL otherwise. These 83906f32e7eSjoerg * diagnostics should be released using clang_disposeDiagnosticSet(). 84006f32e7eSjoerg */ 841*13fbcb42Sjoerg CINDEX_LINKAGE CXDiagnosticSet clang_loadDiagnostics( 842*13fbcb42Sjoerg const char *file, enum CXLoadDiag_Error *error, CXString *errorString); 84306f32e7eSjoerg 84406f32e7eSjoerg /** 84506f32e7eSjoerg * Release a CXDiagnosticSet and all of its contained diagnostics. 84606f32e7eSjoerg */ 84706f32e7eSjoerg CINDEX_LINKAGE void clang_disposeDiagnosticSet(CXDiagnosticSet Diags); 84806f32e7eSjoerg 84906f32e7eSjoerg /** 85006f32e7eSjoerg * Retrieve the child diagnostics of a CXDiagnostic. 85106f32e7eSjoerg * 85206f32e7eSjoerg * This CXDiagnosticSet does not need to be released by 85306f32e7eSjoerg * clang_disposeDiagnosticSet. 85406f32e7eSjoerg */ 85506f32e7eSjoerg CINDEX_LINKAGE CXDiagnosticSet clang_getChildDiagnostics(CXDiagnostic D); 85606f32e7eSjoerg 85706f32e7eSjoerg /** 85806f32e7eSjoerg * Determine the number of diagnostics produced for the given 85906f32e7eSjoerg * translation unit. 86006f32e7eSjoerg */ 86106f32e7eSjoerg CINDEX_LINKAGE unsigned clang_getNumDiagnostics(CXTranslationUnit Unit); 86206f32e7eSjoerg 86306f32e7eSjoerg /** 86406f32e7eSjoerg * Retrieve a diagnostic associated with the given translation unit. 86506f32e7eSjoerg * 86606f32e7eSjoerg * \param Unit the translation unit to query. 86706f32e7eSjoerg * \param Index the zero-based diagnostic number to retrieve. 86806f32e7eSjoerg * 86906f32e7eSjoerg * \returns the requested diagnostic. This diagnostic must be freed 87006f32e7eSjoerg * via a call to \c clang_disposeDiagnostic(). 87106f32e7eSjoerg */ 87206f32e7eSjoerg CINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit, 87306f32e7eSjoerg unsigned Index); 87406f32e7eSjoerg 87506f32e7eSjoerg /** 87606f32e7eSjoerg * Retrieve the complete set of diagnostics associated with a 87706f32e7eSjoerg * translation unit. 87806f32e7eSjoerg * 87906f32e7eSjoerg * \param Unit the translation unit to query. 88006f32e7eSjoerg */ 88106f32e7eSjoerg CINDEX_LINKAGE CXDiagnosticSet 88206f32e7eSjoerg clang_getDiagnosticSetFromTU(CXTranslationUnit Unit); 88306f32e7eSjoerg 88406f32e7eSjoerg /** 88506f32e7eSjoerg * Destroy a diagnostic. 88606f32e7eSjoerg */ 88706f32e7eSjoerg CINDEX_LINKAGE void clang_disposeDiagnostic(CXDiagnostic Diagnostic); 88806f32e7eSjoerg 88906f32e7eSjoerg /** 89006f32e7eSjoerg * Options to control the display of diagnostics. 89106f32e7eSjoerg * 89206f32e7eSjoerg * The values in this enum are meant to be combined to customize the 89306f32e7eSjoerg * behavior of \c clang_formatDiagnostic(). 89406f32e7eSjoerg */ 89506f32e7eSjoerg enum CXDiagnosticDisplayOptions { 89606f32e7eSjoerg /** 89706f32e7eSjoerg * Display the source-location information where the 89806f32e7eSjoerg * diagnostic was located. 89906f32e7eSjoerg * 90006f32e7eSjoerg * When set, diagnostics will be prefixed by the file, line, and 90106f32e7eSjoerg * (optionally) column to which the diagnostic refers. For example, 90206f32e7eSjoerg * 90306f32e7eSjoerg * \code 90406f32e7eSjoerg * test.c:28: warning: extra tokens at end of #endif directive 90506f32e7eSjoerg * \endcode 90606f32e7eSjoerg * 90706f32e7eSjoerg * This option corresponds to the clang flag \c -fshow-source-location. 90806f32e7eSjoerg */ 90906f32e7eSjoerg CXDiagnostic_DisplaySourceLocation = 0x01, 91006f32e7eSjoerg 91106f32e7eSjoerg /** 91206f32e7eSjoerg * If displaying the source-location information of the 91306f32e7eSjoerg * diagnostic, also include the column number. 91406f32e7eSjoerg * 91506f32e7eSjoerg * This option corresponds to the clang flag \c -fshow-column. 91606f32e7eSjoerg */ 91706f32e7eSjoerg CXDiagnostic_DisplayColumn = 0x02, 91806f32e7eSjoerg 91906f32e7eSjoerg /** 92006f32e7eSjoerg * If displaying the source-location information of the 92106f32e7eSjoerg * diagnostic, also include information about source ranges in a 92206f32e7eSjoerg * machine-parsable format. 92306f32e7eSjoerg * 92406f32e7eSjoerg * This option corresponds to the clang flag 92506f32e7eSjoerg * \c -fdiagnostics-print-source-range-info. 92606f32e7eSjoerg */ 92706f32e7eSjoerg CXDiagnostic_DisplaySourceRanges = 0x04, 92806f32e7eSjoerg 92906f32e7eSjoerg /** 93006f32e7eSjoerg * Display the option name associated with this diagnostic, if any. 93106f32e7eSjoerg * 93206f32e7eSjoerg * The option name displayed (e.g., -Wconversion) will be placed in brackets 93306f32e7eSjoerg * after the diagnostic text. This option corresponds to the clang flag 93406f32e7eSjoerg * \c -fdiagnostics-show-option. 93506f32e7eSjoerg */ 93606f32e7eSjoerg CXDiagnostic_DisplayOption = 0x08, 93706f32e7eSjoerg 93806f32e7eSjoerg /** 93906f32e7eSjoerg * Display the category number associated with this diagnostic, if any. 94006f32e7eSjoerg * 94106f32e7eSjoerg * The category number is displayed within brackets after the diagnostic text. 94206f32e7eSjoerg * This option corresponds to the clang flag 94306f32e7eSjoerg * \c -fdiagnostics-show-category=id. 94406f32e7eSjoerg */ 94506f32e7eSjoerg CXDiagnostic_DisplayCategoryId = 0x10, 94606f32e7eSjoerg 94706f32e7eSjoerg /** 94806f32e7eSjoerg * Display the category name associated with this diagnostic, if any. 94906f32e7eSjoerg * 95006f32e7eSjoerg * The category name is displayed within brackets after the diagnostic text. 95106f32e7eSjoerg * This option corresponds to the clang flag 95206f32e7eSjoerg * \c -fdiagnostics-show-category=name. 95306f32e7eSjoerg */ 95406f32e7eSjoerg CXDiagnostic_DisplayCategoryName = 0x20 95506f32e7eSjoerg }; 95606f32e7eSjoerg 95706f32e7eSjoerg /** 95806f32e7eSjoerg * Format the given diagnostic in a manner that is suitable for display. 95906f32e7eSjoerg * 96006f32e7eSjoerg * This routine will format the given diagnostic to a string, rendering 96106f32e7eSjoerg * the diagnostic according to the various options given. The 96206f32e7eSjoerg * \c clang_defaultDiagnosticDisplayOptions() function returns the set of 96306f32e7eSjoerg * options that most closely mimics the behavior of the clang compiler. 96406f32e7eSjoerg * 96506f32e7eSjoerg * \param Diagnostic The diagnostic to print. 96606f32e7eSjoerg * 96706f32e7eSjoerg * \param Options A set of options that control the diagnostic display, 96806f32e7eSjoerg * created by combining \c CXDiagnosticDisplayOptions values. 96906f32e7eSjoerg * 97006f32e7eSjoerg * \returns A new string containing for formatted diagnostic. 97106f32e7eSjoerg */ 97206f32e7eSjoerg CINDEX_LINKAGE CXString clang_formatDiagnostic(CXDiagnostic Diagnostic, 97306f32e7eSjoerg unsigned Options); 97406f32e7eSjoerg 97506f32e7eSjoerg /** 97606f32e7eSjoerg * Retrieve the set of display options most similar to the 97706f32e7eSjoerg * default behavior of the clang compiler. 97806f32e7eSjoerg * 97906f32e7eSjoerg * \returns A set of display options suitable for use with \c 98006f32e7eSjoerg * clang_formatDiagnostic(). 98106f32e7eSjoerg */ 98206f32e7eSjoerg CINDEX_LINKAGE unsigned clang_defaultDiagnosticDisplayOptions(void); 98306f32e7eSjoerg 98406f32e7eSjoerg /** 98506f32e7eSjoerg * Determine the severity of the given diagnostic. 98606f32e7eSjoerg */ 98706f32e7eSjoerg CINDEX_LINKAGE enum CXDiagnosticSeverity 98806f32e7eSjoerg clang_getDiagnosticSeverity(CXDiagnostic); 98906f32e7eSjoerg 99006f32e7eSjoerg /** 99106f32e7eSjoerg * Retrieve the source location of the given diagnostic. 99206f32e7eSjoerg * 99306f32e7eSjoerg * This location is where Clang would print the caret ('^') when 99406f32e7eSjoerg * displaying the diagnostic on the command line. 99506f32e7eSjoerg */ 99606f32e7eSjoerg CINDEX_LINKAGE CXSourceLocation clang_getDiagnosticLocation(CXDiagnostic); 99706f32e7eSjoerg 99806f32e7eSjoerg /** 99906f32e7eSjoerg * Retrieve the text of the given diagnostic. 100006f32e7eSjoerg */ 100106f32e7eSjoerg CINDEX_LINKAGE CXString clang_getDiagnosticSpelling(CXDiagnostic); 100206f32e7eSjoerg 100306f32e7eSjoerg /** 100406f32e7eSjoerg * Retrieve the name of the command-line option that enabled this 100506f32e7eSjoerg * diagnostic. 100606f32e7eSjoerg * 100706f32e7eSjoerg * \param Diag The diagnostic to be queried. 100806f32e7eSjoerg * 100906f32e7eSjoerg * \param Disable If non-NULL, will be set to the option that disables this 101006f32e7eSjoerg * diagnostic (if any). 101106f32e7eSjoerg * 101206f32e7eSjoerg * \returns A string that contains the command-line option used to enable this 101306f32e7eSjoerg * warning, such as "-Wconversion" or "-pedantic". 101406f32e7eSjoerg */ 101506f32e7eSjoerg CINDEX_LINKAGE CXString clang_getDiagnosticOption(CXDiagnostic Diag, 101606f32e7eSjoerg CXString *Disable); 101706f32e7eSjoerg 101806f32e7eSjoerg /** 101906f32e7eSjoerg * Retrieve the category number for this diagnostic. 102006f32e7eSjoerg * 102106f32e7eSjoerg * Diagnostics can be categorized into groups along with other, related 102206f32e7eSjoerg * diagnostics (e.g., diagnostics under the same warning flag). This routine 102306f32e7eSjoerg * retrieves the category number for the given diagnostic. 102406f32e7eSjoerg * 102506f32e7eSjoerg * \returns The number of the category that contains this diagnostic, or zero 102606f32e7eSjoerg * if this diagnostic is uncategorized. 102706f32e7eSjoerg */ 102806f32e7eSjoerg CINDEX_LINKAGE unsigned clang_getDiagnosticCategory(CXDiagnostic); 102906f32e7eSjoerg 103006f32e7eSjoerg /** 103106f32e7eSjoerg * Retrieve the name of a particular diagnostic category. This 103206f32e7eSjoerg * is now deprecated. Use clang_getDiagnosticCategoryText() 103306f32e7eSjoerg * instead. 103406f32e7eSjoerg * 103506f32e7eSjoerg * \param Category A diagnostic category number, as returned by 103606f32e7eSjoerg * \c clang_getDiagnosticCategory(). 103706f32e7eSjoerg * 103806f32e7eSjoerg * \returns The name of the given diagnostic category. 103906f32e7eSjoerg */ 1040*13fbcb42Sjoerg CINDEX_DEPRECATED CINDEX_LINKAGE CXString 1041*13fbcb42Sjoerg clang_getDiagnosticCategoryName(unsigned Category); 104206f32e7eSjoerg 104306f32e7eSjoerg /** 104406f32e7eSjoerg * Retrieve the diagnostic category text for a given diagnostic. 104506f32e7eSjoerg * 104606f32e7eSjoerg * \returns The text of the given diagnostic category. 104706f32e7eSjoerg */ 104806f32e7eSjoerg CINDEX_LINKAGE CXString clang_getDiagnosticCategoryText(CXDiagnostic); 104906f32e7eSjoerg 105006f32e7eSjoerg /** 105106f32e7eSjoerg * Determine the number of source ranges associated with the given 105206f32e7eSjoerg * diagnostic. 105306f32e7eSjoerg */ 105406f32e7eSjoerg CINDEX_LINKAGE unsigned clang_getDiagnosticNumRanges(CXDiagnostic); 105506f32e7eSjoerg 105606f32e7eSjoerg /** 105706f32e7eSjoerg * Retrieve a source range associated with the diagnostic. 105806f32e7eSjoerg * 105906f32e7eSjoerg * A diagnostic's source ranges highlight important elements in the source 106006f32e7eSjoerg * code. On the command line, Clang displays source ranges by 106106f32e7eSjoerg * underlining them with '~' characters. 106206f32e7eSjoerg * 106306f32e7eSjoerg * \param Diagnostic the diagnostic whose range is being extracted. 106406f32e7eSjoerg * 106506f32e7eSjoerg * \param Range the zero-based index specifying which range to 106606f32e7eSjoerg * 106706f32e7eSjoerg * \returns the requested source range. 106806f32e7eSjoerg */ 106906f32e7eSjoerg CINDEX_LINKAGE CXSourceRange clang_getDiagnosticRange(CXDiagnostic Diagnostic, 107006f32e7eSjoerg unsigned Range); 107106f32e7eSjoerg 107206f32e7eSjoerg /** 107306f32e7eSjoerg * Determine the number of fix-it hints associated with the 107406f32e7eSjoerg * given diagnostic. 107506f32e7eSjoerg */ 107606f32e7eSjoerg CINDEX_LINKAGE unsigned clang_getDiagnosticNumFixIts(CXDiagnostic Diagnostic); 107706f32e7eSjoerg 107806f32e7eSjoerg /** 107906f32e7eSjoerg * Retrieve the replacement information for a given fix-it. 108006f32e7eSjoerg * 108106f32e7eSjoerg * Fix-its are described in terms of a source range whose contents 108206f32e7eSjoerg * should be replaced by a string. This approach generalizes over 108306f32e7eSjoerg * three kinds of operations: removal of source code (the range covers 108406f32e7eSjoerg * the code to be removed and the replacement string is empty), 108506f32e7eSjoerg * replacement of source code (the range covers the code to be 108606f32e7eSjoerg * replaced and the replacement string provides the new code), and 108706f32e7eSjoerg * insertion (both the start and end of the range point at the 108806f32e7eSjoerg * insertion location, and the replacement string provides the text to 108906f32e7eSjoerg * insert). 109006f32e7eSjoerg * 109106f32e7eSjoerg * \param Diagnostic The diagnostic whose fix-its are being queried. 109206f32e7eSjoerg * 109306f32e7eSjoerg * \param FixIt The zero-based index of the fix-it. 109406f32e7eSjoerg * 109506f32e7eSjoerg * \param ReplacementRange The source range whose contents will be 109606f32e7eSjoerg * replaced with the returned replacement string. Note that source 109706f32e7eSjoerg * ranges are half-open ranges [a, b), so the source code should be 109806f32e7eSjoerg * replaced from a and up to (but not including) b. 109906f32e7eSjoerg * 110006f32e7eSjoerg * \returns A string containing text that should be replace the source 110106f32e7eSjoerg * code indicated by the \c ReplacementRange. 110206f32e7eSjoerg */ 1103*13fbcb42Sjoerg CINDEX_LINKAGE CXString clang_getDiagnosticFixIt( 1104*13fbcb42Sjoerg CXDiagnostic Diagnostic, unsigned FixIt, CXSourceRange *ReplacementRange); 110506f32e7eSjoerg 110606f32e7eSjoerg /** 110706f32e7eSjoerg * @} 110806f32e7eSjoerg */ 110906f32e7eSjoerg 111006f32e7eSjoerg /** 111106f32e7eSjoerg * \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation 111206f32e7eSjoerg * 111306f32e7eSjoerg * The routines in this group provide the ability to create and destroy 111406f32e7eSjoerg * translation units from files, either by parsing the contents of the files or 111506f32e7eSjoerg * by reading in a serialized representation of a translation unit. 111606f32e7eSjoerg * 111706f32e7eSjoerg * @{ 111806f32e7eSjoerg */ 111906f32e7eSjoerg 112006f32e7eSjoerg /** 112106f32e7eSjoerg * Get the original translation unit source file name. 112206f32e7eSjoerg */ 112306f32e7eSjoerg CINDEX_LINKAGE CXString 112406f32e7eSjoerg clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit); 112506f32e7eSjoerg 112606f32e7eSjoerg /** 112706f32e7eSjoerg * Return the CXTranslationUnit for a given source file and the provided 112806f32e7eSjoerg * command line arguments one would pass to the compiler. 112906f32e7eSjoerg * 113006f32e7eSjoerg * Note: The 'source_filename' argument is optional. If the caller provides a 113106f32e7eSjoerg * NULL pointer, the name of the source file is expected to reside in the 113206f32e7eSjoerg * specified command line arguments. 113306f32e7eSjoerg * 113406f32e7eSjoerg * Note: When encountered in 'clang_command_line_args', the following options 113506f32e7eSjoerg * are ignored: 113606f32e7eSjoerg * 113706f32e7eSjoerg * '-c' 113806f32e7eSjoerg * '-emit-ast' 113906f32e7eSjoerg * '-fsyntax-only' 114006f32e7eSjoerg * '-o \<output file>' (both '-o' and '\<output file>' are ignored) 114106f32e7eSjoerg * 114206f32e7eSjoerg * \param CIdx The index object with which the translation unit will be 114306f32e7eSjoerg * associated. 114406f32e7eSjoerg * 114506f32e7eSjoerg * \param source_filename The name of the source file to load, or NULL if the 114606f32e7eSjoerg * source file is included in \p clang_command_line_args. 114706f32e7eSjoerg * 114806f32e7eSjoerg * \param num_clang_command_line_args The number of command-line arguments in 114906f32e7eSjoerg * \p clang_command_line_args. 115006f32e7eSjoerg * 115106f32e7eSjoerg * \param clang_command_line_args The command-line arguments that would be 115206f32e7eSjoerg * passed to the \c clang executable if it were being invoked out-of-process. 115306f32e7eSjoerg * These command-line options will be parsed and will affect how the translation 115406f32e7eSjoerg * unit is parsed. Note that the following options are ignored: '-c', 115506f32e7eSjoerg * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'. 115606f32e7eSjoerg * 115706f32e7eSjoerg * \param num_unsaved_files the number of unsaved file entries in \p 115806f32e7eSjoerg * unsaved_files. 115906f32e7eSjoerg * 116006f32e7eSjoerg * \param unsaved_files the files that have not yet been saved to disk 116106f32e7eSjoerg * but may be required for code completion, including the contents of 116206f32e7eSjoerg * those files. The contents and name of these files (as specified by 116306f32e7eSjoerg * CXUnsavedFile) are copied when necessary, so the client only needs to 116406f32e7eSjoerg * guarantee their validity until the call to this function returns. 116506f32e7eSjoerg */ 116606f32e7eSjoerg CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnitFromSourceFile( 1167*13fbcb42Sjoerg CXIndex CIdx, const char *source_filename, int num_clang_command_line_args, 1168*13fbcb42Sjoerg const char *const *clang_command_line_args, unsigned num_unsaved_files, 116906f32e7eSjoerg struct CXUnsavedFile *unsaved_files); 117006f32e7eSjoerg 117106f32e7eSjoerg /** 117206f32e7eSjoerg * Same as \c clang_createTranslationUnit2, but returns 117306f32e7eSjoerg * the \c CXTranslationUnit instead of an error code. In case of an error this 117406f32e7eSjoerg * routine returns a \c NULL \c CXTranslationUnit, without further detailed 117506f32e7eSjoerg * error codes. 117606f32e7eSjoerg */ 1177*13fbcb42Sjoerg CINDEX_LINKAGE CXTranslationUnit 1178*13fbcb42Sjoerg clang_createTranslationUnit(CXIndex CIdx, const char *ast_filename); 117906f32e7eSjoerg 118006f32e7eSjoerg /** 118106f32e7eSjoerg * Create a translation unit from an AST file (\c -emit-ast). 118206f32e7eSjoerg * 118306f32e7eSjoerg * \param[out] out_TU A non-NULL pointer to store the created 118406f32e7eSjoerg * \c CXTranslationUnit. 118506f32e7eSjoerg * 118606f32e7eSjoerg * \returns Zero on success, otherwise returns an error code. 118706f32e7eSjoerg */ 1188*13fbcb42Sjoerg CINDEX_LINKAGE enum CXErrorCode 1189*13fbcb42Sjoerg clang_createTranslationUnit2(CXIndex CIdx, const char *ast_filename, 119006f32e7eSjoerg CXTranslationUnit *out_TU); 119106f32e7eSjoerg 119206f32e7eSjoerg /** 119306f32e7eSjoerg * Flags that control the creation of translation units. 119406f32e7eSjoerg * 119506f32e7eSjoerg * The enumerators in this enumeration type are meant to be bitwise 119606f32e7eSjoerg * ORed together to specify which options should be used when 119706f32e7eSjoerg * constructing the translation unit. 119806f32e7eSjoerg */ 119906f32e7eSjoerg enum CXTranslationUnit_Flags { 120006f32e7eSjoerg /** 120106f32e7eSjoerg * Used to indicate that no special translation-unit options are 120206f32e7eSjoerg * needed. 120306f32e7eSjoerg */ 120406f32e7eSjoerg CXTranslationUnit_None = 0x0, 120506f32e7eSjoerg 120606f32e7eSjoerg /** 120706f32e7eSjoerg * Used to indicate that the parser should construct a "detailed" 120806f32e7eSjoerg * preprocessing record, including all macro definitions and instantiations. 120906f32e7eSjoerg * 121006f32e7eSjoerg * Constructing a detailed preprocessing record requires more memory 121106f32e7eSjoerg * and time to parse, since the information contained in the record 121206f32e7eSjoerg * is usually not retained. However, it can be useful for 121306f32e7eSjoerg * applications that require more detailed information about the 121406f32e7eSjoerg * behavior of the preprocessor. 121506f32e7eSjoerg */ 121606f32e7eSjoerg CXTranslationUnit_DetailedPreprocessingRecord = 0x01, 121706f32e7eSjoerg 121806f32e7eSjoerg /** 121906f32e7eSjoerg * Used to indicate that the translation unit is incomplete. 122006f32e7eSjoerg * 122106f32e7eSjoerg * When a translation unit is considered "incomplete", semantic 122206f32e7eSjoerg * analysis that is typically performed at the end of the 122306f32e7eSjoerg * translation unit will be suppressed. For example, this suppresses 122406f32e7eSjoerg * the completion of tentative declarations in C and of 122506f32e7eSjoerg * instantiation of implicitly-instantiation function templates in 122606f32e7eSjoerg * C++. This option is typically used when parsing a header with the 122706f32e7eSjoerg * intent of producing a precompiled header. 122806f32e7eSjoerg */ 122906f32e7eSjoerg CXTranslationUnit_Incomplete = 0x02, 123006f32e7eSjoerg 123106f32e7eSjoerg /** 123206f32e7eSjoerg * Used to indicate that the translation unit should be built with an 123306f32e7eSjoerg * implicit precompiled header for the preamble. 123406f32e7eSjoerg * 123506f32e7eSjoerg * An implicit precompiled header is used as an optimization when a 123606f32e7eSjoerg * particular translation unit is likely to be reparsed many times 123706f32e7eSjoerg * when the sources aren't changing that often. In this case, an 123806f32e7eSjoerg * implicit precompiled header will be built containing all of the 123906f32e7eSjoerg * initial includes at the top of the main file (what we refer to as 124006f32e7eSjoerg * the "preamble" of the file). In subsequent parses, if the 124106f32e7eSjoerg * preamble or the files in it have not changed, \c 124206f32e7eSjoerg * clang_reparseTranslationUnit() will re-use the implicit 124306f32e7eSjoerg * precompiled header to improve parsing performance. 124406f32e7eSjoerg */ 124506f32e7eSjoerg CXTranslationUnit_PrecompiledPreamble = 0x04, 124606f32e7eSjoerg 124706f32e7eSjoerg /** 124806f32e7eSjoerg * Used to indicate that the translation unit should cache some 124906f32e7eSjoerg * code-completion results with each reparse of the source file. 125006f32e7eSjoerg * 125106f32e7eSjoerg * Caching of code-completion results is a performance optimization that 125206f32e7eSjoerg * introduces some overhead to reparsing but improves the performance of 125306f32e7eSjoerg * code-completion operations. 125406f32e7eSjoerg */ 125506f32e7eSjoerg CXTranslationUnit_CacheCompletionResults = 0x08, 125606f32e7eSjoerg 125706f32e7eSjoerg /** 125806f32e7eSjoerg * Used to indicate that the translation unit will be serialized with 125906f32e7eSjoerg * \c clang_saveTranslationUnit. 126006f32e7eSjoerg * 126106f32e7eSjoerg * This option is typically used when parsing a header with the intent of 126206f32e7eSjoerg * producing a precompiled header. 126306f32e7eSjoerg */ 126406f32e7eSjoerg CXTranslationUnit_ForSerialization = 0x10, 126506f32e7eSjoerg 126606f32e7eSjoerg /** 126706f32e7eSjoerg * DEPRECATED: Enabled chained precompiled preambles in C++. 126806f32e7eSjoerg * 126906f32e7eSjoerg * Note: this is a *temporary* option that is available only while 127006f32e7eSjoerg * we are testing C++ precompiled preamble support. It is deprecated. 127106f32e7eSjoerg */ 127206f32e7eSjoerg CXTranslationUnit_CXXChainedPCH = 0x20, 127306f32e7eSjoerg 127406f32e7eSjoerg /** 127506f32e7eSjoerg * Used to indicate that function/method bodies should be skipped while 127606f32e7eSjoerg * parsing. 127706f32e7eSjoerg * 127806f32e7eSjoerg * This option can be used to search for declarations/definitions while 127906f32e7eSjoerg * ignoring the usages. 128006f32e7eSjoerg */ 128106f32e7eSjoerg CXTranslationUnit_SkipFunctionBodies = 0x40, 128206f32e7eSjoerg 128306f32e7eSjoerg /** 128406f32e7eSjoerg * Used to indicate that brief documentation comments should be 128506f32e7eSjoerg * included into the set of code completions returned from this translation 128606f32e7eSjoerg * unit. 128706f32e7eSjoerg */ 128806f32e7eSjoerg CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 0x80, 128906f32e7eSjoerg 129006f32e7eSjoerg /** 129106f32e7eSjoerg * Used to indicate that the precompiled preamble should be created on 129206f32e7eSjoerg * the first parse. Otherwise it will be created on the first reparse. This 129306f32e7eSjoerg * trades runtime on the first parse (serializing the preamble takes time) for 129406f32e7eSjoerg * reduced runtime on the second parse (can now reuse the preamble). 129506f32e7eSjoerg */ 129606f32e7eSjoerg CXTranslationUnit_CreatePreambleOnFirstParse = 0x100, 129706f32e7eSjoerg 129806f32e7eSjoerg /** 129906f32e7eSjoerg * Do not stop processing when fatal errors are encountered. 130006f32e7eSjoerg * 130106f32e7eSjoerg * When fatal errors are encountered while parsing a translation unit, 130206f32e7eSjoerg * semantic analysis is typically stopped early when compiling code. A common 130306f32e7eSjoerg * source for fatal errors are unresolvable include files. For the 130406f32e7eSjoerg * purposes of an IDE, this is undesirable behavior and as much information 130506f32e7eSjoerg * as possible should be reported. Use this flag to enable this behavior. 130606f32e7eSjoerg */ 130706f32e7eSjoerg CXTranslationUnit_KeepGoing = 0x200, 130806f32e7eSjoerg 130906f32e7eSjoerg /** 131006f32e7eSjoerg * Sets the preprocessor in a mode for parsing a single file only. 131106f32e7eSjoerg */ 131206f32e7eSjoerg CXTranslationUnit_SingleFileParse = 0x400, 131306f32e7eSjoerg 131406f32e7eSjoerg /** 131506f32e7eSjoerg * Used in combination with CXTranslationUnit_SkipFunctionBodies to 131606f32e7eSjoerg * constrain the skipping of function bodies to the preamble. 131706f32e7eSjoerg * 131806f32e7eSjoerg * The function bodies of the main file are not skipped. 131906f32e7eSjoerg */ 132006f32e7eSjoerg CXTranslationUnit_LimitSkipFunctionBodiesToPreamble = 0x800, 132106f32e7eSjoerg 132206f32e7eSjoerg /** 132306f32e7eSjoerg * Used to indicate that attributed types should be included in CXType. 132406f32e7eSjoerg */ 132506f32e7eSjoerg CXTranslationUnit_IncludeAttributedTypes = 0x1000, 132606f32e7eSjoerg 132706f32e7eSjoerg /** 132806f32e7eSjoerg * Used to indicate that implicit attributes should be visited. 132906f32e7eSjoerg */ 133006f32e7eSjoerg CXTranslationUnit_VisitImplicitAttributes = 0x2000, 133106f32e7eSjoerg 133206f32e7eSjoerg /** 133306f32e7eSjoerg * Used to indicate that non-errors from included files should be ignored. 133406f32e7eSjoerg * 133506f32e7eSjoerg * If set, clang_getDiagnosticSetFromTU() will not report e.g. warnings from 133606f32e7eSjoerg * included files anymore. This speeds up clang_getDiagnosticSetFromTU() for 133706f32e7eSjoerg * the case where these warnings are not of interest, as for an IDE for 133806f32e7eSjoerg * example, which typically shows only the diagnostics in the main file. 133906f32e7eSjoerg */ 134006f32e7eSjoerg CXTranslationUnit_IgnoreNonErrorsFromIncludedFiles = 0x4000, 134106f32e7eSjoerg 134206f32e7eSjoerg /** 134306f32e7eSjoerg * Tells the preprocessor not to skip excluded conditional blocks. 134406f32e7eSjoerg */ 134506f32e7eSjoerg CXTranslationUnit_RetainExcludedConditionalBlocks = 0x8000 134606f32e7eSjoerg }; 134706f32e7eSjoerg 134806f32e7eSjoerg /** 134906f32e7eSjoerg * Returns the set of flags that is suitable for parsing a translation 135006f32e7eSjoerg * unit that is being edited. 135106f32e7eSjoerg * 135206f32e7eSjoerg * The set of flags returned provide options for \c clang_parseTranslationUnit() 135306f32e7eSjoerg * to indicate that the translation unit is likely to be reparsed many times, 135406f32e7eSjoerg * either explicitly (via \c clang_reparseTranslationUnit()) or implicitly 135506f32e7eSjoerg * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag 135606f32e7eSjoerg * set contains an unspecified set of optimizations (e.g., the precompiled 135706f32e7eSjoerg * preamble) geared toward improving the performance of these routines. The 135806f32e7eSjoerg * set of optimizations enabled may change from one version to the next. 135906f32e7eSjoerg */ 136006f32e7eSjoerg CINDEX_LINKAGE unsigned clang_defaultEditingTranslationUnitOptions(void); 136106f32e7eSjoerg 136206f32e7eSjoerg /** 136306f32e7eSjoerg * Same as \c clang_parseTranslationUnit2, but returns 136406f32e7eSjoerg * the \c CXTranslationUnit instead of an error code. In case of an error this 136506f32e7eSjoerg * routine returns a \c NULL \c CXTranslationUnit, without further detailed 136606f32e7eSjoerg * error codes. 136706f32e7eSjoerg */ 1368*13fbcb42Sjoerg CINDEX_LINKAGE CXTranslationUnit clang_parseTranslationUnit( 1369*13fbcb42Sjoerg CXIndex CIdx, const char *source_filename, 1370*13fbcb42Sjoerg const char *const *command_line_args, int num_command_line_args, 1371*13fbcb42Sjoerg struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files, 137206f32e7eSjoerg unsigned options); 137306f32e7eSjoerg 137406f32e7eSjoerg /** 137506f32e7eSjoerg * Parse the given source file and the translation unit corresponding 137606f32e7eSjoerg * to that file. 137706f32e7eSjoerg * 137806f32e7eSjoerg * This routine is the main entry point for the Clang C API, providing the 137906f32e7eSjoerg * ability to parse a source file into a translation unit that can then be 138006f32e7eSjoerg * queried by other functions in the API. This routine accepts a set of 138106f32e7eSjoerg * command-line arguments so that the compilation can be configured in the same 138206f32e7eSjoerg * way that the compiler is configured on the command line. 138306f32e7eSjoerg * 138406f32e7eSjoerg * \param CIdx The index object with which the translation unit will be 138506f32e7eSjoerg * associated. 138606f32e7eSjoerg * 138706f32e7eSjoerg * \param source_filename The name of the source file to load, or NULL if the 138806f32e7eSjoerg * source file is included in \c command_line_args. 138906f32e7eSjoerg * 139006f32e7eSjoerg * \param command_line_args The command-line arguments that would be 139106f32e7eSjoerg * passed to the \c clang executable if it were being invoked out-of-process. 139206f32e7eSjoerg * These command-line options will be parsed and will affect how the translation 139306f32e7eSjoerg * unit is parsed. Note that the following options are ignored: '-c', 139406f32e7eSjoerg * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'. 139506f32e7eSjoerg * 139606f32e7eSjoerg * \param num_command_line_args The number of command-line arguments in 139706f32e7eSjoerg * \c command_line_args. 139806f32e7eSjoerg * 139906f32e7eSjoerg * \param unsaved_files the files that have not yet been saved to disk 140006f32e7eSjoerg * but may be required for parsing, including the contents of 140106f32e7eSjoerg * those files. The contents and name of these files (as specified by 140206f32e7eSjoerg * CXUnsavedFile) are copied when necessary, so the client only needs to 140306f32e7eSjoerg * guarantee their validity until the call to this function returns. 140406f32e7eSjoerg * 140506f32e7eSjoerg * \param num_unsaved_files the number of unsaved file entries in \p 140606f32e7eSjoerg * unsaved_files. 140706f32e7eSjoerg * 140806f32e7eSjoerg * \param options A bitmask of options that affects how the translation unit 140906f32e7eSjoerg * is managed but not its compilation. This should be a bitwise OR of the 141006f32e7eSjoerg * CXTranslationUnit_XXX flags. 141106f32e7eSjoerg * 141206f32e7eSjoerg * \param[out] out_TU A non-NULL pointer to store the created 141306f32e7eSjoerg * \c CXTranslationUnit, describing the parsed code and containing any 141406f32e7eSjoerg * diagnostics produced by the compiler. 141506f32e7eSjoerg * 141606f32e7eSjoerg * \returns Zero on success, otherwise returns an error code. 141706f32e7eSjoerg */ 1418*13fbcb42Sjoerg CINDEX_LINKAGE enum CXErrorCode clang_parseTranslationUnit2( 1419*13fbcb42Sjoerg CXIndex CIdx, const char *source_filename, 1420*13fbcb42Sjoerg const char *const *command_line_args, int num_command_line_args, 1421*13fbcb42Sjoerg struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files, 1422*13fbcb42Sjoerg unsigned options, CXTranslationUnit *out_TU); 142306f32e7eSjoerg 142406f32e7eSjoerg /** 142506f32e7eSjoerg * Same as clang_parseTranslationUnit2 but requires a full command line 142606f32e7eSjoerg * for \c command_line_args including argv[0]. This is useful if the standard 142706f32e7eSjoerg * library paths are relative to the binary. 142806f32e7eSjoerg */ 142906f32e7eSjoerg CINDEX_LINKAGE enum CXErrorCode clang_parseTranslationUnit2FullArgv( 143006f32e7eSjoerg CXIndex CIdx, const char *source_filename, 143106f32e7eSjoerg const char *const *command_line_args, int num_command_line_args, 143206f32e7eSjoerg struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files, 143306f32e7eSjoerg unsigned options, CXTranslationUnit *out_TU); 143406f32e7eSjoerg 143506f32e7eSjoerg /** 143606f32e7eSjoerg * Flags that control how translation units are saved. 143706f32e7eSjoerg * 143806f32e7eSjoerg * The enumerators in this enumeration type are meant to be bitwise 143906f32e7eSjoerg * ORed together to specify which options should be used when 144006f32e7eSjoerg * saving the translation unit. 144106f32e7eSjoerg */ 144206f32e7eSjoerg enum CXSaveTranslationUnit_Flags { 144306f32e7eSjoerg /** 144406f32e7eSjoerg * Used to indicate that no special saving options are needed. 144506f32e7eSjoerg */ 144606f32e7eSjoerg CXSaveTranslationUnit_None = 0x0 144706f32e7eSjoerg }; 144806f32e7eSjoerg 144906f32e7eSjoerg /** 145006f32e7eSjoerg * Returns the set of flags that is suitable for saving a translation 145106f32e7eSjoerg * unit. 145206f32e7eSjoerg * 145306f32e7eSjoerg * The set of flags returned provide options for 145406f32e7eSjoerg * \c clang_saveTranslationUnit() by default. The returned flag 145506f32e7eSjoerg * set contains an unspecified set of options that save translation units with 145606f32e7eSjoerg * the most commonly-requested data. 145706f32e7eSjoerg */ 145806f32e7eSjoerg CINDEX_LINKAGE unsigned clang_defaultSaveOptions(CXTranslationUnit TU); 145906f32e7eSjoerg 146006f32e7eSjoerg /** 146106f32e7eSjoerg * Describes the kind of error that occurred (if any) in a call to 146206f32e7eSjoerg * \c clang_saveTranslationUnit(). 146306f32e7eSjoerg */ 146406f32e7eSjoerg enum CXSaveError { 146506f32e7eSjoerg /** 146606f32e7eSjoerg * Indicates that no error occurred while saving a translation unit. 146706f32e7eSjoerg */ 146806f32e7eSjoerg CXSaveError_None = 0, 146906f32e7eSjoerg 147006f32e7eSjoerg /** 147106f32e7eSjoerg * Indicates that an unknown error occurred while attempting to save 147206f32e7eSjoerg * the file. 147306f32e7eSjoerg * 147406f32e7eSjoerg * This error typically indicates that file I/O failed when attempting to 147506f32e7eSjoerg * write the file. 147606f32e7eSjoerg */ 147706f32e7eSjoerg CXSaveError_Unknown = 1, 147806f32e7eSjoerg 147906f32e7eSjoerg /** 148006f32e7eSjoerg * Indicates that errors during translation prevented this attempt 148106f32e7eSjoerg * to save the translation unit. 148206f32e7eSjoerg * 148306f32e7eSjoerg * Errors that prevent the translation unit from being saved can be 148406f32e7eSjoerg * extracted using \c clang_getNumDiagnostics() and \c clang_getDiagnostic(). 148506f32e7eSjoerg */ 148606f32e7eSjoerg CXSaveError_TranslationErrors = 2, 148706f32e7eSjoerg 148806f32e7eSjoerg /** 148906f32e7eSjoerg * Indicates that the translation unit to be saved was somehow 149006f32e7eSjoerg * invalid (e.g., NULL). 149106f32e7eSjoerg */ 149206f32e7eSjoerg CXSaveError_InvalidTU = 3 149306f32e7eSjoerg }; 149406f32e7eSjoerg 149506f32e7eSjoerg /** 149606f32e7eSjoerg * Saves a translation unit into a serialized representation of 149706f32e7eSjoerg * that translation unit on disk. 149806f32e7eSjoerg * 149906f32e7eSjoerg * Any translation unit that was parsed without error can be saved 150006f32e7eSjoerg * into a file. The translation unit can then be deserialized into a 150106f32e7eSjoerg * new \c CXTranslationUnit with \c clang_createTranslationUnit() or, 150206f32e7eSjoerg * if it is an incomplete translation unit that corresponds to a 150306f32e7eSjoerg * header, used as a precompiled header when parsing other translation 150406f32e7eSjoerg * units. 150506f32e7eSjoerg * 150606f32e7eSjoerg * \param TU The translation unit to save. 150706f32e7eSjoerg * 150806f32e7eSjoerg * \param FileName The file to which the translation unit will be saved. 150906f32e7eSjoerg * 151006f32e7eSjoerg * \param options A bitmask of options that affects how the translation unit 151106f32e7eSjoerg * is saved. This should be a bitwise OR of the 151206f32e7eSjoerg * CXSaveTranslationUnit_XXX flags. 151306f32e7eSjoerg * 151406f32e7eSjoerg * \returns A value that will match one of the enumerators of the CXSaveError 151506f32e7eSjoerg * enumeration. Zero (CXSaveError_None) indicates that the translation unit was 151606f32e7eSjoerg * saved successfully, while a non-zero value indicates that a problem occurred. 151706f32e7eSjoerg */ 151806f32e7eSjoerg CINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU, 151906f32e7eSjoerg const char *FileName, 152006f32e7eSjoerg unsigned options); 152106f32e7eSjoerg 152206f32e7eSjoerg /** 152306f32e7eSjoerg * Suspend a translation unit in order to free memory associated with it. 152406f32e7eSjoerg * 152506f32e7eSjoerg * A suspended translation unit uses significantly less memory but on the other 152606f32e7eSjoerg * side does not support any other calls than \c clang_reparseTranslationUnit 152706f32e7eSjoerg * to resume it or \c clang_disposeTranslationUnit to dispose it completely. 152806f32e7eSjoerg */ 152906f32e7eSjoerg CINDEX_LINKAGE unsigned clang_suspendTranslationUnit(CXTranslationUnit); 153006f32e7eSjoerg 153106f32e7eSjoerg /** 153206f32e7eSjoerg * Destroy the specified CXTranslationUnit object. 153306f32e7eSjoerg */ 153406f32e7eSjoerg CINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit); 153506f32e7eSjoerg 153606f32e7eSjoerg /** 153706f32e7eSjoerg * Flags that control the reparsing of translation units. 153806f32e7eSjoerg * 153906f32e7eSjoerg * The enumerators in this enumeration type are meant to be bitwise 154006f32e7eSjoerg * ORed together to specify which options should be used when 154106f32e7eSjoerg * reparsing the translation unit. 154206f32e7eSjoerg */ 154306f32e7eSjoerg enum CXReparse_Flags { 154406f32e7eSjoerg /** 154506f32e7eSjoerg * Used to indicate that no special reparsing options are needed. 154606f32e7eSjoerg */ 154706f32e7eSjoerg CXReparse_None = 0x0 154806f32e7eSjoerg }; 154906f32e7eSjoerg 155006f32e7eSjoerg /** 155106f32e7eSjoerg * Returns the set of flags that is suitable for reparsing a translation 155206f32e7eSjoerg * unit. 155306f32e7eSjoerg * 155406f32e7eSjoerg * The set of flags returned provide options for 155506f32e7eSjoerg * \c clang_reparseTranslationUnit() by default. The returned flag 155606f32e7eSjoerg * set contains an unspecified set of optimizations geared toward common uses 155706f32e7eSjoerg * of reparsing. The set of optimizations enabled may change from one version 155806f32e7eSjoerg * to the next. 155906f32e7eSjoerg */ 156006f32e7eSjoerg CINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU); 156106f32e7eSjoerg 156206f32e7eSjoerg /** 156306f32e7eSjoerg * Reparse the source files that produced this translation unit. 156406f32e7eSjoerg * 156506f32e7eSjoerg * This routine can be used to re-parse the source files that originally 156606f32e7eSjoerg * created the given translation unit, for example because those source files 156706f32e7eSjoerg * have changed (either on disk or as passed via \p unsaved_files). The 156806f32e7eSjoerg * source code will be reparsed with the same command-line options as it 156906f32e7eSjoerg * was originally parsed. 157006f32e7eSjoerg * 157106f32e7eSjoerg * Reparsing a translation unit invalidates all cursors and source locations 157206f32e7eSjoerg * that refer into that translation unit. This makes reparsing a translation 157306f32e7eSjoerg * unit semantically equivalent to destroying the translation unit and then 157406f32e7eSjoerg * creating a new translation unit with the same command-line arguments. 157506f32e7eSjoerg * However, it may be more efficient to reparse a translation 157606f32e7eSjoerg * unit using this routine. 157706f32e7eSjoerg * 157806f32e7eSjoerg * \param TU The translation unit whose contents will be re-parsed. The 157906f32e7eSjoerg * translation unit must originally have been built with 158006f32e7eSjoerg * \c clang_createTranslationUnitFromSourceFile(). 158106f32e7eSjoerg * 158206f32e7eSjoerg * \param num_unsaved_files The number of unsaved file entries in \p 158306f32e7eSjoerg * unsaved_files. 158406f32e7eSjoerg * 158506f32e7eSjoerg * \param unsaved_files The files that have not yet been saved to disk 158606f32e7eSjoerg * but may be required for parsing, including the contents of 158706f32e7eSjoerg * those files. The contents and name of these files (as specified by 158806f32e7eSjoerg * CXUnsavedFile) are copied when necessary, so the client only needs to 158906f32e7eSjoerg * guarantee their validity until the call to this function returns. 159006f32e7eSjoerg * 159106f32e7eSjoerg * \param options A bitset of options composed of the flags in CXReparse_Flags. 159206f32e7eSjoerg * The function \c clang_defaultReparseOptions() produces a default set of 159306f32e7eSjoerg * options recommended for most uses, based on the translation unit. 159406f32e7eSjoerg * 159506f32e7eSjoerg * \returns 0 if the sources could be reparsed. A non-zero error code will be 159606f32e7eSjoerg * returned if reparsing was impossible, such that the translation unit is 159706f32e7eSjoerg * invalid. In such cases, the only valid call for \c TU is 159806f32e7eSjoerg * \c clang_disposeTranslationUnit(TU). The error codes returned by this 159906f32e7eSjoerg * routine are described by the \c CXErrorCode enum. 160006f32e7eSjoerg */ 1601*13fbcb42Sjoerg CINDEX_LINKAGE int 1602*13fbcb42Sjoerg clang_reparseTranslationUnit(CXTranslationUnit TU, unsigned num_unsaved_files, 160306f32e7eSjoerg struct CXUnsavedFile *unsaved_files, 160406f32e7eSjoerg unsigned options); 160506f32e7eSjoerg 160606f32e7eSjoerg /** 160706f32e7eSjoerg * Categorizes how memory is being used by a translation unit. 160806f32e7eSjoerg */ 160906f32e7eSjoerg enum CXTUResourceUsageKind { 161006f32e7eSjoerg CXTUResourceUsage_AST = 1, 161106f32e7eSjoerg CXTUResourceUsage_Identifiers = 2, 161206f32e7eSjoerg CXTUResourceUsage_Selectors = 3, 161306f32e7eSjoerg CXTUResourceUsage_GlobalCompletionResults = 4, 161406f32e7eSjoerg CXTUResourceUsage_SourceManagerContentCache = 5, 161506f32e7eSjoerg CXTUResourceUsage_AST_SideTables = 6, 161606f32e7eSjoerg CXTUResourceUsage_SourceManager_Membuffer_Malloc = 7, 161706f32e7eSjoerg CXTUResourceUsage_SourceManager_Membuffer_MMap = 8, 161806f32e7eSjoerg CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc = 9, 161906f32e7eSjoerg CXTUResourceUsage_ExternalASTSource_Membuffer_MMap = 10, 162006f32e7eSjoerg CXTUResourceUsage_Preprocessor = 11, 162106f32e7eSjoerg CXTUResourceUsage_PreprocessingRecord = 12, 162206f32e7eSjoerg CXTUResourceUsage_SourceManager_DataStructures = 13, 162306f32e7eSjoerg CXTUResourceUsage_Preprocessor_HeaderSearch = 14, 162406f32e7eSjoerg CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST, 162506f32e7eSjoerg CXTUResourceUsage_MEMORY_IN_BYTES_END = 162606f32e7eSjoerg CXTUResourceUsage_Preprocessor_HeaderSearch, 162706f32e7eSjoerg 162806f32e7eSjoerg CXTUResourceUsage_First = CXTUResourceUsage_AST, 162906f32e7eSjoerg CXTUResourceUsage_Last = CXTUResourceUsage_Preprocessor_HeaderSearch 163006f32e7eSjoerg }; 163106f32e7eSjoerg 163206f32e7eSjoerg /** 163306f32e7eSjoerg * Returns the human-readable null-terminated C string that represents 163406f32e7eSjoerg * the name of the memory category. This string should never be freed. 163506f32e7eSjoerg */ 163606f32e7eSjoerg CINDEX_LINKAGE 163706f32e7eSjoerg const char *clang_getTUResourceUsageName(enum CXTUResourceUsageKind kind); 163806f32e7eSjoerg 163906f32e7eSjoerg typedef struct CXTUResourceUsageEntry { 164006f32e7eSjoerg /* The memory usage category. */ 164106f32e7eSjoerg enum CXTUResourceUsageKind kind; 164206f32e7eSjoerg /* Amount of resources used. 164306f32e7eSjoerg The units will depend on the resource kind. */ 164406f32e7eSjoerg unsigned long amount; 164506f32e7eSjoerg } CXTUResourceUsageEntry; 164606f32e7eSjoerg 164706f32e7eSjoerg /** 164806f32e7eSjoerg * The memory usage of a CXTranslationUnit, broken into categories. 164906f32e7eSjoerg */ 165006f32e7eSjoerg typedef struct CXTUResourceUsage { 165106f32e7eSjoerg /* Private data member, used for queries. */ 165206f32e7eSjoerg void *data; 165306f32e7eSjoerg 165406f32e7eSjoerg /* The number of entries in the 'entries' array. */ 165506f32e7eSjoerg unsigned numEntries; 165606f32e7eSjoerg 165706f32e7eSjoerg /* An array of key-value pairs, representing the breakdown of memory 165806f32e7eSjoerg usage. */ 165906f32e7eSjoerg CXTUResourceUsageEntry *entries; 166006f32e7eSjoerg 166106f32e7eSjoerg } CXTUResourceUsage; 166206f32e7eSjoerg 166306f32e7eSjoerg /** 166406f32e7eSjoerg * Return the memory usage of a translation unit. This object 166506f32e7eSjoerg * should be released with clang_disposeCXTUResourceUsage(). 166606f32e7eSjoerg */ 1667*13fbcb42Sjoerg CINDEX_LINKAGE CXTUResourceUsage 1668*13fbcb42Sjoerg clang_getCXTUResourceUsage(CXTranslationUnit TU); 166906f32e7eSjoerg 167006f32e7eSjoerg CINDEX_LINKAGE void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage); 167106f32e7eSjoerg 167206f32e7eSjoerg /** 167306f32e7eSjoerg * Get target information for this translation unit. 167406f32e7eSjoerg * 167506f32e7eSjoerg * The CXTargetInfo object cannot outlive the CXTranslationUnit object. 167606f32e7eSjoerg */ 167706f32e7eSjoerg CINDEX_LINKAGE CXTargetInfo 167806f32e7eSjoerg clang_getTranslationUnitTargetInfo(CXTranslationUnit CTUnit); 167906f32e7eSjoerg 168006f32e7eSjoerg /** 168106f32e7eSjoerg * Destroy the CXTargetInfo object. 168206f32e7eSjoerg */ 1683*13fbcb42Sjoerg CINDEX_LINKAGE void clang_TargetInfo_dispose(CXTargetInfo Info); 168406f32e7eSjoerg 168506f32e7eSjoerg /** 168606f32e7eSjoerg * Get the normalized target triple as a string. 168706f32e7eSjoerg * 168806f32e7eSjoerg * Returns the empty string in case of any error. 168906f32e7eSjoerg */ 1690*13fbcb42Sjoerg CINDEX_LINKAGE CXString clang_TargetInfo_getTriple(CXTargetInfo Info); 169106f32e7eSjoerg 169206f32e7eSjoerg /** 169306f32e7eSjoerg * Get the pointer width of the target in bits. 169406f32e7eSjoerg * 169506f32e7eSjoerg * Returns -1 in case of error. 169606f32e7eSjoerg */ 1697*13fbcb42Sjoerg CINDEX_LINKAGE int clang_TargetInfo_getPointerWidth(CXTargetInfo Info); 169806f32e7eSjoerg 169906f32e7eSjoerg /** 170006f32e7eSjoerg * @} 170106f32e7eSjoerg */ 170206f32e7eSjoerg 170306f32e7eSjoerg /** 170406f32e7eSjoerg * Describes the kind of entity that a cursor refers to. 170506f32e7eSjoerg */ 170606f32e7eSjoerg enum CXCursorKind { 170706f32e7eSjoerg /* Declarations */ 170806f32e7eSjoerg /** 170906f32e7eSjoerg * A declaration whose specific kind is not exposed via this 171006f32e7eSjoerg * interface. 171106f32e7eSjoerg * 171206f32e7eSjoerg * Unexposed declarations have the same operations as any other kind 171306f32e7eSjoerg * of declaration; one can extract their location information, 171406f32e7eSjoerg * spelling, find their definitions, etc. However, the specific kind 171506f32e7eSjoerg * of the declaration is not reported. 171606f32e7eSjoerg */ 171706f32e7eSjoerg CXCursor_UnexposedDecl = 1, 171806f32e7eSjoerg /** A C or C++ struct. */ 171906f32e7eSjoerg CXCursor_StructDecl = 2, 172006f32e7eSjoerg /** A C or C++ union. */ 172106f32e7eSjoerg CXCursor_UnionDecl = 3, 172206f32e7eSjoerg /** A C++ class. */ 172306f32e7eSjoerg CXCursor_ClassDecl = 4, 172406f32e7eSjoerg /** An enumeration. */ 172506f32e7eSjoerg CXCursor_EnumDecl = 5, 172606f32e7eSjoerg /** 172706f32e7eSjoerg * A field (in C) or non-static data member (in C++) in a 172806f32e7eSjoerg * struct, union, or C++ class. 172906f32e7eSjoerg */ 173006f32e7eSjoerg CXCursor_FieldDecl = 6, 173106f32e7eSjoerg /** An enumerator constant. */ 173206f32e7eSjoerg CXCursor_EnumConstantDecl = 7, 173306f32e7eSjoerg /** A function. */ 173406f32e7eSjoerg CXCursor_FunctionDecl = 8, 173506f32e7eSjoerg /** A variable. */ 173606f32e7eSjoerg CXCursor_VarDecl = 9, 173706f32e7eSjoerg /** A function or method parameter. */ 173806f32e7eSjoerg CXCursor_ParmDecl = 10, 173906f32e7eSjoerg /** An Objective-C \@interface. */ 174006f32e7eSjoerg CXCursor_ObjCInterfaceDecl = 11, 174106f32e7eSjoerg /** An Objective-C \@interface for a category. */ 174206f32e7eSjoerg CXCursor_ObjCCategoryDecl = 12, 174306f32e7eSjoerg /** An Objective-C \@protocol declaration. */ 174406f32e7eSjoerg CXCursor_ObjCProtocolDecl = 13, 174506f32e7eSjoerg /** An Objective-C \@property declaration. */ 174606f32e7eSjoerg CXCursor_ObjCPropertyDecl = 14, 174706f32e7eSjoerg /** An Objective-C instance variable. */ 174806f32e7eSjoerg CXCursor_ObjCIvarDecl = 15, 174906f32e7eSjoerg /** An Objective-C instance method. */ 175006f32e7eSjoerg CXCursor_ObjCInstanceMethodDecl = 16, 175106f32e7eSjoerg /** An Objective-C class method. */ 175206f32e7eSjoerg CXCursor_ObjCClassMethodDecl = 17, 175306f32e7eSjoerg /** An Objective-C \@implementation. */ 175406f32e7eSjoerg CXCursor_ObjCImplementationDecl = 18, 175506f32e7eSjoerg /** An Objective-C \@implementation for a category. */ 175606f32e7eSjoerg CXCursor_ObjCCategoryImplDecl = 19, 175706f32e7eSjoerg /** A typedef. */ 175806f32e7eSjoerg CXCursor_TypedefDecl = 20, 175906f32e7eSjoerg /** A C++ class method. */ 176006f32e7eSjoerg CXCursor_CXXMethod = 21, 176106f32e7eSjoerg /** A C++ namespace. */ 176206f32e7eSjoerg CXCursor_Namespace = 22, 176306f32e7eSjoerg /** A linkage specification, e.g. 'extern "C"'. */ 176406f32e7eSjoerg CXCursor_LinkageSpec = 23, 176506f32e7eSjoerg /** A C++ constructor. */ 176606f32e7eSjoerg CXCursor_Constructor = 24, 176706f32e7eSjoerg /** A C++ destructor. */ 176806f32e7eSjoerg CXCursor_Destructor = 25, 176906f32e7eSjoerg /** A C++ conversion function. */ 177006f32e7eSjoerg CXCursor_ConversionFunction = 26, 177106f32e7eSjoerg /** A C++ template type parameter. */ 177206f32e7eSjoerg CXCursor_TemplateTypeParameter = 27, 177306f32e7eSjoerg /** A C++ non-type template parameter. */ 177406f32e7eSjoerg CXCursor_NonTypeTemplateParameter = 28, 177506f32e7eSjoerg /** A C++ template template parameter. */ 177606f32e7eSjoerg CXCursor_TemplateTemplateParameter = 29, 177706f32e7eSjoerg /** A C++ function template. */ 177806f32e7eSjoerg CXCursor_FunctionTemplate = 30, 177906f32e7eSjoerg /** A C++ class template. */ 178006f32e7eSjoerg CXCursor_ClassTemplate = 31, 178106f32e7eSjoerg /** A C++ class template partial specialization. */ 178206f32e7eSjoerg CXCursor_ClassTemplatePartialSpecialization = 32, 178306f32e7eSjoerg /** A C++ namespace alias declaration. */ 178406f32e7eSjoerg CXCursor_NamespaceAlias = 33, 178506f32e7eSjoerg /** A C++ using directive. */ 178606f32e7eSjoerg CXCursor_UsingDirective = 34, 178706f32e7eSjoerg /** A C++ using declaration. */ 178806f32e7eSjoerg CXCursor_UsingDeclaration = 35, 178906f32e7eSjoerg /** A C++ alias declaration */ 179006f32e7eSjoerg CXCursor_TypeAliasDecl = 36, 179106f32e7eSjoerg /** An Objective-C \@synthesize definition. */ 179206f32e7eSjoerg CXCursor_ObjCSynthesizeDecl = 37, 179306f32e7eSjoerg /** An Objective-C \@dynamic definition. */ 179406f32e7eSjoerg CXCursor_ObjCDynamicDecl = 38, 179506f32e7eSjoerg /** An access specifier. */ 179606f32e7eSjoerg CXCursor_CXXAccessSpecifier = 39, 179706f32e7eSjoerg 179806f32e7eSjoerg CXCursor_FirstDecl = CXCursor_UnexposedDecl, 179906f32e7eSjoerg CXCursor_LastDecl = CXCursor_CXXAccessSpecifier, 180006f32e7eSjoerg 180106f32e7eSjoerg /* References */ 180206f32e7eSjoerg CXCursor_FirstRef = 40, /* Decl references */ 180306f32e7eSjoerg CXCursor_ObjCSuperClassRef = 40, 180406f32e7eSjoerg CXCursor_ObjCProtocolRef = 41, 180506f32e7eSjoerg CXCursor_ObjCClassRef = 42, 180606f32e7eSjoerg /** 180706f32e7eSjoerg * A reference to a type declaration. 180806f32e7eSjoerg * 180906f32e7eSjoerg * A type reference occurs anywhere where a type is named but not 181006f32e7eSjoerg * declared. For example, given: 181106f32e7eSjoerg * 181206f32e7eSjoerg * \code 181306f32e7eSjoerg * typedef unsigned size_type; 181406f32e7eSjoerg * size_type size; 181506f32e7eSjoerg * \endcode 181606f32e7eSjoerg * 181706f32e7eSjoerg * The typedef is a declaration of size_type (CXCursor_TypedefDecl), 181806f32e7eSjoerg * while the type of the variable "size" is referenced. The cursor 181906f32e7eSjoerg * referenced by the type of size is the typedef for size_type. 182006f32e7eSjoerg */ 182106f32e7eSjoerg CXCursor_TypeRef = 43, 182206f32e7eSjoerg CXCursor_CXXBaseSpecifier = 44, 182306f32e7eSjoerg /** 182406f32e7eSjoerg * A reference to a class template, function template, template 182506f32e7eSjoerg * template parameter, or class template partial specialization. 182606f32e7eSjoerg */ 182706f32e7eSjoerg CXCursor_TemplateRef = 45, 182806f32e7eSjoerg /** 182906f32e7eSjoerg * A reference to a namespace or namespace alias. 183006f32e7eSjoerg */ 183106f32e7eSjoerg CXCursor_NamespaceRef = 46, 183206f32e7eSjoerg /** 183306f32e7eSjoerg * A reference to a member of a struct, union, or class that occurs in 183406f32e7eSjoerg * some non-expression context, e.g., a designated initializer. 183506f32e7eSjoerg */ 183606f32e7eSjoerg CXCursor_MemberRef = 47, 183706f32e7eSjoerg /** 183806f32e7eSjoerg * A reference to a labeled statement. 183906f32e7eSjoerg * 184006f32e7eSjoerg * This cursor kind is used to describe the jump to "start_over" in the 184106f32e7eSjoerg * goto statement in the following example: 184206f32e7eSjoerg * 184306f32e7eSjoerg * \code 184406f32e7eSjoerg * start_over: 184506f32e7eSjoerg * ++counter; 184606f32e7eSjoerg * 184706f32e7eSjoerg * goto start_over; 184806f32e7eSjoerg * \endcode 184906f32e7eSjoerg * 185006f32e7eSjoerg * A label reference cursor refers to a label statement. 185106f32e7eSjoerg */ 185206f32e7eSjoerg CXCursor_LabelRef = 48, 185306f32e7eSjoerg 185406f32e7eSjoerg /** 185506f32e7eSjoerg * A reference to a set of overloaded functions or function templates 185606f32e7eSjoerg * that has not yet been resolved to a specific function or function template. 185706f32e7eSjoerg * 185806f32e7eSjoerg * An overloaded declaration reference cursor occurs in C++ templates where 185906f32e7eSjoerg * a dependent name refers to a function. For example: 186006f32e7eSjoerg * 186106f32e7eSjoerg * \code 186206f32e7eSjoerg * template<typename T> void swap(T&, T&); 186306f32e7eSjoerg * 186406f32e7eSjoerg * struct X { ... }; 186506f32e7eSjoerg * void swap(X&, X&); 186606f32e7eSjoerg * 186706f32e7eSjoerg * template<typename T> 186806f32e7eSjoerg * void reverse(T* first, T* last) { 186906f32e7eSjoerg * while (first < last - 1) { 187006f32e7eSjoerg * swap(*first, *--last); 187106f32e7eSjoerg * ++first; 187206f32e7eSjoerg * } 187306f32e7eSjoerg * } 187406f32e7eSjoerg * 187506f32e7eSjoerg * struct Y { }; 187606f32e7eSjoerg * void swap(Y&, Y&); 187706f32e7eSjoerg * \endcode 187806f32e7eSjoerg * 187906f32e7eSjoerg * Here, the identifier "swap" is associated with an overloaded declaration 188006f32e7eSjoerg * reference. In the template definition, "swap" refers to either of the two 188106f32e7eSjoerg * "swap" functions declared above, so both results will be available. At 188206f32e7eSjoerg * instantiation time, "swap" may also refer to other functions found via 188306f32e7eSjoerg * argument-dependent lookup (e.g., the "swap" function at the end of the 188406f32e7eSjoerg * example). 188506f32e7eSjoerg * 188606f32e7eSjoerg * The functions \c clang_getNumOverloadedDecls() and 188706f32e7eSjoerg * \c clang_getOverloadedDecl() can be used to retrieve the definitions 188806f32e7eSjoerg * referenced by this cursor. 188906f32e7eSjoerg */ 189006f32e7eSjoerg CXCursor_OverloadedDeclRef = 49, 189106f32e7eSjoerg 189206f32e7eSjoerg /** 189306f32e7eSjoerg * A reference to a variable that occurs in some non-expression 189406f32e7eSjoerg * context, e.g., a C++ lambda capture list. 189506f32e7eSjoerg */ 189606f32e7eSjoerg CXCursor_VariableRef = 50, 189706f32e7eSjoerg 189806f32e7eSjoerg CXCursor_LastRef = CXCursor_VariableRef, 189906f32e7eSjoerg 190006f32e7eSjoerg /* Error conditions */ 190106f32e7eSjoerg CXCursor_FirstInvalid = 70, 190206f32e7eSjoerg CXCursor_InvalidFile = 70, 190306f32e7eSjoerg CXCursor_NoDeclFound = 71, 190406f32e7eSjoerg CXCursor_NotImplemented = 72, 190506f32e7eSjoerg CXCursor_InvalidCode = 73, 190606f32e7eSjoerg CXCursor_LastInvalid = CXCursor_InvalidCode, 190706f32e7eSjoerg 190806f32e7eSjoerg /* Expressions */ 190906f32e7eSjoerg CXCursor_FirstExpr = 100, 191006f32e7eSjoerg 191106f32e7eSjoerg /** 191206f32e7eSjoerg * An expression whose specific kind is not exposed via this 191306f32e7eSjoerg * interface. 191406f32e7eSjoerg * 191506f32e7eSjoerg * Unexposed expressions have the same operations as any other kind 191606f32e7eSjoerg * of expression; one can extract their location information, 191706f32e7eSjoerg * spelling, children, etc. However, the specific kind of the 191806f32e7eSjoerg * expression is not reported. 191906f32e7eSjoerg */ 192006f32e7eSjoerg CXCursor_UnexposedExpr = 100, 192106f32e7eSjoerg 192206f32e7eSjoerg /** 192306f32e7eSjoerg * An expression that refers to some value declaration, such 192406f32e7eSjoerg * as a function, variable, or enumerator. 192506f32e7eSjoerg */ 192606f32e7eSjoerg CXCursor_DeclRefExpr = 101, 192706f32e7eSjoerg 192806f32e7eSjoerg /** 192906f32e7eSjoerg * An expression that refers to a member of a struct, union, 193006f32e7eSjoerg * class, Objective-C class, etc. 193106f32e7eSjoerg */ 193206f32e7eSjoerg CXCursor_MemberRefExpr = 102, 193306f32e7eSjoerg 193406f32e7eSjoerg /** An expression that calls a function. */ 193506f32e7eSjoerg CXCursor_CallExpr = 103, 193606f32e7eSjoerg 193706f32e7eSjoerg /** An expression that sends a message to an Objective-C 193806f32e7eSjoerg object or class. */ 193906f32e7eSjoerg CXCursor_ObjCMessageExpr = 104, 194006f32e7eSjoerg 194106f32e7eSjoerg /** An expression that represents a block literal. */ 194206f32e7eSjoerg CXCursor_BlockExpr = 105, 194306f32e7eSjoerg 194406f32e7eSjoerg /** An integer literal. 194506f32e7eSjoerg */ 194606f32e7eSjoerg CXCursor_IntegerLiteral = 106, 194706f32e7eSjoerg 194806f32e7eSjoerg /** A floating point number literal. 194906f32e7eSjoerg */ 195006f32e7eSjoerg CXCursor_FloatingLiteral = 107, 195106f32e7eSjoerg 195206f32e7eSjoerg /** An imaginary number literal. 195306f32e7eSjoerg */ 195406f32e7eSjoerg CXCursor_ImaginaryLiteral = 108, 195506f32e7eSjoerg 195606f32e7eSjoerg /** A string literal. 195706f32e7eSjoerg */ 195806f32e7eSjoerg CXCursor_StringLiteral = 109, 195906f32e7eSjoerg 196006f32e7eSjoerg /** A character literal. 196106f32e7eSjoerg */ 196206f32e7eSjoerg CXCursor_CharacterLiteral = 110, 196306f32e7eSjoerg 196406f32e7eSjoerg /** A parenthesized expression, e.g. "(1)". 196506f32e7eSjoerg * 196606f32e7eSjoerg * This AST node is only formed if full location information is requested. 196706f32e7eSjoerg */ 196806f32e7eSjoerg CXCursor_ParenExpr = 111, 196906f32e7eSjoerg 197006f32e7eSjoerg /** This represents the unary-expression's (except sizeof and 197106f32e7eSjoerg * alignof). 197206f32e7eSjoerg */ 197306f32e7eSjoerg CXCursor_UnaryOperator = 112, 197406f32e7eSjoerg 197506f32e7eSjoerg /** [C99 6.5.2.1] Array Subscripting. 197606f32e7eSjoerg */ 197706f32e7eSjoerg CXCursor_ArraySubscriptExpr = 113, 197806f32e7eSjoerg 197906f32e7eSjoerg /** A builtin binary operation expression such as "x + y" or 198006f32e7eSjoerg * "x <= y". 198106f32e7eSjoerg */ 198206f32e7eSjoerg CXCursor_BinaryOperator = 114, 198306f32e7eSjoerg 198406f32e7eSjoerg /** Compound assignment such as "+=". 198506f32e7eSjoerg */ 198606f32e7eSjoerg CXCursor_CompoundAssignOperator = 115, 198706f32e7eSjoerg 198806f32e7eSjoerg /** The ?: ternary operator. 198906f32e7eSjoerg */ 199006f32e7eSjoerg CXCursor_ConditionalOperator = 116, 199106f32e7eSjoerg 199206f32e7eSjoerg /** An explicit cast in C (C99 6.5.4) or a C-style cast in C++ 199306f32e7eSjoerg * (C++ [expr.cast]), which uses the syntax (Type)expr. 199406f32e7eSjoerg * 199506f32e7eSjoerg * For example: (int)f. 199606f32e7eSjoerg */ 199706f32e7eSjoerg CXCursor_CStyleCastExpr = 117, 199806f32e7eSjoerg 199906f32e7eSjoerg /** [C99 6.5.2.5] 200006f32e7eSjoerg */ 200106f32e7eSjoerg CXCursor_CompoundLiteralExpr = 118, 200206f32e7eSjoerg 200306f32e7eSjoerg /** Describes an C or C++ initializer list. 200406f32e7eSjoerg */ 200506f32e7eSjoerg CXCursor_InitListExpr = 119, 200606f32e7eSjoerg 200706f32e7eSjoerg /** The GNU address of label extension, representing &&label. 200806f32e7eSjoerg */ 200906f32e7eSjoerg CXCursor_AddrLabelExpr = 120, 201006f32e7eSjoerg 201106f32e7eSjoerg /** This is the GNU Statement Expression extension: ({int X=4; X;}) 201206f32e7eSjoerg */ 201306f32e7eSjoerg CXCursor_StmtExpr = 121, 201406f32e7eSjoerg 201506f32e7eSjoerg /** Represents a C11 generic selection. 201606f32e7eSjoerg */ 201706f32e7eSjoerg CXCursor_GenericSelectionExpr = 122, 201806f32e7eSjoerg 201906f32e7eSjoerg /** Implements the GNU __null extension, which is a name for a null 202006f32e7eSjoerg * pointer constant that has integral type (e.g., int or long) and is the same 202106f32e7eSjoerg * size and alignment as a pointer. 202206f32e7eSjoerg * 202306f32e7eSjoerg * The __null extension is typically only used by system headers, which define 202406f32e7eSjoerg * NULL as __null in C++ rather than using 0 (which is an integer that may not 202506f32e7eSjoerg * match the size of a pointer). 202606f32e7eSjoerg */ 202706f32e7eSjoerg CXCursor_GNUNullExpr = 123, 202806f32e7eSjoerg 202906f32e7eSjoerg /** C++'s static_cast<> expression. 203006f32e7eSjoerg */ 203106f32e7eSjoerg CXCursor_CXXStaticCastExpr = 124, 203206f32e7eSjoerg 203306f32e7eSjoerg /** C++'s dynamic_cast<> expression. 203406f32e7eSjoerg */ 203506f32e7eSjoerg CXCursor_CXXDynamicCastExpr = 125, 203606f32e7eSjoerg 203706f32e7eSjoerg /** C++'s reinterpret_cast<> expression. 203806f32e7eSjoerg */ 203906f32e7eSjoerg CXCursor_CXXReinterpretCastExpr = 126, 204006f32e7eSjoerg 204106f32e7eSjoerg /** C++'s const_cast<> expression. 204206f32e7eSjoerg */ 204306f32e7eSjoerg CXCursor_CXXConstCastExpr = 127, 204406f32e7eSjoerg 204506f32e7eSjoerg /** Represents an explicit C++ type conversion that uses "functional" 204606f32e7eSjoerg * notion (C++ [expr.type.conv]). 204706f32e7eSjoerg * 204806f32e7eSjoerg * Example: 204906f32e7eSjoerg * \code 205006f32e7eSjoerg * x = int(0.5); 205106f32e7eSjoerg * \endcode 205206f32e7eSjoerg */ 205306f32e7eSjoerg CXCursor_CXXFunctionalCastExpr = 128, 205406f32e7eSjoerg 205506f32e7eSjoerg /** A C++ typeid expression (C++ [expr.typeid]). 205606f32e7eSjoerg */ 205706f32e7eSjoerg CXCursor_CXXTypeidExpr = 129, 205806f32e7eSjoerg 205906f32e7eSjoerg /** [C++ 2.13.5] C++ Boolean Literal. 206006f32e7eSjoerg */ 206106f32e7eSjoerg CXCursor_CXXBoolLiteralExpr = 130, 206206f32e7eSjoerg 206306f32e7eSjoerg /** [C++0x 2.14.7] C++ Pointer Literal. 206406f32e7eSjoerg */ 206506f32e7eSjoerg CXCursor_CXXNullPtrLiteralExpr = 131, 206606f32e7eSjoerg 206706f32e7eSjoerg /** Represents the "this" expression in C++ 206806f32e7eSjoerg */ 206906f32e7eSjoerg CXCursor_CXXThisExpr = 132, 207006f32e7eSjoerg 207106f32e7eSjoerg /** [C++ 15] C++ Throw Expression. 207206f32e7eSjoerg * 207306f32e7eSjoerg * This handles 'throw' and 'throw' assignment-expression. When 207406f32e7eSjoerg * assignment-expression isn't present, Op will be null. 207506f32e7eSjoerg */ 207606f32e7eSjoerg CXCursor_CXXThrowExpr = 133, 207706f32e7eSjoerg 207806f32e7eSjoerg /** A new expression for memory allocation and constructor calls, e.g: 207906f32e7eSjoerg * "new CXXNewExpr(foo)". 208006f32e7eSjoerg */ 208106f32e7eSjoerg CXCursor_CXXNewExpr = 134, 208206f32e7eSjoerg 208306f32e7eSjoerg /** A delete expression for memory deallocation and destructor calls, 208406f32e7eSjoerg * e.g. "delete[] pArray". 208506f32e7eSjoerg */ 208606f32e7eSjoerg CXCursor_CXXDeleteExpr = 135, 208706f32e7eSjoerg 208806f32e7eSjoerg /** A unary expression. (noexcept, sizeof, or other traits) 208906f32e7eSjoerg */ 209006f32e7eSjoerg CXCursor_UnaryExpr = 136, 209106f32e7eSjoerg 209206f32e7eSjoerg /** An Objective-C string literal i.e. @"foo". 209306f32e7eSjoerg */ 209406f32e7eSjoerg CXCursor_ObjCStringLiteral = 137, 209506f32e7eSjoerg 209606f32e7eSjoerg /** An Objective-C \@encode expression. 209706f32e7eSjoerg */ 209806f32e7eSjoerg CXCursor_ObjCEncodeExpr = 138, 209906f32e7eSjoerg 210006f32e7eSjoerg /** An Objective-C \@selector expression. 210106f32e7eSjoerg */ 210206f32e7eSjoerg CXCursor_ObjCSelectorExpr = 139, 210306f32e7eSjoerg 210406f32e7eSjoerg /** An Objective-C \@protocol expression. 210506f32e7eSjoerg */ 210606f32e7eSjoerg CXCursor_ObjCProtocolExpr = 140, 210706f32e7eSjoerg 210806f32e7eSjoerg /** An Objective-C "bridged" cast expression, which casts between 210906f32e7eSjoerg * Objective-C pointers and C pointers, transferring ownership in the process. 211006f32e7eSjoerg * 211106f32e7eSjoerg * \code 211206f32e7eSjoerg * NSString *str = (__bridge_transfer NSString *)CFCreateString(); 211306f32e7eSjoerg * \endcode 211406f32e7eSjoerg */ 211506f32e7eSjoerg CXCursor_ObjCBridgedCastExpr = 141, 211606f32e7eSjoerg 211706f32e7eSjoerg /** Represents a C++0x pack expansion that produces a sequence of 211806f32e7eSjoerg * expressions. 211906f32e7eSjoerg * 212006f32e7eSjoerg * A pack expansion expression contains a pattern (which itself is an 212106f32e7eSjoerg * expression) followed by an ellipsis. For example: 212206f32e7eSjoerg * 212306f32e7eSjoerg * \code 212406f32e7eSjoerg * template<typename F, typename ...Types> 212506f32e7eSjoerg * void forward(F f, Types &&...args) { 212606f32e7eSjoerg * f(static_cast<Types&&>(args)...); 212706f32e7eSjoerg * } 212806f32e7eSjoerg * \endcode 212906f32e7eSjoerg */ 213006f32e7eSjoerg CXCursor_PackExpansionExpr = 142, 213106f32e7eSjoerg 213206f32e7eSjoerg /** Represents an expression that computes the length of a parameter 213306f32e7eSjoerg * pack. 213406f32e7eSjoerg * 213506f32e7eSjoerg * \code 213606f32e7eSjoerg * template<typename ...Types> 213706f32e7eSjoerg * struct count { 213806f32e7eSjoerg * static const unsigned value = sizeof...(Types); 213906f32e7eSjoerg * }; 214006f32e7eSjoerg * \endcode 214106f32e7eSjoerg */ 214206f32e7eSjoerg CXCursor_SizeOfPackExpr = 143, 214306f32e7eSjoerg 214406f32e7eSjoerg /* Represents a C++ lambda expression that produces a local function 214506f32e7eSjoerg * object. 214606f32e7eSjoerg * 214706f32e7eSjoerg * \code 214806f32e7eSjoerg * void abssort(float *x, unsigned N) { 214906f32e7eSjoerg * std::sort(x, x + N, 215006f32e7eSjoerg * [](float a, float b) { 215106f32e7eSjoerg * return std::abs(a) < std::abs(b); 215206f32e7eSjoerg * }); 215306f32e7eSjoerg * } 215406f32e7eSjoerg * \endcode 215506f32e7eSjoerg */ 215606f32e7eSjoerg CXCursor_LambdaExpr = 144, 215706f32e7eSjoerg 215806f32e7eSjoerg /** Objective-c Boolean Literal. 215906f32e7eSjoerg */ 216006f32e7eSjoerg CXCursor_ObjCBoolLiteralExpr = 145, 216106f32e7eSjoerg 216206f32e7eSjoerg /** Represents the "self" expression in an Objective-C method. 216306f32e7eSjoerg */ 216406f32e7eSjoerg CXCursor_ObjCSelfExpr = 146, 216506f32e7eSjoerg 2166*13fbcb42Sjoerg /** OpenMP 5.0 [2.1.5, Array Section]. 216706f32e7eSjoerg */ 216806f32e7eSjoerg CXCursor_OMPArraySectionExpr = 147, 216906f32e7eSjoerg 217006f32e7eSjoerg /** Represents an @available(...) check. 217106f32e7eSjoerg */ 217206f32e7eSjoerg CXCursor_ObjCAvailabilityCheckExpr = 148, 217306f32e7eSjoerg 217406f32e7eSjoerg /** 217506f32e7eSjoerg * Fixed point literal 217606f32e7eSjoerg */ 217706f32e7eSjoerg CXCursor_FixedPointLiteral = 149, 217806f32e7eSjoerg 2179*13fbcb42Sjoerg /** OpenMP 5.0 [2.1.4, Array Shaping]. 2180*13fbcb42Sjoerg */ 2181*13fbcb42Sjoerg CXCursor_OMPArrayShapingExpr = 150, 2182*13fbcb42Sjoerg 2183*13fbcb42Sjoerg /** 2184*13fbcb42Sjoerg * OpenMP 5.0 [2.1.6 Iterators] 2185*13fbcb42Sjoerg */ 2186*13fbcb42Sjoerg CXCursor_OMPIteratorExpr = 151, 2187*13fbcb42Sjoerg 2188*13fbcb42Sjoerg /** OpenCL's addrspace_cast<> expression. 2189*13fbcb42Sjoerg */ 2190*13fbcb42Sjoerg CXCursor_CXXAddrspaceCastExpr = 152, 2191*13fbcb42Sjoerg 2192*13fbcb42Sjoerg CXCursor_LastExpr = CXCursor_CXXAddrspaceCastExpr, 219306f32e7eSjoerg 219406f32e7eSjoerg /* Statements */ 219506f32e7eSjoerg CXCursor_FirstStmt = 200, 219606f32e7eSjoerg /** 219706f32e7eSjoerg * A statement whose specific kind is not exposed via this 219806f32e7eSjoerg * interface. 219906f32e7eSjoerg * 220006f32e7eSjoerg * Unexposed statements have the same operations as any other kind of 220106f32e7eSjoerg * statement; one can extract their location information, spelling, 220206f32e7eSjoerg * children, etc. However, the specific kind of the statement is not 220306f32e7eSjoerg * reported. 220406f32e7eSjoerg */ 220506f32e7eSjoerg CXCursor_UnexposedStmt = 200, 220606f32e7eSjoerg 220706f32e7eSjoerg /** A labelled statement in a function. 220806f32e7eSjoerg * 220906f32e7eSjoerg * This cursor kind is used to describe the "start_over:" label statement in 221006f32e7eSjoerg * the following example: 221106f32e7eSjoerg * 221206f32e7eSjoerg * \code 221306f32e7eSjoerg * start_over: 221406f32e7eSjoerg * ++counter; 221506f32e7eSjoerg * \endcode 221606f32e7eSjoerg * 221706f32e7eSjoerg */ 221806f32e7eSjoerg CXCursor_LabelStmt = 201, 221906f32e7eSjoerg 222006f32e7eSjoerg /** A group of statements like { stmt stmt }. 222106f32e7eSjoerg * 222206f32e7eSjoerg * This cursor kind is used to describe compound statements, e.g. function 222306f32e7eSjoerg * bodies. 222406f32e7eSjoerg */ 222506f32e7eSjoerg CXCursor_CompoundStmt = 202, 222606f32e7eSjoerg 222706f32e7eSjoerg /** A case statement. 222806f32e7eSjoerg */ 222906f32e7eSjoerg CXCursor_CaseStmt = 203, 223006f32e7eSjoerg 223106f32e7eSjoerg /** A default statement. 223206f32e7eSjoerg */ 223306f32e7eSjoerg CXCursor_DefaultStmt = 204, 223406f32e7eSjoerg 223506f32e7eSjoerg /** An if statement 223606f32e7eSjoerg */ 223706f32e7eSjoerg CXCursor_IfStmt = 205, 223806f32e7eSjoerg 223906f32e7eSjoerg /** A switch statement. 224006f32e7eSjoerg */ 224106f32e7eSjoerg CXCursor_SwitchStmt = 206, 224206f32e7eSjoerg 224306f32e7eSjoerg /** A while statement. 224406f32e7eSjoerg */ 224506f32e7eSjoerg CXCursor_WhileStmt = 207, 224606f32e7eSjoerg 224706f32e7eSjoerg /** A do statement. 224806f32e7eSjoerg */ 224906f32e7eSjoerg CXCursor_DoStmt = 208, 225006f32e7eSjoerg 225106f32e7eSjoerg /** A for statement. 225206f32e7eSjoerg */ 225306f32e7eSjoerg CXCursor_ForStmt = 209, 225406f32e7eSjoerg 225506f32e7eSjoerg /** A goto statement. 225606f32e7eSjoerg */ 225706f32e7eSjoerg CXCursor_GotoStmt = 210, 225806f32e7eSjoerg 225906f32e7eSjoerg /** An indirect goto statement. 226006f32e7eSjoerg */ 226106f32e7eSjoerg CXCursor_IndirectGotoStmt = 211, 226206f32e7eSjoerg 226306f32e7eSjoerg /** A continue statement. 226406f32e7eSjoerg */ 226506f32e7eSjoerg CXCursor_ContinueStmt = 212, 226606f32e7eSjoerg 226706f32e7eSjoerg /** A break statement. 226806f32e7eSjoerg */ 226906f32e7eSjoerg CXCursor_BreakStmt = 213, 227006f32e7eSjoerg 227106f32e7eSjoerg /** A return statement. 227206f32e7eSjoerg */ 227306f32e7eSjoerg CXCursor_ReturnStmt = 214, 227406f32e7eSjoerg 227506f32e7eSjoerg /** A GCC inline assembly statement extension. 227606f32e7eSjoerg */ 227706f32e7eSjoerg CXCursor_GCCAsmStmt = 215, 227806f32e7eSjoerg CXCursor_AsmStmt = CXCursor_GCCAsmStmt, 227906f32e7eSjoerg 228006f32e7eSjoerg /** Objective-C's overall \@try-\@catch-\@finally statement. 228106f32e7eSjoerg */ 228206f32e7eSjoerg CXCursor_ObjCAtTryStmt = 216, 228306f32e7eSjoerg 228406f32e7eSjoerg /** Objective-C's \@catch statement. 228506f32e7eSjoerg */ 228606f32e7eSjoerg CXCursor_ObjCAtCatchStmt = 217, 228706f32e7eSjoerg 228806f32e7eSjoerg /** Objective-C's \@finally statement. 228906f32e7eSjoerg */ 229006f32e7eSjoerg CXCursor_ObjCAtFinallyStmt = 218, 229106f32e7eSjoerg 229206f32e7eSjoerg /** Objective-C's \@throw statement. 229306f32e7eSjoerg */ 229406f32e7eSjoerg CXCursor_ObjCAtThrowStmt = 219, 229506f32e7eSjoerg 229606f32e7eSjoerg /** Objective-C's \@synchronized statement. 229706f32e7eSjoerg */ 229806f32e7eSjoerg CXCursor_ObjCAtSynchronizedStmt = 220, 229906f32e7eSjoerg 230006f32e7eSjoerg /** Objective-C's autorelease pool statement. 230106f32e7eSjoerg */ 230206f32e7eSjoerg CXCursor_ObjCAutoreleasePoolStmt = 221, 230306f32e7eSjoerg 230406f32e7eSjoerg /** Objective-C's collection statement. 230506f32e7eSjoerg */ 230606f32e7eSjoerg CXCursor_ObjCForCollectionStmt = 222, 230706f32e7eSjoerg 230806f32e7eSjoerg /** C++'s catch statement. 230906f32e7eSjoerg */ 231006f32e7eSjoerg CXCursor_CXXCatchStmt = 223, 231106f32e7eSjoerg 231206f32e7eSjoerg /** C++'s try statement. 231306f32e7eSjoerg */ 231406f32e7eSjoerg CXCursor_CXXTryStmt = 224, 231506f32e7eSjoerg 231606f32e7eSjoerg /** C++'s for (* : *) statement. 231706f32e7eSjoerg */ 231806f32e7eSjoerg CXCursor_CXXForRangeStmt = 225, 231906f32e7eSjoerg 232006f32e7eSjoerg /** Windows Structured Exception Handling's try statement. 232106f32e7eSjoerg */ 232206f32e7eSjoerg CXCursor_SEHTryStmt = 226, 232306f32e7eSjoerg 232406f32e7eSjoerg /** Windows Structured Exception Handling's except statement. 232506f32e7eSjoerg */ 232606f32e7eSjoerg CXCursor_SEHExceptStmt = 227, 232706f32e7eSjoerg 232806f32e7eSjoerg /** Windows Structured Exception Handling's finally statement. 232906f32e7eSjoerg */ 233006f32e7eSjoerg CXCursor_SEHFinallyStmt = 228, 233106f32e7eSjoerg 233206f32e7eSjoerg /** A MS inline assembly statement extension. 233306f32e7eSjoerg */ 233406f32e7eSjoerg CXCursor_MSAsmStmt = 229, 233506f32e7eSjoerg 233606f32e7eSjoerg /** The null statement ";": C99 6.8.3p3. 233706f32e7eSjoerg * 233806f32e7eSjoerg * This cursor kind is used to describe the null statement. 233906f32e7eSjoerg */ 234006f32e7eSjoerg CXCursor_NullStmt = 230, 234106f32e7eSjoerg 234206f32e7eSjoerg /** Adaptor class for mixing declarations with statements and 234306f32e7eSjoerg * expressions. 234406f32e7eSjoerg */ 234506f32e7eSjoerg CXCursor_DeclStmt = 231, 234606f32e7eSjoerg 234706f32e7eSjoerg /** OpenMP parallel directive. 234806f32e7eSjoerg */ 234906f32e7eSjoerg CXCursor_OMPParallelDirective = 232, 235006f32e7eSjoerg 235106f32e7eSjoerg /** OpenMP SIMD directive. 235206f32e7eSjoerg */ 235306f32e7eSjoerg CXCursor_OMPSimdDirective = 233, 235406f32e7eSjoerg 235506f32e7eSjoerg /** OpenMP for directive. 235606f32e7eSjoerg */ 235706f32e7eSjoerg CXCursor_OMPForDirective = 234, 235806f32e7eSjoerg 235906f32e7eSjoerg /** OpenMP sections directive. 236006f32e7eSjoerg */ 236106f32e7eSjoerg CXCursor_OMPSectionsDirective = 235, 236206f32e7eSjoerg 236306f32e7eSjoerg /** OpenMP section directive. 236406f32e7eSjoerg */ 236506f32e7eSjoerg CXCursor_OMPSectionDirective = 236, 236606f32e7eSjoerg 236706f32e7eSjoerg /** OpenMP single directive. 236806f32e7eSjoerg */ 236906f32e7eSjoerg CXCursor_OMPSingleDirective = 237, 237006f32e7eSjoerg 237106f32e7eSjoerg /** OpenMP parallel for directive. 237206f32e7eSjoerg */ 237306f32e7eSjoerg CXCursor_OMPParallelForDirective = 238, 237406f32e7eSjoerg 237506f32e7eSjoerg /** OpenMP parallel sections directive. 237606f32e7eSjoerg */ 237706f32e7eSjoerg CXCursor_OMPParallelSectionsDirective = 239, 237806f32e7eSjoerg 237906f32e7eSjoerg /** OpenMP task directive. 238006f32e7eSjoerg */ 238106f32e7eSjoerg CXCursor_OMPTaskDirective = 240, 238206f32e7eSjoerg 238306f32e7eSjoerg /** OpenMP master directive. 238406f32e7eSjoerg */ 238506f32e7eSjoerg CXCursor_OMPMasterDirective = 241, 238606f32e7eSjoerg 238706f32e7eSjoerg /** OpenMP critical directive. 238806f32e7eSjoerg */ 238906f32e7eSjoerg CXCursor_OMPCriticalDirective = 242, 239006f32e7eSjoerg 239106f32e7eSjoerg /** OpenMP taskyield directive. 239206f32e7eSjoerg */ 239306f32e7eSjoerg CXCursor_OMPTaskyieldDirective = 243, 239406f32e7eSjoerg 239506f32e7eSjoerg /** OpenMP barrier directive. 239606f32e7eSjoerg */ 239706f32e7eSjoerg CXCursor_OMPBarrierDirective = 244, 239806f32e7eSjoerg 239906f32e7eSjoerg /** OpenMP taskwait directive. 240006f32e7eSjoerg */ 240106f32e7eSjoerg CXCursor_OMPTaskwaitDirective = 245, 240206f32e7eSjoerg 240306f32e7eSjoerg /** OpenMP flush directive. 240406f32e7eSjoerg */ 240506f32e7eSjoerg CXCursor_OMPFlushDirective = 246, 240606f32e7eSjoerg 240706f32e7eSjoerg /** Windows Structured Exception Handling's leave statement. 240806f32e7eSjoerg */ 240906f32e7eSjoerg CXCursor_SEHLeaveStmt = 247, 241006f32e7eSjoerg 241106f32e7eSjoerg /** OpenMP ordered directive. 241206f32e7eSjoerg */ 241306f32e7eSjoerg CXCursor_OMPOrderedDirective = 248, 241406f32e7eSjoerg 241506f32e7eSjoerg /** OpenMP atomic directive. 241606f32e7eSjoerg */ 241706f32e7eSjoerg CXCursor_OMPAtomicDirective = 249, 241806f32e7eSjoerg 241906f32e7eSjoerg /** OpenMP for SIMD directive. 242006f32e7eSjoerg */ 242106f32e7eSjoerg CXCursor_OMPForSimdDirective = 250, 242206f32e7eSjoerg 242306f32e7eSjoerg /** OpenMP parallel for SIMD directive. 242406f32e7eSjoerg */ 242506f32e7eSjoerg CXCursor_OMPParallelForSimdDirective = 251, 242606f32e7eSjoerg 242706f32e7eSjoerg /** OpenMP target directive. 242806f32e7eSjoerg */ 242906f32e7eSjoerg CXCursor_OMPTargetDirective = 252, 243006f32e7eSjoerg 243106f32e7eSjoerg /** OpenMP teams directive. 243206f32e7eSjoerg */ 243306f32e7eSjoerg CXCursor_OMPTeamsDirective = 253, 243406f32e7eSjoerg 243506f32e7eSjoerg /** OpenMP taskgroup directive. 243606f32e7eSjoerg */ 243706f32e7eSjoerg CXCursor_OMPTaskgroupDirective = 254, 243806f32e7eSjoerg 243906f32e7eSjoerg /** OpenMP cancellation point directive. 244006f32e7eSjoerg */ 244106f32e7eSjoerg CXCursor_OMPCancellationPointDirective = 255, 244206f32e7eSjoerg 244306f32e7eSjoerg /** OpenMP cancel directive. 244406f32e7eSjoerg */ 244506f32e7eSjoerg CXCursor_OMPCancelDirective = 256, 244606f32e7eSjoerg 244706f32e7eSjoerg /** OpenMP target data directive. 244806f32e7eSjoerg */ 244906f32e7eSjoerg CXCursor_OMPTargetDataDirective = 257, 245006f32e7eSjoerg 245106f32e7eSjoerg /** OpenMP taskloop directive. 245206f32e7eSjoerg */ 245306f32e7eSjoerg CXCursor_OMPTaskLoopDirective = 258, 245406f32e7eSjoerg 245506f32e7eSjoerg /** OpenMP taskloop simd directive. 245606f32e7eSjoerg */ 245706f32e7eSjoerg CXCursor_OMPTaskLoopSimdDirective = 259, 245806f32e7eSjoerg 245906f32e7eSjoerg /** OpenMP distribute directive. 246006f32e7eSjoerg */ 246106f32e7eSjoerg CXCursor_OMPDistributeDirective = 260, 246206f32e7eSjoerg 246306f32e7eSjoerg /** OpenMP target enter data directive. 246406f32e7eSjoerg */ 246506f32e7eSjoerg CXCursor_OMPTargetEnterDataDirective = 261, 246606f32e7eSjoerg 246706f32e7eSjoerg /** OpenMP target exit data directive. 246806f32e7eSjoerg */ 246906f32e7eSjoerg CXCursor_OMPTargetExitDataDirective = 262, 247006f32e7eSjoerg 247106f32e7eSjoerg /** OpenMP target parallel directive. 247206f32e7eSjoerg */ 247306f32e7eSjoerg CXCursor_OMPTargetParallelDirective = 263, 247406f32e7eSjoerg 247506f32e7eSjoerg /** OpenMP target parallel for directive. 247606f32e7eSjoerg */ 247706f32e7eSjoerg CXCursor_OMPTargetParallelForDirective = 264, 247806f32e7eSjoerg 247906f32e7eSjoerg /** OpenMP target update directive. 248006f32e7eSjoerg */ 248106f32e7eSjoerg CXCursor_OMPTargetUpdateDirective = 265, 248206f32e7eSjoerg 248306f32e7eSjoerg /** OpenMP distribute parallel for directive. 248406f32e7eSjoerg */ 248506f32e7eSjoerg CXCursor_OMPDistributeParallelForDirective = 266, 248606f32e7eSjoerg 248706f32e7eSjoerg /** OpenMP distribute parallel for simd directive. 248806f32e7eSjoerg */ 248906f32e7eSjoerg CXCursor_OMPDistributeParallelForSimdDirective = 267, 249006f32e7eSjoerg 249106f32e7eSjoerg /** OpenMP distribute simd directive. 249206f32e7eSjoerg */ 249306f32e7eSjoerg CXCursor_OMPDistributeSimdDirective = 268, 249406f32e7eSjoerg 249506f32e7eSjoerg /** OpenMP target parallel for simd directive. 249606f32e7eSjoerg */ 249706f32e7eSjoerg CXCursor_OMPTargetParallelForSimdDirective = 269, 249806f32e7eSjoerg 249906f32e7eSjoerg /** OpenMP target simd directive. 250006f32e7eSjoerg */ 250106f32e7eSjoerg CXCursor_OMPTargetSimdDirective = 270, 250206f32e7eSjoerg 250306f32e7eSjoerg /** OpenMP teams distribute directive. 250406f32e7eSjoerg */ 250506f32e7eSjoerg CXCursor_OMPTeamsDistributeDirective = 271, 250606f32e7eSjoerg 250706f32e7eSjoerg /** OpenMP teams distribute simd directive. 250806f32e7eSjoerg */ 250906f32e7eSjoerg CXCursor_OMPTeamsDistributeSimdDirective = 272, 251006f32e7eSjoerg 251106f32e7eSjoerg /** OpenMP teams distribute parallel for simd directive. 251206f32e7eSjoerg */ 251306f32e7eSjoerg CXCursor_OMPTeamsDistributeParallelForSimdDirective = 273, 251406f32e7eSjoerg 251506f32e7eSjoerg /** OpenMP teams distribute parallel for directive. 251606f32e7eSjoerg */ 251706f32e7eSjoerg CXCursor_OMPTeamsDistributeParallelForDirective = 274, 251806f32e7eSjoerg 251906f32e7eSjoerg /** OpenMP target teams directive. 252006f32e7eSjoerg */ 252106f32e7eSjoerg CXCursor_OMPTargetTeamsDirective = 275, 252206f32e7eSjoerg 252306f32e7eSjoerg /** OpenMP target teams distribute directive. 252406f32e7eSjoerg */ 252506f32e7eSjoerg CXCursor_OMPTargetTeamsDistributeDirective = 276, 252606f32e7eSjoerg 252706f32e7eSjoerg /** OpenMP target teams distribute parallel for directive. 252806f32e7eSjoerg */ 252906f32e7eSjoerg CXCursor_OMPTargetTeamsDistributeParallelForDirective = 277, 253006f32e7eSjoerg 253106f32e7eSjoerg /** OpenMP target teams distribute parallel for simd directive. 253206f32e7eSjoerg */ 253306f32e7eSjoerg CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective = 278, 253406f32e7eSjoerg 253506f32e7eSjoerg /** OpenMP target teams distribute simd directive. 253606f32e7eSjoerg */ 253706f32e7eSjoerg CXCursor_OMPTargetTeamsDistributeSimdDirective = 279, 253806f32e7eSjoerg 253906f32e7eSjoerg /** C++2a std::bit_cast expression. 254006f32e7eSjoerg */ 254106f32e7eSjoerg CXCursor_BuiltinBitCastExpr = 280, 254206f32e7eSjoerg 254306f32e7eSjoerg /** OpenMP master taskloop directive. 254406f32e7eSjoerg */ 254506f32e7eSjoerg CXCursor_OMPMasterTaskLoopDirective = 281, 254606f32e7eSjoerg 254706f32e7eSjoerg /** OpenMP parallel master taskloop directive. 254806f32e7eSjoerg */ 254906f32e7eSjoerg CXCursor_OMPParallelMasterTaskLoopDirective = 282, 255006f32e7eSjoerg 255106f32e7eSjoerg /** OpenMP master taskloop simd directive. 255206f32e7eSjoerg */ 255306f32e7eSjoerg CXCursor_OMPMasterTaskLoopSimdDirective = 283, 255406f32e7eSjoerg 2555*13fbcb42Sjoerg /** OpenMP parallel master taskloop simd directive. 2556*13fbcb42Sjoerg */ 2557*13fbcb42Sjoerg CXCursor_OMPParallelMasterTaskLoopSimdDirective = 284, 255806f32e7eSjoerg 2559*13fbcb42Sjoerg /** OpenMP parallel master directive. 2560*13fbcb42Sjoerg */ 2561*13fbcb42Sjoerg CXCursor_OMPParallelMasterDirective = 285, 2562*13fbcb42Sjoerg 2563*13fbcb42Sjoerg /** OpenMP depobj directive. 2564*13fbcb42Sjoerg */ 2565*13fbcb42Sjoerg CXCursor_OMPDepobjDirective = 286, 2566*13fbcb42Sjoerg 2567*13fbcb42Sjoerg /** OpenMP scan directive. 2568*13fbcb42Sjoerg */ 2569*13fbcb42Sjoerg CXCursor_OMPScanDirective = 287, 2570*13fbcb42Sjoerg 2571*13fbcb42Sjoerg /** OpenMP tile directive. 2572*13fbcb42Sjoerg */ 2573*13fbcb42Sjoerg CXCursor_OMPTileDirective = 288, 2574*13fbcb42Sjoerg 2575*13fbcb42Sjoerg /** OpenMP canonical loop. 2576*13fbcb42Sjoerg */ 2577*13fbcb42Sjoerg CXCursor_OMPCanonicalLoop = 289, 2578*13fbcb42Sjoerg 2579*13fbcb42Sjoerg /** OpenMP interop directive. 2580*13fbcb42Sjoerg */ 2581*13fbcb42Sjoerg CXCursor_OMPInteropDirective = 290, 2582*13fbcb42Sjoerg 2583*13fbcb42Sjoerg /** OpenMP dispatch directive. 2584*13fbcb42Sjoerg */ 2585*13fbcb42Sjoerg CXCursor_OMPDispatchDirective = 291, 2586*13fbcb42Sjoerg 2587*13fbcb42Sjoerg /** OpenMP masked directive. 2588*13fbcb42Sjoerg */ 2589*13fbcb42Sjoerg CXCursor_OMPMaskedDirective = 292, 2590*13fbcb42Sjoerg 2591*13fbcb42Sjoerg CXCursor_LastStmt = CXCursor_OMPMaskedDirective, 259206f32e7eSjoerg 259306f32e7eSjoerg /** 259406f32e7eSjoerg * Cursor that represents the translation unit itself. 259506f32e7eSjoerg * 259606f32e7eSjoerg * The translation unit cursor exists primarily to act as the root 259706f32e7eSjoerg * cursor for traversing the contents of a translation unit. 259806f32e7eSjoerg */ 259906f32e7eSjoerg CXCursor_TranslationUnit = 300, 260006f32e7eSjoerg 260106f32e7eSjoerg /* Attributes */ 260206f32e7eSjoerg CXCursor_FirstAttr = 400, 260306f32e7eSjoerg /** 260406f32e7eSjoerg * An attribute whose specific kind is not exposed via this 260506f32e7eSjoerg * interface. 260606f32e7eSjoerg */ 260706f32e7eSjoerg CXCursor_UnexposedAttr = 400, 260806f32e7eSjoerg 260906f32e7eSjoerg CXCursor_IBActionAttr = 401, 261006f32e7eSjoerg CXCursor_IBOutletAttr = 402, 261106f32e7eSjoerg CXCursor_IBOutletCollectionAttr = 403, 261206f32e7eSjoerg CXCursor_CXXFinalAttr = 404, 261306f32e7eSjoerg CXCursor_CXXOverrideAttr = 405, 261406f32e7eSjoerg CXCursor_AnnotateAttr = 406, 261506f32e7eSjoerg CXCursor_AsmLabelAttr = 407, 261606f32e7eSjoerg CXCursor_PackedAttr = 408, 261706f32e7eSjoerg CXCursor_PureAttr = 409, 261806f32e7eSjoerg CXCursor_ConstAttr = 410, 261906f32e7eSjoerg CXCursor_NoDuplicateAttr = 411, 262006f32e7eSjoerg CXCursor_CUDAConstantAttr = 412, 262106f32e7eSjoerg CXCursor_CUDADeviceAttr = 413, 262206f32e7eSjoerg CXCursor_CUDAGlobalAttr = 414, 262306f32e7eSjoerg CXCursor_CUDAHostAttr = 415, 262406f32e7eSjoerg CXCursor_CUDASharedAttr = 416, 262506f32e7eSjoerg CXCursor_VisibilityAttr = 417, 262606f32e7eSjoerg CXCursor_DLLExport = 418, 262706f32e7eSjoerg CXCursor_DLLImport = 419, 262806f32e7eSjoerg CXCursor_NSReturnsRetained = 420, 262906f32e7eSjoerg CXCursor_NSReturnsNotRetained = 421, 263006f32e7eSjoerg CXCursor_NSReturnsAutoreleased = 422, 263106f32e7eSjoerg CXCursor_NSConsumesSelf = 423, 263206f32e7eSjoerg CXCursor_NSConsumed = 424, 263306f32e7eSjoerg CXCursor_ObjCException = 425, 263406f32e7eSjoerg CXCursor_ObjCNSObject = 426, 263506f32e7eSjoerg CXCursor_ObjCIndependentClass = 427, 263606f32e7eSjoerg CXCursor_ObjCPreciseLifetime = 428, 263706f32e7eSjoerg CXCursor_ObjCReturnsInnerPointer = 429, 263806f32e7eSjoerg CXCursor_ObjCRequiresSuper = 430, 263906f32e7eSjoerg CXCursor_ObjCRootClass = 431, 264006f32e7eSjoerg CXCursor_ObjCSubclassingRestricted = 432, 264106f32e7eSjoerg CXCursor_ObjCExplicitProtocolImpl = 433, 264206f32e7eSjoerg CXCursor_ObjCDesignatedInitializer = 434, 264306f32e7eSjoerg CXCursor_ObjCRuntimeVisible = 435, 264406f32e7eSjoerg CXCursor_ObjCBoxable = 436, 264506f32e7eSjoerg CXCursor_FlagEnum = 437, 264606f32e7eSjoerg CXCursor_ConvergentAttr = 438, 264706f32e7eSjoerg CXCursor_WarnUnusedAttr = 439, 264806f32e7eSjoerg CXCursor_WarnUnusedResultAttr = 440, 264906f32e7eSjoerg CXCursor_AlignedAttr = 441, 265006f32e7eSjoerg CXCursor_LastAttr = CXCursor_AlignedAttr, 265106f32e7eSjoerg 265206f32e7eSjoerg /* Preprocessing */ 265306f32e7eSjoerg CXCursor_PreprocessingDirective = 500, 265406f32e7eSjoerg CXCursor_MacroDefinition = 501, 265506f32e7eSjoerg CXCursor_MacroExpansion = 502, 265606f32e7eSjoerg CXCursor_MacroInstantiation = CXCursor_MacroExpansion, 265706f32e7eSjoerg CXCursor_InclusionDirective = 503, 265806f32e7eSjoerg CXCursor_FirstPreprocessing = CXCursor_PreprocessingDirective, 265906f32e7eSjoerg CXCursor_LastPreprocessing = CXCursor_InclusionDirective, 266006f32e7eSjoerg 266106f32e7eSjoerg /* Extra Declarations */ 266206f32e7eSjoerg /** 266306f32e7eSjoerg * A module import declaration. 266406f32e7eSjoerg */ 266506f32e7eSjoerg CXCursor_ModuleImportDecl = 600, 266606f32e7eSjoerg CXCursor_TypeAliasTemplateDecl = 601, 266706f32e7eSjoerg /** 266806f32e7eSjoerg * A static_assert or _Static_assert node 266906f32e7eSjoerg */ 267006f32e7eSjoerg CXCursor_StaticAssert = 602, 267106f32e7eSjoerg /** 267206f32e7eSjoerg * a friend declaration. 267306f32e7eSjoerg */ 267406f32e7eSjoerg CXCursor_FriendDecl = 603, 267506f32e7eSjoerg CXCursor_FirstExtraDecl = CXCursor_ModuleImportDecl, 267606f32e7eSjoerg CXCursor_LastExtraDecl = CXCursor_FriendDecl, 267706f32e7eSjoerg 267806f32e7eSjoerg /** 267906f32e7eSjoerg * A code completion overload candidate. 268006f32e7eSjoerg */ 268106f32e7eSjoerg CXCursor_OverloadCandidate = 700 268206f32e7eSjoerg }; 268306f32e7eSjoerg 268406f32e7eSjoerg /** 268506f32e7eSjoerg * A cursor representing some element in the abstract syntax tree for 268606f32e7eSjoerg * a translation unit. 268706f32e7eSjoerg * 268806f32e7eSjoerg * The cursor abstraction unifies the different kinds of entities in a 268906f32e7eSjoerg * program--declaration, statements, expressions, references to declarations, 269006f32e7eSjoerg * etc.--under a single "cursor" abstraction with a common set of operations. 269106f32e7eSjoerg * Common operation for a cursor include: getting the physical location in 269206f32e7eSjoerg * a source file where the cursor points, getting the name associated with a 269306f32e7eSjoerg * cursor, and retrieving cursors for any child nodes of a particular cursor. 269406f32e7eSjoerg * 269506f32e7eSjoerg * Cursors can be produced in two specific ways. 269606f32e7eSjoerg * clang_getTranslationUnitCursor() produces a cursor for a translation unit, 269706f32e7eSjoerg * from which one can use clang_visitChildren() to explore the rest of the 269806f32e7eSjoerg * translation unit. clang_getCursor() maps from a physical source location 269906f32e7eSjoerg * to the entity that resides at that location, allowing one to map from the 270006f32e7eSjoerg * source code into the AST. 270106f32e7eSjoerg */ 270206f32e7eSjoerg typedef struct { 270306f32e7eSjoerg enum CXCursorKind kind; 270406f32e7eSjoerg int xdata; 270506f32e7eSjoerg const void *data[3]; 270606f32e7eSjoerg } CXCursor; 270706f32e7eSjoerg 270806f32e7eSjoerg /** 270906f32e7eSjoerg * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations 271006f32e7eSjoerg * 271106f32e7eSjoerg * @{ 271206f32e7eSjoerg */ 271306f32e7eSjoerg 271406f32e7eSjoerg /** 271506f32e7eSjoerg * Retrieve the NULL cursor, which represents no entity. 271606f32e7eSjoerg */ 271706f32e7eSjoerg CINDEX_LINKAGE CXCursor clang_getNullCursor(void); 271806f32e7eSjoerg 271906f32e7eSjoerg /** 272006f32e7eSjoerg * Retrieve the cursor that represents the given translation unit. 272106f32e7eSjoerg * 272206f32e7eSjoerg * The translation unit cursor can be used to start traversing the 272306f32e7eSjoerg * various declarations within the given translation unit. 272406f32e7eSjoerg */ 272506f32e7eSjoerg CINDEX_LINKAGE CXCursor clang_getTranslationUnitCursor(CXTranslationUnit); 272606f32e7eSjoerg 272706f32e7eSjoerg /** 272806f32e7eSjoerg * Determine whether two cursors are equivalent. 272906f32e7eSjoerg */ 273006f32e7eSjoerg CINDEX_LINKAGE unsigned clang_equalCursors(CXCursor, CXCursor); 273106f32e7eSjoerg 273206f32e7eSjoerg /** 273306f32e7eSjoerg * Returns non-zero if \p cursor is null. 273406f32e7eSjoerg */ 273506f32e7eSjoerg CINDEX_LINKAGE int clang_Cursor_isNull(CXCursor cursor); 273606f32e7eSjoerg 273706f32e7eSjoerg /** 273806f32e7eSjoerg * Compute a hash value for the given cursor. 273906f32e7eSjoerg */ 274006f32e7eSjoerg CINDEX_LINKAGE unsigned clang_hashCursor(CXCursor); 274106f32e7eSjoerg 274206f32e7eSjoerg /** 274306f32e7eSjoerg * Retrieve the kind of the given cursor. 274406f32e7eSjoerg */ 274506f32e7eSjoerg CINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor); 274606f32e7eSjoerg 274706f32e7eSjoerg /** 274806f32e7eSjoerg * Determine whether the given cursor kind represents a declaration. 274906f32e7eSjoerg */ 275006f32e7eSjoerg CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind); 275106f32e7eSjoerg 275206f32e7eSjoerg /** 275306f32e7eSjoerg * Determine whether the given declaration is invalid. 275406f32e7eSjoerg * 275506f32e7eSjoerg * A declaration is invalid if it could not be parsed successfully. 275606f32e7eSjoerg * 275706f32e7eSjoerg * \returns non-zero if the cursor represents a declaration and it is 275806f32e7eSjoerg * invalid, otherwise NULL. 275906f32e7eSjoerg */ 276006f32e7eSjoerg CINDEX_LINKAGE unsigned clang_isInvalidDeclaration(CXCursor); 276106f32e7eSjoerg 276206f32e7eSjoerg /** 276306f32e7eSjoerg * Determine whether the given cursor kind represents a simple 276406f32e7eSjoerg * reference. 276506f32e7eSjoerg * 276606f32e7eSjoerg * Note that other kinds of cursors (such as expressions) can also refer to 276706f32e7eSjoerg * other cursors. Use clang_getCursorReferenced() to determine whether a 276806f32e7eSjoerg * particular cursor refers to another entity. 276906f32e7eSjoerg */ 277006f32e7eSjoerg CINDEX_LINKAGE unsigned clang_isReference(enum CXCursorKind); 277106f32e7eSjoerg 277206f32e7eSjoerg /** 277306f32e7eSjoerg * Determine whether the given cursor kind represents an expression. 277406f32e7eSjoerg */ 277506f32e7eSjoerg CINDEX_LINKAGE unsigned clang_isExpression(enum CXCursorKind); 277606f32e7eSjoerg 277706f32e7eSjoerg /** 277806f32e7eSjoerg * Determine whether the given cursor kind represents a statement. 277906f32e7eSjoerg */ 278006f32e7eSjoerg CINDEX_LINKAGE unsigned clang_isStatement(enum CXCursorKind); 278106f32e7eSjoerg 278206f32e7eSjoerg /** 278306f32e7eSjoerg * Determine whether the given cursor kind represents an attribute. 278406f32e7eSjoerg */ 278506f32e7eSjoerg CINDEX_LINKAGE unsigned clang_isAttribute(enum CXCursorKind); 278606f32e7eSjoerg 278706f32e7eSjoerg /** 278806f32e7eSjoerg * Determine whether the given cursor has any attributes. 278906f32e7eSjoerg */ 279006f32e7eSjoerg CINDEX_LINKAGE unsigned clang_Cursor_hasAttrs(CXCursor C); 279106f32e7eSjoerg 279206f32e7eSjoerg /** 279306f32e7eSjoerg * Determine whether the given cursor kind represents an invalid 279406f32e7eSjoerg * cursor. 279506f32e7eSjoerg */ 279606f32e7eSjoerg CINDEX_LINKAGE unsigned clang_isInvalid(enum CXCursorKind); 279706f32e7eSjoerg 279806f32e7eSjoerg /** 279906f32e7eSjoerg * Determine whether the given cursor kind represents a translation 280006f32e7eSjoerg * unit. 280106f32e7eSjoerg */ 280206f32e7eSjoerg CINDEX_LINKAGE unsigned clang_isTranslationUnit(enum CXCursorKind); 280306f32e7eSjoerg 280406f32e7eSjoerg /*** 280506f32e7eSjoerg * Determine whether the given cursor represents a preprocessing 280606f32e7eSjoerg * element, such as a preprocessor directive or macro instantiation. 280706f32e7eSjoerg */ 280806f32e7eSjoerg CINDEX_LINKAGE unsigned clang_isPreprocessing(enum CXCursorKind); 280906f32e7eSjoerg 281006f32e7eSjoerg /*** 281106f32e7eSjoerg * Determine whether the given cursor represents a currently 281206f32e7eSjoerg * unexposed piece of the AST (e.g., CXCursor_UnexposedStmt). 281306f32e7eSjoerg */ 281406f32e7eSjoerg CINDEX_LINKAGE unsigned clang_isUnexposed(enum CXCursorKind); 281506f32e7eSjoerg 281606f32e7eSjoerg /** 281706f32e7eSjoerg * Describe the linkage of the entity referred to by a cursor. 281806f32e7eSjoerg */ 281906f32e7eSjoerg enum CXLinkageKind { 282006f32e7eSjoerg /** This value indicates that no linkage information is available 282106f32e7eSjoerg * for a provided CXCursor. */ 282206f32e7eSjoerg CXLinkage_Invalid, 282306f32e7eSjoerg /** 282406f32e7eSjoerg * This is the linkage for variables, parameters, and so on that 282506f32e7eSjoerg * have automatic storage. This covers normal (non-extern) local variables. 282606f32e7eSjoerg */ 282706f32e7eSjoerg CXLinkage_NoLinkage, 282806f32e7eSjoerg /** This is the linkage for static variables and static functions. */ 282906f32e7eSjoerg CXLinkage_Internal, 283006f32e7eSjoerg /** This is the linkage for entities with external linkage that live 283106f32e7eSjoerg * in C++ anonymous namespaces.*/ 283206f32e7eSjoerg CXLinkage_UniqueExternal, 283306f32e7eSjoerg /** This is the linkage for entities with true, external linkage. */ 283406f32e7eSjoerg CXLinkage_External 283506f32e7eSjoerg }; 283606f32e7eSjoerg 283706f32e7eSjoerg /** 283806f32e7eSjoerg * Determine the linkage of the entity referred to by a given cursor. 283906f32e7eSjoerg */ 284006f32e7eSjoerg CINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor); 284106f32e7eSjoerg 284206f32e7eSjoerg enum CXVisibilityKind { 284306f32e7eSjoerg /** This value indicates that no visibility information is available 284406f32e7eSjoerg * for a provided CXCursor. */ 284506f32e7eSjoerg CXVisibility_Invalid, 284606f32e7eSjoerg 284706f32e7eSjoerg /** Symbol not seen by the linker. */ 284806f32e7eSjoerg CXVisibility_Hidden, 284906f32e7eSjoerg /** Symbol seen by the linker but resolves to a symbol inside this object. */ 285006f32e7eSjoerg CXVisibility_Protected, 285106f32e7eSjoerg /** Symbol seen by the linker and acts like a normal symbol. */ 285206f32e7eSjoerg CXVisibility_Default 285306f32e7eSjoerg }; 285406f32e7eSjoerg 285506f32e7eSjoerg /** 285606f32e7eSjoerg * Describe the visibility of the entity referred to by a cursor. 285706f32e7eSjoerg * 285806f32e7eSjoerg * This returns the default visibility if not explicitly specified by 285906f32e7eSjoerg * a visibility attribute. The default visibility may be changed by 286006f32e7eSjoerg * commandline arguments. 286106f32e7eSjoerg * 286206f32e7eSjoerg * \param cursor The cursor to query. 286306f32e7eSjoerg * 286406f32e7eSjoerg * \returns The visibility of the cursor. 286506f32e7eSjoerg */ 286606f32e7eSjoerg CINDEX_LINKAGE enum CXVisibilityKind clang_getCursorVisibility(CXCursor cursor); 286706f32e7eSjoerg 286806f32e7eSjoerg /** 286906f32e7eSjoerg * Determine the availability of the entity that this cursor refers to, 287006f32e7eSjoerg * taking the current target platform into account. 287106f32e7eSjoerg * 287206f32e7eSjoerg * \param cursor The cursor to query. 287306f32e7eSjoerg * 287406f32e7eSjoerg * \returns The availability of the cursor. 287506f32e7eSjoerg */ 287606f32e7eSjoerg CINDEX_LINKAGE enum CXAvailabilityKind 287706f32e7eSjoerg clang_getCursorAvailability(CXCursor cursor); 287806f32e7eSjoerg 287906f32e7eSjoerg /** 288006f32e7eSjoerg * Describes the availability of a given entity on a particular platform, e.g., 288106f32e7eSjoerg * a particular class might only be available on Mac OS 10.7 or newer. 288206f32e7eSjoerg */ 288306f32e7eSjoerg typedef struct CXPlatformAvailability { 288406f32e7eSjoerg /** 288506f32e7eSjoerg * A string that describes the platform for which this structure 288606f32e7eSjoerg * provides availability information. 288706f32e7eSjoerg * 288806f32e7eSjoerg * Possible values are "ios" or "macos". 288906f32e7eSjoerg */ 289006f32e7eSjoerg CXString Platform; 289106f32e7eSjoerg /** 289206f32e7eSjoerg * The version number in which this entity was introduced. 289306f32e7eSjoerg */ 289406f32e7eSjoerg CXVersion Introduced; 289506f32e7eSjoerg /** 289606f32e7eSjoerg * The version number in which this entity was deprecated (but is 289706f32e7eSjoerg * still available). 289806f32e7eSjoerg */ 289906f32e7eSjoerg CXVersion Deprecated; 290006f32e7eSjoerg /** 290106f32e7eSjoerg * The version number in which this entity was obsoleted, and therefore 290206f32e7eSjoerg * is no longer available. 290306f32e7eSjoerg */ 290406f32e7eSjoerg CXVersion Obsoleted; 290506f32e7eSjoerg /** 290606f32e7eSjoerg * Whether the entity is unconditionally unavailable on this platform. 290706f32e7eSjoerg */ 290806f32e7eSjoerg int Unavailable; 290906f32e7eSjoerg /** 291006f32e7eSjoerg * An optional message to provide to a user of this API, e.g., to 291106f32e7eSjoerg * suggest replacement APIs. 291206f32e7eSjoerg */ 291306f32e7eSjoerg CXString Message; 291406f32e7eSjoerg } CXPlatformAvailability; 291506f32e7eSjoerg 291606f32e7eSjoerg /** 291706f32e7eSjoerg * Determine the availability of the entity that this cursor refers to 291806f32e7eSjoerg * on any platforms for which availability information is known. 291906f32e7eSjoerg * 292006f32e7eSjoerg * \param cursor The cursor to query. 292106f32e7eSjoerg * 292206f32e7eSjoerg * \param always_deprecated If non-NULL, will be set to indicate whether the 292306f32e7eSjoerg * entity is deprecated on all platforms. 292406f32e7eSjoerg * 292506f32e7eSjoerg * \param deprecated_message If non-NULL, will be set to the message text 292606f32e7eSjoerg * provided along with the unconditional deprecation of this entity. The client 292706f32e7eSjoerg * is responsible for deallocating this string. 292806f32e7eSjoerg * 292906f32e7eSjoerg * \param always_unavailable If non-NULL, will be set to indicate whether the 293006f32e7eSjoerg * entity is unavailable on all platforms. 293106f32e7eSjoerg * 293206f32e7eSjoerg * \param unavailable_message If non-NULL, will be set to the message text 293306f32e7eSjoerg * provided along with the unconditional unavailability of this entity. The 293406f32e7eSjoerg * client is responsible for deallocating this string. 293506f32e7eSjoerg * 293606f32e7eSjoerg * \param availability If non-NULL, an array of CXPlatformAvailability instances 293706f32e7eSjoerg * that will be populated with platform availability information, up to either 293806f32e7eSjoerg * the number of platforms for which availability information is available (as 293906f32e7eSjoerg * returned by this function) or \c availability_size, whichever is smaller. 294006f32e7eSjoerg * 294106f32e7eSjoerg * \param availability_size The number of elements available in the 294206f32e7eSjoerg * \c availability array. 294306f32e7eSjoerg * 294406f32e7eSjoerg * \returns The number of platforms (N) for which availability information is 294506f32e7eSjoerg * available (which is unrelated to \c availability_size). 294606f32e7eSjoerg * 294706f32e7eSjoerg * Note that the client is responsible for calling 294806f32e7eSjoerg * \c clang_disposeCXPlatformAvailability to free each of the 294906f32e7eSjoerg * platform-availability structures returned. There are 295006f32e7eSjoerg * \c min(N, availability_size) such structures. 295106f32e7eSjoerg */ 2952*13fbcb42Sjoerg CINDEX_LINKAGE int clang_getCursorPlatformAvailability( 2953*13fbcb42Sjoerg CXCursor cursor, int *always_deprecated, CXString *deprecated_message, 2954*13fbcb42Sjoerg int *always_unavailable, CXString *unavailable_message, 2955*13fbcb42Sjoerg CXPlatformAvailability *availability, int availability_size); 295606f32e7eSjoerg 295706f32e7eSjoerg /** 295806f32e7eSjoerg * Free the memory associated with a \c CXPlatformAvailability structure. 295906f32e7eSjoerg */ 296006f32e7eSjoerg CINDEX_LINKAGE void 296106f32e7eSjoerg clang_disposeCXPlatformAvailability(CXPlatformAvailability *availability); 296206f32e7eSjoerg 296306f32e7eSjoerg /** 2964*13fbcb42Sjoerg * If cursor refers to a variable declaration and it has initializer returns 2965*13fbcb42Sjoerg * cursor referring to the initializer otherwise return null cursor. 2966*13fbcb42Sjoerg */ 2967*13fbcb42Sjoerg CINDEX_LINKAGE CXCursor clang_Cursor_getVarDeclInitializer(CXCursor cursor); 2968*13fbcb42Sjoerg 2969*13fbcb42Sjoerg /** 2970*13fbcb42Sjoerg * If cursor refers to a variable declaration that has global storage returns 1. 2971*13fbcb42Sjoerg * If cursor refers to a variable declaration that doesn't have global storage 2972*13fbcb42Sjoerg * returns 0. Otherwise returns -1. 2973*13fbcb42Sjoerg */ 2974*13fbcb42Sjoerg CINDEX_LINKAGE int clang_Cursor_hasVarDeclGlobalStorage(CXCursor cursor); 2975*13fbcb42Sjoerg 2976*13fbcb42Sjoerg /** 2977*13fbcb42Sjoerg * If cursor refers to a variable declaration that has external storage 2978*13fbcb42Sjoerg * returns 1. If cursor refers to a variable declaration that doesn't have 2979*13fbcb42Sjoerg * external storage returns 0. Otherwise returns -1. 2980*13fbcb42Sjoerg */ 2981*13fbcb42Sjoerg CINDEX_LINKAGE int clang_Cursor_hasVarDeclExternalStorage(CXCursor cursor); 2982*13fbcb42Sjoerg 2983*13fbcb42Sjoerg /** 298406f32e7eSjoerg * Describe the "language" of the entity referred to by a cursor. 298506f32e7eSjoerg */ 298606f32e7eSjoerg enum CXLanguageKind { 298706f32e7eSjoerg CXLanguage_Invalid = 0, 298806f32e7eSjoerg CXLanguage_C, 298906f32e7eSjoerg CXLanguage_ObjC, 299006f32e7eSjoerg CXLanguage_CPlusPlus 299106f32e7eSjoerg }; 299206f32e7eSjoerg 299306f32e7eSjoerg /** 299406f32e7eSjoerg * Determine the "language" of the entity referred to by a given cursor. 299506f32e7eSjoerg */ 299606f32e7eSjoerg CINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor); 299706f32e7eSjoerg 299806f32e7eSjoerg /** 299906f32e7eSjoerg * Describe the "thread-local storage (TLS) kind" of the declaration 300006f32e7eSjoerg * referred to by a cursor. 300106f32e7eSjoerg */ 3002*13fbcb42Sjoerg enum CXTLSKind { CXTLS_None = 0, CXTLS_Dynamic, CXTLS_Static }; 300306f32e7eSjoerg 300406f32e7eSjoerg /** 300506f32e7eSjoerg * Determine the "thread-local storage (TLS) kind" of the declaration 300606f32e7eSjoerg * referred to by a cursor. 300706f32e7eSjoerg */ 300806f32e7eSjoerg CINDEX_LINKAGE enum CXTLSKind clang_getCursorTLSKind(CXCursor cursor); 300906f32e7eSjoerg 301006f32e7eSjoerg /** 301106f32e7eSjoerg * Returns the translation unit that a cursor originated from. 301206f32e7eSjoerg */ 301306f32e7eSjoerg CINDEX_LINKAGE CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor); 301406f32e7eSjoerg 301506f32e7eSjoerg /** 301606f32e7eSjoerg * A fast container representing a set of CXCursors. 301706f32e7eSjoerg */ 301806f32e7eSjoerg typedef struct CXCursorSetImpl *CXCursorSet; 301906f32e7eSjoerg 302006f32e7eSjoerg /** 302106f32e7eSjoerg * Creates an empty CXCursorSet. 302206f32e7eSjoerg */ 302306f32e7eSjoerg CINDEX_LINKAGE CXCursorSet clang_createCXCursorSet(void); 302406f32e7eSjoerg 302506f32e7eSjoerg /** 302606f32e7eSjoerg * Disposes a CXCursorSet and releases its associated memory. 302706f32e7eSjoerg */ 302806f32e7eSjoerg CINDEX_LINKAGE void clang_disposeCXCursorSet(CXCursorSet cset); 302906f32e7eSjoerg 303006f32e7eSjoerg /** 303106f32e7eSjoerg * Queries a CXCursorSet to see if it contains a specific CXCursor. 303206f32e7eSjoerg * 303306f32e7eSjoerg * \returns non-zero if the set contains the specified cursor. 303406f32e7eSjoerg */ 303506f32e7eSjoerg CINDEX_LINKAGE unsigned clang_CXCursorSet_contains(CXCursorSet cset, 303606f32e7eSjoerg CXCursor cursor); 303706f32e7eSjoerg 303806f32e7eSjoerg /** 303906f32e7eSjoerg * Inserts a CXCursor into a CXCursorSet. 304006f32e7eSjoerg * 304106f32e7eSjoerg * \returns zero if the CXCursor was already in the set, and non-zero otherwise. 304206f32e7eSjoerg */ 304306f32e7eSjoerg CINDEX_LINKAGE unsigned clang_CXCursorSet_insert(CXCursorSet cset, 304406f32e7eSjoerg CXCursor cursor); 304506f32e7eSjoerg 304606f32e7eSjoerg /** 304706f32e7eSjoerg * Determine the semantic parent of the given cursor. 304806f32e7eSjoerg * 304906f32e7eSjoerg * The semantic parent of a cursor is the cursor that semantically contains 305006f32e7eSjoerg * the given \p cursor. For many declarations, the lexical and semantic parents 305106f32e7eSjoerg * are equivalent (the lexical parent is returned by 305206f32e7eSjoerg * \c clang_getCursorLexicalParent()). They diverge when declarations or 305306f32e7eSjoerg * definitions are provided out-of-line. For example: 305406f32e7eSjoerg * 305506f32e7eSjoerg * \code 305606f32e7eSjoerg * class C { 305706f32e7eSjoerg * void f(); 305806f32e7eSjoerg * }; 305906f32e7eSjoerg * 306006f32e7eSjoerg * void C::f() { } 306106f32e7eSjoerg * \endcode 306206f32e7eSjoerg * 306306f32e7eSjoerg * In the out-of-line definition of \c C::f, the semantic parent is 306406f32e7eSjoerg * the class \c C, of which this function is a member. The lexical parent is 306506f32e7eSjoerg * the place where the declaration actually occurs in the source code; in this 306606f32e7eSjoerg * case, the definition occurs in the translation unit. In general, the 306706f32e7eSjoerg * lexical parent for a given entity can change without affecting the semantics 306806f32e7eSjoerg * of the program, and the lexical parent of different declarations of the 306906f32e7eSjoerg * same entity may be different. Changing the semantic parent of a declaration, 307006f32e7eSjoerg * on the other hand, can have a major impact on semantics, and redeclarations 307106f32e7eSjoerg * of a particular entity should all have the same semantic context. 307206f32e7eSjoerg * 307306f32e7eSjoerg * In the example above, both declarations of \c C::f have \c C as their 307406f32e7eSjoerg * semantic context, while the lexical context of the first \c C::f is \c C 307506f32e7eSjoerg * and the lexical context of the second \c C::f is the translation unit. 307606f32e7eSjoerg * 307706f32e7eSjoerg * For global declarations, the semantic parent is the translation unit. 307806f32e7eSjoerg */ 307906f32e7eSjoerg CINDEX_LINKAGE CXCursor clang_getCursorSemanticParent(CXCursor cursor); 308006f32e7eSjoerg 308106f32e7eSjoerg /** 308206f32e7eSjoerg * Determine the lexical parent of the given cursor. 308306f32e7eSjoerg * 308406f32e7eSjoerg * The lexical parent of a cursor is the cursor in which the given \p cursor 308506f32e7eSjoerg * was actually written. For many declarations, the lexical and semantic parents 308606f32e7eSjoerg * are equivalent (the semantic parent is returned by 308706f32e7eSjoerg * \c clang_getCursorSemanticParent()). They diverge when declarations or 308806f32e7eSjoerg * definitions are provided out-of-line. For example: 308906f32e7eSjoerg * 309006f32e7eSjoerg * \code 309106f32e7eSjoerg * class C { 309206f32e7eSjoerg * void f(); 309306f32e7eSjoerg * }; 309406f32e7eSjoerg * 309506f32e7eSjoerg * void C::f() { } 309606f32e7eSjoerg * \endcode 309706f32e7eSjoerg * 309806f32e7eSjoerg * In the out-of-line definition of \c C::f, the semantic parent is 309906f32e7eSjoerg * the class \c C, of which this function is a member. The lexical parent is 310006f32e7eSjoerg * the place where the declaration actually occurs in the source code; in this 310106f32e7eSjoerg * case, the definition occurs in the translation unit. In general, the 310206f32e7eSjoerg * lexical parent for a given entity can change without affecting the semantics 310306f32e7eSjoerg * of the program, and the lexical parent of different declarations of the 310406f32e7eSjoerg * same entity may be different. Changing the semantic parent of a declaration, 310506f32e7eSjoerg * on the other hand, can have a major impact on semantics, and redeclarations 310606f32e7eSjoerg * of a particular entity should all have the same semantic context. 310706f32e7eSjoerg * 310806f32e7eSjoerg * In the example above, both declarations of \c C::f have \c C as their 310906f32e7eSjoerg * semantic context, while the lexical context of the first \c C::f is \c C 311006f32e7eSjoerg * and the lexical context of the second \c C::f is the translation unit. 311106f32e7eSjoerg * 311206f32e7eSjoerg * For declarations written in the global scope, the lexical parent is 311306f32e7eSjoerg * the translation unit. 311406f32e7eSjoerg */ 311506f32e7eSjoerg CINDEX_LINKAGE CXCursor clang_getCursorLexicalParent(CXCursor cursor); 311606f32e7eSjoerg 311706f32e7eSjoerg /** 311806f32e7eSjoerg * Determine the set of methods that are overridden by the given 311906f32e7eSjoerg * method. 312006f32e7eSjoerg * 312106f32e7eSjoerg * In both Objective-C and C++, a method (aka virtual member function, 312206f32e7eSjoerg * in C++) can override a virtual method in a base class. For 312306f32e7eSjoerg * Objective-C, a method is said to override any method in the class's 312406f32e7eSjoerg * base class, its protocols, or its categories' protocols, that has the same 312506f32e7eSjoerg * selector and is of the same kind (class or instance). 312606f32e7eSjoerg * If no such method exists, the search continues to the class's superclass, 312706f32e7eSjoerg * its protocols, and its categories, and so on. A method from an Objective-C 312806f32e7eSjoerg * implementation is considered to override the same methods as its 312906f32e7eSjoerg * corresponding method in the interface. 313006f32e7eSjoerg * 313106f32e7eSjoerg * For C++, a virtual member function overrides any virtual member 313206f32e7eSjoerg * function with the same signature that occurs in its base 313306f32e7eSjoerg * classes. With multiple inheritance, a virtual member function can 313406f32e7eSjoerg * override several virtual member functions coming from different 313506f32e7eSjoerg * base classes. 313606f32e7eSjoerg * 313706f32e7eSjoerg * In all cases, this function determines the immediate overridden 313806f32e7eSjoerg * method, rather than all of the overridden methods. For example, if 313906f32e7eSjoerg * a method is originally declared in a class A, then overridden in B 314006f32e7eSjoerg * (which in inherits from A) and also in C (which inherited from B), 314106f32e7eSjoerg * then the only overridden method returned from this function when 314206f32e7eSjoerg * invoked on C's method will be B's method. The client may then 314306f32e7eSjoerg * invoke this function again, given the previously-found overridden 314406f32e7eSjoerg * methods, to map out the complete method-override set. 314506f32e7eSjoerg * 314606f32e7eSjoerg * \param cursor A cursor representing an Objective-C or C++ 314706f32e7eSjoerg * method. This routine will compute the set of methods that this 314806f32e7eSjoerg * method overrides. 314906f32e7eSjoerg * 315006f32e7eSjoerg * \param overridden A pointer whose pointee will be replaced with a 315106f32e7eSjoerg * pointer to an array of cursors, representing the set of overridden 315206f32e7eSjoerg * methods. If there are no overridden methods, the pointee will be 315306f32e7eSjoerg * set to NULL. The pointee must be freed via a call to 315406f32e7eSjoerg * \c clang_disposeOverriddenCursors(). 315506f32e7eSjoerg * 315606f32e7eSjoerg * \param num_overridden A pointer to the number of overridden 315706f32e7eSjoerg * functions, will be set to the number of overridden functions in the 315806f32e7eSjoerg * array pointed to by \p overridden. 315906f32e7eSjoerg */ 316006f32e7eSjoerg CINDEX_LINKAGE void clang_getOverriddenCursors(CXCursor cursor, 316106f32e7eSjoerg CXCursor **overridden, 316206f32e7eSjoerg unsigned *num_overridden); 316306f32e7eSjoerg 316406f32e7eSjoerg /** 316506f32e7eSjoerg * Free the set of overridden cursors returned by \c 316606f32e7eSjoerg * clang_getOverriddenCursors(). 316706f32e7eSjoerg */ 316806f32e7eSjoerg CINDEX_LINKAGE void clang_disposeOverriddenCursors(CXCursor *overridden); 316906f32e7eSjoerg 317006f32e7eSjoerg /** 317106f32e7eSjoerg * Retrieve the file that is included by the given inclusion directive 317206f32e7eSjoerg * cursor. 317306f32e7eSjoerg */ 317406f32e7eSjoerg CINDEX_LINKAGE CXFile clang_getIncludedFile(CXCursor cursor); 317506f32e7eSjoerg 317606f32e7eSjoerg /** 317706f32e7eSjoerg * @} 317806f32e7eSjoerg */ 317906f32e7eSjoerg 318006f32e7eSjoerg /** 318106f32e7eSjoerg * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code 318206f32e7eSjoerg * 318306f32e7eSjoerg * Cursors represent a location within the Abstract Syntax Tree (AST). These 318406f32e7eSjoerg * routines help map between cursors and the physical locations where the 318506f32e7eSjoerg * described entities occur in the source code. The mapping is provided in 318606f32e7eSjoerg * both directions, so one can map from source code to the AST and back. 318706f32e7eSjoerg * 318806f32e7eSjoerg * @{ 318906f32e7eSjoerg */ 319006f32e7eSjoerg 319106f32e7eSjoerg /** 319206f32e7eSjoerg * Map a source location to the cursor that describes the entity at that 319306f32e7eSjoerg * location in the source code. 319406f32e7eSjoerg * 319506f32e7eSjoerg * clang_getCursor() maps an arbitrary source location within a translation 319606f32e7eSjoerg * unit down to the most specific cursor that describes the entity at that 319706f32e7eSjoerg * location. For example, given an expression \c x + y, invoking 319806f32e7eSjoerg * clang_getCursor() with a source location pointing to "x" will return the 319906f32e7eSjoerg * cursor for "x"; similarly for "y". If the cursor points anywhere between 320006f32e7eSjoerg * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor() 320106f32e7eSjoerg * will return a cursor referring to the "+" expression. 320206f32e7eSjoerg * 320306f32e7eSjoerg * \returns a cursor representing the entity at the given source location, or 320406f32e7eSjoerg * a NULL cursor if no such entity can be found. 320506f32e7eSjoerg */ 320606f32e7eSjoerg CINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, CXSourceLocation); 320706f32e7eSjoerg 320806f32e7eSjoerg /** 320906f32e7eSjoerg * Retrieve the physical location of the source constructor referenced 321006f32e7eSjoerg * by the given cursor. 321106f32e7eSjoerg * 321206f32e7eSjoerg * The location of a declaration is typically the location of the name of that 321306f32e7eSjoerg * declaration, where the name of that declaration would occur if it is 321406f32e7eSjoerg * unnamed, or some keyword that introduces that particular declaration. 321506f32e7eSjoerg * The location of a reference is where that reference occurs within the 321606f32e7eSjoerg * source code. 321706f32e7eSjoerg */ 321806f32e7eSjoerg CINDEX_LINKAGE CXSourceLocation clang_getCursorLocation(CXCursor); 321906f32e7eSjoerg 322006f32e7eSjoerg /** 322106f32e7eSjoerg * Retrieve the physical extent of the source construct referenced by 322206f32e7eSjoerg * the given cursor. 322306f32e7eSjoerg * 322406f32e7eSjoerg * The extent of a cursor starts with the file/line/column pointing at the 322506f32e7eSjoerg * first character within the source construct that the cursor refers to and 322606f32e7eSjoerg * ends with the last character within that source construct. For a 322706f32e7eSjoerg * declaration, the extent covers the declaration itself. For a reference, 322806f32e7eSjoerg * the extent covers the location of the reference (e.g., where the referenced 322906f32e7eSjoerg * entity was actually used). 323006f32e7eSjoerg */ 323106f32e7eSjoerg CINDEX_LINKAGE CXSourceRange clang_getCursorExtent(CXCursor); 323206f32e7eSjoerg 323306f32e7eSjoerg /** 323406f32e7eSjoerg * @} 323506f32e7eSjoerg */ 323606f32e7eSjoerg 323706f32e7eSjoerg /** 323806f32e7eSjoerg * \defgroup CINDEX_TYPES Type information for CXCursors 323906f32e7eSjoerg * 324006f32e7eSjoerg * @{ 324106f32e7eSjoerg */ 324206f32e7eSjoerg 324306f32e7eSjoerg /** 324406f32e7eSjoerg * Describes the kind of type 324506f32e7eSjoerg */ 324606f32e7eSjoerg enum CXTypeKind { 324706f32e7eSjoerg /** 324806f32e7eSjoerg * Represents an invalid type (e.g., where no type is available). 324906f32e7eSjoerg */ 325006f32e7eSjoerg CXType_Invalid = 0, 325106f32e7eSjoerg 325206f32e7eSjoerg /** 325306f32e7eSjoerg * A type whose specific kind is not exposed via this 325406f32e7eSjoerg * interface. 325506f32e7eSjoerg */ 325606f32e7eSjoerg CXType_Unexposed = 1, 325706f32e7eSjoerg 325806f32e7eSjoerg /* Builtin types */ 325906f32e7eSjoerg CXType_Void = 2, 326006f32e7eSjoerg CXType_Bool = 3, 326106f32e7eSjoerg CXType_Char_U = 4, 326206f32e7eSjoerg CXType_UChar = 5, 326306f32e7eSjoerg CXType_Char16 = 6, 326406f32e7eSjoerg CXType_Char32 = 7, 326506f32e7eSjoerg CXType_UShort = 8, 326606f32e7eSjoerg CXType_UInt = 9, 326706f32e7eSjoerg CXType_ULong = 10, 326806f32e7eSjoerg CXType_ULongLong = 11, 326906f32e7eSjoerg CXType_UInt128 = 12, 327006f32e7eSjoerg CXType_Char_S = 13, 327106f32e7eSjoerg CXType_SChar = 14, 327206f32e7eSjoerg CXType_WChar = 15, 327306f32e7eSjoerg CXType_Short = 16, 327406f32e7eSjoerg CXType_Int = 17, 327506f32e7eSjoerg CXType_Long = 18, 327606f32e7eSjoerg CXType_LongLong = 19, 327706f32e7eSjoerg CXType_Int128 = 20, 327806f32e7eSjoerg CXType_Float = 21, 327906f32e7eSjoerg CXType_Double = 22, 328006f32e7eSjoerg CXType_LongDouble = 23, 328106f32e7eSjoerg CXType_NullPtr = 24, 328206f32e7eSjoerg CXType_Overload = 25, 328306f32e7eSjoerg CXType_Dependent = 26, 328406f32e7eSjoerg CXType_ObjCId = 27, 328506f32e7eSjoerg CXType_ObjCClass = 28, 328606f32e7eSjoerg CXType_ObjCSel = 29, 328706f32e7eSjoerg CXType_Float128 = 30, 328806f32e7eSjoerg CXType_Half = 31, 328906f32e7eSjoerg CXType_Float16 = 32, 329006f32e7eSjoerg CXType_ShortAccum = 33, 329106f32e7eSjoerg CXType_Accum = 34, 329206f32e7eSjoerg CXType_LongAccum = 35, 329306f32e7eSjoerg CXType_UShortAccum = 36, 329406f32e7eSjoerg CXType_UAccum = 37, 329506f32e7eSjoerg CXType_ULongAccum = 38, 3296*13fbcb42Sjoerg CXType_BFloat16 = 39, 329706f32e7eSjoerg CXType_FirstBuiltin = CXType_Void, 3298*13fbcb42Sjoerg CXType_LastBuiltin = CXType_BFloat16, 329906f32e7eSjoerg 330006f32e7eSjoerg CXType_Complex = 100, 330106f32e7eSjoerg CXType_Pointer = 101, 330206f32e7eSjoerg CXType_BlockPointer = 102, 330306f32e7eSjoerg CXType_LValueReference = 103, 330406f32e7eSjoerg CXType_RValueReference = 104, 330506f32e7eSjoerg CXType_Record = 105, 330606f32e7eSjoerg CXType_Enum = 106, 330706f32e7eSjoerg CXType_Typedef = 107, 330806f32e7eSjoerg CXType_ObjCInterface = 108, 330906f32e7eSjoerg CXType_ObjCObjectPointer = 109, 331006f32e7eSjoerg CXType_FunctionNoProto = 110, 331106f32e7eSjoerg CXType_FunctionProto = 111, 331206f32e7eSjoerg CXType_ConstantArray = 112, 331306f32e7eSjoerg CXType_Vector = 113, 331406f32e7eSjoerg CXType_IncompleteArray = 114, 331506f32e7eSjoerg CXType_VariableArray = 115, 331606f32e7eSjoerg CXType_DependentSizedArray = 116, 331706f32e7eSjoerg CXType_MemberPointer = 117, 331806f32e7eSjoerg CXType_Auto = 118, 331906f32e7eSjoerg 332006f32e7eSjoerg /** 332106f32e7eSjoerg * Represents a type that was referred to using an elaborated type keyword. 332206f32e7eSjoerg * 332306f32e7eSjoerg * E.g., struct S, or via a qualified name, e.g., N::M::type, or both. 332406f32e7eSjoerg */ 332506f32e7eSjoerg CXType_Elaborated = 119, 332606f32e7eSjoerg 332706f32e7eSjoerg /* OpenCL PipeType. */ 332806f32e7eSjoerg CXType_Pipe = 120, 332906f32e7eSjoerg 333006f32e7eSjoerg /* OpenCL builtin types. */ 333106f32e7eSjoerg CXType_OCLImage1dRO = 121, 333206f32e7eSjoerg CXType_OCLImage1dArrayRO = 122, 333306f32e7eSjoerg CXType_OCLImage1dBufferRO = 123, 333406f32e7eSjoerg CXType_OCLImage2dRO = 124, 333506f32e7eSjoerg CXType_OCLImage2dArrayRO = 125, 333606f32e7eSjoerg CXType_OCLImage2dDepthRO = 126, 333706f32e7eSjoerg CXType_OCLImage2dArrayDepthRO = 127, 333806f32e7eSjoerg CXType_OCLImage2dMSAARO = 128, 333906f32e7eSjoerg CXType_OCLImage2dArrayMSAARO = 129, 334006f32e7eSjoerg CXType_OCLImage2dMSAADepthRO = 130, 334106f32e7eSjoerg CXType_OCLImage2dArrayMSAADepthRO = 131, 334206f32e7eSjoerg CXType_OCLImage3dRO = 132, 334306f32e7eSjoerg CXType_OCLImage1dWO = 133, 334406f32e7eSjoerg CXType_OCLImage1dArrayWO = 134, 334506f32e7eSjoerg CXType_OCLImage1dBufferWO = 135, 334606f32e7eSjoerg CXType_OCLImage2dWO = 136, 334706f32e7eSjoerg CXType_OCLImage2dArrayWO = 137, 334806f32e7eSjoerg CXType_OCLImage2dDepthWO = 138, 334906f32e7eSjoerg CXType_OCLImage2dArrayDepthWO = 139, 335006f32e7eSjoerg CXType_OCLImage2dMSAAWO = 140, 335106f32e7eSjoerg CXType_OCLImage2dArrayMSAAWO = 141, 335206f32e7eSjoerg CXType_OCLImage2dMSAADepthWO = 142, 335306f32e7eSjoerg CXType_OCLImage2dArrayMSAADepthWO = 143, 335406f32e7eSjoerg CXType_OCLImage3dWO = 144, 335506f32e7eSjoerg CXType_OCLImage1dRW = 145, 335606f32e7eSjoerg CXType_OCLImage1dArrayRW = 146, 335706f32e7eSjoerg CXType_OCLImage1dBufferRW = 147, 335806f32e7eSjoerg CXType_OCLImage2dRW = 148, 335906f32e7eSjoerg CXType_OCLImage2dArrayRW = 149, 336006f32e7eSjoerg CXType_OCLImage2dDepthRW = 150, 336106f32e7eSjoerg CXType_OCLImage2dArrayDepthRW = 151, 336206f32e7eSjoerg CXType_OCLImage2dMSAARW = 152, 336306f32e7eSjoerg CXType_OCLImage2dArrayMSAARW = 153, 336406f32e7eSjoerg CXType_OCLImage2dMSAADepthRW = 154, 336506f32e7eSjoerg CXType_OCLImage2dArrayMSAADepthRW = 155, 336606f32e7eSjoerg CXType_OCLImage3dRW = 156, 336706f32e7eSjoerg CXType_OCLSampler = 157, 336806f32e7eSjoerg CXType_OCLEvent = 158, 336906f32e7eSjoerg CXType_OCLQueue = 159, 337006f32e7eSjoerg CXType_OCLReserveID = 160, 337106f32e7eSjoerg 337206f32e7eSjoerg CXType_ObjCObject = 161, 337306f32e7eSjoerg CXType_ObjCTypeParam = 162, 337406f32e7eSjoerg CXType_Attributed = 163, 337506f32e7eSjoerg 337606f32e7eSjoerg CXType_OCLIntelSubgroupAVCMcePayload = 164, 337706f32e7eSjoerg CXType_OCLIntelSubgroupAVCImePayload = 165, 337806f32e7eSjoerg CXType_OCLIntelSubgroupAVCRefPayload = 166, 337906f32e7eSjoerg CXType_OCLIntelSubgroupAVCSicPayload = 167, 338006f32e7eSjoerg CXType_OCLIntelSubgroupAVCMceResult = 168, 338106f32e7eSjoerg CXType_OCLIntelSubgroupAVCImeResult = 169, 338206f32e7eSjoerg CXType_OCLIntelSubgroupAVCRefResult = 170, 338306f32e7eSjoerg CXType_OCLIntelSubgroupAVCSicResult = 171, 338406f32e7eSjoerg CXType_OCLIntelSubgroupAVCImeResultSingleRefStreamout = 172, 338506f32e7eSjoerg CXType_OCLIntelSubgroupAVCImeResultDualRefStreamout = 173, 338606f32e7eSjoerg CXType_OCLIntelSubgroupAVCImeSingleRefStreamin = 174, 338706f32e7eSjoerg 338806f32e7eSjoerg CXType_OCLIntelSubgroupAVCImeDualRefStreamin = 175, 338906f32e7eSjoerg 3390*13fbcb42Sjoerg CXType_ExtVector = 176, 3391*13fbcb42Sjoerg CXType_Atomic = 177 339206f32e7eSjoerg }; 339306f32e7eSjoerg 339406f32e7eSjoerg /** 339506f32e7eSjoerg * Describes the calling convention of a function type 339606f32e7eSjoerg */ 339706f32e7eSjoerg enum CXCallingConv { 339806f32e7eSjoerg CXCallingConv_Default = 0, 339906f32e7eSjoerg CXCallingConv_C = 1, 340006f32e7eSjoerg CXCallingConv_X86StdCall = 2, 340106f32e7eSjoerg CXCallingConv_X86FastCall = 3, 340206f32e7eSjoerg CXCallingConv_X86ThisCall = 4, 340306f32e7eSjoerg CXCallingConv_X86Pascal = 5, 340406f32e7eSjoerg CXCallingConv_AAPCS = 6, 340506f32e7eSjoerg CXCallingConv_AAPCS_VFP = 7, 340606f32e7eSjoerg CXCallingConv_X86RegCall = 8, 340706f32e7eSjoerg CXCallingConv_IntelOclBicc = 9, 340806f32e7eSjoerg CXCallingConv_Win64 = 10, 340906f32e7eSjoerg /* Alias for compatibility with older versions of API. */ 341006f32e7eSjoerg CXCallingConv_X86_64Win64 = CXCallingConv_Win64, 341106f32e7eSjoerg CXCallingConv_X86_64SysV = 11, 341206f32e7eSjoerg CXCallingConv_X86VectorCall = 12, 341306f32e7eSjoerg CXCallingConv_Swift = 13, 341406f32e7eSjoerg CXCallingConv_PreserveMost = 14, 341506f32e7eSjoerg CXCallingConv_PreserveAll = 15, 341606f32e7eSjoerg CXCallingConv_AArch64VectorCall = 16, 341706f32e7eSjoerg 341806f32e7eSjoerg CXCallingConv_Invalid = 100, 341906f32e7eSjoerg CXCallingConv_Unexposed = 200 342006f32e7eSjoerg }; 342106f32e7eSjoerg 342206f32e7eSjoerg /** 342306f32e7eSjoerg * The type of an element in the abstract syntax tree. 342406f32e7eSjoerg * 342506f32e7eSjoerg */ 342606f32e7eSjoerg typedef struct { 342706f32e7eSjoerg enum CXTypeKind kind; 342806f32e7eSjoerg void *data[2]; 342906f32e7eSjoerg } CXType; 343006f32e7eSjoerg 343106f32e7eSjoerg /** 343206f32e7eSjoerg * Retrieve the type of a CXCursor (if any). 343306f32e7eSjoerg */ 343406f32e7eSjoerg CINDEX_LINKAGE CXType clang_getCursorType(CXCursor C); 343506f32e7eSjoerg 343606f32e7eSjoerg /** 343706f32e7eSjoerg * Pretty-print the underlying type using the rules of the 343806f32e7eSjoerg * language of the translation unit from which it came. 343906f32e7eSjoerg * 344006f32e7eSjoerg * If the type is invalid, an empty string is returned. 344106f32e7eSjoerg */ 344206f32e7eSjoerg CINDEX_LINKAGE CXString clang_getTypeSpelling(CXType CT); 344306f32e7eSjoerg 344406f32e7eSjoerg /** 344506f32e7eSjoerg * Retrieve the underlying type of a typedef declaration. 344606f32e7eSjoerg * 344706f32e7eSjoerg * If the cursor does not reference a typedef declaration, an invalid type is 344806f32e7eSjoerg * returned. 344906f32e7eSjoerg */ 345006f32e7eSjoerg CINDEX_LINKAGE CXType clang_getTypedefDeclUnderlyingType(CXCursor C); 345106f32e7eSjoerg 345206f32e7eSjoerg /** 345306f32e7eSjoerg * Retrieve the integer type of an enum declaration. 345406f32e7eSjoerg * 345506f32e7eSjoerg * If the cursor does not reference an enum declaration, an invalid type is 345606f32e7eSjoerg * returned. 345706f32e7eSjoerg */ 345806f32e7eSjoerg CINDEX_LINKAGE CXType clang_getEnumDeclIntegerType(CXCursor C); 345906f32e7eSjoerg 346006f32e7eSjoerg /** 346106f32e7eSjoerg * Retrieve the integer value of an enum constant declaration as a signed 346206f32e7eSjoerg * long long. 346306f32e7eSjoerg * 3464*13fbcb42Sjoerg * If the cursor does not reference an enum constant declaration, LLONG_MIN is 3465*13fbcb42Sjoerg * returned. Since this is also potentially a valid constant value, the kind of 3466*13fbcb42Sjoerg * the cursor must be verified before calling this function. 346706f32e7eSjoerg */ 346806f32e7eSjoerg CINDEX_LINKAGE long long clang_getEnumConstantDeclValue(CXCursor C); 346906f32e7eSjoerg 347006f32e7eSjoerg /** 347106f32e7eSjoerg * Retrieve the integer value of an enum constant declaration as an unsigned 347206f32e7eSjoerg * long long. 347306f32e7eSjoerg * 3474*13fbcb42Sjoerg * If the cursor does not reference an enum constant declaration, ULLONG_MAX is 3475*13fbcb42Sjoerg * returned. Since this is also potentially a valid constant value, the kind of 3476*13fbcb42Sjoerg * the cursor must be verified before calling this function. 347706f32e7eSjoerg */ 3478*13fbcb42Sjoerg CINDEX_LINKAGE unsigned long long 3479*13fbcb42Sjoerg clang_getEnumConstantDeclUnsignedValue(CXCursor C); 348006f32e7eSjoerg 348106f32e7eSjoerg /** 348206f32e7eSjoerg * Retrieve the bit width of a bit field declaration as an integer. 348306f32e7eSjoerg * 348406f32e7eSjoerg * If a cursor that is not a bit field declaration is passed in, -1 is returned. 348506f32e7eSjoerg */ 348606f32e7eSjoerg CINDEX_LINKAGE int clang_getFieldDeclBitWidth(CXCursor C); 348706f32e7eSjoerg 348806f32e7eSjoerg /** 348906f32e7eSjoerg * Retrieve the number of non-variadic arguments associated with a given 349006f32e7eSjoerg * cursor. 349106f32e7eSjoerg * 349206f32e7eSjoerg * The number of arguments can be determined for calls as well as for 349306f32e7eSjoerg * declarations of functions or methods. For other cursors -1 is returned. 349406f32e7eSjoerg */ 349506f32e7eSjoerg CINDEX_LINKAGE int clang_Cursor_getNumArguments(CXCursor C); 349606f32e7eSjoerg 349706f32e7eSjoerg /** 349806f32e7eSjoerg * Retrieve the argument cursor of a function or method. 349906f32e7eSjoerg * 350006f32e7eSjoerg * The argument cursor can be determined for calls as well as for declarations 350106f32e7eSjoerg * of functions or methods. For other cursors and for invalid indices, an 350206f32e7eSjoerg * invalid cursor is returned. 350306f32e7eSjoerg */ 350406f32e7eSjoerg CINDEX_LINKAGE CXCursor clang_Cursor_getArgument(CXCursor C, unsigned i); 350506f32e7eSjoerg 350606f32e7eSjoerg /** 350706f32e7eSjoerg * Describes the kind of a template argument. 350806f32e7eSjoerg * 350906f32e7eSjoerg * See the definition of llvm::clang::TemplateArgument::ArgKind for full 351006f32e7eSjoerg * element descriptions. 351106f32e7eSjoerg */ 351206f32e7eSjoerg enum CXTemplateArgumentKind { 351306f32e7eSjoerg CXTemplateArgumentKind_Null, 351406f32e7eSjoerg CXTemplateArgumentKind_Type, 351506f32e7eSjoerg CXTemplateArgumentKind_Declaration, 351606f32e7eSjoerg CXTemplateArgumentKind_NullPtr, 351706f32e7eSjoerg CXTemplateArgumentKind_Integral, 351806f32e7eSjoerg CXTemplateArgumentKind_Template, 351906f32e7eSjoerg CXTemplateArgumentKind_TemplateExpansion, 352006f32e7eSjoerg CXTemplateArgumentKind_Expression, 352106f32e7eSjoerg CXTemplateArgumentKind_Pack, 352206f32e7eSjoerg /* Indicates an error case, preventing the kind from being deduced. */ 352306f32e7eSjoerg CXTemplateArgumentKind_Invalid 352406f32e7eSjoerg }; 352506f32e7eSjoerg 352606f32e7eSjoerg /** 352706f32e7eSjoerg *Returns the number of template args of a function decl representing a 352806f32e7eSjoerg * template specialization. 352906f32e7eSjoerg * 353006f32e7eSjoerg * If the argument cursor cannot be converted into a template function 353106f32e7eSjoerg * declaration, -1 is returned. 353206f32e7eSjoerg * 353306f32e7eSjoerg * For example, for the following declaration and specialization: 353406f32e7eSjoerg * template <typename T, int kInt, bool kBool> 353506f32e7eSjoerg * void foo() { ... } 353606f32e7eSjoerg * 353706f32e7eSjoerg * template <> 353806f32e7eSjoerg * void foo<float, -7, true>(); 353906f32e7eSjoerg * 354006f32e7eSjoerg * The value 3 would be returned from this call. 354106f32e7eSjoerg */ 354206f32e7eSjoerg CINDEX_LINKAGE int clang_Cursor_getNumTemplateArguments(CXCursor C); 354306f32e7eSjoerg 354406f32e7eSjoerg /** 354506f32e7eSjoerg * Retrieve the kind of the I'th template argument of the CXCursor C. 354606f32e7eSjoerg * 354706f32e7eSjoerg * If the argument CXCursor does not represent a FunctionDecl, an invalid 354806f32e7eSjoerg * template argument kind is returned. 354906f32e7eSjoerg * 355006f32e7eSjoerg * For example, for the following declaration and specialization: 355106f32e7eSjoerg * template <typename T, int kInt, bool kBool> 355206f32e7eSjoerg * void foo() { ... } 355306f32e7eSjoerg * 355406f32e7eSjoerg * template <> 355506f32e7eSjoerg * void foo<float, -7, true>(); 355606f32e7eSjoerg * 355706f32e7eSjoerg * For I = 0, 1, and 2, Type, Integral, and Integral will be returned, 355806f32e7eSjoerg * respectively. 355906f32e7eSjoerg */ 3560*13fbcb42Sjoerg CINDEX_LINKAGE enum CXTemplateArgumentKind 3561*13fbcb42Sjoerg clang_Cursor_getTemplateArgumentKind(CXCursor C, unsigned I); 356206f32e7eSjoerg 356306f32e7eSjoerg /** 356406f32e7eSjoerg * Retrieve a CXType representing the type of a TemplateArgument of a 356506f32e7eSjoerg * function decl representing a template specialization. 356606f32e7eSjoerg * 356706f32e7eSjoerg * If the argument CXCursor does not represent a FunctionDecl whose I'th 356806f32e7eSjoerg * template argument has a kind of CXTemplateArgKind_Integral, an invalid type 356906f32e7eSjoerg * is returned. 357006f32e7eSjoerg * 357106f32e7eSjoerg * For example, for the following declaration and specialization: 357206f32e7eSjoerg * template <typename T, int kInt, bool kBool> 357306f32e7eSjoerg * void foo() { ... } 357406f32e7eSjoerg * 357506f32e7eSjoerg * template <> 357606f32e7eSjoerg * void foo<float, -7, true>(); 357706f32e7eSjoerg * 357806f32e7eSjoerg * If called with I = 0, "float", will be returned. 357906f32e7eSjoerg * Invalid types will be returned for I == 1 or 2. 358006f32e7eSjoerg */ 358106f32e7eSjoerg CINDEX_LINKAGE CXType clang_Cursor_getTemplateArgumentType(CXCursor C, 358206f32e7eSjoerg unsigned I); 358306f32e7eSjoerg 358406f32e7eSjoerg /** 358506f32e7eSjoerg * Retrieve the value of an Integral TemplateArgument (of a function 358606f32e7eSjoerg * decl representing a template specialization) as a signed long long. 358706f32e7eSjoerg * 358806f32e7eSjoerg * It is undefined to call this function on a CXCursor that does not represent a 358906f32e7eSjoerg * FunctionDecl or whose I'th template argument is not an integral value. 359006f32e7eSjoerg * 359106f32e7eSjoerg * For example, for the following declaration and specialization: 359206f32e7eSjoerg * template <typename T, int kInt, bool kBool> 359306f32e7eSjoerg * void foo() { ... } 359406f32e7eSjoerg * 359506f32e7eSjoerg * template <> 359606f32e7eSjoerg * void foo<float, -7, true>(); 359706f32e7eSjoerg * 359806f32e7eSjoerg * If called with I = 1 or 2, -7 or true will be returned, respectively. 359906f32e7eSjoerg * For I == 0, this function's behavior is undefined. 360006f32e7eSjoerg */ 360106f32e7eSjoerg CINDEX_LINKAGE long long clang_Cursor_getTemplateArgumentValue(CXCursor C, 360206f32e7eSjoerg unsigned I); 360306f32e7eSjoerg 360406f32e7eSjoerg /** 360506f32e7eSjoerg * Retrieve the value of an Integral TemplateArgument (of a function 360606f32e7eSjoerg * decl representing a template specialization) as an unsigned long long. 360706f32e7eSjoerg * 360806f32e7eSjoerg * It is undefined to call this function on a CXCursor that does not represent a 360906f32e7eSjoerg * FunctionDecl or whose I'th template argument is not an integral value. 361006f32e7eSjoerg * 361106f32e7eSjoerg * For example, for the following declaration and specialization: 361206f32e7eSjoerg * template <typename T, int kInt, bool kBool> 361306f32e7eSjoerg * void foo() { ... } 361406f32e7eSjoerg * 361506f32e7eSjoerg * template <> 361606f32e7eSjoerg * void foo<float, 2147483649, true>(); 361706f32e7eSjoerg * 361806f32e7eSjoerg * If called with I = 1 or 2, 2147483649 or true will be returned, respectively. 361906f32e7eSjoerg * For I == 0, this function's behavior is undefined. 362006f32e7eSjoerg */ 3621*13fbcb42Sjoerg CINDEX_LINKAGE unsigned long long 3622*13fbcb42Sjoerg clang_Cursor_getTemplateArgumentUnsignedValue(CXCursor C, unsigned I); 362306f32e7eSjoerg 362406f32e7eSjoerg /** 362506f32e7eSjoerg * Determine whether two CXTypes represent the same type. 362606f32e7eSjoerg * 362706f32e7eSjoerg * \returns non-zero if the CXTypes represent the same type and 362806f32e7eSjoerg * zero otherwise. 362906f32e7eSjoerg */ 363006f32e7eSjoerg CINDEX_LINKAGE unsigned clang_equalTypes(CXType A, CXType B); 363106f32e7eSjoerg 363206f32e7eSjoerg /** 363306f32e7eSjoerg * Return the canonical type for a CXType. 363406f32e7eSjoerg * 363506f32e7eSjoerg * Clang's type system explicitly models typedefs and all the ways 363606f32e7eSjoerg * a specific type can be represented. The canonical type is the underlying 363706f32e7eSjoerg * type with all the "sugar" removed. For example, if 'T' is a typedef 363806f32e7eSjoerg * for 'int', the canonical type for 'T' would be 'int'. 363906f32e7eSjoerg */ 364006f32e7eSjoerg CINDEX_LINKAGE CXType clang_getCanonicalType(CXType T); 364106f32e7eSjoerg 364206f32e7eSjoerg /** 364306f32e7eSjoerg * Determine whether a CXType has the "const" qualifier set, 364406f32e7eSjoerg * without looking through typedefs that may have added "const" at a 364506f32e7eSjoerg * different level. 364606f32e7eSjoerg */ 364706f32e7eSjoerg CINDEX_LINKAGE unsigned clang_isConstQualifiedType(CXType T); 364806f32e7eSjoerg 364906f32e7eSjoerg /** 365006f32e7eSjoerg * Determine whether a CXCursor that is a macro, is 365106f32e7eSjoerg * function like. 365206f32e7eSjoerg */ 365306f32e7eSjoerg CINDEX_LINKAGE unsigned clang_Cursor_isMacroFunctionLike(CXCursor C); 365406f32e7eSjoerg 365506f32e7eSjoerg /** 365606f32e7eSjoerg * Determine whether a CXCursor that is a macro, is a 365706f32e7eSjoerg * builtin one. 365806f32e7eSjoerg */ 365906f32e7eSjoerg CINDEX_LINKAGE unsigned clang_Cursor_isMacroBuiltin(CXCursor C); 366006f32e7eSjoerg 366106f32e7eSjoerg /** 366206f32e7eSjoerg * Determine whether a CXCursor that is a function declaration, is an 366306f32e7eSjoerg * inline declaration. 366406f32e7eSjoerg */ 366506f32e7eSjoerg CINDEX_LINKAGE unsigned clang_Cursor_isFunctionInlined(CXCursor C); 366606f32e7eSjoerg 366706f32e7eSjoerg /** 366806f32e7eSjoerg * Determine whether a CXType has the "volatile" qualifier set, 366906f32e7eSjoerg * without looking through typedefs that may have added "volatile" at 367006f32e7eSjoerg * a different level. 367106f32e7eSjoerg */ 367206f32e7eSjoerg CINDEX_LINKAGE unsigned clang_isVolatileQualifiedType(CXType T); 367306f32e7eSjoerg 367406f32e7eSjoerg /** 367506f32e7eSjoerg * Determine whether a CXType has the "restrict" qualifier set, 367606f32e7eSjoerg * without looking through typedefs that may have added "restrict" at a 367706f32e7eSjoerg * different level. 367806f32e7eSjoerg */ 367906f32e7eSjoerg CINDEX_LINKAGE unsigned clang_isRestrictQualifiedType(CXType T); 368006f32e7eSjoerg 368106f32e7eSjoerg /** 368206f32e7eSjoerg * Returns the address space of the given type. 368306f32e7eSjoerg */ 368406f32e7eSjoerg CINDEX_LINKAGE unsigned clang_getAddressSpace(CXType T); 368506f32e7eSjoerg 368606f32e7eSjoerg /** 368706f32e7eSjoerg * Returns the typedef name of the given type. 368806f32e7eSjoerg */ 368906f32e7eSjoerg CINDEX_LINKAGE CXString clang_getTypedefName(CXType CT); 369006f32e7eSjoerg 369106f32e7eSjoerg /** 369206f32e7eSjoerg * For pointer types, returns the type of the pointee. 369306f32e7eSjoerg */ 369406f32e7eSjoerg CINDEX_LINKAGE CXType clang_getPointeeType(CXType T); 369506f32e7eSjoerg 369606f32e7eSjoerg /** 369706f32e7eSjoerg * Return the cursor for the declaration of the given type. 369806f32e7eSjoerg */ 369906f32e7eSjoerg CINDEX_LINKAGE CXCursor clang_getTypeDeclaration(CXType T); 370006f32e7eSjoerg 370106f32e7eSjoerg /** 370206f32e7eSjoerg * Returns the Objective-C type encoding for the specified declaration. 370306f32e7eSjoerg */ 370406f32e7eSjoerg CINDEX_LINKAGE CXString clang_getDeclObjCTypeEncoding(CXCursor C); 370506f32e7eSjoerg 370606f32e7eSjoerg /** 370706f32e7eSjoerg * Returns the Objective-C type encoding for the specified CXType. 370806f32e7eSjoerg */ 370906f32e7eSjoerg CINDEX_LINKAGE CXString clang_Type_getObjCEncoding(CXType type); 371006f32e7eSjoerg 371106f32e7eSjoerg /** 371206f32e7eSjoerg * Retrieve the spelling of a given CXTypeKind. 371306f32e7eSjoerg */ 371406f32e7eSjoerg CINDEX_LINKAGE CXString clang_getTypeKindSpelling(enum CXTypeKind K); 371506f32e7eSjoerg 371606f32e7eSjoerg /** 371706f32e7eSjoerg * Retrieve the calling convention associated with a function type. 371806f32e7eSjoerg * 371906f32e7eSjoerg * If a non-function type is passed in, CXCallingConv_Invalid is returned. 372006f32e7eSjoerg */ 372106f32e7eSjoerg CINDEX_LINKAGE enum CXCallingConv clang_getFunctionTypeCallingConv(CXType T); 372206f32e7eSjoerg 372306f32e7eSjoerg /** 372406f32e7eSjoerg * Retrieve the return type associated with a function type. 372506f32e7eSjoerg * 372606f32e7eSjoerg * If a non-function type is passed in, an invalid type is returned. 372706f32e7eSjoerg */ 372806f32e7eSjoerg CINDEX_LINKAGE CXType clang_getResultType(CXType T); 372906f32e7eSjoerg 373006f32e7eSjoerg /** 373106f32e7eSjoerg * Retrieve the exception specification type associated with a function type. 373206f32e7eSjoerg * This is a value of type CXCursor_ExceptionSpecificationKind. 373306f32e7eSjoerg * 373406f32e7eSjoerg * If a non-function type is passed in, an error code of -1 is returned. 373506f32e7eSjoerg */ 373606f32e7eSjoerg CINDEX_LINKAGE int clang_getExceptionSpecificationType(CXType T); 373706f32e7eSjoerg 373806f32e7eSjoerg /** 373906f32e7eSjoerg * Retrieve the number of non-variadic parameters associated with a 374006f32e7eSjoerg * function type. 374106f32e7eSjoerg * 374206f32e7eSjoerg * If a non-function type is passed in, -1 is returned. 374306f32e7eSjoerg */ 374406f32e7eSjoerg CINDEX_LINKAGE int clang_getNumArgTypes(CXType T); 374506f32e7eSjoerg 374606f32e7eSjoerg /** 374706f32e7eSjoerg * Retrieve the type of a parameter of a function type. 374806f32e7eSjoerg * 374906f32e7eSjoerg * If a non-function type is passed in or the function does not have enough 375006f32e7eSjoerg * parameters, an invalid type is returned. 375106f32e7eSjoerg */ 375206f32e7eSjoerg CINDEX_LINKAGE CXType clang_getArgType(CXType T, unsigned i); 375306f32e7eSjoerg 375406f32e7eSjoerg /** 375506f32e7eSjoerg * Retrieves the base type of the ObjCObjectType. 375606f32e7eSjoerg * 375706f32e7eSjoerg * If the type is not an ObjC object, an invalid type is returned. 375806f32e7eSjoerg */ 375906f32e7eSjoerg CINDEX_LINKAGE CXType clang_Type_getObjCObjectBaseType(CXType T); 376006f32e7eSjoerg 376106f32e7eSjoerg /** 376206f32e7eSjoerg * Retrieve the number of protocol references associated with an ObjC object/id. 376306f32e7eSjoerg * 376406f32e7eSjoerg * If the type is not an ObjC object, 0 is returned. 376506f32e7eSjoerg */ 376606f32e7eSjoerg CINDEX_LINKAGE unsigned clang_Type_getNumObjCProtocolRefs(CXType T); 376706f32e7eSjoerg 376806f32e7eSjoerg /** 376906f32e7eSjoerg * Retrieve the decl for a protocol reference for an ObjC object/id. 377006f32e7eSjoerg * 377106f32e7eSjoerg * If the type is not an ObjC object or there are not enough protocol 377206f32e7eSjoerg * references, an invalid cursor is returned. 377306f32e7eSjoerg */ 377406f32e7eSjoerg CINDEX_LINKAGE CXCursor clang_Type_getObjCProtocolDecl(CXType T, unsigned i); 377506f32e7eSjoerg 377606f32e7eSjoerg /** 3777*13fbcb42Sjoerg * Retrieve the number of type arguments associated with an ObjC object. 377806f32e7eSjoerg * 377906f32e7eSjoerg * If the type is not an ObjC object, 0 is returned. 378006f32e7eSjoerg */ 378106f32e7eSjoerg CINDEX_LINKAGE unsigned clang_Type_getNumObjCTypeArgs(CXType T); 378206f32e7eSjoerg 378306f32e7eSjoerg /** 378406f32e7eSjoerg * Retrieve a type argument associated with an ObjC object. 378506f32e7eSjoerg * 378606f32e7eSjoerg * If the type is not an ObjC or the index is not valid, 378706f32e7eSjoerg * an invalid type is returned. 378806f32e7eSjoerg */ 378906f32e7eSjoerg CINDEX_LINKAGE CXType clang_Type_getObjCTypeArg(CXType T, unsigned i); 379006f32e7eSjoerg 379106f32e7eSjoerg /** 379206f32e7eSjoerg * Return 1 if the CXType is a variadic function type, and 0 otherwise. 379306f32e7eSjoerg */ 379406f32e7eSjoerg CINDEX_LINKAGE unsigned clang_isFunctionTypeVariadic(CXType T); 379506f32e7eSjoerg 379606f32e7eSjoerg /** 379706f32e7eSjoerg * Retrieve the return type associated with a given cursor. 379806f32e7eSjoerg * 379906f32e7eSjoerg * This only returns a valid type if the cursor refers to a function or method. 380006f32e7eSjoerg */ 380106f32e7eSjoerg CINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C); 380206f32e7eSjoerg 380306f32e7eSjoerg /** 380406f32e7eSjoerg * Retrieve the exception specification type associated with a given cursor. 380506f32e7eSjoerg * This is a value of type CXCursor_ExceptionSpecificationKind. 380606f32e7eSjoerg * 3807*13fbcb42Sjoerg * This only returns a valid result if the cursor refers to a function or 3808*13fbcb42Sjoerg * method. 380906f32e7eSjoerg */ 381006f32e7eSjoerg CINDEX_LINKAGE int clang_getCursorExceptionSpecificationType(CXCursor C); 381106f32e7eSjoerg 381206f32e7eSjoerg /** 381306f32e7eSjoerg * Return 1 if the CXType is a POD (plain old data) type, and 0 381406f32e7eSjoerg * otherwise. 381506f32e7eSjoerg */ 381606f32e7eSjoerg CINDEX_LINKAGE unsigned clang_isPODType(CXType T); 381706f32e7eSjoerg 381806f32e7eSjoerg /** 381906f32e7eSjoerg * Return the element type of an array, complex, or vector type. 382006f32e7eSjoerg * 382106f32e7eSjoerg * If a type is passed in that is not an array, complex, or vector type, 382206f32e7eSjoerg * an invalid type is returned. 382306f32e7eSjoerg */ 382406f32e7eSjoerg CINDEX_LINKAGE CXType clang_getElementType(CXType T); 382506f32e7eSjoerg 382606f32e7eSjoerg /** 382706f32e7eSjoerg * Return the number of elements of an array or vector type. 382806f32e7eSjoerg * 382906f32e7eSjoerg * If a type is passed in that is not an array or vector type, 383006f32e7eSjoerg * -1 is returned. 383106f32e7eSjoerg */ 383206f32e7eSjoerg CINDEX_LINKAGE long long clang_getNumElements(CXType T); 383306f32e7eSjoerg 383406f32e7eSjoerg /** 383506f32e7eSjoerg * Return the element type of an array type. 383606f32e7eSjoerg * 383706f32e7eSjoerg * If a non-array type is passed in, an invalid type is returned. 383806f32e7eSjoerg */ 383906f32e7eSjoerg CINDEX_LINKAGE CXType clang_getArrayElementType(CXType T); 384006f32e7eSjoerg 384106f32e7eSjoerg /** 384206f32e7eSjoerg * Return the array size of a constant array. 384306f32e7eSjoerg * 384406f32e7eSjoerg * If a non-array type is passed in, -1 is returned. 384506f32e7eSjoerg */ 384606f32e7eSjoerg CINDEX_LINKAGE long long clang_getArraySize(CXType T); 384706f32e7eSjoerg 384806f32e7eSjoerg /** 384906f32e7eSjoerg * Retrieve the type named by the qualified-id. 385006f32e7eSjoerg * 385106f32e7eSjoerg * If a non-elaborated type is passed in, an invalid type is returned. 385206f32e7eSjoerg */ 385306f32e7eSjoerg CINDEX_LINKAGE CXType clang_Type_getNamedType(CXType T); 385406f32e7eSjoerg 385506f32e7eSjoerg /** 385606f32e7eSjoerg * Determine if a typedef is 'transparent' tag. 385706f32e7eSjoerg * 385806f32e7eSjoerg * A typedef is considered 'transparent' if it shares a name and spelling 385906f32e7eSjoerg * location with its underlying tag type, as is the case with the NS_ENUM macro. 386006f32e7eSjoerg * 386106f32e7eSjoerg * \returns non-zero if transparent and zero otherwise. 386206f32e7eSjoerg */ 386306f32e7eSjoerg CINDEX_LINKAGE unsigned clang_Type_isTransparentTagTypedef(CXType T); 386406f32e7eSjoerg 386506f32e7eSjoerg enum CXTypeNullabilityKind { 386606f32e7eSjoerg /** 386706f32e7eSjoerg * Values of this type can never be null. 386806f32e7eSjoerg */ 386906f32e7eSjoerg CXTypeNullability_NonNull = 0, 387006f32e7eSjoerg /** 387106f32e7eSjoerg * Values of this type can be null. 387206f32e7eSjoerg */ 387306f32e7eSjoerg CXTypeNullability_Nullable = 1, 387406f32e7eSjoerg /** 387506f32e7eSjoerg * Whether values of this type can be null is (explicitly) 387606f32e7eSjoerg * unspecified. This captures a (fairly rare) case where we 387706f32e7eSjoerg * can't conclude anything about the nullability of the type even 387806f32e7eSjoerg * though it has been considered. 387906f32e7eSjoerg */ 388006f32e7eSjoerg CXTypeNullability_Unspecified = 2, 388106f32e7eSjoerg /** 388206f32e7eSjoerg * Nullability is not applicable to this type. 388306f32e7eSjoerg */ 3884*13fbcb42Sjoerg CXTypeNullability_Invalid = 3, 3885*13fbcb42Sjoerg 3886*13fbcb42Sjoerg /** 3887*13fbcb42Sjoerg * Generally behaves like Nullable, except when used in a block parameter that 3888*13fbcb42Sjoerg * was imported into a swift async method. There, swift will assume that the 3889*13fbcb42Sjoerg * parameter can get null even if no error occured. _Nullable parameters are 3890*13fbcb42Sjoerg * assumed to only get null on error. 3891*13fbcb42Sjoerg */ 3892*13fbcb42Sjoerg CXTypeNullability_NullableResult = 4 389306f32e7eSjoerg }; 389406f32e7eSjoerg 389506f32e7eSjoerg /** 389606f32e7eSjoerg * Retrieve the nullability kind of a pointer type. 389706f32e7eSjoerg */ 389806f32e7eSjoerg CINDEX_LINKAGE enum CXTypeNullabilityKind clang_Type_getNullability(CXType T); 389906f32e7eSjoerg 390006f32e7eSjoerg /** 390106f32e7eSjoerg * List the possible error codes for \c clang_Type_getSizeOf, 390206f32e7eSjoerg * \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf and 390306f32e7eSjoerg * \c clang_Cursor_getOffsetOf. 390406f32e7eSjoerg * 390506f32e7eSjoerg * A value of this enumeration type can be returned if the target type is not 390606f32e7eSjoerg * a valid argument to sizeof, alignof or offsetof. 390706f32e7eSjoerg */ 390806f32e7eSjoerg enum CXTypeLayoutError { 390906f32e7eSjoerg /** 391006f32e7eSjoerg * Type is of kind CXType_Invalid. 391106f32e7eSjoerg */ 391206f32e7eSjoerg CXTypeLayoutError_Invalid = -1, 391306f32e7eSjoerg /** 391406f32e7eSjoerg * The type is an incomplete Type. 391506f32e7eSjoerg */ 391606f32e7eSjoerg CXTypeLayoutError_Incomplete = -2, 391706f32e7eSjoerg /** 391806f32e7eSjoerg * The type is a dependent Type. 391906f32e7eSjoerg */ 392006f32e7eSjoerg CXTypeLayoutError_Dependent = -3, 392106f32e7eSjoerg /** 392206f32e7eSjoerg * The type is not a constant size type. 392306f32e7eSjoerg */ 392406f32e7eSjoerg CXTypeLayoutError_NotConstantSize = -4, 392506f32e7eSjoerg /** 392606f32e7eSjoerg * The Field name is not valid for this record. 392706f32e7eSjoerg */ 392806f32e7eSjoerg CXTypeLayoutError_InvalidFieldName = -5, 392906f32e7eSjoerg /** 393006f32e7eSjoerg * The type is undeduced. 393106f32e7eSjoerg */ 393206f32e7eSjoerg CXTypeLayoutError_Undeduced = -6 393306f32e7eSjoerg }; 393406f32e7eSjoerg 393506f32e7eSjoerg /** 393606f32e7eSjoerg * Return the alignment of a type in bytes as per C++[expr.alignof] 393706f32e7eSjoerg * standard. 393806f32e7eSjoerg * 393906f32e7eSjoerg * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned. 394006f32e7eSjoerg * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete 394106f32e7eSjoerg * is returned. 394206f32e7eSjoerg * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is 394306f32e7eSjoerg * returned. 394406f32e7eSjoerg * If the type declaration is not a constant size type, 394506f32e7eSjoerg * CXTypeLayoutError_NotConstantSize is returned. 394606f32e7eSjoerg */ 394706f32e7eSjoerg CINDEX_LINKAGE long long clang_Type_getAlignOf(CXType T); 394806f32e7eSjoerg 394906f32e7eSjoerg /** 395006f32e7eSjoerg * Return the class type of an member pointer type. 395106f32e7eSjoerg * 395206f32e7eSjoerg * If a non-member-pointer type is passed in, an invalid type is returned. 395306f32e7eSjoerg */ 395406f32e7eSjoerg CINDEX_LINKAGE CXType clang_Type_getClassType(CXType T); 395506f32e7eSjoerg 395606f32e7eSjoerg /** 395706f32e7eSjoerg * Return the size of a type in bytes as per C++[expr.sizeof] standard. 395806f32e7eSjoerg * 395906f32e7eSjoerg * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned. 396006f32e7eSjoerg * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete 396106f32e7eSjoerg * is returned. 396206f32e7eSjoerg * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is 396306f32e7eSjoerg * returned. 396406f32e7eSjoerg */ 396506f32e7eSjoerg CINDEX_LINKAGE long long clang_Type_getSizeOf(CXType T); 396606f32e7eSjoerg 396706f32e7eSjoerg /** 396806f32e7eSjoerg * Return the offset of a field named S in a record of type T in bits 396906f32e7eSjoerg * as it would be returned by __offsetof__ as per C++11[18.2p4] 397006f32e7eSjoerg * 397106f32e7eSjoerg * If the cursor is not a record field declaration, CXTypeLayoutError_Invalid 397206f32e7eSjoerg * is returned. 397306f32e7eSjoerg * If the field's type declaration is an incomplete type, 397406f32e7eSjoerg * CXTypeLayoutError_Incomplete is returned. 397506f32e7eSjoerg * If the field's type declaration is a dependent type, 397606f32e7eSjoerg * CXTypeLayoutError_Dependent is returned. 397706f32e7eSjoerg * If the field's name S is not found, 397806f32e7eSjoerg * CXTypeLayoutError_InvalidFieldName is returned. 397906f32e7eSjoerg */ 398006f32e7eSjoerg CINDEX_LINKAGE long long clang_Type_getOffsetOf(CXType T, const char *S); 398106f32e7eSjoerg 398206f32e7eSjoerg /** 398306f32e7eSjoerg * Return the type that was modified by this attributed type. 398406f32e7eSjoerg * 398506f32e7eSjoerg * If the type is not an attributed type, an invalid type is returned. 398606f32e7eSjoerg */ 398706f32e7eSjoerg CINDEX_LINKAGE CXType clang_Type_getModifiedType(CXType T); 398806f32e7eSjoerg 398906f32e7eSjoerg /** 3990*13fbcb42Sjoerg * Gets the type contained by this atomic type. 3991*13fbcb42Sjoerg * 3992*13fbcb42Sjoerg * If a non-atomic type is passed in, an invalid type is returned. 3993*13fbcb42Sjoerg */ 3994*13fbcb42Sjoerg CINDEX_LINKAGE CXType clang_Type_getValueType(CXType CT); 3995*13fbcb42Sjoerg 3996*13fbcb42Sjoerg /** 399706f32e7eSjoerg * Return the offset of the field represented by the Cursor. 399806f32e7eSjoerg * 399906f32e7eSjoerg * If the cursor is not a field declaration, -1 is returned. 400006f32e7eSjoerg * If the cursor semantic parent is not a record field declaration, 400106f32e7eSjoerg * CXTypeLayoutError_Invalid is returned. 400206f32e7eSjoerg * If the field's type declaration is an incomplete type, 400306f32e7eSjoerg * CXTypeLayoutError_Incomplete is returned. 400406f32e7eSjoerg * If the field's type declaration is a dependent type, 400506f32e7eSjoerg * CXTypeLayoutError_Dependent is returned. 400606f32e7eSjoerg * If the field's name S is not found, 400706f32e7eSjoerg * CXTypeLayoutError_InvalidFieldName is returned. 400806f32e7eSjoerg */ 400906f32e7eSjoerg CINDEX_LINKAGE long long clang_Cursor_getOffsetOfField(CXCursor C); 401006f32e7eSjoerg 401106f32e7eSjoerg /** 401206f32e7eSjoerg * Determine whether the given cursor represents an anonymous 401306f32e7eSjoerg * tag or namespace 401406f32e7eSjoerg */ 401506f32e7eSjoerg CINDEX_LINKAGE unsigned clang_Cursor_isAnonymous(CXCursor C); 401606f32e7eSjoerg 401706f32e7eSjoerg /** 401806f32e7eSjoerg * Determine whether the given cursor represents an anonymous record 401906f32e7eSjoerg * declaration. 402006f32e7eSjoerg */ 402106f32e7eSjoerg CINDEX_LINKAGE unsigned clang_Cursor_isAnonymousRecordDecl(CXCursor C); 402206f32e7eSjoerg 402306f32e7eSjoerg /** 402406f32e7eSjoerg * Determine whether the given cursor represents an inline namespace 402506f32e7eSjoerg * declaration. 402606f32e7eSjoerg */ 402706f32e7eSjoerg CINDEX_LINKAGE unsigned clang_Cursor_isInlineNamespace(CXCursor C); 402806f32e7eSjoerg 402906f32e7eSjoerg enum CXRefQualifierKind { 403006f32e7eSjoerg /** No ref-qualifier was provided. */ 403106f32e7eSjoerg CXRefQualifier_None = 0, 403206f32e7eSjoerg /** An lvalue ref-qualifier was provided (\c &). */ 403306f32e7eSjoerg CXRefQualifier_LValue, 403406f32e7eSjoerg /** An rvalue ref-qualifier was provided (\c &&). */ 403506f32e7eSjoerg CXRefQualifier_RValue 403606f32e7eSjoerg }; 403706f32e7eSjoerg 403806f32e7eSjoerg /** 403906f32e7eSjoerg * Returns the number of template arguments for given template 404006f32e7eSjoerg * specialization, or -1 if type \c T is not a template specialization. 404106f32e7eSjoerg */ 404206f32e7eSjoerg CINDEX_LINKAGE int clang_Type_getNumTemplateArguments(CXType T); 404306f32e7eSjoerg 404406f32e7eSjoerg /** 404506f32e7eSjoerg * Returns the type template argument of a template class specialization 404606f32e7eSjoerg * at given index. 404706f32e7eSjoerg * 404806f32e7eSjoerg * This function only returns template type arguments and does not handle 404906f32e7eSjoerg * template template arguments or variadic packs. 405006f32e7eSjoerg */ 4051*13fbcb42Sjoerg CINDEX_LINKAGE CXType clang_Type_getTemplateArgumentAsType(CXType T, 4052*13fbcb42Sjoerg unsigned i); 405306f32e7eSjoerg 405406f32e7eSjoerg /** 405506f32e7eSjoerg * Retrieve the ref-qualifier kind of a function or method. 405606f32e7eSjoerg * 405706f32e7eSjoerg * The ref-qualifier is returned for C++ functions or methods. For other types 405806f32e7eSjoerg * or non-C++ declarations, CXRefQualifier_None is returned. 405906f32e7eSjoerg */ 406006f32e7eSjoerg CINDEX_LINKAGE enum CXRefQualifierKind clang_Type_getCXXRefQualifier(CXType T); 406106f32e7eSjoerg 406206f32e7eSjoerg /** 406306f32e7eSjoerg * Returns non-zero if the cursor specifies a Record member that is a 406406f32e7eSjoerg * bitfield. 406506f32e7eSjoerg */ 406606f32e7eSjoerg CINDEX_LINKAGE unsigned clang_Cursor_isBitField(CXCursor C); 406706f32e7eSjoerg 406806f32e7eSjoerg /** 406906f32e7eSjoerg * Returns 1 if the base class specified by the cursor with kind 407006f32e7eSjoerg * CX_CXXBaseSpecifier is virtual. 407106f32e7eSjoerg */ 407206f32e7eSjoerg CINDEX_LINKAGE unsigned clang_isVirtualBase(CXCursor); 407306f32e7eSjoerg 407406f32e7eSjoerg /** 407506f32e7eSjoerg * Represents the C++ access control level to a base class for a 407606f32e7eSjoerg * cursor with kind CX_CXXBaseSpecifier. 407706f32e7eSjoerg */ 407806f32e7eSjoerg enum CX_CXXAccessSpecifier { 407906f32e7eSjoerg CX_CXXInvalidAccessSpecifier, 408006f32e7eSjoerg CX_CXXPublic, 408106f32e7eSjoerg CX_CXXProtected, 408206f32e7eSjoerg CX_CXXPrivate 408306f32e7eSjoerg }; 408406f32e7eSjoerg 408506f32e7eSjoerg /** 408606f32e7eSjoerg * Returns the access control level for the referenced object. 408706f32e7eSjoerg * 4088*13fbcb42Sjoerg * If the cursor refers to a C++ declaration, its access control level within 4089*13fbcb42Sjoerg * its parent scope is returned. Otherwise, if the cursor refers to a base 4090*13fbcb42Sjoerg * specifier or access specifier, the specifier itself is returned. 409106f32e7eSjoerg */ 409206f32e7eSjoerg CINDEX_LINKAGE enum CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor); 409306f32e7eSjoerg 409406f32e7eSjoerg /** 409506f32e7eSjoerg * Represents the storage classes as declared in the source. CX_SC_Invalid 409606f32e7eSjoerg * was added for the case that the passed cursor in not a declaration. 409706f32e7eSjoerg */ 409806f32e7eSjoerg enum CX_StorageClass { 409906f32e7eSjoerg CX_SC_Invalid, 410006f32e7eSjoerg CX_SC_None, 410106f32e7eSjoerg CX_SC_Extern, 410206f32e7eSjoerg CX_SC_Static, 410306f32e7eSjoerg CX_SC_PrivateExtern, 410406f32e7eSjoerg CX_SC_OpenCLWorkGroupLocal, 410506f32e7eSjoerg CX_SC_Auto, 410606f32e7eSjoerg CX_SC_Register 410706f32e7eSjoerg }; 410806f32e7eSjoerg 410906f32e7eSjoerg /** 411006f32e7eSjoerg * Returns the storage class for a function or variable declaration. 411106f32e7eSjoerg * 411206f32e7eSjoerg * If the passed in Cursor is not a function or variable declaration, 411306f32e7eSjoerg * CX_SC_Invalid is returned else the storage class. 411406f32e7eSjoerg */ 411506f32e7eSjoerg CINDEX_LINKAGE enum CX_StorageClass clang_Cursor_getStorageClass(CXCursor); 411606f32e7eSjoerg 411706f32e7eSjoerg /** 411806f32e7eSjoerg * Determine the number of overloaded declarations referenced by a 411906f32e7eSjoerg * \c CXCursor_OverloadedDeclRef cursor. 412006f32e7eSjoerg * 412106f32e7eSjoerg * \param cursor The cursor whose overloaded declarations are being queried. 412206f32e7eSjoerg * 412306f32e7eSjoerg * \returns The number of overloaded declarations referenced by \c cursor. If it 412406f32e7eSjoerg * is not a \c CXCursor_OverloadedDeclRef cursor, returns 0. 412506f32e7eSjoerg */ 412606f32e7eSjoerg CINDEX_LINKAGE unsigned clang_getNumOverloadedDecls(CXCursor cursor); 412706f32e7eSjoerg 412806f32e7eSjoerg /** 412906f32e7eSjoerg * Retrieve a cursor for one of the overloaded declarations referenced 413006f32e7eSjoerg * by a \c CXCursor_OverloadedDeclRef cursor. 413106f32e7eSjoerg * 413206f32e7eSjoerg * \param cursor The cursor whose overloaded declarations are being queried. 413306f32e7eSjoerg * 413406f32e7eSjoerg * \param index The zero-based index into the set of overloaded declarations in 413506f32e7eSjoerg * the cursor. 413606f32e7eSjoerg * 413706f32e7eSjoerg * \returns A cursor representing the declaration referenced by the given 413806f32e7eSjoerg * \c cursor at the specified \c index. If the cursor does not have an 413906f32e7eSjoerg * associated set of overloaded declarations, or if the index is out of bounds, 414006f32e7eSjoerg * returns \c clang_getNullCursor(); 414106f32e7eSjoerg */ 414206f32e7eSjoerg CINDEX_LINKAGE CXCursor clang_getOverloadedDecl(CXCursor cursor, 414306f32e7eSjoerg unsigned index); 414406f32e7eSjoerg 414506f32e7eSjoerg /** 414606f32e7eSjoerg * @} 414706f32e7eSjoerg */ 414806f32e7eSjoerg 414906f32e7eSjoerg /** 415006f32e7eSjoerg * \defgroup CINDEX_ATTRIBUTES Information for attributes 415106f32e7eSjoerg * 415206f32e7eSjoerg * @{ 415306f32e7eSjoerg */ 415406f32e7eSjoerg 415506f32e7eSjoerg /** 415606f32e7eSjoerg * For cursors representing an iboutletcollection attribute, 415706f32e7eSjoerg * this function returns the collection element type. 415806f32e7eSjoerg * 415906f32e7eSjoerg */ 416006f32e7eSjoerg CINDEX_LINKAGE CXType clang_getIBOutletCollectionType(CXCursor); 416106f32e7eSjoerg 416206f32e7eSjoerg /** 416306f32e7eSjoerg * @} 416406f32e7eSjoerg */ 416506f32e7eSjoerg 416606f32e7eSjoerg /** 416706f32e7eSjoerg * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors 416806f32e7eSjoerg * 416906f32e7eSjoerg * These routines provide the ability to traverse the abstract syntax tree 417006f32e7eSjoerg * using cursors. 417106f32e7eSjoerg * 417206f32e7eSjoerg * @{ 417306f32e7eSjoerg */ 417406f32e7eSjoerg 417506f32e7eSjoerg /** 417606f32e7eSjoerg * Describes how the traversal of the children of a particular 417706f32e7eSjoerg * cursor should proceed after visiting a particular child cursor. 417806f32e7eSjoerg * 417906f32e7eSjoerg * A value of this enumeration type should be returned by each 418006f32e7eSjoerg * \c CXCursorVisitor to indicate how clang_visitChildren() proceed. 418106f32e7eSjoerg */ 418206f32e7eSjoerg enum CXChildVisitResult { 418306f32e7eSjoerg /** 418406f32e7eSjoerg * Terminates the cursor traversal. 418506f32e7eSjoerg */ 418606f32e7eSjoerg CXChildVisit_Break, 418706f32e7eSjoerg /** 418806f32e7eSjoerg * Continues the cursor traversal with the next sibling of 418906f32e7eSjoerg * the cursor just visited, without visiting its children. 419006f32e7eSjoerg */ 419106f32e7eSjoerg CXChildVisit_Continue, 419206f32e7eSjoerg /** 419306f32e7eSjoerg * Recursively traverse the children of this cursor, using 419406f32e7eSjoerg * the same visitor and client data. 419506f32e7eSjoerg */ 419606f32e7eSjoerg CXChildVisit_Recurse 419706f32e7eSjoerg }; 419806f32e7eSjoerg 419906f32e7eSjoerg /** 420006f32e7eSjoerg * Visitor invoked for each cursor found by a traversal. 420106f32e7eSjoerg * 420206f32e7eSjoerg * This visitor function will be invoked for each cursor found by 420306f32e7eSjoerg * clang_visitCursorChildren(). Its first argument is the cursor being 420406f32e7eSjoerg * visited, its second argument is the parent visitor for that cursor, 420506f32e7eSjoerg * and its third argument is the client data provided to 420606f32e7eSjoerg * clang_visitCursorChildren(). 420706f32e7eSjoerg * 420806f32e7eSjoerg * The visitor should return one of the \c CXChildVisitResult values 420906f32e7eSjoerg * to direct clang_visitCursorChildren(). 421006f32e7eSjoerg */ 421106f32e7eSjoerg typedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor, 421206f32e7eSjoerg CXCursor parent, 421306f32e7eSjoerg CXClientData client_data); 421406f32e7eSjoerg 421506f32e7eSjoerg /** 421606f32e7eSjoerg * Visit the children of a particular cursor. 421706f32e7eSjoerg * 421806f32e7eSjoerg * This function visits all the direct children of the given cursor, 421906f32e7eSjoerg * invoking the given \p visitor function with the cursors of each 422006f32e7eSjoerg * visited child. The traversal may be recursive, if the visitor returns 422106f32e7eSjoerg * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if 422206f32e7eSjoerg * the visitor returns \c CXChildVisit_Break. 422306f32e7eSjoerg * 422406f32e7eSjoerg * \param parent the cursor whose child may be visited. All kinds of 422506f32e7eSjoerg * cursors can be visited, including invalid cursors (which, by 422606f32e7eSjoerg * definition, have no children). 422706f32e7eSjoerg * 422806f32e7eSjoerg * \param visitor the visitor function that will be invoked for each 422906f32e7eSjoerg * child of \p parent. 423006f32e7eSjoerg * 423106f32e7eSjoerg * \param client_data pointer data supplied by the client, which will 423206f32e7eSjoerg * be passed to the visitor each time it is invoked. 423306f32e7eSjoerg * 423406f32e7eSjoerg * \returns a non-zero value if the traversal was terminated 423506f32e7eSjoerg * prematurely by the visitor returning \c CXChildVisit_Break. 423606f32e7eSjoerg */ 423706f32e7eSjoerg CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent, 423806f32e7eSjoerg CXCursorVisitor visitor, 423906f32e7eSjoerg CXClientData client_data); 424006f32e7eSjoerg #ifdef __has_feature 424106f32e7eSjoerg #if __has_feature(blocks) 424206f32e7eSjoerg /** 424306f32e7eSjoerg * Visitor invoked for each cursor found by a traversal. 424406f32e7eSjoerg * 424506f32e7eSjoerg * This visitor block will be invoked for each cursor found by 424606f32e7eSjoerg * clang_visitChildrenWithBlock(). Its first argument is the cursor being 424706f32e7eSjoerg * visited, its second argument is the parent visitor for that cursor. 424806f32e7eSjoerg * 424906f32e7eSjoerg * The visitor should return one of the \c CXChildVisitResult values 425006f32e7eSjoerg * to direct clang_visitChildrenWithBlock(). 425106f32e7eSjoerg */ 4252*13fbcb42Sjoerg typedef enum CXChildVisitResult (^CXCursorVisitorBlock)(CXCursor cursor, 4253*13fbcb42Sjoerg CXCursor parent); 425406f32e7eSjoerg 425506f32e7eSjoerg /** 425606f32e7eSjoerg * Visits the children of a cursor using the specified block. Behaves 425706f32e7eSjoerg * identically to clang_visitChildren() in all other respects. 425806f32e7eSjoerg */ 4259*13fbcb42Sjoerg CINDEX_LINKAGE unsigned 4260*13fbcb42Sjoerg clang_visitChildrenWithBlock(CXCursor parent, CXCursorVisitorBlock block); 426106f32e7eSjoerg #endif 426206f32e7eSjoerg #endif 426306f32e7eSjoerg 426406f32e7eSjoerg /** 426506f32e7eSjoerg * @} 426606f32e7eSjoerg */ 426706f32e7eSjoerg 426806f32e7eSjoerg /** 426906f32e7eSjoerg * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST 427006f32e7eSjoerg * 427106f32e7eSjoerg * These routines provide the ability to determine references within and 427206f32e7eSjoerg * across translation units, by providing the names of the entities referenced 427306f32e7eSjoerg * by cursors, follow reference cursors to the declarations they reference, 427406f32e7eSjoerg * and associate declarations with their definitions. 427506f32e7eSjoerg * 427606f32e7eSjoerg * @{ 427706f32e7eSjoerg */ 427806f32e7eSjoerg 427906f32e7eSjoerg /** 428006f32e7eSjoerg * Retrieve a Unified Symbol Resolution (USR) for the entity referenced 428106f32e7eSjoerg * by the given cursor. 428206f32e7eSjoerg * 428306f32e7eSjoerg * A Unified Symbol Resolution (USR) is a string that identifies a particular 428406f32e7eSjoerg * entity (function, class, variable, etc.) within a program. USRs can be 428506f32e7eSjoerg * compared across translation units to determine, e.g., when references in 428606f32e7eSjoerg * one translation refer to an entity defined in another translation unit. 428706f32e7eSjoerg */ 428806f32e7eSjoerg CINDEX_LINKAGE CXString clang_getCursorUSR(CXCursor); 428906f32e7eSjoerg 429006f32e7eSjoerg /** 429106f32e7eSjoerg * Construct a USR for a specified Objective-C class. 429206f32e7eSjoerg */ 429306f32e7eSjoerg CINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name); 429406f32e7eSjoerg 429506f32e7eSjoerg /** 429606f32e7eSjoerg * Construct a USR for a specified Objective-C category. 429706f32e7eSjoerg */ 4298*13fbcb42Sjoerg CINDEX_LINKAGE CXString clang_constructUSR_ObjCCategory( 4299*13fbcb42Sjoerg const char *class_name, const char *category_name); 430006f32e7eSjoerg 430106f32e7eSjoerg /** 430206f32e7eSjoerg * Construct a USR for a specified Objective-C protocol. 430306f32e7eSjoerg */ 430406f32e7eSjoerg CINDEX_LINKAGE CXString 430506f32e7eSjoerg clang_constructUSR_ObjCProtocol(const char *protocol_name); 430606f32e7eSjoerg 430706f32e7eSjoerg /** 430806f32e7eSjoerg * Construct a USR for a specified Objective-C instance variable and 430906f32e7eSjoerg * the USR for its containing class. 431006f32e7eSjoerg */ 431106f32e7eSjoerg CINDEX_LINKAGE CXString clang_constructUSR_ObjCIvar(const char *name, 431206f32e7eSjoerg CXString classUSR); 431306f32e7eSjoerg 431406f32e7eSjoerg /** 431506f32e7eSjoerg * Construct a USR for a specified Objective-C method and 431606f32e7eSjoerg * the USR for its containing class. 431706f32e7eSjoerg */ 431806f32e7eSjoerg CINDEX_LINKAGE CXString clang_constructUSR_ObjCMethod(const char *name, 431906f32e7eSjoerg unsigned isInstanceMethod, 432006f32e7eSjoerg CXString classUSR); 432106f32e7eSjoerg 432206f32e7eSjoerg /** 432306f32e7eSjoerg * Construct a USR for a specified Objective-C property and the USR 432406f32e7eSjoerg * for its containing class. 432506f32e7eSjoerg */ 432606f32e7eSjoerg CINDEX_LINKAGE CXString clang_constructUSR_ObjCProperty(const char *property, 432706f32e7eSjoerg CXString classUSR); 432806f32e7eSjoerg 432906f32e7eSjoerg /** 433006f32e7eSjoerg * Retrieve a name for the entity referenced by this cursor. 433106f32e7eSjoerg */ 433206f32e7eSjoerg CINDEX_LINKAGE CXString clang_getCursorSpelling(CXCursor); 433306f32e7eSjoerg 433406f32e7eSjoerg /** 433506f32e7eSjoerg * Retrieve a range for a piece that forms the cursors spelling name. 433606f32e7eSjoerg * Most of the times there is only one range for the complete spelling but for 433706f32e7eSjoerg * Objective-C methods and Objective-C message expressions, there are multiple 433806f32e7eSjoerg * pieces for each selector identifier. 433906f32e7eSjoerg * 434006f32e7eSjoerg * \param pieceIndex the index of the spelling name piece. If this is greater 434106f32e7eSjoerg * than the actual number of pieces, it will return a NULL (invalid) range. 434206f32e7eSjoerg * 434306f32e7eSjoerg * \param options Reserved. 434406f32e7eSjoerg */ 4345*13fbcb42Sjoerg CINDEX_LINKAGE CXSourceRange clang_Cursor_getSpellingNameRange( 4346*13fbcb42Sjoerg CXCursor, unsigned pieceIndex, unsigned options); 434706f32e7eSjoerg 434806f32e7eSjoerg /** 434906f32e7eSjoerg * Opaque pointer representing a policy that controls pretty printing 435006f32e7eSjoerg * for \c clang_getCursorPrettyPrinted. 435106f32e7eSjoerg */ 435206f32e7eSjoerg typedef void *CXPrintingPolicy; 435306f32e7eSjoerg 435406f32e7eSjoerg /** 435506f32e7eSjoerg * Properties for the printing policy. 435606f32e7eSjoerg * 435706f32e7eSjoerg * See \c clang::PrintingPolicy for more information. 435806f32e7eSjoerg */ 435906f32e7eSjoerg enum CXPrintingPolicyProperty { 436006f32e7eSjoerg CXPrintingPolicy_Indentation, 436106f32e7eSjoerg CXPrintingPolicy_SuppressSpecifiers, 436206f32e7eSjoerg CXPrintingPolicy_SuppressTagKeyword, 436306f32e7eSjoerg CXPrintingPolicy_IncludeTagDefinition, 436406f32e7eSjoerg CXPrintingPolicy_SuppressScope, 436506f32e7eSjoerg CXPrintingPolicy_SuppressUnwrittenScope, 436606f32e7eSjoerg CXPrintingPolicy_SuppressInitializers, 436706f32e7eSjoerg CXPrintingPolicy_ConstantArraySizeAsWritten, 436806f32e7eSjoerg CXPrintingPolicy_AnonymousTagLocations, 436906f32e7eSjoerg CXPrintingPolicy_SuppressStrongLifetime, 437006f32e7eSjoerg CXPrintingPolicy_SuppressLifetimeQualifiers, 437106f32e7eSjoerg CXPrintingPolicy_SuppressTemplateArgsInCXXConstructors, 437206f32e7eSjoerg CXPrintingPolicy_Bool, 437306f32e7eSjoerg CXPrintingPolicy_Restrict, 437406f32e7eSjoerg CXPrintingPolicy_Alignof, 437506f32e7eSjoerg CXPrintingPolicy_UnderscoreAlignof, 437606f32e7eSjoerg CXPrintingPolicy_UseVoidForZeroParams, 437706f32e7eSjoerg CXPrintingPolicy_TerseOutput, 437806f32e7eSjoerg CXPrintingPolicy_PolishForDeclaration, 437906f32e7eSjoerg CXPrintingPolicy_Half, 438006f32e7eSjoerg CXPrintingPolicy_MSWChar, 438106f32e7eSjoerg CXPrintingPolicy_IncludeNewlines, 438206f32e7eSjoerg CXPrintingPolicy_MSVCFormatting, 438306f32e7eSjoerg CXPrintingPolicy_ConstantsAsWritten, 438406f32e7eSjoerg CXPrintingPolicy_SuppressImplicitBase, 438506f32e7eSjoerg CXPrintingPolicy_FullyQualifiedName, 438606f32e7eSjoerg 438706f32e7eSjoerg CXPrintingPolicy_LastProperty = CXPrintingPolicy_FullyQualifiedName 438806f32e7eSjoerg }; 438906f32e7eSjoerg 439006f32e7eSjoerg /** 439106f32e7eSjoerg * Get a property value for the given printing policy. 439206f32e7eSjoerg */ 439306f32e7eSjoerg CINDEX_LINKAGE unsigned 439406f32e7eSjoerg clang_PrintingPolicy_getProperty(CXPrintingPolicy Policy, 439506f32e7eSjoerg enum CXPrintingPolicyProperty Property); 439606f32e7eSjoerg 439706f32e7eSjoerg /** 439806f32e7eSjoerg * Set a property value for the given printing policy. 439906f32e7eSjoerg */ 4400*13fbcb42Sjoerg CINDEX_LINKAGE void 4401*13fbcb42Sjoerg clang_PrintingPolicy_setProperty(CXPrintingPolicy Policy, 440206f32e7eSjoerg enum CXPrintingPolicyProperty Property, 440306f32e7eSjoerg unsigned Value); 440406f32e7eSjoerg 440506f32e7eSjoerg /** 440606f32e7eSjoerg * Retrieve the default policy for the cursor. 440706f32e7eSjoerg * 440806f32e7eSjoerg * The policy should be released after use with \c 440906f32e7eSjoerg * clang_PrintingPolicy_dispose. 441006f32e7eSjoerg */ 441106f32e7eSjoerg CINDEX_LINKAGE CXPrintingPolicy clang_getCursorPrintingPolicy(CXCursor); 441206f32e7eSjoerg 441306f32e7eSjoerg /** 441406f32e7eSjoerg * Release a printing policy. 441506f32e7eSjoerg */ 441606f32e7eSjoerg CINDEX_LINKAGE void clang_PrintingPolicy_dispose(CXPrintingPolicy Policy); 441706f32e7eSjoerg 441806f32e7eSjoerg /** 441906f32e7eSjoerg * Pretty print declarations. 442006f32e7eSjoerg * 442106f32e7eSjoerg * \param Cursor The cursor representing a declaration. 442206f32e7eSjoerg * 442306f32e7eSjoerg * \param Policy The policy to control the entities being printed. If 442406f32e7eSjoerg * NULL, a default policy is used. 442506f32e7eSjoerg * 442606f32e7eSjoerg * \returns The pretty printed declaration or the empty string for 442706f32e7eSjoerg * other cursors. 442806f32e7eSjoerg */ 442906f32e7eSjoerg CINDEX_LINKAGE CXString clang_getCursorPrettyPrinted(CXCursor Cursor, 443006f32e7eSjoerg CXPrintingPolicy Policy); 443106f32e7eSjoerg 443206f32e7eSjoerg /** 443306f32e7eSjoerg * Retrieve the display name for the entity referenced by this cursor. 443406f32e7eSjoerg * 443506f32e7eSjoerg * The display name contains extra information that helps identify the cursor, 443606f32e7eSjoerg * such as the parameters of a function or template or the arguments of a 443706f32e7eSjoerg * class template specialization. 443806f32e7eSjoerg */ 443906f32e7eSjoerg CINDEX_LINKAGE CXString clang_getCursorDisplayName(CXCursor); 444006f32e7eSjoerg 444106f32e7eSjoerg /** For a cursor that is a reference, retrieve a cursor representing the 444206f32e7eSjoerg * entity that it references. 444306f32e7eSjoerg * 444406f32e7eSjoerg * Reference cursors refer to other entities in the AST. For example, an 444506f32e7eSjoerg * Objective-C superclass reference cursor refers to an Objective-C class. 444606f32e7eSjoerg * This function produces the cursor for the Objective-C class from the 444706f32e7eSjoerg * cursor for the superclass reference. If the input cursor is a declaration or 444806f32e7eSjoerg * definition, it returns that declaration or definition unchanged. 444906f32e7eSjoerg * Otherwise, returns the NULL cursor. 445006f32e7eSjoerg */ 445106f32e7eSjoerg CINDEX_LINKAGE CXCursor clang_getCursorReferenced(CXCursor); 445206f32e7eSjoerg 445306f32e7eSjoerg /** 445406f32e7eSjoerg * For a cursor that is either a reference to or a declaration 445506f32e7eSjoerg * of some entity, retrieve a cursor that describes the definition of 445606f32e7eSjoerg * that entity. 445706f32e7eSjoerg * 445806f32e7eSjoerg * Some entities can be declared multiple times within a translation 445906f32e7eSjoerg * unit, but only one of those declarations can also be a 446006f32e7eSjoerg * definition. For example, given: 446106f32e7eSjoerg * 446206f32e7eSjoerg * \code 446306f32e7eSjoerg * int f(int, int); 446406f32e7eSjoerg * int g(int x, int y) { return f(x, y); } 446506f32e7eSjoerg * int f(int a, int b) { return a + b; } 446606f32e7eSjoerg * int f(int, int); 446706f32e7eSjoerg * \endcode 446806f32e7eSjoerg * 446906f32e7eSjoerg * there are three declarations of the function "f", but only the 447006f32e7eSjoerg * second one is a definition. The clang_getCursorDefinition() 447106f32e7eSjoerg * function will take any cursor pointing to a declaration of "f" 447206f32e7eSjoerg * (the first or fourth lines of the example) or a cursor referenced 447306f32e7eSjoerg * that uses "f" (the call to "f' inside "g") and will return a 447406f32e7eSjoerg * declaration cursor pointing to the definition (the second "f" 447506f32e7eSjoerg * declaration). 447606f32e7eSjoerg * 447706f32e7eSjoerg * If given a cursor for which there is no corresponding definition, 447806f32e7eSjoerg * e.g., because there is no definition of that entity within this 447906f32e7eSjoerg * translation unit, returns a NULL cursor. 448006f32e7eSjoerg */ 448106f32e7eSjoerg CINDEX_LINKAGE CXCursor clang_getCursorDefinition(CXCursor); 448206f32e7eSjoerg 448306f32e7eSjoerg /** 448406f32e7eSjoerg * Determine whether the declaration pointed to by this cursor 448506f32e7eSjoerg * is also a definition of that entity. 448606f32e7eSjoerg */ 448706f32e7eSjoerg CINDEX_LINKAGE unsigned clang_isCursorDefinition(CXCursor); 448806f32e7eSjoerg 448906f32e7eSjoerg /** 449006f32e7eSjoerg * Retrieve the canonical cursor corresponding to the given cursor. 449106f32e7eSjoerg * 449206f32e7eSjoerg * In the C family of languages, many kinds of entities can be declared several 449306f32e7eSjoerg * times within a single translation unit. For example, a structure type can 449406f32e7eSjoerg * be forward-declared (possibly multiple times) and later defined: 449506f32e7eSjoerg * 449606f32e7eSjoerg * \code 449706f32e7eSjoerg * struct X; 449806f32e7eSjoerg * struct X; 449906f32e7eSjoerg * struct X { 450006f32e7eSjoerg * int member; 450106f32e7eSjoerg * }; 450206f32e7eSjoerg * \endcode 450306f32e7eSjoerg * 450406f32e7eSjoerg * The declarations and the definition of \c X are represented by three 450506f32e7eSjoerg * different cursors, all of which are declarations of the same underlying 450606f32e7eSjoerg * entity. One of these cursor is considered the "canonical" cursor, which 450706f32e7eSjoerg * is effectively the representative for the underlying entity. One can 450806f32e7eSjoerg * determine if two cursors are declarations of the same underlying entity by 450906f32e7eSjoerg * comparing their canonical cursors. 451006f32e7eSjoerg * 451106f32e7eSjoerg * \returns The canonical cursor for the entity referred to by the given cursor. 451206f32e7eSjoerg */ 451306f32e7eSjoerg CINDEX_LINKAGE CXCursor clang_getCanonicalCursor(CXCursor); 451406f32e7eSjoerg 451506f32e7eSjoerg /** 451606f32e7eSjoerg * If the cursor points to a selector identifier in an Objective-C 451706f32e7eSjoerg * method or message expression, this returns the selector index. 451806f32e7eSjoerg * 451906f32e7eSjoerg * After getting a cursor with #clang_getCursor, this can be called to 452006f32e7eSjoerg * determine if the location points to a selector identifier. 452106f32e7eSjoerg * 452206f32e7eSjoerg * \returns The selector index if the cursor is an Objective-C method or message 452306f32e7eSjoerg * expression and the cursor is pointing to a selector identifier, or -1 452406f32e7eSjoerg * otherwise. 452506f32e7eSjoerg */ 452606f32e7eSjoerg CINDEX_LINKAGE int clang_Cursor_getObjCSelectorIndex(CXCursor); 452706f32e7eSjoerg 452806f32e7eSjoerg /** 452906f32e7eSjoerg * Given a cursor pointing to a C++ method call or an Objective-C 453006f32e7eSjoerg * message, returns non-zero if the method/message is "dynamic", meaning: 453106f32e7eSjoerg * 453206f32e7eSjoerg * For a C++ method: the call is virtual. 453306f32e7eSjoerg * For an Objective-C message: the receiver is an object instance, not 'super' 453406f32e7eSjoerg * or a specific class. 453506f32e7eSjoerg * 453606f32e7eSjoerg * If the method/message is "static" or the cursor does not point to a 453706f32e7eSjoerg * method/message, it will return zero. 453806f32e7eSjoerg */ 453906f32e7eSjoerg CINDEX_LINKAGE int clang_Cursor_isDynamicCall(CXCursor C); 454006f32e7eSjoerg 454106f32e7eSjoerg /** 454206f32e7eSjoerg * Given a cursor pointing to an Objective-C message or property 454306f32e7eSjoerg * reference, or C++ method call, returns the CXType of the receiver. 454406f32e7eSjoerg */ 454506f32e7eSjoerg CINDEX_LINKAGE CXType clang_Cursor_getReceiverType(CXCursor C); 454606f32e7eSjoerg 454706f32e7eSjoerg /** 454806f32e7eSjoerg * Property attributes for a \c CXCursor_ObjCPropertyDecl. 454906f32e7eSjoerg */ 455006f32e7eSjoerg typedef enum { 455106f32e7eSjoerg CXObjCPropertyAttr_noattr = 0x00, 455206f32e7eSjoerg CXObjCPropertyAttr_readonly = 0x01, 455306f32e7eSjoerg CXObjCPropertyAttr_getter = 0x02, 455406f32e7eSjoerg CXObjCPropertyAttr_assign = 0x04, 455506f32e7eSjoerg CXObjCPropertyAttr_readwrite = 0x08, 455606f32e7eSjoerg CXObjCPropertyAttr_retain = 0x10, 455706f32e7eSjoerg CXObjCPropertyAttr_copy = 0x20, 455806f32e7eSjoerg CXObjCPropertyAttr_nonatomic = 0x40, 455906f32e7eSjoerg CXObjCPropertyAttr_setter = 0x80, 456006f32e7eSjoerg CXObjCPropertyAttr_atomic = 0x100, 456106f32e7eSjoerg CXObjCPropertyAttr_weak = 0x200, 456206f32e7eSjoerg CXObjCPropertyAttr_strong = 0x400, 456306f32e7eSjoerg CXObjCPropertyAttr_unsafe_unretained = 0x800, 456406f32e7eSjoerg CXObjCPropertyAttr_class = 0x1000 456506f32e7eSjoerg } CXObjCPropertyAttrKind; 456606f32e7eSjoerg 456706f32e7eSjoerg /** 456806f32e7eSjoerg * Given a cursor that represents a property declaration, return the 456906f32e7eSjoerg * associated property attributes. The bits are formed from 457006f32e7eSjoerg * \c CXObjCPropertyAttrKind. 457106f32e7eSjoerg * 457206f32e7eSjoerg * \param reserved Reserved for future use, pass 0. 457306f32e7eSjoerg */ 4574*13fbcb42Sjoerg CINDEX_LINKAGE unsigned 4575*13fbcb42Sjoerg clang_Cursor_getObjCPropertyAttributes(CXCursor C, unsigned reserved); 457606f32e7eSjoerg 457706f32e7eSjoerg /** 457806f32e7eSjoerg * Given a cursor that represents a property declaration, return the 457906f32e7eSjoerg * name of the method that implements the getter. 458006f32e7eSjoerg */ 458106f32e7eSjoerg CINDEX_LINKAGE CXString clang_Cursor_getObjCPropertyGetterName(CXCursor C); 458206f32e7eSjoerg 458306f32e7eSjoerg /** 458406f32e7eSjoerg * Given a cursor that represents a property declaration, return the 458506f32e7eSjoerg * name of the method that implements the setter, if any. 458606f32e7eSjoerg */ 458706f32e7eSjoerg CINDEX_LINKAGE CXString clang_Cursor_getObjCPropertySetterName(CXCursor C); 458806f32e7eSjoerg 458906f32e7eSjoerg /** 459006f32e7eSjoerg * 'Qualifiers' written next to the return and parameter types in 459106f32e7eSjoerg * Objective-C method declarations. 459206f32e7eSjoerg */ 459306f32e7eSjoerg typedef enum { 459406f32e7eSjoerg CXObjCDeclQualifier_None = 0x0, 459506f32e7eSjoerg CXObjCDeclQualifier_In = 0x1, 459606f32e7eSjoerg CXObjCDeclQualifier_Inout = 0x2, 459706f32e7eSjoerg CXObjCDeclQualifier_Out = 0x4, 459806f32e7eSjoerg CXObjCDeclQualifier_Bycopy = 0x8, 459906f32e7eSjoerg CXObjCDeclQualifier_Byref = 0x10, 460006f32e7eSjoerg CXObjCDeclQualifier_Oneway = 0x20 460106f32e7eSjoerg } CXObjCDeclQualifierKind; 460206f32e7eSjoerg 460306f32e7eSjoerg /** 460406f32e7eSjoerg * Given a cursor that represents an Objective-C method or parameter 460506f32e7eSjoerg * declaration, return the associated Objective-C qualifiers for the return 460606f32e7eSjoerg * type or the parameter respectively. The bits are formed from 460706f32e7eSjoerg * CXObjCDeclQualifierKind. 460806f32e7eSjoerg */ 460906f32e7eSjoerg CINDEX_LINKAGE unsigned clang_Cursor_getObjCDeclQualifiers(CXCursor C); 461006f32e7eSjoerg 461106f32e7eSjoerg /** 461206f32e7eSjoerg * Given a cursor that represents an Objective-C method or property 461306f32e7eSjoerg * declaration, return non-zero if the declaration was affected by "\@optional". 461406f32e7eSjoerg * Returns zero if the cursor is not such a declaration or it is "\@required". 461506f32e7eSjoerg */ 461606f32e7eSjoerg CINDEX_LINKAGE unsigned clang_Cursor_isObjCOptional(CXCursor C); 461706f32e7eSjoerg 461806f32e7eSjoerg /** 461906f32e7eSjoerg * Returns non-zero if the given cursor is a variadic function or method. 462006f32e7eSjoerg */ 462106f32e7eSjoerg CINDEX_LINKAGE unsigned clang_Cursor_isVariadic(CXCursor C); 462206f32e7eSjoerg 462306f32e7eSjoerg /** 462406f32e7eSjoerg * Returns non-zero if the given cursor points to a symbol marked with 462506f32e7eSjoerg * external_source_symbol attribute. 462606f32e7eSjoerg * 462706f32e7eSjoerg * \param language If non-NULL, and the attribute is present, will be set to 462806f32e7eSjoerg * the 'language' string from the attribute. 462906f32e7eSjoerg * 463006f32e7eSjoerg * \param definedIn If non-NULL, and the attribute is present, will be set to 463106f32e7eSjoerg * the 'definedIn' string from the attribute. 463206f32e7eSjoerg * 463306f32e7eSjoerg * \param isGenerated If non-NULL, and the attribute is present, will be set to 463406f32e7eSjoerg * non-zero if the 'generated_declaration' is set in the attribute. 463506f32e7eSjoerg */ 463606f32e7eSjoerg CINDEX_LINKAGE unsigned clang_Cursor_isExternalSymbol(CXCursor C, 4637*13fbcb42Sjoerg CXString *language, 4638*13fbcb42Sjoerg CXString *definedIn, 463906f32e7eSjoerg unsigned *isGenerated); 464006f32e7eSjoerg 464106f32e7eSjoerg /** 464206f32e7eSjoerg * Given a cursor that represents a declaration, return the associated 464306f32e7eSjoerg * comment's source range. The range may include multiple consecutive comments 464406f32e7eSjoerg * with whitespace in between. 464506f32e7eSjoerg */ 464606f32e7eSjoerg CINDEX_LINKAGE CXSourceRange clang_Cursor_getCommentRange(CXCursor C); 464706f32e7eSjoerg 464806f32e7eSjoerg /** 464906f32e7eSjoerg * Given a cursor that represents a declaration, return the associated 465006f32e7eSjoerg * comment text, including comment markers. 465106f32e7eSjoerg */ 465206f32e7eSjoerg CINDEX_LINKAGE CXString clang_Cursor_getRawCommentText(CXCursor C); 465306f32e7eSjoerg 465406f32e7eSjoerg /** 465506f32e7eSjoerg * Given a cursor that represents a documentable entity (e.g., 465606f32e7eSjoerg * declaration), return the associated \paragraph; otherwise return the 465706f32e7eSjoerg * first paragraph. 465806f32e7eSjoerg */ 465906f32e7eSjoerg CINDEX_LINKAGE CXString clang_Cursor_getBriefCommentText(CXCursor C); 466006f32e7eSjoerg 466106f32e7eSjoerg /** 466206f32e7eSjoerg * @} 466306f32e7eSjoerg */ 466406f32e7eSjoerg 466506f32e7eSjoerg /** \defgroup CINDEX_MANGLE Name Mangling API Functions 466606f32e7eSjoerg * 466706f32e7eSjoerg * @{ 466806f32e7eSjoerg */ 466906f32e7eSjoerg 467006f32e7eSjoerg /** 467106f32e7eSjoerg * Retrieve the CXString representing the mangled name of the cursor. 467206f32e7eSjoerg */ 467306f32e7eSjoerg CINDEX_LINKAGE CXString clang_Cursor_getMangling(CXCursor); 467406f32e7eSjoerg 467506f32e7eSjoerg /** 467606f32e7eSjoerg * Retrieve the CXStrings representing the mangled symbols of the C++ 467706f32e7eSjoerg * constructor or destructor at the cursor. 467806f32e7eSjoerg */ 467906f32e7eSjoerg CINDEX_LINKAGE CXStringSet *clang_Cursor_getCXXManglings(CXCursor); 468006f32e7eSjoerg 468106f32e7eSjoerg /** 468206f32e7eSjoerg * Retrieve the CXStrings representing the mangled symbols of the ObjC 468306f32e7eSjoerg * class interface or implementation at the cursor. 468406f32e7eSjoerg */ 468506f32e7eSjoerg CINDEX_LINKAGE CXStringSet *clang_Cursor_getObjCManglings(CXCursor); 468606f32e7eSjoerg 468706f32e7eSjoerg /** 468806f32e7eSjoerg * @} 468906f32e7eSjoerg */ 469006f32e7eSjoerg 469106f32e7eSjoerg /** 469206f32e7eSjoerg * \defgroup CINDEX_MODULE Module introspection 469306f32e7eSjoerg * 469406f32e7eSjoerg * The functions in this group provide access to information about modules. 469506f32e7eSjoerg * 469606f32e7eSjoerg * @{ 469706f32e7eSjoerg */ 469806f32e7eSjoerg 469906f32e7eSjoerg typedef void *CXModule; 470006f32e7eSjoerg 470106f32e7eSjoerg /** 470206f32e7eSjoerg * Given a CXCursor_ModuleImportDecl cursor, return the associated module. 470306f32e7eSjoerg */ 470406f32e7eSjoerg CINDEX_LINKAGE CXModule clang_Cursor_getModule(CXCursor C); 470506f32e7eSjoerg 470606f32e7eSjoerg /** 470706f32e7eSjoerg * Given a CXFile header file, return the module that contains it, if one 470806f32e7eSjoerg * exists. 470906f32e7eSjoerg */ 471006f32e7eSjoerg CINDEX_LINKAGE CXModule clang_getModuleForFile(CXTranslationUnit, CXFile); 471106f32e7eSjoerg 471206f32e7eSjoerg /** 471306f32e7eSjoerg * \param Module a module object. 471406f32e7eSjoerg * 471506f32e7eSjoerg * \returns the module file where the provided module object came from. 471606f32e7eSjoerg */ 471706f32e7eSjoerg CINDEX_LINKAGE CXFile clang_Module_getASTFile(CXModule Module); 471806f32e7eSjoerg 471906f32e7eSjoerg /** 472006f32e7eSjoerg * \param Module a module object. 472106f32e7eSjoerg * 472206f32e7eSjoerg * \returns the parent of a sub-module or NULL if the given module is top-level, 472306f32e7eSjoerg * e.g. for 'std.vector' it will return the 'std' module. 472406f32e7eSjoerg */ 472506f32e7eSjoerg CINDEX_LINKAGE CXModule clang_Module_getParent(CXModule Module); 472606f32e7eSjoerg 472706f32e7eSjoerg /** 472806f32e7eSjoerg * \param Module a module object. 472906f32e7eSjoerg * 473006f32e7eSjoerg * \returns the name of the module, e.g. for the 'std.vector' sub-module it 473106f32e7eSjoerg * will return "vector". 473206f32e7eSjoerg */ 473306f32e7eSjoerg CINDEX_LINKAGE CXString clang_Module_getName(CXModule Module); 473406f32e7eSjoerg 473506f32e7eSjoerg /** 473606f32e7eSjoerg * \param Module a module object. 473706f32e7eSjoerg * 473806f32e7eSjoerg * \returns the full name of the module, e.g. "std.vector". 473906f32e7eSjoerg */ 474006f32e7eSjoerg CINDEX_LINKAGE CXString clang_Module_getFullName(CXModule Module); 474106f32e7eSjoerg 474206f32e7eSjoerg /** 474306f32e7eSjoerg * \param Module a module object. 474406f32e7eSjoerg * 474506f32e7eSjoerg * \returns non-zero if the module is a system one. 474606f32e7eSjoerg */ 474706f32e7eSjoerg CINDEX_LINKAGE int clang_Module_isSystem(CXModule Module); 474806f32e7eSjoerg 474906f32e7eSjoerg /** 475006f32e7eSjoerg * \param Module a module object. 475106f32e7eSjoerg * 475206f32e7eSjoerg * \returns the number of top level headers associated with this module. 475306f32e7eSjoerg */ 475406f32e7eSjoerg CINDEX_LINKAGE unsigned clang_Module_getNumTopLevelHeaders(CXTranslationUnit, 475506f32e7eSjoerg CXModule Module); 475606f32e7eSjoerg 475706f32e7eSjoerg /** 475806f32e7eSjoerg * \param Module a module object. 475906f32e7eSjoerg * 476006f32e7eSjoerg * \param Index top level header index (zero-based). 476106f32e7eSjoerg * 476206f32e7eSjoerg * \returns the specified top level header associated with the module. 476306f32e7eSjoerg */ 476406f32e7eSjoerg CINDEX_LINKAGE 4765*13fbcb42Sjoerg CXFile clang_Module_getTopLevelHeader(CXTranslationUnit, CXModule Module, 4766*13fbcb42Sjoerg unsigned Index); 476706f32e7eSjoerg 476806f32e7eSjoerg /** 476906f32e7eSjoerg * @} 477006f32e7eSjoerg */ 477106f32e7eSjoerg 477206f32e7eSjoerg /** 477306f32e7eSjoerg * \defgroup CINDEX_CPP C++ AST introspection 477406f32e7eSjoerg * 477506f32e7eSjoerg * The routines in this group provide access information in the ASTs specific 477606f32e7eSjoerg * to C++ language features. 477706f32e7eSjoerg * 477806f32e7eSjoerg * @{ 477906f32e7eSjoerg */ 478006f32e7eSjoerg 478106f32e7eSjoerg /** 478206f32e7eSjoerg * Determine if a C++ constructor is a converting constructor. 478306f32e7eSjoerg */ 4784*13fbcb42Sjoerg CINDEX_LINKAGE unsigned 4785*13fbcb42Sjoerg clang_CXXConstructor_isConvertingConstructor(CXCursor C); 478606f32e7eSjoerg 478706f32e7eSjoerg /** 478806f32e7eSjoerg * Determine if a C++ constructor is a copy constructor. 478906f32e7eSjoerg */ 479006f32e7eSjoerg CINDEX_LINKAGE unsigned clang_CXXConstructor_isCopyConstructor(CXCursor C); 479106f32e7eSjoerg 479206f32e7eSjoerg /** 479306f32e7eSjoerg * Determine if a C++ constructor is the default constructor. 479406f32e7eSjoerg */ 479506f32e7eSjoerg CINDEX_LINKAGE unsigned clang_CXXConstructor_isDefaultConstructor(CXCursor C); 479606f32e7eSjoerg 479706f32e7eSjoerg /** 479806f32e7eSjoerg * Determine if a C++ constructor is a move constructor. 479906f32e7eSjoerg */ 480006f32e7eSjoerg CINDEX_LINKAGE unsigned clang_CXXConstructor_isMoveConstructor(CXCursor C); 480106f32e7eSjoerg 480206f32e7eSjoerg /** 480306f32e7eSjoerg * Determine if a C++ field is declared 'mutable'. 480406f32e7eSjoerg */ 480506f32e7eSjoerg CINDEX_LINKAGE unsigned clang_CXXField_isMutable(CXCursor C); 480606f32e7eSjoerg 480706f32e7eSjoerg /** 480806f32e7eSjoerg * Determine if a C++ method is declared '= default'. 480906f32e7eSjoerg */ 481006f32e7eSjoerg CINDEX_LINKAGE unsigned clang_CXXMethod_isDefaulted(CXCursor C); 481106f32e7eSjoerg 481206f32e7eSjoerg /** 481306f32e7eSjoerg * Determine if a C++ member function or member function template is 481406f32e7eSjoerg * pure virtual. 481506f32e7eSjoerg */ 481606f32e7eSjoerg CINDEX_LINKAGE unsigned clang_CXXMethod_isPureVirtual(CXCursor C); 481706f32e7eSjoerg 481806f32e7eSjoerg /** 481906f32e7eSjoerg * Determine if a C++ member function or member function template is 482006f32e7eSjoerg * declared 'static'. 482106f32e7eSjoerg */ 482206f32e7eSjoerg CINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C); 482306f32e7eSjoerg 482406f32e7eSjoerg /** 482506f32e7eSjoerg * Determine if a C++ member function or member function template is 482606f32e7eSjoerg * explicitly declared 'virtual' or if it overrides a virtual method from 482706f32e7eSjoerg * one of the base classes. 482806f32e7eSjoerg */ 482906f32e7eSjoerg CINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual(CXCursor C); 483006f32e7eSjoerg 483106f32e7eSjoerg /** 483206f32e7eSjoerg * Determine if a C++ record is abstract, i.e. whether a class or struct 483306f32e7eSjoerg * has a pure virtual member function. 483406f32e7eSjoerg */ 483506f32e7eSjoerg CINDEX_LINKAGE unsigned clang_CXXRecord_isAbstract(CXCursor C); 483606f32e7eSjoerg 483706f32e7eSjoerg /** 483806f32e7eSjoerg * Determine if an enum declaration refers to a scoped enum. 483906f32e7eSjoerg */ 484006f32e7eSjoerg CINDEX_LINKAGE unsigned clang_EnumDecl_isScoped(CXCursor C); 484106f32e7eSjoerg 484206f32e7eSjoerg /** 484306f32e7eSjoerg * Determine if a C++ member function or member function template is 484406f32e7eSjoerg * declared 'const'. 484506f32e7eSjoerg */ 484606f32e7eSjoerg CINDEX_LINKAGE unsigned clang_CXXMethod_isConst(CXCursor C); 484706f32e7eSjoerg 484806f32e7eSjoerg /** 484906f32e7eSjoerg * Given a cursor that represents a template, determine 485006f32e7eSjoerg * the cursor kind of the specializations would be generated by instantiating 485106f32e7eSjoerg * the template. 485206f32e7eSjoerg * 485306f32e7eSjoerg * This routine can be used to determine what flavor of function template, 485406f32e7eSjoerg * class template, or class template partial specialization is stored in the 485506f32e7eSjoerg * cursor. For example, it can describe whether a class template cursor is 485606f32e7eSjoerg * declared with "struct", "class" or "union". 485706f32e7eSjoerg * 485806f32e7eSjoerg * \param C The cursor to query. This cursor should represent a template 485906f32e7eSjoerg * declaration. 486006f32e7eSjoerg * 486106f32e7eSjoerg * \returns The cursor kind of the specializations that would be generated 486206f32e7eSjoerg * by instantiating the template \p C. If \p C is not a template, returns 486306f32e7eSjoerg * \c CXCursor_NoDeclFound. 486406f32e7eSjoerg */ 486506f32e7eSjoerg CINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind(CXCursor C); 486606f32e7eSjoerg 486706f32e7eSjoerg /** 486806f32e7eSjoerg * Given a cursor that may represent a specialization or instantiation 486906f32e7eSjoerg * of a template, retrieve the cursor that represents the template that it 487006f32e7eSjoerg * specializes or from which it was instantiated. 487106f32e7eSjoerg * 487206f32e7eSjoerg * This routine determines the template involved both for explicit 487306f32e7eSjoerg * specializations of templates and for implicit instantiations of the template, 487406f32e7eSjoerg * both of which are referred to as "specializations". For a class template 487506f32e7eSjoerg * specialization (e.g., \c std::vector<bool>), this routine will return 487606f32e7eSjoerg * either the primary template (\c std::vector) or, if the specialization was 487706f32e7eSjoerg * instantiated from a class template partial specialization, the class template 487806f32e7eSjoerg * partial specialization. For a class template partial specialization and a 487906f32e7eSjoerg * function template specialization (including instantiations), this 488006f32e7eSjoerg * this routine will return the specialized template. 488106f32e7eSjoerg * 488206f32e7eSjoerg * For members of a class template (e.g., member functions, member classes, or 488306f32e7eSjoerg * static data members), returns the specialized or instantiated member. 488406f32e7eSjoerg * Although not strictly "templates" in the C++ language, members of class 488506f32e7eSjoerg * templates have the same notions of specializations and instantiations that 488606f32e7eSjoerg * templates do, so this routine treats them similarly. 488706f32e7eSjoerg * 488806f32e7eSjoerg * \param C A cursor that may be a specialization of a template or a member 488906f32e7eSjoerg * of a template. 489006f32e7eSjoerg * 489106f32e7eSjoerg * \returns If the given cursor is a specialization or instantiation of a 489206f32e7eSjoerg * template or a member thereof, the template or member that it specializes or 489306f32e7eSjoerg * from which it was instantiated. Otherwise, returns a NULL cursor. 489406f32e7eSjoerg */ 489506f32e7eSjoerg CINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate(CXCursor C); 489606f32e7eSjoerg 489706f32e7eSjoerg /** 489806f32e7eSjoerg * Given a cursor that references something else, return the source range 489906f32e7eSjoerg * covering that reference. 490006f32e7eSjoerg * 490106f32e7eSjoerg * \param C A cursor pointing to a member reference, a declaration reference, or 490206f32e7eSjoerg * an operator call. 490306f32e7eSjoerg * \param NameFlags A bitset with three independent flags: 490406f32e7eSjoerg * CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and 490506f32e7eSjoerg * CXNameRange_WantSinglePiece. 490606f32e7eSjoerg * \param PieceIndex For contiguous names or when passing the flag 490706f32e7eSjoerg * CXNameRange_WantSinglePiece, only one piece with index 0 is 490806f32e7eSjoerg * available. When the CXNameRange_WantSinglePiece flag is not passed for a 490906f32e7eSjoerg * non-contiguous names, this index can be used to retrieve the individual 491006f32e7eSjoerg * pieces of the name. See also CXNameRange_WantSinglePiece. 491106f32e7eSjoerg * 491206f32e7eSjoerg * \returns The piece of the name pointed to by the given cursor. If there is no 491306f32e7eSjoerg * name, or if the PieceIndex is out-of-range, a null-cursor will be returned. 491406f32e7eSjoerg */ 4915*13fbcb42Sjoerg CINDEX_LINKAGE CXSourceRange clang_getCursorReferenceNameRange( 4916*13fbcb42Sjoerg CXCursor C, unsigned NameFlags, unsigned PieceIndex); 491706f32e7eSjoerg 491806f32e7eSjoerg enum CXNameRefFlags { 491906f32e7eSjoerg /** 492006f32e7eSjoerg * Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the 492106f32e7eSjoerg * range. 492206f32e7eSjoerg */ 492306f32e7eSjoerg CXNameRange_WantQualifier = 0x1, 492406f32e7eSjoerg 492506f32e7eSjoerg /** 492606f32e7eSjoerg * Include the explicit template arguments, e.g. \<int> in x.f<int>, 492706f32e7eSjoerg * in the range. 492806f32e7eSjoerg */ 492906f32e7eSjoerg CXNameRange_WantTemplateArgs = 0x2, 493006f32e7eSjoerg 493106f32e7eSjoerg /** 493206f32e7eSjoerg * If the name is non-contiguous, return the full spanning range. 493306f32e7eSjoerg * 493406f32e7eSjoerg * Non-contiguous names occur in Objective-C when a selector with two or more 493506f32e7eSjoerg * parameters is used, or in C++ when using an operator: 493606f32e7eSjoerg * \code 493706f32e7eSjoerg * [object doSomething:here withValue:there]; // Objective-C 493806f32e7eSjoerg * return some_vector[1]; // C++ 493906f32e7eSjoerg * \endcode 494006f32e7eSjoerg */ 494106f32e7eSjoerg CXNameRange_WantSinglePiece = 0x4 494206f32e7eSjoerg }; 494306f32e7eSjoerg 494406f32e7eSjoerg /** 494506f32e7eSjoerg * @} 494606f32e7eSjoerg */ 494706f32e7eSjoerg 494806f32e7eSjoerg /** 494906f32e7eSjoerg * \defgroup CINDEX_LEX Token extraction and manipulation 495006f32e7eSjoerg * 495106f32e7eSjoerg * The routines in this group provide access to the tokens within a 495206f32e7eSjoerg * translation unit, along with a semantic mapping of those tokens to 495306f32e7eSjoerg * their corresponding cursors. 495406f32e7eSjoerg * 495506f32e7eSjoerg * @{ 495606f32e7eSjoerg */ 495706f32e7eSjoerg 495806f32e7eSjoerg /** 495906f32e7eSjoerg * Describes a kind of token. 496006f32e7eSjoerg */ 496106f32e7eSjoerg typedef enum CXTokenKind { 496206f32e7eSjoerg /** 496306f32e7eSjoerg * A token that contains some kind of punctuation. 496406f32e7eSjoerg */ 496506f32e7eSjoerg CXToken_Punctuation, 496606f32e7eSjoerg 496706f32e7eSjoerg /** 496806f32e7eSjoerg * A language keyword. 496906f32e7eSjoerg */ 497006f32e7eSjoerg CXToken_Keyword, 497106f32e7eSjoerg 497206f32e7eSjoerg /** 497306f32e7eSjoerg * An identifier (that is not a keyword). 497406f32e7eSjoerg */ 497506f32e7eSjoerg CXToken_Identifier, 497606f32e7eSjoerg 497706f32e7eSjoerg /** 497806f32e7eSjoerg * A numeric, string, or character literal. 497906f32e7eSjoerg */ 498006f32e7eSjoerg CXToken_Literal, 498106f32e7eSjoerg 498206f32e7eSjoerg /** 498306f32e7eSjoerg * A comment. 498406f32e7eSjoerg */ 498506f32e7eSjoerg CXToken_Comment 498606f32e7eSjoerg } CXTokenKind; 498706f32e7eSjoerg 498806f32e7eSjoerg /** 498906f32e7eSjoerg * Describes a single preprocessing token. 499006f32e7eSjoerg */ 499106f32e7eSjoerg typedef struct { 499206f32e7eSjoerg unsigned int_data[4]; 499306f32e7eSjoerg void *ptr_data; 499406f32e7eSjoerg } CXToken; 499506f32e7eSjoerg 499606f32e7eSjoerg /** 499706f32e7eSjoerg * Get the raw lexical token starting with the given location. 499806f32e7eSjoerg * 499906f32e7eSjoerg * \param TU the translation unit whose text is being tokenized. 500006f32e7eSjoerg * 500106f32e7eSjoerg * \param Location the source location with which the token starts. 500206f32e7eSjoerg * 500306f32e7eSjoerg * \returns The token starting with the given location or NULL if no such token 500406f32e7eSjoerg * exist. The returned pointer must be freed with clang_disposeTokens before the 500506f32e7eSjoerg * translation unit is destroyed. 500606f32e7eSjoerg */ 500706f32e7eSjoerg CINDEX_LINKAGE CXToken *clang_getToken(CXTranslationUnit TU, 500806f32e7eSjoerg CXSourceLocation Location); 500906f32e7eSjoerg 501006f32e7eSjoerg /** 501106f32e7eSjoerg * Determine the kind of the given token. 501206f32e7eSjoerg */ 501306f32e7eSjoerg CINDEX_LINKAGE CXTokenKind clang_getTokenKind(CXToken); 501406f32e7eSjoerg 501506f32e7eSjoerg /** 501606f32e7eSjoerg * Determine the spelling of the given token. 501706f32e7eSjoerg * 501806f32e7eSjoerg * The spelling of a token is the textual representation of that token, e.g., 501906f32e7eSjoerg * the text of an identifier or keyword. 502006f32e7eSjoerg */ 502106f32e7eSjoerg CINDEX_LINKAGE CXString clang_getTokenSpelling(CXTranslationUnit, CXToken); 502206f32e7eSjoerg 502306f32e7eSjoerg /** 502406f32e7eSjoerg * Retrieve the source location of the given token. 502506f32e7eSjoerg */ 502606f32e7eSjoerg CINDEX_LINKAGE CXSourceLocation clang_getTokenLocation(CXTranslationUnit, 502706f32e7eSjoerg CXToken); 502806f32e7eSjoerg 502906f32e7eSjoerg /** 503006f32e7eSjoerg * Retrieve a source range that covers the given token. 503106f32e7eSjoerg */ 503206f32e7eSjoerg CINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken); 503306f32e7eSjoerg 503406f32e7eSjoerg /** 503506f32e7eSjoerg * Tokenize the source code described by the given range into raw 503606f32e7eSjoerg * lexical tokens. 503706f32e7eSjoerg * 503806f32e7eSjoerg * \param TU the translation unit whose text is being tokenized. 503906f32e7eSjoerg * 504006f32e7eSjoerg * \param Range the source range in which text should be tokenized. All of the 504106f32e7eSjoerg * tokens produced by tokenization will fall within this source range, 504206f32e7eSjoerg * 504306f32e7eSjoerg * \param Tokens this pointer will be set to point to the array of tokens 504406f32e7eSjoerg * that occur within the given source range. The returned pointer must be 504506f32e7eSjoerg * freed with clang_disposeTokens() before the translation unit is destroyed. 504606f32e7eSjoerg * 504706f32e7eSjoerg * \param NumTokens will be set to the number of tokens in the \c *Tokens 504806f32e7eSjoerg * array. 504906f32e7eSjoerg * 505006f32e7eSjoerg */ 505106f32e7eSjoerg CINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range, 505206f32e7eSjoerg CXToken **Tokens, unsigned *NumTokens); 505306f32e7eSjoerg 505406f32e7eSjoerg /** 505506f32e7eSjoerg * Annotate the given set of tokens by providing cursors for each token 505606f32e7eSjoerg * that can be mapped to a specific entity within the abstract syntax tree. 505706f32e7eSjoerg * 505806f32e7eSjoerg * This token-annotation routine is equivalent to invoking 505906f32e7eSjoerg * clang_getCursor() for the source locations of each of the 506006f32e7eSjoerg * tokens. The cursors provided are filtered, so that only those 506106f32e7eSjoerg * cursors that have a direct correspondence to the token are 506206f32e7eSjoerg * accepted. For example, given a function call \c f(x), 506306f32e7eSjoerg * clang_getCursor() would provide the following cursors: 506406f32e7eSjoerg * 506506f32e7eSjoerg * * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'. 506606f32e7eSjoerg * * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'. 506706f32e7eSjoerg * * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'. 506806f32e7eSjoerg * 506906f32e7eSjoerg * Only the first and last of these cursors will occur within the 507006f32e7eSjoerg * annotate, since the tokens "f" and "x' directly refer to a function 507106f32e7eSjoerg * and a variable, respectively, but the parentheses are just a small 507206f32e7eSjoerg * part of the full syntax of the function call expression, which is 507306f32e7eSjoerg * not provided as an annotation. 507406f32e7eSjoerg * 507506f32e7eSjoerg * \param TU the translation unit that owns the given tokens. 507606f32e7eSjoerg * 507706f32e7eSjoerg * \param Tokens the set of tokens to annotate. 507806f32e7eSjoerg * 507906f32e7eSjoerg * \param NumTokens the number of tokens in \p Tokens. 508006f32e7eSjoerg * 508106f32e7eSjoerg * \param Cursors an array of \p NumTokens cursors, whose contents will be 508206f32e7eSjoerg * replaced with the cursors corresponding to each token. 508306f32e7eSjoerg */ 5084*13fbcb42Sjoerg CINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU, CXToken *Tokens, 5085*13fbcb42Sjoerg unsigned NumTokens, CXCursor *Cursors); 508606f32e7eSjoerg 508706f32e7eSjoerg /** 508806f32e7eSjoerg * Free the given set of tokens. 508906f32e7eSjoerg */ 5090*13fbcb42Sjoerg CINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU, CXToken *Tokens, 5091*13fbcb42Sjoerg unsigned NumTokens); 509206f32e7eSjoerg 509306f32e7eSjoerg /** 509406f32e7eSjoerg * @} 509506f32e7eSjoerg */ 509606f32e7eSjoerg 509706f32e7eSjoerg /** 509806f32e7eSjoerg * \defgroup CINDEX_DEBUG Debugging facilities 509906f32e7eSjoerg * 510006f32e7eSjoerg * These routines are used for testing and debugging, only, and should not 510106f32e7eSjoerg * be relied upon. 510206f32e7eSjoerg * 510306f32e7eSjoerg * @{ 510406f32e7eSjoerg */ 510506f32e7eSjoerg 510606f32e7eSjoerg /* for debug/testing */ 510706f32e7eSjoerg CINDEX_LINKAGE CXString clang_getCursorKindSpelling(enum CXCursorKind Kind); 5108*13fbcb42Sjoerg CINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent( 5109*13fbcb42Sjoerg CXCursor, const char **startBuf, const char **endBuf, unsigned *startLine, 5110*13fbcb42Sjoerg unsigned *startColumn, unsigned *endLine, unsigned *endColumn); 511106f32e7eSjoerg CINDEX_LINKAGE void clang_enableStackTraces(void); 511206f32e7eSjoerg CINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void *), void *user_data, 511306f32e7eSjoerg unsigned stack_size); 511406f32e7eSjoerg 511506f32e7eSjoerg /** 511606f32e7eSjoerg * @} 511706f32e7eSjoerg */ 511806f32e7eSjoerg 511906f32e7eSjoerg /** 512006f32e7eSjoerg * \defgroup CINDEX_CODE_COMPLET Code completion 512106f32e7eSjoerg * 512206f32e7eSjoerg * Code completion involves taking an (incomplete) source file, along with 512306f32e7eSjoerg * knowledge of where the user is actively editing that file, and suggesting 512406f32e7eSjoerg * syntactically- and semantically-valid constructs that the user might want to 512506f32e7eSjoerg * use at that particular point in the source code. These data structures and 512606f32e7eSjoerg * routines provide support for code completion. 512706f32e7eSjoerg * 512806f32e7eSjoerg * @{ 512906f32e7eSjoerg */ 513006f32e7eSjoerg 513106f32e7eSjoerg /** 513206f32e7eSjoerg * A semantic string that describes a code-completion result. 513306f32e7eSjoerg * 513406f32e7eSjoerg * A semantic string that describes the formatting of a code-completion 513506f32e7eSjoerg * result as a single "template" of text that should be inserted into the 513606f32e7eSjoerg * source buffer when a particular code-completion result is selected. 513706f32e7eSjoerg * Each semantic string is made up of some number of "chunks", each of which 513806f32e7eSjoerg * contains some text along with a description of what that text means, e.g., 513906f32e7eSjoerg * the name of the entity being referenced, whether the text chunk is part of 514006f32e7eSjoerg * the template, or whether it is a "placeholder" that the user should replace 514106f32e7eSjoerg * with actual code,of a specific kind. See \c CXCompletionChunkKind for a 514206f32e7eSjoerg * description of the different kinds of chunks. 514306f32e7eSjoerg */ 514406f32e7eSjoerg typedef void *CXCompletionString; 514506f32e7eSjoerg 514606f32e7eSjoerg /** 514706f32e7eSjoerg * A single result of code completion. 514806f32e7eSjoerg */ 514906f32e7eSjoerg typedef struct { 515006f32e7eSjoerg /** 515106f32e7eSjoerg * The kind of entity that this completion refers to. 515206f32e7eSjoerg * 515306f32e7eSjoerg * The cursor kind will be a macro, keyword, or a declaration (one of the 515406f32e7eSjoerg * *Decl cursor kinds), describing the entity that the completion is 515506f32e7eSjoerg * referring to. 515606f32e7eSjoerg * 515706f32e7eSjoerg * \todo In the future, we would like to provide a full cursor, to allow 515806f32e7eSjoerg * the client to extract additional information from declaration. 515906f32e7eSjoerg */ 516006f32e7eSjoerg enum CXCursorKind CursorKind; 516106f32e7eSjoerg 516206f32e7eSjoerg /** 516306f32e7eSjoerg * The code-completion string that describes how to insert this 516406f32e7eSjoerg * code-completion result into the editing buffer. 516506f32e7eSjoerg */ 516606f32e7eSjoerg CXCompletionString CompletionString; 516706f32e7eSjoerg } CXCompletionResult; 516806f32e7eSjoerg 516906f32e7eSjoerg /** 517006f32e7eSjoerg * Describes a single piece of text within a code-completion string. 517106f32e7eSjoerg * 517206f32e7eSjoerg * Each "chunk" within a code-completion string (\c CXCompletionString) is 517306f32e7eSjoerg * either a piece of text with a specific "kind" that describes how that text 517406f32e7eSjoerg * should be interpreted by the client or is another completion string. 517506f32e7eSjoerg */ 517606f32e7eSjoerg enum CXCompletionChunkKind { 517706f32e7eSjoerg /** 517806f32e7eSjoerg * A code-completion string that describes "optional" text that 517906f32e7eSjoerg * could be a part of the template (but is not required). 518006f32e7eSjoerg * 518106f32e7eSjoerg * The Optional chunk is the only kind of chunk that has a code-completion 518206f32e7eSjoerg * string for its representation, which is accessible via 518306f32e7eSjoerg * \c clang_getCompletionChunkCompletionString(). The code-completion string 518406f32e7eSjoerg * describes an additional part of the template that is completely optional. 518506f32e7eSjoerg * For example, optional chunks can be used to describe the placeholders for 518606f32e7eSjoerg * arguments that match up with defaulted function parameters, e.g. given: 518706f32e7eSjoerg * 518806f32e7eSjoerg * \code 518906f32e7eSjoerg * void f(int x, float y = 3.14, double z = 2.71828); 519006f32e7eSjoerg * \endcode 519106f32e7eSjoerg * 519206f32e7eSjoerg * The code-completion string for this function would contain: 519306f32e7eSjoerg * - a TypedText chunk for "f". 519406f32e7eSjoerg * - a LeftParen chunk for "(". 519506f32e7eSjoerg * - a Placeholder chunk for "int x" 519606f32e7eSjoerg * - an Optional chunk containing the remaining defaulted arguments, e.g., 519706f32e7eSjoerg * - a Comma chunk for "," 519806f32e7eSjoerg * - a Placeholder chunk for "float y" 519906f32e7eSjoerg * - an Optional chunk containing the last defaulted argument: 520006f32e7eSjoerg * - a Comma chunk for "," 520106f32e7eSjoerg * - a Placeholder chunk for "double z" 520206f32e7eSjoerg * - a RightParen chunk for ")" 520306f32e7eSjoerg * 520406f32e7eSjoerg * There are many ways to handle Optional chunks. Two simple approaches are: 520506f32e7eSjoerg * - Completely ignore optional chunks, in which case the template for the 520606f32e7eSjoerg * function "f" would only include the first parameter ("int x"). 520706f32e7eSjoerg * - Fully expand all optional chunks, in which case the template for the 520806f32e7eSjoerg * function "f" would have all of the parameters. 520906f32e7eSjoerg */ 521006f32e7eSjoerg CXCompletionChunk_Optional, 521106f32e7eSjoerg /** 521206f32e7eSjoerg * Text that a user would be expected to type to get this 521306f32e7eSjoerg * code-completion result. 521406f32e7eSjoerg * 521506f32e7eSjoerg * There will be exactly one "typed text" chunk in a semantic string, which 521606f32e7eSjoerg * will typically provide the spelling of a keyword or the name of a 521706f32e7eSjoerg * declaration that could be used at the current code point. Clients are 521806f32e7eSjoerg * expected to filter the code-completion results based on the text in this 521906f32e7eSjoerg * chunk. 522006f32e7eSjoerg */ 522106f32e7eSjoerg CXCompletionChunk_TypedText, 522206f32e7eSjoerg /** 522306f32e7eSjoerg * Text that should be inserted as part of a code-completion result. 522406f32e7eSjoerg * 522506f32e7eSjoerg * A "text" chunk represents text that is part of the template to be 522606f32e7eSjoerg * inserted into user code should this particular code-completion result 522706f32e7eSjoerg * be selected. 522806f32e7eSjoerg */ 522906f32e7eSjoerg CXCompletionChunk_Text, 523006f32e7eSjoerg /** 523106f32e7eSjoerg * Placeholder text that should be replaced by the user. 523206f32e7eSjoerg * 523306f32e7eSjoerg * A "placeholder" chunk marks a place where the user should insert text 523406f32e7eSjoerg * into the code-completion template. For example, placeholders might mark 523506f32e7eSjoerg * the function parameters for a function declaration, to indicate that the 523606f32e7eSjoerg * user should provide arguments for each of those parameters. The actual 523706f32e7eSjoerg * text in a placeholder is a suggestion for the text to display before 523806f32e7eSjoerg * the user replaces the placeholder with real code. 523906f32e7eSjoerg */ 524006f32e7eSjoerg CXCompletionChunk_Placeholder, 524106f32e7eSjoerg /** 524206f32e7eSjoerg * Informative text that should be displayed but never inserted as 524306f32e7eSjoerg * part of the template. 524406f32e7eSjoerg * 524506f32e7eSjoerg * An "informative" chunk contains annotations that can be displayed to 524606f32e7eSjoerg * help the user decide whether a particular code-completion result is the 524706f32e7eSjoerg * right option, but which is not part of the actual template to be inserted 524806f32e7eSjoerg * by code completion. 524906f32e7eSjoerg */ 525006f32e7eSjoerg CXCompletionChunk_Informative, 525106f32e7eSjoerg /** 525206f32e7eSjoerg * Text that describes the current parameter when code-completion is 525306f32e7eSjoerg * referring to function call, message send, or template specialization. 525406f32e7eSjoerg * 525506f32e7eSjoerg * A "current parameter" chunk occurs when code-completion is providing 525606f32e7eSjoerg * information about a parameter corresponding to the argument at the 525706f32e7eSjoerg * code-completion point. For example, given a function 525806f32e7eSjoerg * 525906f32e7eSjoerg * \code 526006f32e7eSjoerg * int add(int x, int y); 526106f32e7eSjoerg * \endcode 526206f32e7eSjoerg * 526306f32e7eSjoerg * and the source code \c add(, where the code-completion point is after the 526406f32e7eSjoerg * "(", the code-completion string will contain a "current parameter" chunk 526506f32e7eSjoerg * for "int x", indicating that the current argument will initialize that 526606f32e7eSjoerg * parameter. After typing further, to \c add(17, (where the code-completion 526706f32e7eSjoerg * point is after the ","), the code-completion string will contain a 526806f32e7eSjoerg * "current parameter" chunk to "int y". 526906f32e7eSjoerg */ 527006f32e7eSjoerg CXCompletionChunk_CurrentParameter, 527106f32e7eSjoerg /** 527206f32e7eSjoerg * A left parenthesis ('('), used to initiate a function call or 527306f32e7eSjoerg * signal the beginning of a function parameter list. 527406f32e7eSjoerg */ 527506f32e7eSjoerg CXCompletionChunk_LeftParen, 527606f32e7eSjoerg /** 527706f32e7eSjoerg * A right parenthesis (')'), used to finish a function call or 527806f32e7eSjoerg * signal the end of a function parameter list. 527906f32e7eSjoerg */ 528006f32e7eSjoerg CXCompletionChunk_RightParen, 528106f32e7eSjoerg /** 528206f32e7eSjoerg * A left bracket ('['). 528306f32e7eSjoerg */ 528406f32e7eSjoerg CXCompletionChunk_LeftBracket, 528506f32e7eSjoerg /** 528606f32e7eSjoerg * A right bracket (']'). 528706f32e7eSjoerg */ 528806f32e7eSjoerg CXCompletionChunk_RightBracket, 528906f32e7eSjoerg /** 529006f32e7eSjoerg * A left brace ('{'). 529106f32e7eSjoerg */ 529206f32e7eSjoerg CXCompletionChunk_LeftBrace, 529306f32e7eSjoerg /** 529406f32e7eSjoerg * A right brace ('}'). 529506f32e7eSjoerg */ 529606f32e7eSjoerg CXCompletionChunk_RightBrace, 529706f32e7eSjoerg /** 529806f32e7eSjoerg * A left angle bracket ('<'). 529906f32e7eSjoerg */ 530006f32e7eSjoerg CXCompletionChunk_LeftAngle, 530106f32e7eSjoerg /** 530206f32e7eSjoerg * A right angle bracket ('>'). 530306f32e7eSjoerg */ 530406f32e7eSjoerg CXCompletionChunk_RightAngle, 530506f32e7eSjoerg /** 530606f32e7eSjoerg * A comma separator (','). 530706f32e7eSjoerg */ 530806f32e7eSjoerg CXCompletionChunk_Comma, 530906f32e7eSjoerg /** 531006f32e7eSjoerg * Text that specifies the result type of a given result. 531106f32e7eSjoerg * 531206f32e7eSjoerg * This special kind of informative chunk is not meant to be inserted into 531306f32e7eSjoerg * the text buffer. Rather, it is meant to illustrate the type that an 531406f32e7eSjoerg * expression using the given completion string would have. 531506f32e7eSjoerg */ 531606f32e7eSjoerg CXCompletionChunk_ResultType, 531706f32e7eSjoerg /** 531806f32e7eSjoerg * A colon (':'). 531906f32e7eSjoerg */ 532006f32e7eSjoerg CXCompletionChunk_Colon, 532106f32e7eSjoerg /** 532206f32e7eSjoerg * A semicolon (';'). 532306f32e7eSjoerg */ 532406f32e7eSjoerg CXCompletionChunk_SemiColon, 532506f32e7eSjoerg /** 532606f32e7eSjoerg * An '=' sign. 532706f32e7eSjoerg */ 532806f32e7eSjoerg CXCompletionChunk_Equal, 532906f32e7eSjoerg /** 533006f32e7eSjoerg * Horizontal space (' '). 533106f32e7eSjoerg */ 533206f32e7eSjoerg CXCompletionChunk_HorizontalSpace, 533306f32e7eSjoerg /** 533406f32e7eSjoerg * Vertical space ('\\n'), after which it is generally a good idea to 533506f32e7eSjoerg * perform indentation. 533606f32e7eSjoerg */ 533706f32e7eSjoerg CXCompletionChunk_VerticalSpace 533806f32e7eSjoerg }; 533906f32e7eSjoerg 534006f32e7eSjoerg /** 534106f32e7eSjoerg * Determine the kind of a particular chunk within a completion string. 534206f32e7eSjoerg * 534306f32e7eSjoerg * \param completion_string the completion string to query. 534406f32e7eSjoerg * 534506f32e7eSjoerg * \param chunk_number the 0-based index of the chunk in the completion string. 534606f32e7eSjoerg * 534706f32e7eSjoerg * \returns the kind of the chunk at the index \c chunk_number. 534806f32e7eSjoerg */ 534906f32e7eSjoerg CINDEX_LINKAGE enum CXCompletionChunkKind 535006f32e7eSjoerg clang_getCompletionChunkKind(CXCompletionString completion_string, 535106f32e7eSjoerg unsigned chunk_number); 535206f32e7eSjoerg 535306f32e7eSjoerg /** 535406f32e7eSjoerg * Retrieve the text associated with a particular chunk within a 535506f32e7eSjoerg * completion string. 535606f32e7eSjoerg * 535706f32e7eSjoerg * \param completion_string the completion string to query. 535806f32e7eSjoerg * 535906f32e7eSjoerg * \param chunk_number the 0-based index of the chunk in the completion string. 536006f32e7eSjoerg * 536106f32e7eSjoerg * \returns the text associated with the chunk at index \c chunk_number. 536206f32e7eSjoerg */ 5363*13fbcb42Sjoerg CINDEX_LINKAGE CXString clang_getCompletionChunkText( 5364*13fbcb42Sjoerg CXCompletionString completion_string, unsigned chunk_number); 536506f32e7eSjoerg 536606f32e7eSjoerg /** 536706f32e7eSjoerg * Retrieve the completion string associated with a particular chunk 536806f32e7eSjoerg * within a completion string. 536906f32e7eSjoerg * 537006f32e7eSjoerg * \param completion_string the completion string to query. 537106f32e7eSjoerg * 537206f32e7eSjoerg * \param chunk_number the 0-based index of the chunk in the completion string. 537306f32e7eSjoerg * 537406f32e7eSjoerg * \returns the completion string associated with the chunk at index 537506f32e7eSjoerg * \c chunk_number. 537606f32e7eSjoerg */ 5377*13fbcb42Sjoerg CINDEX_LINKAGE CXCompletionString clang_getCompletionChunkCompletionString( 5378*13fbcb42Sjoerg CXCompletionString completion_string, unsigned chunk_number); 537906f32e7eSjoerg 538006f32e7eSjoerg /** 538106f32e7eSjoerg * Retrieve the number of chunks in the given code-completion string. 538206f32e7eSjoerg */ 538306f32e7eSjoerg CINDEX_LINKAGE unsigned 538406f32e7eSjoerg clang_getNumCompletionChunks(CXCompletionString completion_string); 538506f32e7eSjoerg 538606f32e7eSjoerg /** 538706f32e7eSjoerg * Determine the priority of this code completion. 538806f32e7eSjoerg * 538906f32e7eSjoerg * The priority of a code completion indicates how likely it is that this 539006f32e7eSjoerg * particular completion is the completion that the user will select. The 539106f32e7eSjoerg * priority is selected by various internal heuristics. 539206f32e7eSjoerg * 539306f32e7eSjoerg * \param completion_string The completion string to query. 539406f32e7eSjoerg * 539506f32e7eSjoerg * \returns The priority of this completion string. Smaller values indicate 539606f32e7eSjoerg * higher-priority (more likely) completions. 539706f32e7eSjoerg */ 539806f32e7eSjoerg CINDEX_LINKAGE unsigned 539906f32e7eSjoerg clang_getCompletionPriority(CXCompletionString completion_string); 540006f32e7eSjoerg 540106f32e7eSjoerg /** 540206f32e7eSjoerg * Determine the availability of the entity that this code-completion 540306f32e7eSjoerg * string refers to. 540406f32e7eSjoerg * 540506f32e7eSjoerg * \param completion_string The completion string to query. 540606f32e7eSjoerg * 540706f32e7eSjoerg * \returns The availability of the completion string. 540806f32e7eSjoerg */ 540906f32e7eSjoerg CINDEX_LINKAGE enum CXAvailabilityKind 541006f32e7eSjoerg clang_getCompletionAvailability(CXCompletionString completion_string); 541106f32e7eSjoerg 541206f32e7eSjoerg /** 541306f32e7eSjoerg * Retrieve the number of annotations associated with the given 541406f32e7eSjoerg * completion string. 541506f32e7eSjoerg * 541606f32e7eSjoerg * \param completion_string the completion string to query. 541706f32e7eSjoerg * 541806f32e7eSjoerg * \returns the number of annotations associated with the given completion 541906f32e7eSjoerg * string. 542006f32e7eSjoerg */ 542106f32e7eSjoerg CINDEX_LINKAGE unsigned 542206f32e7eSjoerg clang_getCompletionNumAnnotations(CXCompletionString completion_string); 542306f32e7eSjoerg 542406f32e7eSjoerg /** 542506f32e7eSjoerg * Retrieve the annotation associated with the given completion string. 542606f32e7eSjoerg * 542706f32e7eSjoerg * \param completion_string the completion string to query. 542806f32e7eSjoerg * 542906f32e7eSjoerg * \param annotation_number the 0-based index of the annotation of the 543006f32e7eSjoerg * completion string. 543106f32e7eSjoerg * 543206f32e7eSjoerg * \returns annotation string associated with the completion at index 543306f32e7eSjoerg * \c annotation_number, or a NULL string if that annotation is not available. 543406f32e7eSjoerg */ 5435*13fbcb42Sjoerg CINDEX_LINKAGE CXString clang_getCompletionAnnotation( 5436*13fbcb42Sjoerg CXCompletionString completion_string, unsigned annotation_number); 543706f32e7eSjoerg 543806f32e7eSjoerg /** 543906f32e7eSjoerg * Retrieve the parent context of the given completion string. 544006f32e7eSjoerg * 544106f32e7eSjoerg * The parent context of a completion string is the semantic parent of 544206f32e7eSjoerg * the declaration (if any) that the code completion represents. For example, 544306f32e7eSjoerg * a code completion for an Objective-C method would have the method's class 544406f32e7eSjoerg * or protocol as its context. 544506f32e7eSjoerg * 544606f32e7eSjoerg * \param completion_string The code completion string whose parent is 544706f32e7eSjoerg * being queried. 544806f32e7eSjoerg * 544906f32e7eSjoerg * \param kind DEPRECATED: always set to CXCursor_NotImplemented if non-NULL. 545006f32e7eSjoerg * 545106f32e7eSjoerg * \returns The name of the completion parent, e.g., "NSObject" if 545206f32e7eSjoerg * the completion string represents a method in the NSObject class. 545306f32e7eSjoerg */ 5454*13fbcb42Sjoerg CINDEX_LINKAGE CXString clang_getCompletionParent( 5455*13fbcb42Sjoerg CXCompletionString completion_string, enum CXCursorKind *kind); 545606f32e7eSjoerg 545706f32e7eSjoerg /** 545806f32e7eSjoerg * Retrieve the brief documentation comment attached to the declaration 545906f32e7eSjoerg * that corresponds to the given completion string. 546006f32e7eSjoerg */ 546106f32e7eSjoerg CINDEX_LINKAGE CXString 546206f32e7eSjoerg clang_getCompletionBriefComment(CXCompletionString completion_string); 546306f32e7eSjoerg 546406f32e7eSjoerg /** 546506f32e7eSjoerg * Retrieve a completion string for an arbitrary declaration or macro 546606f32e7eSjoerg * definition cursor. 546706f32e7eSjoerg * 546806f32e7eSjoerg * \param cursor The cursor to query. 546906f32e7eSjoerg * 547006f32e7eSjoerg * \returns A non-context-sensitive completion string for declaration and macro 547106f32e7eSjoerg * definition cursors, or NULL for other kinds of cursors. 547206f32e7eSjoerg */ 547306f32e7eSjoerg CINDEX_LINKAGE CXCompletionString 547406f32e7eSjoerg clang_getCursorCompletionString(CXCursor cursor); 547506f32e7eSjoerg 547606f32e7eSjoerg /** 547706f32e7eSjoerg * Contains the results of code-completion. 547806f32e7eSjoerg * 547906f32e7eSjoerg * This data structure contains the results of code completion, as 548006f32e7eSjoerg * produced by \c clang_codeCompleteAt(). Its contents must be freed by 548106f32e7eSjoerg * \c clang_disposeCodeCompleteResults. 548206f32e7eSjoerg */ 548306f32e7eSjoerg typedef struct { 548406f32e7eSjoerg /** 548506f32e7eSjoerg * The code-completion results. 548606f32e7eSjoerg */ 548706f32e7eSjoerg CXCompletionResult *Results; 548806f32e7eSjoerg 548906f32e7eSjoerg /** 549006f32e7eSjoerg * The number of code-completion results stored in the 549106f32e7eSjoerg * \c Results array. 549206f32e7eSjoerg */ 549306f32e7eSjoerg unsigned NumResults; 549406f32e7eSjoerg } CXCodeCompleteResults; 549506f32e7eSjoerg 549606f32e7eSjoerg /** 549706f32e7eSjoerg * Retrieve the number of fix-its for the given completion index. 549806f32e7eSjoerg * 549906f32e7eSjoerg * Calling this makes sense only if CXCodeComplete_IncludeCompletionsWithFixIts 550006f32e7eSjoerg * option was set. 550106f32e7eSjoerg * 550206f32e7eSjoerg * \param results The structure keeping all completion results 550306f32e7eSjoerg * 550406f32e7eSjoerg * \param completion_index The index of the completion 550506f32e7eSjoerg * 550606f32e7eSjoerg * \return The number of fix-its which must be applied before the completion at 550706f32e7eSjoerg * completion_index can be applied 550806f32e7eSjoerg */ 550906f32e7eSjoerg CINDEX_LINKAGE unsigned 551006f32e7eSjoerg clang_getCompletionNumFixIts(CXCodeCompleteResults *results, 551106f32e7eSjoerg unsigned completion_index); 551206f32e7eSjoerg 551306f32e7eSjoerg /** 551406f32e7eSjoerg * Fix-its that *must* be applied before inserting the text for the 551506f32e7eSjoerg * corresponding completion. 551606f32e7eSjoerg * 551706f32e7eSjoerg * By default, clang_codeCompleteAt() only returns completions with empty 551806f32e7eSjoerg * fix-its. Extra completions with non-empty fix-its should be explicitly 551906f32e7eSjoerg * requested by setting CXCodeComplete_IncludeCompletionsWithFixIts. 552006f32e7eSjoerg * 552106f32e7eSjoerg * For the clients to be able to compute position of the cursor after applying 552206f32e7eSjoerg * fix-its, the following conditions are guaranteed to hold for 552306f32e7eSjoerg * replacement_range of the stored fix-its: 552406f32e7eSjoerg * - Ranges in the fix-its are guaranteed to never contain the completion 552506f32e7eSjoerg * point (or identifier under completion point, if any) inside them, except 552606f32e7eSjoerg * at the start or at the end of the range. 552706f32e7eSjoerg * - If a fix-it range starts or ends with completion point (or starts or 552806f32e7eSjoerg * ends after the identifier under completion point), it will contain at 552906f32e7eSjoerg * least one character. It allows to unambiguously recompute completion 553006f32e7eSjoerg * point after applying the fix-it. 553106f32e7eSjoerg * 553206f32e7eSjoerg * The intuition is that provided fix-its change code around the identifier we 553306f32e7eSjoerg * complete, but are not allowed to touch the identifier itself or the 553406f32e7eSjoerg * completion point. One example of completions with corrections are the ones 553506f32e7eSjoerg * replacing '.' with '->' and vice versa: 553606f32e7eSjoerg * 553706f32e7eSjoerg * std::unique_ptr<std::vector<int>> vec_ptr; 553806f32e7eSjoerg * In 'vec_ptr.^', one of the completions is 'push_back', it requires 553906f32e7eSjoerg * replacing '.' with '->'. 554006f32e7eSjoerg * In 'vec_ptr->^', one of the completions is 'release', it requires 554106f32e7eSjoerg * replacing '->' with '.'. 554206f32e7eSjoerg * 554306f32e7eSjoerg * \param results The structure keeping all completion results 554406f32e7eSjoerg * 554506f32e7eSjoerg * \param completion_index The index of the completion 554606f32e7eSjoerg * 554706f32e7eSjoerg * \param fixit_index The index of the fix-it for the completion at 554806f32e7eSjoerg * completion_index 554906f32e7eSjoerg * 555006f32e7eSjoerg * \param replacement_range The fix-it range that must be replaced before the 555106f32e7eSjoerg * completion at completion_index can be applied 555206f32e7eSjoerg * 555306f32e7eSjoerg * \returns The fix-it string that must replace the code at replacement_range 555406f32e7eSjoerg * before the completion at completion_index can be applied 555506f32e7eSjoerg */ 555606f32e7eSjoerg CINDEX_LINKAGE CXString clang_getCompletionFixIt( 555706f32e7eSjoerg CXCodeCompleteResults *results, unsigned completion_index, 555806f32e7eSjoerg unsigned fixit_index, CXSourceRange *replacement_range); 555906f32e7eSjoerg 556006f32e7eSjoerg /** 556106f32e7eSjoerg * Flags that can be passed to \c clang_codeCompleteAt() to 556206f32e7eSjoerg * modify its behavior. 556306f32e7eSjoerg * 556406f32e7eSjoerg * The enumerators in this enumeration can be bitwise-OR'd together to 556506f32e7eSjoerg * provide multiple options to \c clang_codeCompleteAt(). 556606f32e7eSjoerg */ 556706f32e7eSjoerg enum CXCodeComplete_Flags { 556806f32e7eSjoerg /** 556906f32e7eSjoerg * Whether to include macros within the set of code 557006f32e7eSjoerg * completions returned. 557106f32e7eSjoerg */ 557206f32e7eSjoerg CXCodeComplete_IncludeMacros = 0x01, 557306f32e7eSjoerg 557406f32e7eSjoerg /** 557506f32e7eSjoerg * Whether to include code patterns for language constructs 557606f32e7eSjoerg * within the set of code completions, e.g., for loops. 557706f32e7eSjoerg */ 557806f32e7eSjoerg CXCodeComplete_IncludeCodePatterns = 0x02, 557906f32e7eSjoerg 558006f32e7eSjoerg /** 558106f32e7eSjoerg * Whether to include brief documentation within the set of code 558206f32e7eSjoerg * completions returned. 558306f32e7eSjoerg */ 558406f32e7eSjoerg CXCodeComplete_IncludeBriefComments = 0x04, 558506f32e7eSjoerg 558606f32e7eSjoerg /** 558706f32e7eSjoerg * Whether to speed up completion by omitting top- or namespace-level entities 558806f32e7eSjoerg * defined in the preamble. There's no guarantee any particular entity is 558906f32e7eSjoerg * omitted. This may be useful if the headers are indexed externally. 559006f32e7eSjoerg */ 559106f32e7eSjoerg CXCodeComplete_SkipPreamble = 0x08, 559206f32e7eSjoerg 559306f32e7eSjoerg /** 559406f32e7eSjoerg * Whether to include completions with small 559506f32e7eSjoerg * fix-its, e.g. change '.' to '->' on member access, etc. 559606f32e7eSjoerg */ 559706f32e7eSjoerg CXCodeComplete_IncludeCompletionsWithFixIts = 0x10 559806f32e7eSjoerg }; 559906f32e7eSjoerg 560006f32e7eSjoerg /** 560106f32e7eSjoerg * Bits that represent the context under which completion is occurring. 560206f32e7eSjoerg * 560306f32e7eSjoerg * The enumerators in this enumeration may be bitwise-OR'd together if multiple 560406f32e7eSjoerg * contexts are occurring simultaneously. 560506f32e7eSjoerg */ 560606f32e7eSjoerg enum CXCompletionContext { 560706f32e7eSjoerg /** 560806f32e7eSjoerg * The context for completions is unexposed, as only Clang results 560906f32e7eSjoerg * should be included. (This is equivalent to having no context bits set.) 561006f32e7eSjoerg */ 561106f32e7eSjoerg CXCompletionContext_Unexposed = 0, 561206f32e7eSjoerg 561306f32e7eSjoerg /** 561406f32e7eSjoerg * Completions for any possible type should be included in the results. 561506f32e7eSjoerg */ 561606f32e7eSjoerg CXCompletionContext_AnyType = 1 << 0, 561706f32e7eSjoerg 561806f32e7eSjoerg /** 561906f32e7eSjoerg * Completions for any possible value (variables, function calls, etc.) 562006f32e7eSjoerg * should be included in the results. 562106f32e7eSjoerg */ 562206f32e7eSjoerg CXCompletionContext_AnyValue = 1 << 1, 562306f32e7eSjoerg /** 562406f32e7eSjoerg * Completions for values that resolve to an Objective-C object should 562506f32e7eSjoerg * be included in the results. 562606f32e7eSjoerg */ 562706f32e7eSjoerg CXCompletionContext_ObjCObjectValue = 1 << 2, 562806f32e7eSjoerg /** 562906f32e7eSjoerg * Completions for values that resolve to an Objective-C selector 563006f32e7eSjoerg * should be included in the results. 563106f32e7eSjoerg */ 563206f32e7eSjoerg CXCompletionContext_ObjCSelectorValue = 1 << 3, 563306f32e7eSjoerg /** 563406f32e7eSjoerg * Completions for values that resolve to a C++ class type should be 563506f32e7eSjoerg * included in the results. 563606f32e7eSjoerg */ 563706f32e7eSjoerg CXCompletionContext_CXXClassTypeValue = 1 << 4, 563806f32e7eSjoerg 563906f32e7eSjoerg /** 564006f32e7eSjoerg * Completions for fields of the member being accessed using the dot 564106f32e7eSjoerg * operator should be included in the results. 564206f32e7eSjoerg */ 564306f32e7eSjoerg CXCompletionContext_DotMemberAccess = 1 << 5, 564406f32e7eSjoerg /** 564506f32e7eSjoerg * Completions for fields of the member being accessed using the arrow 564606f32e7eSjoerg * operator should be included in the results. 564706f32e7eSjoerg */ 564806f32e7eSjoerg CXCompletionContext_ArrowMemberAccess = 1 << 6, 564906f32e7eSjoerg /** 565006f32e7eSjoerg * Completions for properties of the Objective-C object being accessed 565106f32e7eSjoerg * using the dot operator should be included in the results. 565206f32e7eSjoerg */ 565306f32e7eSjoerg CXCompletionContext_ObjCPropertyAccess = 1 << 7, 565406f32e7eSjoerg 565506f32e7eSjoerg /** 565606f32e7eSjoerg * Completions for enum tags should be included in the results. 565706f32e7eSjoerg */ 565806f32e7eSjoerg CXCompletionContext_EnumTag = 1 << 8, 565906f32e7eSjoerg /** 566006f32e7eSjoerg * Completions for union tags should be included in the results. 566106f32e7eSjoerg */ 566206f32e7eSjoerg CXCompletionContext_UnionTag = 1 << 9, 566306f32e7eSjoerg /** 566406f32e7eSjoerg * Completions for struct tags should be included in the results. 566506f32e7eSjoerg */ 566606f32e7eSjoerg CXCompletionContext_StructTag = 1 << 10, 566706f32e7eSjoerg 566806f32e7eSjoerg /** 566906f32e7eSjoerg * Completions for C++ class names should be included in the results. 567006f32e7eSjoerg */ 567106f32e7eSjoerg CXCompletionContext_ClassTag = 1 << 11, 567206f32e7eSjoerg /** 567306f32e7eSjoerg * Completions for C++ namespaces and namespace aliases should be 567406f32e7eSjoerg * included in the results. 567506f32e7eSjoerg */ 567606f32e7eSjoerg CXCompletionContext_Namespace = 1 << 12, 567706f32e7eSjoerg /** 567806f32e7eSjoerg * Completions for C++ nested name specifiers should be included in 567906f32e7eSjoerg * the results. 568006f32e7eSjoerg */ 568106f32e7eSjoerg CXCompletionContext_NestedNameSpecifier = 1 << 13, 568206f32e7eSjoerg 568306f32e7eSjoerg /** 568406f32e7eSjoerg * Completions for Objective-C interfaces (classes) should be included 568506f32e7eSjoerg * in the results. 568606f32e7eSjoerg */ 568706f32e7eSjoerg CXCompletionContext_ObjCInterface = 1 << 14, 568806f32e7eSjoerg /** 568906f32e7eSjoerg * Completions for Objective-C protocols should be included in 569006f32e7eSjoerg * the results. 569106f32e7eSjoerg */ 569206f32e7eSjoerg CXCompletionContext_ObjCProtocol = 1 << 15, 569306f32e7eSjoerg /** 569406f32e7eSjoerg * Completions for Objective-C categories should be included in 569506f32e7eSjoerg * the results. 569606f32e7eSjoerg */ 569706f32e7eSjoerg CXCompletionContext_ObjCCategory = 1 << 16, 569806f32e7eSjoerg /** 569906f32e7eSjoerg * Completions for Objective-C instance messages should be included 570006f32e7eSjoerg * in the results. 570106f32e7eSjoerg */ 570206f32e7eSjoerg CXCompletionContext_ObjCInstanceMessage = 1 << 17, 570306f32e7eSjoerg /** 570406f32e7eSjoerg * Completions for Objective-C class messages should be included in 570506f32e7eSjoerg * the results. 570606f32e7eSjoerg */ 570706f32e7eSjoerg CXCompletionContext_ObjCClassMessage = 1 << 18, 570806f32e7eSjoerg /** 570906f32e7eSjoerg * Completions for Objective-C selector names should be included in 571006f32e7eSjoerg * the results. 571106f32e7eSjoerg */ 571206f32e7eSjoerg CXCompletionContext_ObjCSelectorName = 1 << 19, 571306f32e7eSjoerg 571406f32e7eSjoerg /** 571506f32e7eSjoerg * Completions for preprocessor macro names should be included in 571606f32e7eSjoerg * the results. 571706f32e7eSjoerg */ 571806f32e7eSjoerg CXCompletionContext_MacroName = 1 << 20, 571906f32e7eSjoerg 572006f32e7eSjoerg /** 572106f32e7eSjoerg * Natural language completions should be included in the results. 572206f32e7eSjoerg */ 572306f32e7eSjoerg CXCompletionContext_NaturalLanguage = 1 << 21, 572406f32e7eSjoerg 572506f32e7eSjoerg /** 572606f32e7eSjoerg * #include file completions should be included in the results. 572706f32e7eSjoerg */ 572806f32e7eSjoerg CXCompletionContext_IncludedFile = 1 << 22, 572906f32e7eSjoerg 573006f32e7eSjoerg /** 573106f32e7eSjoerg * The current context is unknown, so set all contexts. 573206f32e7eSjoerg */ 573306f32e7eSjoerg CXCompletionContext_Unknown = ((1 << 23) - 1) 573406f32e7eSjoerg }; 573506f32e7eSjoerg 573606f32e7eSjoerg /** 573706f32e7eSjoerg * Returns a default set of code-completion options that can be 573806f32e7eSjoerg * passed to\c clang_codeCompleteAt(). 573906f32e7eSjoerg */ 574006f32e7eSjoerg CINDEX_LINKAGE unsigned clang_defaultCodeCompleteOptions(void); 574106f32e7eSjoerg 574206f32e7eSjoerg /** 574306f32e7eSjoerg * Perform code completion at a given location in a translation unit. 574406f32e7eSjoerg * 574506f32e7eSjoerg * This function performs code completion at a particular file, line, and 574606f32e7eSjoerg * column within source code, providing results that suggest potential 574706f32e7eSjoerg * code snippets based on the context of the completion. The basic model 574806f32e7eSjoerg * for code completion is that Clang will parse a complete source file, 574906f32e7eSjoerg * performing syntax checking up to the location where code-completion has 575006f32e7eSjoerg * been requested. At that point, a special code-completion token is passed 575106f32e7eSjoerg * to the parser, which recognizes this token and determines, based on the 575206f32e7eSjoerg * current location in the C/Objective-C/C++ grammar and the state of 575306f32e7eSjoerg * semantic analysis, what completions to provide. These completions are 575406f32e7eSjoerg * returned via a new \c CXCodeCompleteResults structure. 575506f32e7eSjoerg * 575606f32e7eSjoerg * Code completion itself is meant to be triggered by the client when the 575706f32e7eSjoerg * user types punctuation characters or whitespace, at which point the 575806f32e7eSjoerg * code-completion location will coincide with the cursor. For example, if \c p 575906f32e7eSjoerg * is a pointer, code-completion might be triggered after the "-" and then 576006f32e7eSjoerg * after the ">" in \c p->. When the code-completion location is after the ">", 576106f32e7eSjoerg * the completion results will provide, e.g., the members of the struct that 576206f32e7eSjoerg * "p" points to. The client is responsible for placing the cursor at the 576306f32e7eSjoerg * beginning of the token currently being typed, then filtering the results 576406f32e7eSjoerg * based on the contents of the token. For example, when code-completing for 576506f32e7eSjoerg * the expression \c p->get, the client should provide the location just after 576606f32e7eSjoerg * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the 576706f32e7eSjoerg * client can filter the results based on the current token text ("get"), only 576806f32e7eSjoerg * showing those results that start with "get". The intent of this interface 576906f32e7eSjoerg * is to separate the relatively high-latency acquisition of code-completion 577006f32e7eSjoerg * results from the filtering of results on a per-character basis, which must 577106f32e7eSjoerg * have a lower latency. 577206f32e7eSjoerg * 577306f32e7eSjoerg * \param TU The translation unit in which code-completion should 577406f32e7eSjoerg * occur. The source files for this translation unit need not be 577506f32e7eSjoerg * completely up-to-date (and the contents of those source files may 577606f32e7eSjoerg * be overridden via \p unsaved_files). Cursors referring into the 577706f32e7eSjoerg * translation unit may be invalidated by this invocation. 577806f32e7eSjoerg * 577906f32e7eSjoerg * \param complete_filename The name of the source file where code 578006f32e7eSjoerg * completion should be performed. This filename may be any file 578106f32e7eSjoerg * included in the translation unit. 578206f32e7eSjoerg * 578306f32e7eSjoerg * \param complete_line The line at which code-completion should occur. 578406f32e7eSjoerg * 578506f32e7eSjoerg * \param complete_column The column at which code-completion should occur. 578606f32e7eSjoerg * Note that the column should point just after the syntactic construct that 578706f32e7eSjoerg * initiated code completion, and not in the middle of a lexical token. 578806f32e7eSjoerg * 578906f32e7eSjoerg * \param unsaved_files the Files that have not yet been saved to disk 579006f32e7eSjoerg * but may be required for parsing or code completion, including the 579106f32e7eSjoerg * contents of those files. The contents and name of these files (as 579206f32e7eSjoerg * specified by CXUnsavedFile) are copied when necessary, so the 579306f32e7eSjoerg * client only needs to guarantee their validity until the call to 579406f32e7eSjoerg * this function returns. 579506f32e7eSjoerg * 579606f32e7eSjoerg * \param num_unsaved_files The number of unsaved file entries in \p 579706f32e7eSjoerg * unsaved_files. 579806f32e7eSjoerg * 579906f32e7eSjoerg * \param options Extra options that control the behavior of code 580006f32e7eSjoerg * completion, expressed as a bitwise OR of the enumerators of the 580106f32e7eSjoerg * CXCodeComplete_Flags enumeration. The 580206f32e7eSjoerg * \c clang_defaultCodeCompleteOptions() function returns a default set 580306f32e7eSjoerg * of code-completion options. 580406f32e7eSjoerg * 580506f32e7eSjoerg * \returns If successful, a new \c CXCodeCompleteResults structure 580606f32e7eSjoerg * containing code-completion results, which should eventually be 580706f32e7eSjoerg * freed with \c clang_disposeCodeCompleteResults(). If code 580806f32e7eSjoerg * completion fails, returns NULL. 580906f32e7eSjoerg */ 581006f32e7eSjoerg CINDEX_LINKAGE 5811*13fbcb42Sjoerg CXCodeCompleteResults * 5812*13fbcb42Sjoerg clang_codeCompleteAt(CXTranslationUnit TU, const char *complete_filename, 5813*13fbcb42Sjoerg unsigned complete_line, unsigned complete_column, 581406f32e7eSjoerg struct CXUnsavedFile *unsaved_files, 5815*13fbcb42Sjoerg unsigned num_unsaved_files, unsigned options); 581606f32e7eSjoerg 581706f32e7eSjoerg /** 581806f32e7eSjoerg * Sort the code-completion results in case-insensitive alphabetical 581906f32e7eSjoerg * order. 582006f32e7eSjoerg * 582106f32e7eSjoerg * \param Results The set of results to sort. 582206f32e7eSjoerg * \param NumResults The number of results in \p Results. 582306f32e7eSjoerg */ 582406f32e7eSjoerg CINDEX_LINKAGE 582506f32e7eSjoerg void clang_sortCodeCompletionResults(CXCompletionResult *Results, 582606f32e7eSjoerg unsigned NumResults); 582706f32e7eSjoerg 582806f32e7eSjoerg /** 582906f32e7eSjoerg * Free the given set of code-completion results. 583006f32e7eSjoerg */ 583106f32e7eSjoerg CINDEX_LINKAGE 583206f32e7eSjoerg void clang_disposeCodeCompleteResults(CXCodeCompleteResults *Results); 583306f32e7eSjoerg 583406f32e7eSjoerg /** 583506f32e7eSjoerg * Determine the number of diagnostics produced prior to the 583606f32e7eSjoerg * location where code completion was performed. 583706f32e7eSjoerg */ 583806f32e7eSjoerg CINDEX_LINKAGE 583906f32e7eSjoerg unsigned clang_codeCompleteGetNumDiagnostics(CXCodeCompleteResults *Results); 584006f32e7eSjoerg 584106f32e7eSjoerg /** 584206f32e7eSjoerg * Retrieve a diagnostic associated with the given code completion. 584306f32e7eSjoerg * 584406f32e7eSjoerg * \param Results the code completion results to query. 584506f32e7eSjoerg * \param Index the zero-based diagnostic number to retrieve. 584606f32e7eSjoerg * 584706f32e7eSjoerg * \returns the requested diagnostic. This diagnostic must be freed 584806f32e7eSjoerg * via a call to \c clang_disposeDiagnostic(). 584906f32e7eSjoerg */ 585006f32e7eSjoerg CINDEX_LINKAGE 585106f32e7eSjoerg CXDiagnostic clang_codeCompleteGetDiagnostic(CXCodeCompleteResults *Results, 585206f32e7eSjoerg unsigned Index); 585306f32e7eSjoerg 585406f32e7eSjoerg /** 585506f32e7eSjoerg * Determines what completions are appropriate for the context 585606f32e7eSjoerg * the given code completion. 585706f32e7eSjoerg * 585806f32e7eSjoerg * \param Results the code completion results to query 585906f32e7eSjoerg * 586006f32e7eSjoerg * \returns the kinds of completions that are appropriate for use 586106f32e7eSjoerg * along with the given code completion results. 586206f32e7eSjoerg */ 586306f32e7eSjoerg CINDEX_LINKAGE 5864*13fbcb42Sjoerg unsigned long long 5865*13fbcb42Sjoerg clang_codeCompleteGetContexts(CXCodeCompleteResults *Results); 586606f32e7eSjoerg 586706f32e7eSjoerg /** 586806f32e7eSjoerg * Returns the cursor kind for the container for the current code 586906f32e7eSjoerg * completion context. The container is only guaranteed to be set for 587006f32e7eSjoerg * contexts where a container exists (i.e. member accesses or Objective-C 587106f32e7eSjoerg * message sends); if there is not a container, this function will return 587206f32e7eSjoerg * CXCursor_InvalidCode. 587306f32e7eSjoerg * 587406f32e7eSjoerg * \param Results the code completion results to query 587506f32e7eSjoerg * 587606f32e7eSjoerg * \param IsIncomplete on return, this value will be false if Clang has complete 587706f32e7eSjoerg * information about the container. If Clang does not have complete 587806f32e7eSjoerg * information, this value will be true. 587906f32e7eSjoerg * 588006f32e7eSjoerg * \returns the container kind, or CXCursor_InvalidCode if there is not a 588106f32e7eSjoerg * container 588206f32e7eSjoerg */ 588306f32e7eSjoerg CINDEX_LINKAGE 5884*13fbcb42Sjoerg enum CXCursorKind 5885*13fbcb42Sjoerg clang_codeCompleteGetContainerKind(CXCodeCompleteResults *Results, 588606f32e7eSjoerg unsigned *IsIncomplete); 588706f32e7eSjoerg 588806f32e7eSjoerg /** 588906f32e7eSjoerg * Returns the USR for the container for the current code completion 589006f32e7eSjoerg * context. If there is not a container for the current context, this 589106f32e7eSjoerg * function will return the empty string. 589206f32e7eSjoerg * 589306f32e7eSjoerg * \param Results the code completion results to query 589406f32e7eSjoerg * 589506f32e7eSjoerg * \returns the USR for the container 589606f32e7eSjoerg */ 589706f32e7eSjoerg CINDEX_LINKAGE 589806f32e7eSjoerg CXString clang_codeCompleteGetContainerUSR(CXCodeCompleteResults *Results); 589906f32e7eSjoerg 590006f32e7eSjoerg /** 590106f32e7eSjoerg * Returns the currently-entered selector for an Objective-C message 590206f32e7eSjoerg * send, formatted like "initWithFoo:bar:". Only guaranteed to return a 590306f32e7eSjoerg * non-empty string for CXCompletionContext_ObjCInstanceMessage and 590406f32e7eSjoerg * CXCompletionContext_ObjCClassMessage. 590506f32e7eSjoerg * 590606f32e7eSjoerg * \param Results the code completion results to query 590706f32e7eSjoerg * 590806f32e7eSjoerg * \returns the selector (or partial selector) that has been entered thus far 590906f32e7eSjoerg * for an Objective-C message send. 591006f32e7eSjoerg */ 591106f32e7eSjoerg CINDEX_LINKAGE 591206f32e7eSjoerg CXString clang_codeCompleteGetObjCSelector(CXCodeCompleteResults *Results); 591306f32e7eSjoerg 591406f32e7eSjoerg /** 591506f32e7eSjoerg * @} 591606f32e7eSjoerg */ 591706f32e7eSjoerg 591806f32e7eSjoerg /** 591906f32e7eSjoerg * \defgroup CINDEX_MISC Miscellaneous utility functions 592006f32e7eSjoerg * 592106f32e7eSjoerg * @{ 592206f32e7eSjoerg */ 592306f32e7eSjoerg 592406f32e7eSjoerg /** 592506f32e7eSjoerg * Return a version string, suitable for showing to a user, but not 592606f32e7eSjoerg * intended to be parsed (the format is not guaranteed to be stable). 592706f32e7eSjoerg */ 592806f32e7eSjoerg CINDEX_LINKAGE CXString clang_getClangVersion(void); 592906f32e7eSjoerg 593006f32e7eSjoerg /** 593106f32e7eSjoerg * Enable/disable crash recovery. 593206f32e7eSjoerg * 593306f32e7eSjoerg * \param isEnabled Flag to indicate if crash recovery is enabled. A non-zero 593406f32e7eSjoerg * value enables crash recovery, while 0 disables it. 593506f32e7eSjoerg */ 593606f32e7eSjoerg CINDEX_LINKAGE void clang_toggleCrashRecovery(unsigned isEnabled); 593706f32e7eSjoerg 593806f32e7eSjoerg /** 593906f32e7eSjoerg * Visitor invoked for each file in a translation unit 594006f32e7eSjoerg * (used with clang_getInclusions()). 594106f32e7eSjoerg * 594206f32e7eSjoerg * This visitor function will be invoked by clang_getInclusions() for each 594306f32e7eSjoerg * file included (either at the top-level or by \#include directives) within 594406f32e7eSjoerg * a translation unit. The first argument is the file being included, and 594506f32e7eSjoerg * the second and third arguments provide the inclusion stack. The 594606f32e7eSjoerg * array is sorted in order of immediate inclusion. For example, 594706f32e7eSjoerg * the first element refers to the location that included 'included_file'. 594806f32e7eSjoerg */ 594906f32e7eSjoerg typedef void (*CXInclusionVisitor)(CXFile included_file, 595006f32e7eSjoerg CXSourceLocation *inclusion_stack, 595106f32e7eSjoerg unsigned include_len, 595206f32e7eSjoerg CXClientData client_data); 595306f32e7eSjoerg 595406f32e7eSjoerg /** 595506f32e7eSjoerg * Visit the set of preprocessor inclusions in a translation unit. 595606f32e7eSjoerg * The visitor function is called with the provided data for every included 595706f32e7eSjoerg * file. This does not include headers included by the PCH file (unless one 595806f32e7eSjoerg * is inspecting the inclusions in the PCH file itself). 595906f32e7eSjoerg */ 596006f32e7eSjoerg CINDEX_LINKAGE void clang_getInclusions(CXTranslationUnit tu, 596106f32e7eSjoerg CXInclusionVisitor visitor, 596206f32e7eSjoerg CXClientData client_data); 596306f32e7eSjoerg 596406f32e7eSjoerg typedef enum { 596506f32e7eSjoerg CXEval_Int = 1, 596606f32e7eSjoerg CXEval_Float = 2, 596706f32e7eSjoerg CXEval_ObjCStrLiteral = 3, 596806f32e7eSjoerg CXEval_StrLiteral = 4, 596906f32e7eSjoerg CXEval_CFStr = 5, 597006f32e7eSjoerg CXEval_Other = 6, 597106f32e7eSjoerg 597206f32e7eSjoerg CXEval_UnExposed = 0 597306f32e7eSjoerg 597406f32e7eSjoerg } CXEvalResultKind; 597506f32e7eSjoerg 597606f32e7eSjoerg /** 597706f32e7eSjoerg * Evaluation result of a cursor 597806f32e7eSjoerg */ 597906f32e7eSjoerg typedef void *CXEvalResult; 598006f32e7eSjoerg 598106f32e7eSjoerg /** 598206f32e7eSjoerg * If cursor is a statement declaration tries to evaluate the 598306f32e7eSjoerg * statement and if its variable, tries to evaluate its initializer, 598406f32e7eSjoerg * into its corresponding type. 5985*13fbcb42Sjoerg * If it's an expression, tries to evaluate the expression. 598606f32e7eSjoerg */ 598706f32e7eSjoerg CINDEX_LINKAGE CXEvalResult clang_Cursor_Evaluate(CXCursor C); 598806f32e7eSjoerg 598906f32e7eSjoerg /** 599006f32e7eSjoerg * Returns the kind of the evaluated result. 599106f32e7eSjoerg */ 599206f32e7eSjoerg CINDEX_LINKAGE CXEvalResultKind clang_EvalResult_getKind(CXEvalResult E); 599306f32e7eSjoerg 599406f32e7eSjoerg /** 599506f32e7eSjoerg * Returns the evaluation result as integer if the 599606f32e7eSjoerg * kind is Int. 599706f32e7eSjoerg */ 599806f32e7eSjoerg CINDEX_LINKAGE int clang_EvalResult_getAsInt(CXEvalResult E); 599906f32e7eSjoerg 600006f32e7eSjoerg /** 600106f32e7eSjoerg * Returns the evaluation result as a long long integer if the 600206f32e7eSjoerg * kind is Int. This prevents overflows that may happen if the result is 600306f32e7eSjoerg * returned with clang_EvalResult_getAsInt. 600406f32e7eSjoerg */ 600506f32e7eSjoerg CINDEX_LINKAGE long long clang_EvalResult_getAsLongLong(CXEvalResult E); 600606f32e7eSjoerg 600706f32e7eSjoerg /** 600806f32e7eSjoerg * Returns a non-zero value if the kind is Int and the evaluation 600906f32e7eSjoerg * result resulted in an unsigned integer. 601006f32e7eSjoerg */ 601106f32e7eSjoerg CINDEX_LINKAGE unsigned clang_EvalResult_isUnsignedInt(CXEvalResult E); 601206f32e7eSjoerg 601306f32e7eSjoerg /** 601406f32e7eSjoerg * Returns the evaluation result as an unsigned integer if 601506f32e7eSjoerg * the kind is Int and clang_EvalResult_isUnsignedInt is non-zero. 601606f32e7eSjoerg */ 6017*13fbcb42Sjoerg CINDEX_LINKAGE unsigned long long 6018*13fbcb42Sjoerg clang_EvalResult_getAsUnsigned(CXEvalResult E); 601906f32e7eSjoerg 602006f32e7eSjoerg /** 602106f32e7eSjoerg * Returns the evaluation result as double if the 602206f32e7eSjoerg * kind is double. 602306f32e7eSjoerg */ 602406f32e7eSjoerg CINDEX_LINKAGE double clang_EvalResult_getAsDouble(CXEvalResult E); 602506f32e7eSjoerg 602606f32e7eSjoerg /** 602706f32e7eSjoerg * Returns the evaluation result as a constant string if the 602806f32e7eSjoerg * kind is other than Int or float. User must not free this pointer, 602906f32e7eSjoerg * instead call clang_EvalResult_dispose on the CXEvalResult returned 603006f32e7eSjoerg * by clang_Cursor_Evaluate. 603106f32e7eSjoerg */ 603206f32e7eSjoerg CINDEX_LINKAGE const char *clang_EvalResult_getAsStr(CXEvalResult E); 603306f32e7eSjoerg 603406f32e7eSjoerg /** 603506f32e7eSjoerg * Disposes the created Eval memory. 603606f32e7eSjoerg */ 603706f32e7eSjoerg CINDEX_LINKAGE void clang_EvalResult_dispose(CXEvalResult E); 603806f32e7eSjoerg /** 603906f32e7eSjoerg * @} 604006f32e7eSjoerg */ 604106f32e7eSjoerg 604206f32e7eSjoerg /** \defgroup CINDEX_REMAPPING Remapping functions 604306f32e7eSjoerg * 604406f32e7eSjoerg * @{ 604506f32e7eSjoerg */ 604606f32e7eSjoerg 604706f32e7eSjoerg /** 604806f32e7eSjoerg * A remapping of original source files and their translated files. 604906f32e7eSjoerg */ 605006f32e7eSjoerg typedef void *CXRemapping; 605106f32e7eSjoerg 605206f32e7eSjoerg /** 605306f32e7eSjoerg * Retrieve a remapping. 605406f32e7eSjoerg * 605506f32e7eSjoerg * \param path the path that contains metadata about remappings. 605606f32e7eSjoerg * 605706f32e7eSjoerg * \returns the requested remapping. This remapping must be freed 605806f32e7eSjoerg * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred. 605906f32e7eSjoerg */ 606006f32e7eSjoerg CINDEX_LINKAGE CXRemapping clang_getRemappings(const char *path); 606106f32e7eSjoerg 606206f32e7eSjoerg /** 606306f32e7eSjoerg * Retrieve a remapping. 606406f32e7eSjoerg * 606506f32e7eSjoerg * \param filePaths pointer to an array of file paths containing remapping info. 606606f32e7eSjoerg * 606706f32e7eSjoerg * \param numFiles number of file paths. 606806f32e7eSjoerg * 606906f32e7eSjoerg * \returns the requested remapping. This remapping must be freed 607006f32e7eSjoerg * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred. 607106f32e7eSjoerg */ 607206f32e7eSjoerg CINDEX_LINKAGE 607306f32e7eSjoerg CXRemapping clang_getRemappingsFromFileList(const char **filePaths, 607406f32e7eSjoerg unsigned numFiles); 607506f32e7eSjoerg 607606f32e7eSjoerg /** 607706f32e7eSjoerg * Determine the number of remappings. 607806f32e7eSjoerg */ 607906f32e7eSjoerg CINDEX_LINKAGE unsigned clang_remap_getNumFiles(CXRemapping); 608006f32e7eSjoerg 608106f32e7eSjoerg /** 608206f32e7eSjoerg * Get the original and the associated filename from the remapping. 608306f32e7eSjoerg * 608406f32e7eSjoerg * \param original If non-NULL, will be set to the original filename. 608506f32e7eSjoerg * 608606f32e7eSjoerg * \param transformed If non-NULL, will be set to the filename that the original 608706f32e7eSjoerg * is associated with. 608806f32e7eSjoerg */ 608906f32e7eSjoerg CINDEX_LINKAGE void clang_remap_getFilenames(CXRemapping, unsigned index, 6090*13fbcb42Sjoerg CXString *original, 6091*13fbcb42Sjoerg CXString *transformed); 609206f32e7eSjoerg 609306f32e7eSjoerg /** 609406f32e7eSjoerg * Dispose the remapping. 609506f32e7eSjoerg */ 609606f32e7eSjoerg CINDEX_LINKAGE void clang_remap_dispose(CXRemapping); 609706f32e7eSjoerg 609806f32e7eSjoerg /** 609906f32e7eSjoerg * @} 610006f32e7eSjoerg */ 610106f32e7eSjoerg 610206f32e7eSjoerg /** \defgroup CINDEX_HIGH Higher level API functions 610306f32e7eSjoerg * 610406f32e7eSjoerg * @{ 610506f32e7eSjoerg */ 610606f32e7eSjoerg 6107*13fbcb42Sjoerg enum CXVisitorResult { CXVisit_Break, CXVisit_Continue }; 610806f32e7eSjoerg 610906f32e7eSjoerg typedef struct CXCursorAndRangeVisitor { 611006f32e7eSjoerg void *context; 611106f32e7eSjoerg enum CXVisitorResult (*visit)(void *context, CXCursor, CXSourceRange); 611206f32e7eSjoerg } CXCursorAndRangeVisitor; 611306f32e7eSjoerg 611406f32e7eSjoerg typedef enum { 611506f32e7eSjoerg /** 611606f32e7eSjoerg * Function returned successfully. 611706f32e7eSjoerg */ 611806f32e7eSjoerg CXResult_Success = 0, 611906f32e7eSjoerg /** 612006f32e7eSjoerg * One of the parameters was invalid for the function. 612106f32e7eSjoerg */ 612206f32e7eSjoerg CXResult_Invalid = 1, 612306f32e7eSjoerg /** 612406f32e7eSjoerg * The function was terminated by a callback (e.g. it returned 612506f32e7eSjoerg * CXVisit_Break) 612606f32e7eSjoerg */ 612706f32e7eSjoerg CXResult_VisitBreak = 2 612806f32e7eSjoerg 612906f32e7eSjoerg } CXResult; 613006f32e7eSjoerg 613106f32e7eSjoerg /** 613206f32e7eSjoerg * Find references of a declaration in a specific file. 613306f32e7eSjoerg * 613406f32e7eSjoerg * \param cursor pointing to a declaration or a reference of one. 613506f32e7eSjoerg * 613606f32e7eSjoerg * \param file to search for references. 613706f32e7eSjoerg * 613806f32e7eSjoerg * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for 613906f32e7eSjoerg * each reference found. 614006f32e7eSjoerg * The CXSourceRange will point inside the file; if the reference is inside 614106f32e7eSjoerg * a macro (and not a macro argument) the CXSourceRange will be invalid. 614206f32e7eSjoerg * 614306f32e7eSjoerg * \returns one of the CXResult enumerators. 614406f32e7eSjoerg */ 6145*13fbcb42Sjoerg CINDEX_LINKAGE CXResult clang_findReferencesInFile( 6146*13fbcb42Sjoerg CXCursor cursor, CXFile file, CXCursorAndRangeVisitor visitor); 614706f32e7eSjoerg 614806f32e7eSjoerg /** 614906f32e7eSjoerg * Find #import/#include directives in a specific file. 615006f32e7eSjoerg * 615106f32e7eSjoerg * \param TU translation unit containing the file to query. 615206f32e7eSjoerg * 615306f32e7eSjoerg * \param file to search for #import/#include directives. 615406f32e7eSjoerg * 615506f32e7eSjoerg * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for 615606f32e7eSjoerg * each directive found. 615706f32e7eSjoerg * 615806f32e7eSjoerg * \returns one of the CXResult enumerators. 615906f32e7eSjoerg */ 6160*13fbcb42Sjoerg CINDEX_LINKAGE CXResult clang_findIncludesInFile( 6161*13fbcb42Sjoerg CXTranslationUnit TU, CXFile file, CXCursorAndRangeVisitor visitor); 616206f32e7eSjoerg 616306f32e7eSjoerg #ifdef __has_feature 616406f32e7eSjoerg #if __has_feature(blocks) 616506f32e7eSjoerg 6166*13fbcb42Sjoerg typedef enum CXVisitorResult (^CXCursorAndRangeVisitorBlock)(CXCursor, 6167*13fbcb42Sjoerg CXSourceRange); 616806f32e7eSjoerg 616906f32e7eSjoerg CINDEX_LINKAGE 617006f32e7eSjoerg CXResult clang_findReferencesInFileWithBlock(CXCursor, CXFile, 617106f32e7eSjoerg CXCursorAndRangeVisitorBlock); 617206f32e7eSjoerg 617306f32e7eSjoerg CINDEX_LINKAGE 617406f32e7eSjoerg CXResult clang_findIncludesInFileWithBlock(CXTranslationUnit, CXFile, 617506f32e7eSjoerg CXCursorAndRangeVisitorBlock); 617606f32e7eSjoerg 617706f32e7eSjoerg #endif 617806f32e7eSjoerg #endif 617906f32e7eSjoerg 618006f32e7eSjoerg /** 618106f32e7eSjoerg * The client's data object that is associated with a CXFile. 618206f32e7eSjoerg */ 618306f32e7eSjoerg typedef void *CXIdxClientFile; 618406f32e7eSjoerg 618506f32e7eSjoerg /** 618606f32e7eSjoerg * The client's data object that is associated with a semantic entity. 618706f32e7eSjoerg */ 618806f32e7eSjoerg typedef void *CXIdxClientEntity; 618906f32e7eSjoerg 619006f32e7eSjoerg /** 619106f32e7eSjoerg * The client's data object that is associated with a semantic container 619206f32e7eSjoerg * of entities. 619306f32e7eSjoerg */ 619406f32e7eSjoerg typedef void *CXIdxClientContainer; 619506f32e7eSjoerg 619606f32e7eSjoerg /** 619706f32e7eSjoerg * The client's data object that is associated with an AST file (PCH 619806f32e7eSjoerg * or module). 619906f32e7eSjoerg */ 620006f32e7eSjoerg typedef void *CXIdxClientASTFile; 620106f32e7eSjoerg 620206f32e7eSjoerg /** 620306f32e7eSjoerg * Source location passed to index callbacks. 620406f32e7eSjoerg */ 620506f32e7eSjoerg typedef struct { 620606f32e7eSjoerg void *ptr_data[2]; 620706f32e7eSjoerg unsigned int_data; 620806f32e7eSjoerg } CXIdxLoc; 620906f32e7eSjoerg 621006f32e7eSjoerg /** 621106f32e7eSjoerg * Data for ppIncludedFile callback. 621206f32e7eSjoerg */ 621306f32e7eSjoerg typedef struct { 621406f32e7eSjoerg /** 621506f32e7eSjoerg * Location of '#' in the \#include/\#import directive. 621606f32e7eSjoerg */ 621706f32e7eSjoerg CXIdxLoc hashLoc; 621806f32e7eSjoerg /** 621906f32e7eSjoerg * Filename as written in the \#include/\#import directive. 622006f32e7eSjoerg */ 622106f32e7eSjoerg const char *filename; 622206f32e7eSjoerg /** 622306f32e7eSjoerg * The actual file that the \#include/\#import directive resolved to. 622406f32e7eSjoerg */ 622506f32e7eSjoerg CXFile file; 622606f32e7eSjoerg int isImport; 622706f32e7eSjoerg int isAngled; 622806f32e7eSjoerg /** 622906f32e7eSjoerg * Non-zero if the directive was automatically turned into a module 623006f32e7eSjoerg * import. 623106f32e7eSjoerg */ 623206f32e7eSjoerg int isModuleImport; 623306f32e7eSjoerg } CXIdxIncludedFileInfo; 623406f32e7eSjoerg 623506f32e7eSjoerg /** 623606f32e7eSjoerg * Data for IndexerCallbacks#importedASTFile. 623706f32e7eSjoerg */ 623806f32e7eSjoerg typedef struct { 623906f32e7eSjoerg /** 624006f32e7eSjoerg * Top level AST file containing the imported PCH, module or submodule. 624106f32e7eSjoerg */ 624206f32e7eSjoerg CXFile file; 624306f32e7eSjoerg /** 624406f32e7eSjoerg * The imported module or NULL if the AST file is a PCH. 624506f32e7eSjoerg */ 624606f32e7eSjoerg CXModule module; 624706f32e7eSjoerg /** 624806f32e7eSjoerg * Location where the file is imported. Applicable only for modules. 624906f32e7eSjoerg */ 625006f32e7eSjoerg CXIdxLoc loc; 625106f32e7eSjoerg /** 625206f32e7eSjoerg * Non-zero if an inclusion directive was automatically turned into 625306f32e7eSjoerg * a module import. Applicable only for modules. 625406f32e7eSjoerg */ 625506f32e7eSjoerg int isImplicit; 625606f32e7eSjoerg 625706f32e7eSjoerg } CXIdxImportedASTFileInfo; 625806f32e7eSjoerg 625906f32e7eSjoerg typedef enum { 626006f32e7eSjoerg CXIdxEntity_Unexposed = 0, 626106f32e7eSjoerg CXIdxEntity_Typedef = 1, 626206f32e7eSjoerg CXIdxEntity_Function = 2, 626306f32e7eSjoerg CXIdxEntity_Variable = 3, 626406f32e7eSjoerg CXIdxEntity_Field = 4, 626506f32e7eSjoerg CXIdxEntity_EnumConstant = 5, 626606f32e7eSjoerg 626706f32e7eSjoerg CXIdxEntity_ObjCClass = 6, 626806f32e7eSjoerg CXIdxEntity_ObjCProtocol = 7, 626906f32e7eSjoerg CXIdxEntity_ObjCCategory = 8, 627006f32e7eSjoerg 627106f32e7eSjoerg CXIdxEntity_ObjCInstanceMethod = 9, 627206f32e7eSjoerg CXIdxEntity_ObjCClassMethod = 10, 627306f32e7eSjoerg CXIdxEntity_ObjCProperty = 11, 627406f32e7eSjoerg CXIdxEntity_ObjCIvar = 12, 627506f32e7eSjoerg 627606f32e7eSjoerg CXIdxEntity_Enum = 13, 627706f32e7eSjoerg CXIdxEntity_Struct = 14, 627806f32e7eSjoerg CXIdxEntity_Union = 15, 627906f32e7eSjoerg 628006f32e7eSjoerg CXIdxEntity_CXXClass = 16, 628106f32e7eSjoerg CXIdxEntity_CXXNamespace = 17, 628206f32e7eSjoerg CXIdxEntity_CXXNamespaceAlias = 18, 628306f32e7eSjoerg CXIdxEntity_CXXStaticVariable = 19, 628406f32e7eSjoerg CXIdxEntity_CXXStaticMethod = 20, 628506f32e7eSjoerg CXIdxEntity_CXXInstanceMethod = 21, 628606f32e7eSjoerg CXIdxEntity_CXXConstructor = 22, 628706f32e7eSjoerg CXIdxEntity_CXXDestructor = 23, 628806f32e7eSjoerg CXIdxEntity_CXXConversionFunction = 24, 628906f32e7eSjoerg CXIdxEntity_CXXTypeAlias = 25, 629006f32e7eSjoerg CXIdxEntity_CXXInterface = 26 629106f32e7eSjoerg 629206f32e7eSjoerg } CXIdxEntityKind; 629306f32e7eSjoerg 629406f32e7eSjoerg typedef enum { 629506f32e7eSjoerg CXIdxEntityLang_None = 0, 629606f32e7eSjoerg CXIdxEntityLang_C = 1, 629706f32e7eSjoerg CXIdxEntityLang_ObjC = 2, 629806f32e7eSjoerg CXIdxEntityLang_CXX = 3, 629906f32e7eSjoerg CXIdxEntityLang_Swift = 4 630006f32e7eSjoerg } CXIdxEntityLanguage; 630106f32e7eSjoerg 630206f32e7eSjoerg /** 630306f32e7eSjoerg * Extra C++ template information for an entity. This can apply to: 630406f32e7eSjoerg * CXIdxEntity_Function 630506f32e7eSjoerg * CXIdxEntity_CXXClass 630606f32e7eSjoerg * CXIdxEntity_CXXStaticMethod 630706f32e7eSjoerg * CXIdxEntity_CXXInstanceMethod 630806f32e7eSjoerg * CXIdxEntity_CXXConstructor 630906f32e7eSjoerg * CXIdxEntity_CXXConversionFunction 631006f32e7eSjoerg * CXIdxEntity_CXXTypeAlias 631106f32e7eSjoerg */ 631206f32e7eSjoerg typedef enum { 631306f32e7eSjoerg CXIdxEntity_NonTemplate = 0, 631406f32e7eSjoerg CXIdxEntity_Template = 1, 631506f32e7eSjoerg CXIdxEntity_TemplatePartialSpecialization = 2, 631606f32e7eSjoerg CXIdxEntity_TemplateSpecialization = 3 631706f32e7eSjoerg } CXIdxEntityCXXTemplateKind; 631806f32e7eSjoerg 631906f32e7eSjoerg typedef enum { 632006f32e7eSjoerg CXIdxAttr_Unexposed = 0, 632106f32e7eSjoerg CXIdxAttr_IBAction = 1, 632206f32e7eSjoerg CXIdxAttr_IBOutlet = 2, 632306f32e7eSjoerg CXIdxAttr_IBOutletCollection = 3 632406f32e7eSjoerg } CXIdxAttrKind; 632506f32e7eSjoerg 632606f32e7eSjoerg typedef struct { 632706f32e7eSjoerg CXIdxAttrKind kind; 632806f32e7eSjoerg CXCursor cursor; 632906f32e7eSjoerg CXIdxLoc loc; 633006f32e7eSjoerg } CXIdxAttrInfo; 633106f32e7eSjoerg 633206f32e7eSjoerg typedef struct { 633306f32e7eSjoerg CXIdxEntityKind kind; 633406f32e7eSjoerg CXIdxEntityCXXTemplateKind templateKind; 633506f32e7eSjoerg CXIdxEntityLanguage lang; 633606f32e7eSjoerg const char *name; 633706f32e7eSjoerg const char *USR; 633806f32e7eSjoerg CXCursor cursor; 633906f32e7eSjoerg const CXIdxAttrInfo *const *attributes; 634006f32e7eSjoerg unsigned numAttributes; 634106f32e7eSjoerg } CXIdxEntityInfo; 634206f32e7eSjoerg 634306f32e7eSjoerg typedef struct { 634406f32e7eSjoerg CXCursor cursor; 634506f32e7eSjoerg } CXIdxContainerInfo; 634606f32e7eSjoerg 634706f32e7eSjoerg typedef struct { 634806f32e7eSjoerg const CXIdxAttrInfo *attrInfo; 634906f32e7eSjoerg const CXIdxEntityInfo *objcClass; 635006f32e7eSjoerg CXCursor classCursor; 635106f32e7eSjoerg CXIdxLoc classLoc; 635206f32e7eSjoerg } CXIdxIBOutletCollectionAttrInfo; 635306f32e7eSjoerg 6354*13fbcb42Sjoerg typedef enum { CXIdxDeclFlag_Skipped = 0x1 } CXIdxDeclInfoFlags; 635506f32e7eSjoerg 635606f32e7eSjoerg typedef struct { 635706f32e7eSjoerg const CXIdxEntityInfo *entityInfo; 635806f32e7eSjoerg CXCursor cursor; 635906f32e7eSjoerg CXIdxLoc loc; 636006f32e7eSjoerg const CXIdxContainerInfo *semanticContainer; 636106f32e7eSjoerg /** 636206f32e7eSjoerg * Generally same as #semanticContainer but can be different in 636306f32e7eSjoerg * cases like out-of-line C++ member functions. 636406f32e7eSjoerg */ 636506f32e7eSjoerg const CXIdxContainerInfo *lexicalContainer; 636606f32e7eSjoerg int isRedeclaration; 636706f32e7eSjoerg int isDefinition; 636806f32e7eSjoerg int isContainer; 636906f32e7eSjoerg const CXIdxContainerInfo *declAsContainer; 637006f32e7eSjoerg /** 637106f32e7eSjoerg * Whether the declaration exists in code or was created implicitly 637206f32e7eSjoerg * by the compiler, e.g. implicit Objective-C methods for properties. 637306f32e7eSjoerg */ 637406f32e7eSjoerg int isImplicit; 637506f32e7eSjoerg const CXIdxAttrInfo *const *attributes; 637606f32e7eSjoerg unsigned numAttributes; 637706f32e7eSjoerg 637806f32e7eSjoerg unsigned flags; 637906f32e7eSjoerg 638006f32e7eSjoerg } CXIdxDeclInfo; 638106f32e7eSjoerg 638206f32e7eSjoerg typedef enum { 638306f32e7eSjoerg CXIdxObjCContainer_ForwardRef = 0, 638406f32e7eSjoerg CXIdxObjCContainer_Interface = 1, 638506f32e7eSjoerg CXIdxObjCContainer_Implementation = 2 638606f32e7eSjoerg } CXIdxObjCContainerKind; 638706f32e7eSjoerg 638806f32e7eSjoerg typedef struct { 638906f32e7eSjoerg const CXIdxDeclInfo *declInfo; 639006f32e7eSjoerg CXIdxObjCContainerKind kind; 639106f32e7eSjoerg } CXIdxObjCContainerDeclInfo; 639206f32e7eSjoerg 639306f32e7eSjoerg typedef struct { 639406f32e7eSjoerg const CXIdxEntityInfo *base; 639506f32e7eSjoerg CXCursor cursor; 639606f32e7eSjoerg CXIdxLoc loc; 639706f32e7eSjoerg } CXIdxBaseClassInfo; 639806f32e7eSjoerg 639906f32e7eSjoerg typedef struct { 640006f32e7eSjoerg const CXIdxEntityInfo *protocol; 640106f32e7eSjoerg CXCursor cursor; 640206f32e7eSjoerg CXIdxLoc loc; 640306f32e7eSjoerg } CXIdxObjCProtocolRefInfo; 640406f32e7eSjoerg 640506f32e7eSjoerg typedef struct { 640606f32e7eSjoerg const CXIdxObjCProtocolRefInfo *const *protocols; 640706f32e7eSjoerg unsigned numProtocols; 640806f32e7eSjoerg } CXIdxObjCProtocolRefListInfo; 640906f32e7eSjoerg 641006f32e7eSjoerg typedef struct { 641106f32e7eSjoerg const CXIdxObjCContainerDeclInfo *containerInfo; 641206f32e7eSjoerg const CXIdxBaseClassInfo *superInfo; 641306f32e7eSjoerg const CXIdxObjCProtocolRefListInfo *protocols; 641406f32e7eSjoerg } CXIdxObjCInterfaceDeclInfo; 641506f32e7eSjoerg 641606f32e7eSjoerg typedef struct { 641706f32e7eSjoerg const CXIdxObjCContainerDeclInfo *containerInfo; 641806f32e7eSjoerg const CXIdxEntityInfo *objcClass; 641906f32e7eSjoerg CXCursor classCursor; 642006f32e7eSjoerg CXIdxLoc classLoc; 642106f32e7eSjoerg const CXIdxObjCProtocolRefListInfo *protocols; 642206f32e7eSjoerg } CXIdxObjCCategoryDeclInfo; 642306f32e7eSjoerg 642406f32e7eSjoerg typedef struct { 642506f32e7eSjoerg const CXIdxDeclInfo *declInfo; 642606f32e7eSjoerg const CXIdxEntityInfo *getter; 642706f32e7eSjoerg const CXIdxEntityInfo *setter; 642806f32e7eSjoerg } CXIdxObjCPropertyDeclInfo; 642906f32e7eSjoerg 643006f32e7eSjoerg typedef struct { 643106f32e7eSjoerg const CXIdxDeclInfo *declInfo; 643206f32e7eSjoerg const CXIdxBaseClassInfo *const *bases; 643306f32e7eSjoerg unsigned numBases; 643406f32e7eSjoerg } CXIdxCXXClassDeclInfo; 643506f32e7eSjoerg 643606f32e7eSjoerg /** 643706f32e7eSjoerg * Data for IndexerCallbacks#indexEntityReference. 643806f32e7eSjoerg * 643906f32e7eSjoerg * This may be deprecated in a future version as this duplicates 644006f32e7eSjoerg * the \c CXSymbolRole_Implicit bit in \c CXSymbolRole. 644106f32e7eSjoerg */ 644206f32e7eSjoerg typedef enum { 644306f32e7eSjoerg /** 644406f32e7eSjoerg * The entity is referenced directly in user's code. 644506f32e7eSjoerg */ 644606f32e7eSjoerg CXIdxEntityRef_Direct = 1, 644706f32e7eSjoerg /** 644806f32e7eSjoerg * An implicit reference, e.g. a reference of an Objective-C method 644906f32e7eSjoerg * via the dot syntax. 645006f32e7eSjoerg */ 645106f32e7eSjoerg CXIdxEntityRef_Implicit = 2 645206f32e7eSjoerg } CXIdxEntityRefKind; 645306f32e7eSjoerg 645406f32e7eSjoerg /** 645506f32e7eSjoerg * Roles that are attributed to symbol occurrences. 645606f32e7eSjoerg * 645706f32e7eSjoerg * Internal: this currently mirrors low 9 bits of clang::index::SymbolRole with 645806f32e7eSjoerg * higher bits zeroed. These high bits may be exposed in the future. 645906f32e7eSjoerg */ 646006f32e7eSjoerg typedef enum { 646106f32e7eSjoerg CXSymbolRole_None = 0, 646206f32e7eSjoerg CXSymbolRole_Declaration = 1 << 0, 646306f32e7eSjoerg CXSymbolRole_Definition = 1 << 1, 646406f32e7eSjoerg CXSymbolRole_Reference = 1 << 2, 646506f32e7eSjoerg CXSymbolRole_Read = 1 << 3, 646606f32e7eSjoerg CXSymbolRole_Write = 1 << 4, 646706f32e7eSjoerg CXSymbolRole_Call = 1 << 5, 646806f32e7eSjoerg CXSymbolRole_Dynamic = 1 << 6, 646906f32e7eSjoerg CXSymbolRole_AddressOf = 1 << 7, 647006f32e7eSjoerg CXSymbolRole_Implicit = 1 << 8 647106f32e7eSjoerg } CXSymbolRole; 647206f32e7eSjoerg 647306f32e7eSjoerg /** 647406f32e7eSjoerg * Data for IndexerCallbacks#indexEntityReference. 647506f32e7eSjoerg */ 647606f32e7eSjoerg typedef struct { 647706f32e7eSjoerg CXIdxEntityRefKind kind; 647806f32e7eSjoerg /** 647906f32e7eSjoerg * Reference cursor. 648006f32e7eSjoerg */ 648106f32e7eSjoerg CXCursor cursor; 648206f32e7eSjoerg CXIdxLoc loc; 648306f32e7eSjoerg /** 648406f32e7eSjoerg * The entity that gets referenced. 648506f32e7eSjoerg */ 648606f32e7eSjoerg const CXIdxEntityInfo *referencedEntity; 648706f32e7eSjoerg /** 648806f32e7eSjoerg * Immediate "parent" of the reference. For example: 648906f32e7eSjoerg * 649006f32e7eSjoerg * \code 649106f32e7eSjoerg * Foo *var; 649206f32e7eSjoerg * \endcode 649306f32e7eSjoerg * 649406f32e7eSjoerg * The parent of reference of type 'Foo' is the variable 'var'. 649506f32e7eSjoerg * For references inside statement bodies of functions/methods, 649606f32e7eSjoerg * the parentEntity will be the function/method. 649706f32e7eSjoerg */ 649806f32e7eSjoerg const CXIdxEntityInfo *parentEntity; 649906f32e7eSjoerg /** 650006f32e7eSjoerg * Lexical container context of the reference. 650106f32e7eSjoerg */ 650206f32e7eSjoerg const CXIdxContainerInfo *container; 650306f32e7eSjoerg /** 650406f32e7eSjoerg * Sets of symbol roles of the reference. 650506f32e7eSjoerg */ 650606f32e7eSjoerg CXSymbolRole role; 650706f32e7eSjoerg } CXIdxEntityRefInfo; 650806f32e7eSjoerg 650906f32e7eSjoerg /** 651006f32e7eSjoerg * A group of callbacks used by #clang_indexSourceFile and 651106f32e7eSjoerg * #clang_indexTranslationUnit. 651206f32e7eSjoerg */ 651306f32e7eSjoerg typedef struct { 651406f32e7eSjoerg /** 651506f32e7eSjoerg * Called periodically to check whether indexing should be aborted. 651606f32e7eSjoerg * Should return 0 to continue, and non-zero to abort. 651706f32e7eSjoerg */ 651806f32e7eSjoerg int (*abortQuery)(CXClientData client_data, void *reserved); 651906f32e7eSjoerg 652006f32e7eSjoerg /** 652106f32e7eSjoerg * Called at the end of indexing; passes the complete diagnostic set. 652206f32e7eSjoerg */ 6523*13fbcb42Sjoerg void (*diagnostic)(CXClientData client_data, CXDiagnosticSet, void *reserved); 652406f32e7eSjoerg 6525*13fbcb42Sjoerg CXIdxClientFile (*enteredMainFile)(CXClientData client_data, CXFile mainFile, 6526*13fbcb42Sjoerg void *reserved); 652706f32e7eSjoerg 652806f32e7eSjoerg /** 652906f32e7eSjoerg * Called when a file gets \#included/\#imported. 653006f32e7eSjoerg */ 653106f32e7eSjoerg CXIdxClientFile (*ppIncludedFile)(CXClientData client_data, 653206f32e7eSjoerg const CXIdxIncludedFileInfo *); 653306f32e7eSjoerg 653406f32e7eSjoerg /** 653506f32e7eSjoerg * Called when a AST file (PCH or module) gets imported. 653606f32e7eSjoerg * 653706f32e7eSjoerg * AST files will not get indexed (there will not be callbacks to index all 653806f32e7eSjoerg * the entities in an AST file). The recommended action is that, if the AST 653906f32e7eSjoerg * file is not already indexed, to initiate a new indexing job specific to 654006f32e7eSjoerg * the AST file. 654106f32e7eSjoerg */ 654206f32e7eSjoerg CXIdxClientASTFile (*importedASTFile)(CXClientData client_data, 654306f32e7eSjoerg const CXIdxImportedASTFileInfo *); 654406f32e7eSjoerg 654506f32e7eSjoerg /** 654606f32e7eSjoerg * Called at the beginning of indexing a translation unit. 654706f32e7eSjoerg */ 654806f32e7eSjoerg CXIdxClientContainer (*startedTranslationUnit)(CXClientData client_data, 654906f32e7eSjoerg void *reserved); 655006f32e7eSjoerg 6551*13fbcb42Sjoerg void (*indexDeclaration)(CXClientData client_data, const CXIdxDeclInfo *); 655206f32e7eSjoerg 655306f32e7eSjoerg /** 655406f32e7eSjoerg * Called to index a reference of an entity. 655506f32e7eSjoerg */ 655606f32e7eSjoerg void (*indexEntityReference)(CXClientData client_data, 655706f32e7eSjoerg const CXIdxEntityRefInfo *); 655806f32e7eSjoerg 655906f32e7eSjoerg } IndexerCallbacks; 656006f32e7eSjoerg 656106f32e7eSjoerg CINDEX_LINKAGE int clang_index_isEntityObjCContainerKind(CXIdxEntityKind); 656206f32e7eSjoerg CINDEX_LINKAGE const CXIdxObjCContainerDeclInfo * 656306f32e7eSjoerg clang_index_getObjCContainerDeclInfo(const CXIdxDeclInfo *); 656406f32e7eSjoerg 656506f32e7eSjoerg CINDEX_LINKAGE const CXIdxObjCInterfaceDeclInfo * 656606f32e7eSjoerg clang_index_getObjCInterfaceDeclInfo(const CXIdxDeclInfo *); 656706f32e7eSjoerg 656806f32e7eSjoerg CINDEX_LINKAGE 656906f32e7eSjoerg const CXIdxObjCCategoryDeclInfo * 657006f32e7eSjoerg clang_index_getObjCCategoryDeclInfo(const CXIdxDeclInfo *); 657106f32e7eSjoerg 657206f32e7eSjoerg CINDEX_LINKAGE const CXIdxObjCProtocolRefListInfo * 657306f32e7eSjoerg clang_index_getObjCProtocolRefListInfo(const CXIdxDeclInfo *); 657406f32e7eSjoerg 657506f32e7eSjoerg CINDEX_LINKAGE const CXIdxObjCPropertyDeclInfo * 657606f32e7eSjoerg clang_index_getObjCPropertyDeclInfo(const CXIdxDeclInfo *); 657706f32e7eSjoerg 657806f32e7eSjoerg CINDEX_LINKAGE const CXIdxIBOutletCollectionAttrInfo * 657906f32e7eSjoerg clang_index_getIBOutletCollectionAttrInfo(const CXIdxAttrInfo *); 658006f32e7eSjoerg 658106f32e7eSjoerg CINDEX_LINKAGE const CXIdxCXXClassDeclInfo * 658206f32e7eSjoerg clang_index_getCXXClassDeclInfo(const CXIdxDeclInfo *); 658306f32e7eSjoerg 658406f32e7eSjoerg /** 658506f32e7eSjoerg * For retrieving a custom CXIdxClientContainer attached to a 658606f32e7eSjoerg * container. 658706f32e7eSjoerg */ 658806f32e7eSjoerg CINDEX_LINKAGE CXIdxClientContainer 658906f32e7eSjoerg clang_index_getClientContainer(const CXIdxContainerInfo *); 659006f32e7eSjoerg 659106f32e7eSjoerg /** 659206f32e7eSjoerg * For setting a custom CXIdxClientContainer attached to a 659306f32e7eSjoerg * container. 659406f32e7eSjoerg */ 6595*13fbcb42Sjoerg CINDEX_LINKAGE void clang_index_setClientContainer(const CXIdxContainerInfo *, 6596*13fbcb42Sjoerg CXIdxClientContainer); 659706f32e7eSjoerg 659806f32e7eSjoerg /** 659906f32e7eSjoerg * For retrieving a custom CXIdxClientEntity attached to an entity. 660006f32e7eSjoerg */ 660106f32e7eSjoerg CINDEX_LINKAGE CXIdxClientEntity 660206f32e7eSjoerg clang_index_getClientEntity(const CXIdxEntityInfo *); 660306f32e7eSjoerg 660406f32e7eSjoerg /** 660506f32e7eSjoerg * For setting a custom CXIdxClientEntity attached to an entity. 660606f32e7eSjoerg */ 6607*13fbcb42Sjoerg CINDEX_LINKAGE void clang_index_setClientEntity(const CXIdxEntityInfo *, 6608*13fbcb42Sjoerg CXIdxClientEntity); 660906f32e7eSjoerg 661006f32e7eSjoerg /** 661106f32e7eSjoerg * An indexing action/session, to be applied to one or multiple 661206f32e7eSjoerg * translation units. 661306f32e7eSjoerg */ 661406f32e7eSjoerg typedef void *CXIndexAction; 661506f32e7eSjoerg 661606f32e7eSjoerg /** 661706f32e7eSjoerg * An indexing action/session, to be applied to one or multiple 661806f32e7eSjoerg * translation units. 661906f32e7eSjoerg * 662006f32e7eSjoerg * \param CIdx The index object with which the index action will be associated. 662106f32e7eSjoerg */ 662206f32e7eSjoerg CINDEX_LINKAGE CXIndexAction clang_IndexAction_create(CXIndex CIdx); 662306f32e7eSjoerg 662406f32e7eSjoerg /** 662506f32e7eSjoerg * Destroy the given index action. 662606f32e7eSjoerg * 662706f32e7eSjoerg * The index action must not be destroyed until all of the translation units 662806f32e7eSjoerg * created within that index action have been destroyed. 662906f32e7eSjoerg */ 663006f32e7eSjoerg CINDEX_LINKAGE void clang_IndexAction_dispose(CXIndexAction); 663106f32e7eSjoerg 663206f32e7eSjoerg typedef enum { 663306f32e7eSjoerg /** 663406f32e7eSjoerg * Used to indicate that no special indexing options are needed. 663506f32e7eSjoerg */ 663606f32e7eSjoerg CXIndexOpt_None = 0x0, 663706f32e7eSjoerg 663806f32e7eSjoerg /** 663906f32e7eSjoerg * Used to indicate that IndexerCallbacks#indexEntityReference should 664006f32e7eSjoerg * be invoked for only one reference of an entity per source file that does 664106f32e7eSjoerg * not also include a declaration/definition of the entity. 664206f32e7eSjoerg */ 664306f32e7eSjoerg CXIndexOpt_SuppressRedundantRefs = 0x1, 664406f32e7eSjoerg 664506f32e7eSjoerg /** 664606f32e7eSjoerg * Function-local symbols should be indexed. If this is not set 664706f32e7eSjoerg * function-local symbols will be ignored. 664806f32e7eSjoerg */ 664906f32e7eSjoerg CXIndexOpt_IndexFunctionLocalSymbols = 0x2, 665006f32e7eSjoerg 665106f32e7eSjoerg /** 665206f32e7eSjoerg * Implicit function/class template instantiations should be indexed. 665306f32e7eSjoerg * If this is not set, implicit instantiations will be ignored. 665406f32e7eSjoerg */ 665506f32e7eSjoerg CXIndexOpt_IndexImplicitTemplateInstantiations = 0x4, 665606f32e7eSjoerg 665706f32e7eSjoerg /** 665806f32e7eSjoerg * Suppress all compiler warnings when parsing for indexing. 665906f32e7eSjoerg */ 666006f32e7eSjoerg CXIndexOpt_SuppressWarnings = 0x8, 666106f32e7eSjoerg 666206f32e7eSjoerg /** 666306f32e7eSjoerg * Skip a function/method body that was already parsed during an 666406f32e7eSjoerg * indexing session associated with a \c CXIndexAction object. 666506f32e7eSjoerg * Bodies in system headers are always skipped. 666606f32e7eSjoerg */ 666706f32e7eSjoerg CXIndexOpt_SkipParsedBodiesInSession = 0x10 666806f32e7eSjoerg 666906f32e7eSjoerg } CXIndexOptFlags; 667006f32e7eSjoerg 667106f32e7eSjoerg /** 667206f32e7eSjoerg * Index the given source file and the translation unit corresponding 667306f32e7eSjoerg * to that file via callbacks implemented through #IndexerCallbacks. 667406f32e7eSjoerg * 667506f32e7eSjoerg * \param client_data pointer data supplied by the client, which will 667606f32e7eSjoerg * be passed to the invoked callbacks. 667706f32e7eSjoerg * 667806f32e7eSjoerg * \param index_callbacks Pointer to indexing callbacks that the client 667906f32e7eSjoerg * implements. 668006f32e7eSjoerg * 668106f32e7eSjoerg * \param index_callbacks_size Size of #IndexerCallbacks structure that gets 668206f32e7eSjoerg * passed in index_callbacks. 668306f32e7eSjoerg * 668406f32e7eSjoerg * \param index_options A bitmask of options that affects how indexing is 668506f32e7eSjoerg * performed. This should be a bitwise OR of the CXIndexOpt_XXX flags. 668606f32e7eSjoerg * 668706f32e7eSjoerg * \param[out] out_TU pointer to store a \c CXTranslationUnit that can be 668806f32e7eSjoerg * reused after indexing is finished. Set to \c NULL if you do not require it. 668906f32e7eSjoerg * 669006f32e7eSjoerg * \returns 0 on success or if there were errors from which the compiler could 669106f32e7eSjoerg * recover. If there is a failure from which there is no recovery, returns 669206f32e7eSjoerg * a non-zero \c CXErrorCode. 669306f32e7eSjoerg * 669406f32e7eSjoerg * The rest of the parameters are the same as #clang_parseTranslationUnit. 669506f32e7eSjoerg */ 6696*13fbcb42Sjoerg CINDEX_LINKAGE int clang_indexSourceFile( 6697*13fbcb42Sjoerg CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks, 6698*13fbcb42Sjoerg unsigned index_callbacks_size, unsigned index_options, 6699*13fbcb42Sjoerg const char *source_filename, const char *const *command_line_args, 6700*13fbcb42Sjoerg int num_command_line_args, struct CXUnsavedFile *unsaved_files, 6701*13fbcb42Sjoerg unsigned num_unsaved_files, CXTranslationUnit *out_TU, unsigned TU_options); 670206f32e7eSjoerg 670306f32e7eSjoerg /** 670406f32e7eSjoerg * Same as clang_indexSourceFile but requires a full command line 670506f32e7eSjoerg * for \c command_line_args including argv[0]. This is useful if the standard 670606f32e7eSjoerg * library paths are relative to the binary. 670706f32e7eSjoerg */ 670806f32e7eSjoerg CINDEX_LINKAGE int clang_indexSourceFileFullArgv( 670906f32e7eSjoerg CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks, 671006f32e7eSjoerg unsigned index_callbacks_size, unsigned index_options, 671106f32e7eSjoerg const char *source_filename, const char *const *command_line_args, 671206f32e7eSjoerg int num_command_line_args, struct CXUnsavedFile *unsaved_files, 671306f32e7eSjoerg unsigned num_unsaved_files, CXTranslationUnit *out_TU, unsigned TU_options); 671406f32e7eSjoerg 671506f32e7eSjoerg /** 671606f32e7eSjoerg * Index the given translation unit via callbacks implemented through 671706f32e7eSjoerg * #IndexerCallbacks. 671806f32e7eSjoerg * 671906f32e7eSjoerg * The order of callback invocations is not guaranteed to be the same as 672006f32e7eSjoerg * when indexing a source file. The high level order will be: 672106f32e7eSjoerg * 672206f32e7eSjoerg * -Preprocessor callbacks invocations 672306f32e7eSjoerg * -Declaration/reference callbacks invocations 672406f32e7eSjoerg * -Diagnostic callback invocations 672506f32e7eSjoerg * 672606f32e7eSjoerg * The parameters are the same as #clang_indexSourceFile. 672706f32e7eSjoerg * 672806f32e7eSjoerg * \returns If there is a failure from which there is no recovery, returns 672906f32e7eSjoerg * non-zero, otherwise returns 0. 673006f32e7eSjoerg */ 6731*13fbcb42Sjoerg CINDEX_LINKAGE int clang_indexTranslationUnit( 6732*13fbcb42Sjoerg CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks, 6733*13fbcb42Sjoerg unsigned index_callbacks_size, unsigned index_options, CXTranslationUnit); 673406f32e7eSjoerg 673506f32e7eSjoerg /** 673606f32e7eSjoerg * Retrieve the CXIdxFile, file, line, column, and offset represented by 673706f32e7eSjoerg * the given CXIdxLoc. 673806f32e7eSjoerg * 673906f32e7eSjoerg * If the location refers into a macro expansion, retrieves the 674006f32e7eSjoerg * location of the macro expansion and if it refers into a macro argument 674106f32e7eSjoerg * retrieves the location of the argument. 674206f32e7eSjoerg */ 674306f32e7eSjoerg CINDEX_LINKAGE void clang_indexLoc_getFileLocation(CXIdxLoc loc, 674406f32e7eSjoerg CXIdxClientFile *indexFile, 6745*13fbcb42Sjoerg CXFile *file, unsigned *line, 674606f32e7eSjoerg unsigned *column, 674706f32e7eSjoerg unsigned *offset); 674806f32e7eSjoerg 674906f32e7eSjoerg /** 675006f32e7eSjoerg * Retrieve the CXSourceLocation represented by the given CXIdxLoc. 675106f32e7eSjoerg */ 675206f32e7eSjoerg CINDEX_LINKAGE 675306f32e7eSjoerg CXSourceLocation clang_indexLoc_getCXSourceLocation(CXIdxLoc loc); 675406f32e7eSjoerg 675506f32e7eSjoerg /** 675606f32e7eSjoerg * Visitor invoked for each field found by a traversal. 675706f32e7eSjoerg * 675806f32e7eSjoerg * This visitor function will be invoked for each field found by 675906f32e7eSjoerg * \c clang_Type_visitFields. Its first argument is the cursor being 676006f32e7eSjoerg * visited, its second argument is the client data provided to 676106f32e7eSjoerg * \c clang_Type_visitFields. 676206f32e7eSjoerg * 676306f32e7eSjoerg * The visitor should return one of the \c CXVisitorResult values 676406f32e7eSjoerg * to direct \c clang_Type_visitFields. 676506f32e7eSjoerg */ 676606f32e7eSjoerg typedef enum CXVisitorResult (*CXFieldVisitor)(CXCursor C, 676706f32e7eSjoerg CXClientData client_data); 676806f32e7eSjoerg 676906f32e7eSjoerg /** 677006f32e7eSjoerg * Visit the fields of a particular type. 677106f32e7eSjoerg * 677206f32e7eSjoerg * This function visits all the direct fields of the given cursor, 677306f32e7eSjoerg * invoking the given \p visitor function with the cursors of each 677406f32e7eSjoerg * visited field. The traversal may be ended prematurely, if 677506f32e7eSjoerg * the visitor returns \c CXFieldVisit_Break. 677606f32e7eSjoerg * 677706f32e7eSjoerg * \param T the record type whose field may be visited. 677806f32e7eSjoerg * 677906f32e7eSjoerg * \param visitor the visitor function that will be invoked for each 678006f32e7eSjoerg * field of \p T. 678106f32e7eSjoerg * 678206f32e7eSjoerg * \param client_data pointer data supplied by the client, which will 678306f32e7eSjoerg * be passed to the visitor each time it is invoked. 678406f32e7eSjoerg * 678506f32e7eSjoerg * \returns a non-zero value if the traversal was terminated 678606f32e7eSjoerg * prematurely by the visitor returning \c CXFieldVisit_Break. 678706f32e7eSjoerg */ 6788*13fbcb42Sjoerg CINDEX_LINKAGE unsigned clang_Type_visitFields(CXType T, CXFieldVisitor visitor, 678906f32e7eSjoerg CXClientData client_data); 679006f32e7eSjoerg 679106f32e7eSjoerg /** 679206f32e7eSjoerg * @} 679306f32e7eSjoerg */ 679406f32e7eSjoerg 679506f32e7eSjoerg /** 679606f32e7eSjoerg * @} 679706f32e7eSjoerg */ 679806f32e7eSjoerg 6799*13fbcb42Sjoerg LLVM_CLANG_C_EXTERN_C_END 6800*13fbcb42Sjoerg 680106f32e7eSjoerg #endif 6802