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