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