Index.h revision 327952
1198092Srdivacky/*===-- clang-c/Index.h - Indexing Public C Interface -------------*- C -*-===*\ 2198092Srdivacky|* *| 3198092Srdivacky|* The LLVM Compiler Infrastructure *| 4198092Srdivacky|* *| 5198092Srdivacky|* This file is distributed under the University of Illinois Open Source *| 6198092Srdivacky|* License. See LICENSE.TXT for details. *| 7198092Srdivacky|* *| 8198092Srdivacky|*===----------------------------------------------------------------------===*| 9198092Srdivacky|* *| 10321369Sdim|* This header provides a public interface to a Clang library for extracting *| 11198092Srdivacky|* high-level symbol information from source files without exposing the full *| 12198092Srdivacky|* Clang C++ API. *| 13198092Srdivacky|* *| 14198092Srdivacky\*===----------------------------------------------------------------------===*/ 15198092Srdivacky 16280031Sdim#ifndef LLVM_CLANG_C_INDEX_H 17280031Sdim#define LLVM_CLANG_C_INDEX_H 18198092Srdivacky 19201361Srdivacky#include <time.h> 20198893Srdivacky 21239462Sdim#include "clang-c/Platform.h" 22276479Sdim#include "clang-c/CXErrorCode.h" 23239462Sdim#include "clang-c/CXString.h" 24276479Sdim#include "clang-c/BuildSystem.h" 25239462Sdim 26243830Sdim/** 27243830Sdim * \brief The version constants for the libclang API. 28243830Sdim * CINDEX_VERSION_MINOR should increase when there are API additions. 29243830Sdim * CINDEX_VERSION_MAJOR is intended for "major" source/ABI breaking changes. 30243830Sdim * 31243830Sdim * The policy about the libclang API was always to keep it source and ABI 32243830Sdim * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable. 33243830Sdim */ 34243830Sdim#define CINDEX_VERSION_MAJOR 0 35327952Sdim#define CINDEX_VERSION_MINOR 45 36243830Sdim 37243830Sdim#define CINDEX_VERSION_ENCODE(major, minor) ( \ 38243830Sdim ((major) * 10000) \ 39243830Sdim + ((minor) * 1)) 40243830Sdim 41243830Sdim#define CINDEX_VERSION CINDEX_VERSION_ENCODE( \ 42243830Sdim CINDEX_VERSION_MAJOR, \ 43243830Sdim CINDEX_VERSION_MINOR ) 44243830Sdim 45243830Sdim#define CINDEX_VERSION_STRINGIZE_(major, minor) \ 46243830Sdim #major"."#minor 47243830Sdim#define CINDEX_VERSION_STRINGIZE(major, minor) \ 48243830Sdim CINDEX_VERSION_STRINGIZE_(major, minor) 49243830Sdim 50243830Sdim#define CINDEX_VERSION_STRING CINDEX_VERSION_STRINGIZE( \ 51243830Sdim CINDEX_VERSION_MAJOR, \ 52243830Sdim CINDEX_VERSION_MINOR) 53243830Sdim 54198092Srdivacky#ifdef __cplusplus 55198092Srdivackyextern "C" { 56198092Srdivacky#endif 57198092Srdivacky 58219077Sdim/** \defgroup CINDEX libclang: C Interface to Clang 59202879Srdivacky * 60203955Srdivacky * The C Interface to Clang provides a relatively small API that exposes 61202879Srdivacky * facilities for parsing source code into an abstract syntax tree (AST), 62202879Srdivacky * loading already-parsed ASTs, traversing the AST, associating 63202879Srdivacky * physical source locations with elements within the AST, and other 64202879Srdivacky * facilities that support Clang-based development tools. 65202879Srdivacky * 66203955Srdivacky * This C interface to Clang will never provide all of the information 67202879Srdivacky * representation stored in Clang's C++ AST, nor should it: the intent is to 68202879Srdivacky * maintain an API that is relatively stable from one release to the next, 69202879Srdivacky * providing only the basic functionality needed to support development tools. 70203955Srdivacky * 71203955Srdivacky * To avoid namespace pollution, data types are prefixed with "CX" and 72202879Srdivacky * functions are prefixed with "clang_". 73202879Srdivacky * 74202879Srdivacky * @{ 75202879Srdivacky */ 76203955Srdivacky 77202879Srdivacky/** 78202879Srdivacky * \brief An "index" that consists of a set of translation units that would 79202879Srdivacky * typically be linked together into an executable or library. 80202879Srdivacky */ 81202879Srdivackytypedef void *CXIndex; 82198092Srdivacky 83202879Srdivacky/** 84321369Sdim * \brief An opaque type representing target information for a given translation 85321369Sdim * unit. 86321369Sdim */ 87321369Sdimtypedef struct CXTargetInfoImpl *CXTargetInfo; 88321369Sdim 89321369Sdim/** 90202879Srdivacky * \brief A single translation unit, which resides in an index. 91202879Srdivacky */ 92218893Sdimtypedef struct CXTranslationUnitImpl *CXTranslationUnit; 93198092Srdivacky 94200583Srdivacky/** 95202879Srdivacky * \brief Opaque pointer representing client data that will be passed through 96202879Srdivacky * to various callbacks and visitors. 97202879Srdivacky */ 98202879Srdivackytypedef void *CXClientData; 99203955Srdivacky 100202879Srdivacky/** 101200583Srdivacky * \brief Provides the contents of a file that has not yet been saved to disk. 102200583Srdivacky * 103200583Srdivacky * Each CXUnsavedFile instance provides the name of a file on the 104200583Srdivacky * system along with the current contents of that file that have not 105200583Srdivacky * yet been saved to disk. 106200583Srdivacky */ 107200583Srdivackystruct CXUnsavedFile { 108203955Srdivacky /** 109203955Srdivacky * \brief The file whose contents have not yet been saved. 110200583Srdivacky * 111200583Srdivacky * This file must already exist in the file system. 112200583Srdivacky */ 113200583Srdivacky const char *Filename; 114200583Srdivacky 115203955Srdivacky /** 116204643Srdivacky * \brief A buffer containing the unsaved contents of this file. 117200583Srdivacky */ 118200583Srdivacky const char *Contents; 119200583Srdivacky 120200583Srdivacky /** 121204643Srdivacky * \brief The length of the unsaved contents of this buffer. 122200583Srdivacky */ 123200583Srdivacky unsigned long Length; 124200583Srdivacky}; 125200583Srdivacky 126199482Srdivacky/** 127212904Sdim * \brief Describes the availability of a particular entity, which indicates 128212904Sdim * whether the use of this entity will result in a warning or error due to 129212904Sdim * it being deprecated or unavailable. 130212904Sdim */ 131212904Sdimenum CXAvailabilityKind { 132212904Sdim /** 133212904Sdim * \brief The entity is available. 134212904Sdim */ 135212904Sdim CXAvailability_Available, 136212904Sdim /** 137212904Sdim * \brief The entity is available, but has been deprecated (and its use is 138212904Sdim * not recommended). 139212904Sdim */ 140212904Sdim CXAvailability_Deprecated, 141212904Sdim /** 142212904Sdim * \brief The entity is not available; any use of it will be an error. 143212904Sdim */ 144226633Sdim CXAvailability_NotAvailable, 145226633Sdim /** 146226633Sdim * \brief The entity is available, but not accessible; any use of it will be 147226633Sdim * an error. 148226633Sdim */ 149226633Sdim CXAvailability_NotAccessible 150212904Sdim}; 151203955Srdivacky 152202879Srdivacky/** 153239462Sdim * \brief Describes a version number of the form major.minor.subminor. 154202879Srdivacky */ 155239462Sdimtypedef struct CXVersion { 156239462Sdim /** 157239462Sdim * \brief The major version number, e.g., the '10' in '10.7.3'. A negative 158239462Sdim * value indicates that there is no version number at all. 159239462Sdim */ 160239462Sdim int Major; 161239462Sdim /** 162239462Sdim * \brief The minor version number, e.g., the '7' in '10.7.3'. This value 163239462Sdim * will be negative if no minor version number was provided, e.g., for 164239462Sdim * version '10'. 165239462Sdim */ 166239462Sdim int Minor; 167239462Sdim /** 168239462Sdim * \brief The subminor version number, e.g., the '3' in '10.7.3'. This value 169239462Sdim * will be negative if no minor or subminor version number was provided, 170239462Sdim * e.g., in version '10' or '10.7'. 171239462Sdim */ 172239462Sdim int Subminor; 173239462Sdim} CXVersion; 174321369Sdim 175202879Srdivacky/** 176321369Sdim * \brief Describes the exception specification of a cursor. 177321369Sdim * 178321369Sdim * A negative value indicates that the cursor is not a function declaration. 179321369Sdim */ 180321369Sdimenum CXCursor_ExceptionSpecificationKind { 181321369Sdim 182321369Sdim /** 183321369Sdim * \brief The cursor has no exception specification. 184321369Sdim */ 185321369Sdim CXCursor_ExceptionSpecificationKind_None, 186321369Sdim 187321369Sdim /** 188321369Sdim * \brief The cursor has exception specification throw() 189321369Sdim */ 190321369Sdim CXCursor_ExceptionSpecificationKind_DynamicNone, 191321369Sdim 192321369Sdim /** 193321369Sdim * \brief The cursor has exception specification throw(T1, T2) 194321369Sdim */ 195321369Sdim CXCursor_ExceptionSpecificationKind_Dynamic, 196321369Sdim 197321369Sdim /** 198321369Sdim * \brief The cursor has exception specification throw(...). 199321369Sdim */ 200321369Sdim CXCursor_ExceptionSpecificationKind_MSAny, 201321369Sdim 202321369Sdim /** 203321369Sdim * \brief The cursor has exception specification basic noexcept. 204321369Sdim */ 205321369Sdim CXCursor_ExceptionSpecificationKind_BasicNoexcept, 206321369Sdim 207321369Sdim /** 208321369Sdim * \brief The cursor has exception specification computed noexcept. 209321369Sdim */ 210321369Sdim CXCursor_ExceptionSpecificationKind_ComputedNoexcept, 211321369Sdim 212321369Sdim /** 213321369Sdim * \brief The exception specification has not yet been evaluated. 214321369Sdim */ 215321369Sdim CXCursor_ExceptionSpecificationKind_Unevaluated, 216321369Sdim 217321369Sdim /** 218321369Sdim * \brief The exception specification has not yet been instantiated. 219321369Sdim */ 220321369Sdim CXCursor_ExceptionSpecificationKind_Uninstantiated, 221321369Sdim 222321369Sdim /** 223321369Sdim * \brief The exception specification has not been parsed yet. 224321369Sdim */ 225321369Sdim CXCursor_ExceptionSpecificationKind_Unparsed 226321369Sdim}; 227321369Sdim 228321369Sdim/** 229239462Sdim * \brief Provides a shared context for creating translation units. 230198398Srdivacky * 231239462Sdim * It provides two options: 232239462Sdim * 233198398Srdivacky * - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local" 234198398Srdivacky * declarations (when loading any new translation units). A "local" declaration 235203955Srdivacky * is one that belongs in the translation unit itself and not in a precompiled 236198398Srdivacky * header that was used by the translation unit. If zero, all declarations 237198398Srdivacky * will be enumerated. 238198398Srdivacky * 239198398Srdivacky * Here is an example: 240198398Srdivacky * 241239462Sdim * \code 242204643Srdivacky * // excludeDeclsFromPCH = 1, displayDiagnostics=1 243204643Srdivacky * Idx = clang_createIndex(1, 1); 244198398Srdivacky * 245198398Srdivacky * // IndexTest.pch was produced with the following command: 246198398Srdivacky * // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch" 247198398Srdivacky * TU = clang_createTranslationUnit(Idx, "IndexTest.pch"); 248198398Srdivacky * 249198398Srdivacky * // This will load all the symbols from 'IndexTest.pch' 250203955Srdivacky * clang_visitChildren(clang_getTranslationUnitCursor(TU), 251202879Srdivacky * TranslationUnitVisitor, 0); 252198398Srdivacky * clang_disposeTranslationUnit(TU); 253198398Srdivacky * 254198398Srdivacky * // This will load all the symbols from 'IndexTest.c', excluding symbols 255198398Srdivacky * // from 'IndexTest.pch'. 256203955Srdivacky * char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" }; 257203955Srdivacky * TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args, 258203955Srdivacky * 0, 0); 259202879Srdivacky * clang_visitChildren(clang_getTranslationUnitCursor(TU), 260202879Srdivacky * TranslationUnitVisitor, 0); 261198398Srdivacky * clang_disposeTranslationUnit(TU); 262239462Sdim * \endcode 263198398Srdivacky * 264198398Srdivacky * This process of creating the 'pch', loading it separately, and using it (via 265198398Srdivacky * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks 266198398Srdivacky * (which gives the indexer the same performance benefit as the compiler). 267198398Srdivacky */ 268204643SrdivackyCINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH, 269204643Srdivacky int displayDiagnostics); 270205219Srdivacky 271203955Srdivacky/** 272203955Srdivacky * \brief Destroy the given index. 273203955Srdivacky * 274203955Srdivacky * The index must not be destroyed until all of the translation units created 275203955Srdivacky * within that index have been destroyed. 276203955Srdivacky */ 277200583SrdivackyCINDEX_LINKAGE void clang_disposeIndex(CXIndex index); 278198092Srdivacky 279234353Sdimtypedef enum { 280234353Sdim /** 281234353Sdim * \brief Used to indicate that no special CXIndex options are needed. 282234353Sdim */ 283234353Sdim CXGlobalOpt_None = 0x0, 284234353Sdim 285234353Sdim /** 286234353Sdim * \brief Used to indicate that threads that libclang creates for indexing 287234353Sdim * purposes should use background priority. 288239462Sdim * 289239462Sdim * Affects #clang_indexSourceFile, #clang_indexTranslationUnit, 290239462Sdim * #clang_parseTranslationUnit, #clang_saveTranslationUnit. 291234353Sdim */ 292234353Sdim CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1, 293234353Sdim 294234353Sdim /** 295234353Sdim * \brief Used to indicate that threads that libclang creates for editing 296234353Sdim * purposes should use background priority. 297239462Sdim * 298239462Sdim * Affects #clang_reparseTranslationUnit, #clang_codeCompleteAt, 299239462Sdim * #clang_annotateTokens 300234353Sdim */ 301234353Sdim CXGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2, 302234353Sdim 303234353Sdim /** 304234353Sdim * \brief Used to indicate that all threads that libclang creates should use 305234353Sdim * background priority. 306234353Sdim */ 307234353Sdim CXGlobalOpt_ThreadBackgroundPriorityForAll = 308234353Sdim CXGlobalOpt_ThreadBackgroundPriorityForIndexing | 309234353Sdim CXGlobalOpt_ThreadBackgroundPriorityForEditing 310234353Sdim 311234353Sdim} CXGlobalOptFlags; 312234353Sdim 313202879Srdivacky/** 314239462Sdim * \brief Sets general options associated with a CXIndex. 315234353Sdim * 316234353Sdim * For example: 317234353Sdim * \code 318234353Sdim * CXIndex idx = ...; 319234353Sdim * clang_CXIndex_setGlobalOptions(idx, 320234353Sdim * clang_CXIndex_getGlobalOptions(idx) | 321234353Sdim * CXGlobalOpt_ThreadBackgroundPriorityForIndexing); 322234353Sdim * \endcode 323234353Sdim * 324234353Sdim * \param options A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags. 325234353Sdim */ 326234353SdimCINDEX_LINKAGE void clang_CXIndex_setGlobalOptions(CXIndex, unsigned options); 327234353Sdim 328234353Sdim/** 329234353Sdim * \brief Gets the general options associated with a CXIndex. 330234353Sdim * 331234353Sdim * \returns A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags that 332234353Sdim * are associated with the given CXIndex object. 333234353Sdim */ 334234353SdimCINDEX_LINKAGE unsigned clang_CXIndex_getGlobalOptions(CXIndex); 335234353Sdim 336234353Sdim/** 337327952Sdim * \brief Sets the invocation emission path option in a CXIndex. 338327952Sdim * 339327952Sdim * The invocation emission path specifies a path which will contain log 340327952Sdim * files for certain libclang invocations. A null value (default) implies that 341327952Sdim * libclang invocations are not logged.. 342327952Sdim */ 343327952SdimCINDEX_LINKAGE void 344327952Sdimclang_CXIndex_setInvocationEmissionPathOption(CXIndex, const char *Path); 345327952Sdim 346327952Sdim/** 347202879Srdivacky * \defgroup CINDEX_FILES File manipulation routines 348202879Srdivacky * 349202879Srdivacky * @{ 350202879Srdivacky */ 351203955Srdivacky 352202879Srdivacky/** 353202879Srdivacky * \brief A particular source file that is part of a translation unit. 354202879Srdivacky */ 355202879Srdivackytypedef void *CXFile; 356198092Srdivacky 357202879Srdivacky/** 358202879Srdivacky * \brief Retrieve the complete file and path name of the given file. 359202879Srdivacky */ 360204643SrdivackyCINDEX_LINKAGE CXString clang_getFileName(CXFile SFile); 361203955Srdivacky 362202879Srdivacky/** 363202879Srdivacky * \brief Retrieve the last modification time of the given file. 364202879Srdivacky */ 365202879SrdivackyCINDEX_LINKAGE time_t clang_getFileTime(CXFile SFile); 366198092Srdivacky 367202879Srdivacky/** 368249423Sdim * \brief Uniquely identifies a CXFile, that refers to the same underlying file, 369249423Sdim * across an indexing session. 370249423Sdim */ 371249423Sdimtypedef struct { 372249423Sdim unsigned long long data[3]; 373249423Sdim} CXFileUniqueID; 374249423Sdim 375249423Sdim/** 376249423Sdim * \brief Retrieve the unique ID for the given \c file. 377249423Sdim * 378249423Sdim * \param file the file to get the ID for. 379249423Sdim * \param outID stores the returned CXFileUniqueID. 380249423Sdim * \returns If there was a failure getting the unique ID, returns non-zero, 381249423Sdim * otherwise returns 0. 382249423Sdim*/ 383249423SdimCINDEX_LINKAGE int clang_getFileUniqueID(CXFile file, CXFileUniqueID *outID); 384249423Sdim 385249423Sdim/** 386223017Sdim * \brief Determine whether the given header is guarded against 387223017Sdim * multiple inclusions, either with the conventional 388239462Sdim * \#ifndef/\#define/\#endif macro guards or with \#pragma once. 389223017Sdim */ 390223017SdimCINDEX_LINKAGE unsigned 391223017Sdimclang_isFileMultipleIncludeGuarded(CXTranslationUnit tu, CXFile file); 392223017Sdim 393223017Sdim/** 394202879Srdivacky * \brief Retrieve a file handle within the given translation unit. 395202879Srdivacky * 396202879Srdivacky * \param tu the translation unit 397203955Srdivacky * 398314564Sdim * \param file_name the name of the file. 399202879Srdivacky * 400202879Srdivacky * \returns the file handle for the named file in the translation unit \p tu, 401202879Srdivacky * or a NULL file handle if the file was not a part of this translation unit. 402202879Srdivacky */ 403203955SrdivackyCINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu, 404202879Srdivacky const char *file_name); 405203955Srdivacky 406202879Srdivacky/** 407327952Sdim * \brief Retrieve the buffer associated with the given file. 408327952Sdim * 409327952Sdim * \param tu the translation unit 410327952Sdim * 411327952Sdim * \param file the file for which to retrieve the buffer. 412327952Sdim * 413327952Sdim * \param size [out] if non-NULL, will be set to the size of the buffer. 414327952Sdim * 415327952Sdim * \returns a pointer to the buffer in memory that holds the contents of 416327952Sdim * \p file, or a NULL pointer when the file is not loaded. 417327952Sdim */ 418327952SdimCINDEX_LINKAGE const char *clang_getFileContents(CXTranslationUnit tu, 419327952Sdim CXFile file, size_t *size); 420327952Sdim 421327952Sdim/** 422280031Sdim * \brief Returns non-zero if the \c file1 and \c file2 point to the same file, 423280031Sdim * or they are both NULL. 424280031Sdim */ 425280031SdimCINDEX_LINKAGE int clang_File_isEqual(CXFile file1, CXFile file2); 426280031Sdim 427280031Sdim/** 428202879Srdivacky * @} 429202879Srdivacky */ 430198092Srdivacky 431202879Srdivacky/** 432202879Srdivacky * \defgroup CINDEX_LOCATIONS Physical source locations 433202879Srdivacky * 434202879Srdivacky * Clang represents physical source locations in its abstract syntax tree in 435202879Srdivacky * great detail, with file, line, and column information for the majority of 436202879Srdivacky * the tokens parsed in the source code. These data types and functions are 437202879Srdivacky * used to represent source location information, either for a particular 438202879Srdivacky * point in the program or for a range of points in the program, and extract 439202879Srdivacky * specific location information from those data types. 440202879Srdivacky * 441202879Srdivacky * @{ 442202879Srdivacky */ 443203955Srdivacky 444202879Srdivacky/** 445202879Srdivacky * \brief Identifies a specific source location within a translation 446202879Srdivacky * unit. 447202879Srdivacky * 448226633Sdim * Use clang_getExpansionLocation() or clang_getSpellingLocation() 449218893Sdim * to map a source location to a particular file, line, and column. 450202879Srdivacky */ 451202879Srdivackytypedef struct { 452249423Sdim const void *ptr_data[2]; 453202879Srdivacky unsigned int_data; 454202879Srdivacky} CXSourceLocation; 455198092Srdivacky 456202879Srdivacky/** 457203955Srdivacky * \brief Identifies a half-open character range in the source code. 458202879Srdivacky * 459202879Srdivacky * Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the 460202879Srdivacky * starting and end locations from a source range, respectively. 461198893Srdivacky */ 462202879Srdivackytypedef struct { 463249423Sdim const void *ptr_data[2]; 464202879Srdivacky unsigned begin_int_data; 465202879Srdivacky unsigned end_int_data; 466202879Srdivacky} CXSourceRange; 467198893Srdivacky 468202879Srdivacky/** 469202879Srdivacky * \brief Retrieve a NULL (invalid) source location. 470198092Srdivacky */ 471249423SdimCINDEX_LINKAGE CXSourceLocation clang_getNullLocation(void); 472203955Srdivacky 473202879Srdivacky/** 474239462Sdim * \brief Determine whether two source locations, which must refer into 475203955Srdivacky * the same translation unit, refer to exactly the same point in the source 476202879Srdivacky * code. 477202879Srdivacky * 478202879Srdivacky * \returns non-zero if the source locations refer to the same location, zero 479202879Srdivacky * if they refer to different locations. 480202879Srdivacky */ 481202879SrdivackyCINDEX_LINKAGE unsigned clang_equalLocations(CXSourceLocation loc1, 482202879Srdivacky CXSourceLocation loc2); 483203955Srdivacky 484202879Srdivacky/** 485203955Srdivacky * \brief Retrieves the source location associated with a given file/line/column 486203955Srdivacky * in a particular translation unit. 487202879Srdivacky */ 488202879SrdivackyCINDEX_LINKAGE CXSourceLocation clang_getLocation(CXTranslationUnit tu, 489202879Srdivacky CXFile file, 490202879Srdivacky unsigned line, 491202879Srdivacky unsigned column); 492218893Sdim/** 493218893Sdim * \brief Retrieves the source location associated with a given character offset 494218893Sdim * in a particular translation unit. 495218893Sdim */ 496218893SdimCINDEX_LINKAGE CXSourceLocation clang_getLocationForOffset(CXTranslationUnit tu, 497218893Sdim CXFile file, 498218893Sdim unsigned offset); 499203955Srdivacky 500203955Srdivacky/** 501251662Sdim * \brief Returns non-zero if the given source location is in a system header. 502251662Sdim */ 503251662SdimCINDEX_LINKAGE int clang_Location_isInSystemHeader(CXSourceLocation location); 504251662Sdim 505251662Sdim/** 506261991Sdim * \brief Returns non-zero if the given source location is in the main file of 507261991Sdim * the corresponding translation unit. 508261991Sdim */ 509261991SdimCINDEX_LINKAGE int clang_Location_isFromMainFile(CXSourceLocation location); 510261991Sdim 511261991Sdim/** 512203955Srdivacky * \brief Retrieve a NULL (invalid) source range. 513203955Srdivacky */ 514249423SdimCINDEX_LINKAGE CXSourceRange clang_getNullRange(void); 515205219Srdivacky 516202879Srdivacky/** 517202879Srdivacky * \brief Retrieve a source range given the beginning and ending source 518202879Srdivacky * locations. 519202879Srdivacky */ 520202879SrdivackyCINDEX_LINKAGE CXSourceRange clang_getRange(CXSourceLocation begin, 521202879Srdivacky CXSourceLocation end); 522203955Srdivacky 523202879Srdivacky/** 524226633Sdim * \brief Determine whether two ranges are equivalent. 525226633Sdim * 526226633Sdim * \returns non-zero if the ranges are the same, zero if they differ. 527226633Sdim */ 528226633SdimCINDEX_LINKAGE unsigned clang_equalRanges(CXSourceRange range1, 529226633Sdim CXSourceRange range2); 530226633Sdim 531226633Sdim/** 532243830Sdim * \brief Returns non-zero if \p range is null. 533226633Sdim */ 534226633SdimCINDEX_LINKAGE int clang_Range_isNull(CXSourceRange range); 535226633Sdim 536226633Sdim/** 537203955Srdivacky * \brief Retrieve the file, line, column, and offset represented by 538203955Srdivacky * the given source location. 539202879Srdivacky * 540226633Sdim * If the location refers into a macro expansion, retrieves the 541226633Sdim * location of the macro expansion. 542218893Sdim * 543203955Srdivacky * \param location the location within a source file that will be decomposed 544203955Srdivacky * into its parts. 545202879Srdivacky * 546203955Srdivacky * \param file [out] if non-NULL, will be set to the file to which the given 547202879Srdivacky * source location points. 548202879Srdivacky * 549203955Srdivacky * \param line [out] if non-NULL, will be set to the line to which the given 550202879Srdivacky * source location points. 551202879Srdivacky * 552203955Srdivacky * \param column [out] if non-NULL, will be set to the column to which the given 553203955Srdivacky * source location points. 554203955Srdivacky * 555203955Srdivacky * \param offset [out] if non-NULL, will be set to the offset into the 556203955Srdivacky * buffer to which the given source location points. 557202879Srdivacky */ 558226633SdimCINDEX_LINKAGE void clang_getExpansionLocation(CXSourceLocation location, 559226633Sdim CXFile *file, 560226633Sdim unsigned *line, 561226633Sdim unsigned *column, 562226633Sdim unsigned *offset); 563226633Sdim 564226633Sdim/** 565321369Sdim * \brief Retrieve the file, line and column represented by the given source 566321369Sdim * location, as specified in a # line directive. 567226633Sdim * 568226633Sdim * Example: given the following source code in a file somefile.c 569226633Sdim * 570239462Sdim * \code 571226633Sdim * #123 "dummy.c" 1 572226633Sdim * 573226633Sdim * static int func(void) 574226633Sdim * { 575226633Sdim * return 0; 576226633Sdim * } 577239462Sdim * \endcode 578226633Sdim * 579226633Sdim * the location information returned by this function would be 580226633Sdim * 581226633Sdim * File: dummy.c Line: 124 Column: 12 582226633Sdim * 583226633Sdim * whereas clang_getExpansionLocation would have returned 584226633Sdim * 585226633Sdim * File: somefile.c Line: 3 Column: 12 586226633Sdim * 587226633Sdim * \param location the location within a source file that will be decomposed 588226633Sdim * into its parts. 589226633Sdim * 590226633Sdim * \param filename [out] if non-NULL, will be set to the filename of the 591226633Sdim * source location. Note that filenames returned will be for "virtual" files, 592226633Sdim * which don't necessarily exist on the machine running clang - e.g. when 593226633Sdim * parsing preprocessed output obtained from a different environment. If 594226633Sdim * a non-NULL value is passed in, remember to dispose of the returned value 595226633Sdim * using \c clang_disposeString() once you've finished with it. For an invalid 596226633Sdim * source location, an empty string is returned. 597226633Sdim * 598226633Sdim * \param line [out] if non-NULL, will be set to the line number of the 599226633Sdim * source location. For an invalid source location, zero is returned. 600226633Sdim * 601226633Sdim * \param column [out] if non-NULL, will be set to the column number of the 602226633Sdim * source location. For an invalid source location, zero is returned. 603226633Sdim */ 604226633SdimCINDEX_LINKAGE void clang_getPresumedLocation(CXSourceLocation location, 605226633Sdim CXString *filename, 606226633Sdim unsigned *line, 607226633Sdim unsigned *column); 608226633Sdim 609226633Sdim/** 610226633Sdim * \brief Legacy API to retrieve the file, line, column, and offset represented 611226633Sdim * by the given source location. 612226633Sdim * 613226633Sdim * This interface has been replaced by the newer interface 614239462Sdim * #clang_getExpansionLocation(). See that interface's documentation for 615226633Sdim * details. 616226633Sdim */ 617202879SrdivackyCINDEX_LINKAGE void clang_getInstantiationLocation(CXSourceLocation location, 618202879Srdivacky CXFile *file, 619202879Srdivacky unsigned *line, 620203955Srdivacky unsigned *column, 621203955Srdivacky unsigned *offset); 622202379Srdivacky 623202879Srdivacky/** 624218893Sdim * \brief Retrieve the file, line, column, and offset represented by 625218893Sdim * the given source location. 626218893Sdim * 627218893Sdim * If the location refers into a macro instantiation, return where the 628218893Sdim * location was originally spelled in the source file. 629218893Sdim * 630218893Sdim * \param location the location within a source file that will be decomposed 631218893Sdim * into its parts. 632218893Sdim * 633218893Sdim * \param file [out] if non-NULL, will be set to the file to which the given 634218893Sdim * source location points. 635218893Sdim * 636218893Sdim * \param line [out] if non-NULL, will be set to the line to which the given 637218893Sdim * source location points. 638218893Sdim * 639218893Sdim * \param column [out] if non-NULL, will be set to the column to which the given 640218893Sdim * source location points. 641218893Sdim * 642218893Sdim * \param offset [out] if non-NULL, will be set to the offset into the 643218893Sdim * buffer to which the given source location points. 644218893Sdim */ 645218893SdimCINDEX_LINKAGE void clang_getSpellingLocation(CXSourceLocation location, 646218893Sdim CXFile *file, 647218893Sdim unsigned *line, 648218893Sdim unsigned *column, 649218893Sdim unsigned *offset); 650218893Sdim 651218893Sdim/** 652249423Sdim * \brief Retrieve the file, line, column, and offset represented by 653249423Sdim * the given source location. 654249423Sdim * 655249423Sdim * If the location refers into a macro expansion, return where the macro was 656249423Sdim * expanded or where the macro argument was written, if the location points at 657249423Sdim * a macro argument. 658249423Sdim * 659249423Sdim * \param location the location within a source file that will be decomposed 660249423Sdim * into its parts. 661249423Sdim * 662249423Sdim * \param file [out] if non-NULL, will be set to the file to which the given 663249423Sdim * source location points. 664249423Sdim * 665249423Sdim * \param line [out] if non-NULL, will be set to the line to which the given 666249423Sdim * source location points. 667249423Sdim * 668249423Sdim * \param column [out] if non-NULL, will be set to the column to which the given 669249423Sdim * source location points. 670249423Sdim * 671249423Sdim * \param offset [out] if non-NULL, will be set to the offset into the 672249423Sdim * buffer to which the given source location points. 673249423Sdim */ 674249423SdimCINDEX_LINKAGE void clang_getFileLocation(CXSourceLocation location, 675249423Sdim CXFile *file, 676249423Sdim unsigned *line, 677249423Sdim unsigned *column, 678249423Sdim unsigned *offset); 679249423Sdim 680249423Sdim/** 681203955Srdivacky * \brief Retrieve a source location representing the first character within a 682203955Srdivacky * source range. 683198092Srdivacky */ 684202879SrdivackyCINDEX_LINKAGE CXSourceLocation clang_getRangeStart(CXSourceRange range); 685198092Srdivacky 686202879Srdivacky/** 687203955Srdivacky * \brief Retrieve a source location representing the last character within a 688203955Srdivacky * source range. 689202879Srdivacky */ 690202879SrdivackyCINDEX_LINKAGE CXSourceLocation clang_getRangeEnd(CXSourceRange range); 691202379Srdivacky 692202879Srdivacky/** 693276479Sdim * \brief Identifies an array of ranges. 694276479Sdim */ 695276479Sdimtypedef struct { 696276479Sdim /** \brief The number of ranges in the \c ranges array. */ 697276479Sdim unsigned count; 698276479Sdim /** 699276479Sdim * \brief An array of \c CXSourceRanges. 700276479Sdim */ 701276479Sdim CXSourceRange *ranges; 702276479Sdim} CXSourceRangeList; 703276479Sdim 704276479Sdim/** 705276479Sdim * \brief Retrieve all ranges that were skipped by the preprocessor. 706276479Sdim * 707276479Sdim * The preprocessor will skip lines when they are surrounded by an 708276479Sdim * if/ifdef/ifndef directive whose condition does not evaluate to true. 709276479Sdim */ 710276479SdimCINDEX_LINKAGE CXSourceRangeList *clang_getSkippedRanges(CXTranslationUnit tu, 711276479Sdim CXFile file); 712276479Sdim 713276479Sdim/** 714314564Sdim * \brief Retrieve all ranges from all files that were skipped by the 715314564Sdim * preprocessor. 716314564Sdim * 717314564Sdim * The preprocessor will skip lines when they are surrounded by an 718314564Sdim * if/ifdef/ifndef directive whose condition does not evaluate to true. 719314564Sdim */ 720314564SdimCINDEX_LINKAGE CXSourceRangeList *clang_getAllSkippedRanges(CXTranslationUnit tu); 721314564Sdim 722314564Sdim/** 723276479Sdim * \brief Destroy the given \c CXSourceRangeList. 724276479Sdim */ 725276479SdimCINDEX_LINKAGE void clang_disposeSourceRangeList(CXSourceRangeList *ranges); 726276479Sdim 727276479Sdim/** 728202879Srdivacky * @} 729202879Srdivacky */ 730202379Srdivacky 731202879Srdivacky/** 732203955Srdivacky * \defgroup CINDEX_DIAG Diagnostic reporting 733203955Srdivacky * 734203955Srdivacky * @{ 735203955Srdivacky */ 736203955Srdivacky 737203955Srdivacky/** 738203955Srdivacky * \brief Describes the severity of a particular diagnostic. 739203955Srdivacky */ 740203955Srdivackyenum CXDiagnosticSeverity { 741203955Srdivacky /** 742205219Srdivacky * \brief A diagnostic that has been suppressed, e.g., by a command-line 743203955Srdivacky * option. 744203955Srdivacky */ 745203955Srdivacky CXDiagnostic_Ignored = 0, 746205219Srdivacky 747203955Srdivacky /** 748203955Srdivacky * \brief This diagnostic is a note that should be attached to the 749203955Srdivacky * previous (non-note) diagnostic. 750203955Srdivacky */ 751203955Srdivacky CXDiagnostic_Note = 1, 752203955Srdivacky 753203955Srdivacky /** 754203955Srdivacky * \brief This diagnostic indicates suspicious code that may not be 755203955Srdivacky * wrong. 756203955Srdivacky */ 757203955Srdivacky CXDiagnostic_Warning = 2, 758203955Srdivacky 759203955Srdivacky /** 760203955Srdivacky * \brief This diagnostic indicates that the code is ill-formed. 761203955Srdivacky */ 762203955Srdivacky CXDiagnostic_Error = 3, 763203955Srdivacky 764203955Srdivacky /** 765203955Srdivacky * \brief This diagnostic indicates that the code is ill-formed such 766203955Srdivacky * that future parser recovery is unlikely to produce useful 767203955Srdivacky * results. 768203955Srdivacky */ 769203955Srdivacky CXDiagnostic_Fatal = 4 770203955Srdivacky}; 771203955Srdivacky 772203955Srdivacky/** 773204643Srdivacky * \brief A single diagnostic, containing the diagnostic's severity, 774204643Srdivacky * location, text, source ranges, and fix-it hints. 775203955Srdivacky */ 776204643Srdivackytypedef void *CXDiagnostic; 777204643Srdivacky 778204643Srdivacky/** 779234353Sdim * \brief A group of CXDiagnostics. 780234353Sdim */ 781234353Sdimtypedef void *CXDiagnosticSet; 782234353Sdim 783234353Sdim/** 784234353Sdim * \brief Determine the number of diagnostics in a CXDiagnosticSet. 785234353Sdim */ 786234353SdimCINDEX_LINKAGE unsigned clang_getNumDiagnosticsInSet(CXDiagnosticSet Diags); 787234353Sdim 788234353Sdim/** 789234353Sdim * \brief Retrieve a diagnostic associated with the given CXDiagnosticSet. 790234353Sdim * 791239462Sdim * \param Diags the CXDiagnosticSet to query. 792234353Sdim * \param Index the zero-based diagnostic number to retrieve. 793234353Sdim * 794234353Sdim * \returns the requested diagnostic. This diagnostic must be freed 795234353Sdim * via a call to \c clang_disposeDiagnostic(). 796234353Sdim */ 797234353SdimCINDEX_LINKAGE CXDiagnostic clang_getDiagnosticInSet(CXDiagnosticSet Diags, 798234353Sdim unsigned Index); 799234353Sdim 800234353Sdim/** 801234353Sdim * \brief Describes the kind of error that occurred (if any) in a call to 802234353Sdim * \c clang_loadDiagnostics. 803234353Sdim */ 804234353Sdimenum CXLoadDiag_Error { 805234353Sdim /** 806234353Sdim * \brief Indicates that no error occurred. 807234353Sdim */ 808234353Sdim CXLoadDiag_None = 0, 809234353Sdim 810234353Sdim /** 811234353Sdim * \brief Indicates that an unknown error occurred while attempting to 812234353Sdim * deserialize diagnostics. 813234353Sdim */ 814234353Sdim CXLoadDiag_Unknown = 1, 815234353Sdim 816234353Sdim /** 817234353Sdim * \brief Indicates that the file containing the serialized diagnostics 818234353Sdim * could not be opened. 819234353Sdim */ 820234353Sdim CXLoadDiag_CannotLoad = 2, 821234353Sdim 822234353Sdim /** 823234353Sdim * \brief Indicates that the serialized diagnostics file is invalid or 824239462Sdim * corrupt. 825234353Sdim */ 826234353Sdim CXLoadDiag_InvalidFile = 3 827234353Sdim}; 828234353Sdim 829234353Sdim/** 830234353Sdim * \brief Deserialize a set of diagnostics from a Clang diagnostics bitcode 831239462Sdim * file. 832234353Sdim * 833239462Sdim * \param file The name of the file to deserialize. 834239462Sdim * \param error A pointer to a enum value recording if there was a problem 835234353Sdim * deserializing the diagnostics. 836239462Sdim * \param errorString A pointer to a CXString for recording the error string 837234353Sdim * if the file was not successfully loaded. 838234353Sdim * 839234353Sdim * \returns A loaded CXDiagnosticSet if successful, and NULL otherwise. These 840239462Sdim * diagnostics should be released using clang_disposeDiagnosticSet(). 841234353Sdim */ 842234353SdimCINDEX_LINKAGE CXDiagnosticSet clang_loadDiagnostics(const char *file, 843234353Sdim enum CXLoadDiag_Error *error, 844234353Sdim CXString *errorString); 845234353Sdim 846234353Sdim/** 847234353Sdim * \brief Release a CXDiagnosticSet and all of its contained diagnostics. 848234353Sdim */ 849234353SdimCINDEX_LINKAGE void clang_disposeDiagnosticSet(CXDiagnosticSet Diags); 850234353Sdim 851234353Sdim/** 852239462Sdim * \brief Retrieve the child diagnostics of a CXDiagnostic. 853239462Sdim * 854239462Sdim * This CXDiagnosticSet does not need to be released by 855261991Sdim * clang_disposeDiagnosticSet. 856234353Sdim */ 857234353SdimCINDEX_LINKAGE CXDiagnosticSet clang_getChildDiagnostics(CXDiagnostic D); 858234353Sdim 859234353Sdim/** 860204643Srdivacky * \brief Determine the number of diagnostics produced for the given 861204643Srdivacky * translation unit. 862204643Srdivacky */ 863204643SrdivackyCINDEX_LINKAGE unsigned clang_getNumDiagnostics(CXTranslationUnit Unit); 864204643Srdivacky 865204643Srdivacky/** 866204643Srdivacky * \brief Retrieve a diagnostic associated with the given translation unit. 867204643Srdivacky * 868204643Srdivacky * \param Unit the translation unit to query. 869204643Srdivacky * \param Index the zero-based diagnostic number to retrieve. 870204643Srdivacky * 871204643Srdivacky * \returns the requested diagnostic. This diagnostic must be freed 872204643Srdivacky * via a call to \c clang_disposeDiagnostic(). 873204643Srdivacky */ 874204643SrdivackyCINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit, 875204643Srdivacky unsigned Index); 876204643Srdivacky 877204643Srdivacky/** 878234353Sdim * \brief Retrieve the complete set of diagnostics associated with a 879234353Sdim * translation unit. 880234353Sdim * 881234353Sdim * \param Unit the translation unit to query. 882234353Sdim */ 883234353SdimCINDEX_LINKAGE CXDiagnosticSet 884234353Sdim clang_getDiagnosticSetFromTU(CXTranslationUnit Unit); 885234353Sdim 886234353Sdim/** 887204643Srdivacky * \brief Destroy a diagnostic. 888204643Srdivacky */ 889204643SrdivackyCINDEX_LINKAGE void clang_disposeDiagnostic(CXDiagnostic Diagnostic); 890204643Srdivacky 891204643Srdivacky/** 892204643Srdivacky * \brief Options to control the display of diagnostics. 893204643Srdivacky * 894204643Srdivacky * The values in this enum are meant to be combined to customize the 895261991Sdim * behavior of \c clang_formatDiagnostic(). 896204643Srdivacky */ 897204643Srdivackyenum CXDiagnosticDisplayOptions { 898203955Srdivacky /** 899204643Srdivacky * \brief Display the source-location information where the 900204643Srdivacky * diagnostic was located. 901204643Srdivacky * 902204643Srdivacky * When set, diagnostics will be prefixed by the file, line, and 903204643Srdivacky * (optionally) column to which the diagnostic refers. For example, 904204643Srdivacky * 905204643Srdivacky * \code 906204643Srdivacky * test.c:28: warning: extra tokens at end of #endif directive 907204643Srdivacky * \endcode 908204643Srdivacky * 909204643Srdivacky * This option corresponds to the clang flag \c -fshow-source-location. 910203955Srdivacky */ 911204643Srdivacky CXDiagnostic_DisplaySourceLocation = 0x01, 912203955Srdivacky 913203955Srdivacky /** 914204643Srdivacky * \brief If displaying the source-location information of the 915204643Srdivacky * diagnostic, also include the column number. 916204643Srdivacky * 917204643Srdivacky * This option corresponds to the clang flag \c -fshow-column. 918203955Srdivacky */ 919204643Srdivacky CXDiagnostic_DisplayColumn = 0x02, 920203955Srdivacky 921203955Srdivacky /** 922204643Srdivacky * \brief If displaying the source-location information of the 923204643Srdivacky * diagnostic, also include information about source ranges in a 924204643Srdivacky * machine-parsable format. 925204643Srdivacky * 926205219Srdivacky * This option corresponds to the clang flag 927204643Srdivacky * \c -fdiagnostics-print-source-range-info. 928203955Srdivacky */ 929218893Sdim CXDiagnostic_DisplaySourceRanges = 0x04, 930218893Sdim 931218893Sdim /** 932218893Sdim * \brief Display the option name associated with this diagnostic, if any. 933218893Sdim * 934218893Sdim * The option name displayed (e.g., -Wconversion) will be placed in brackets 935218893Sdim * after the diagnostic text. This option corresponds to the clang flag 936218893Sdim * \c -fdiagnostics-show-option. 937218893Sdim */ 938218893Sdim CXDiagnostic_DisplayOption = 0x08, 939218893Sdim 940218893Sdim /** 941218893Sdim * \brief Display the category number associated with this diagnostic, if any. 942218893Sdim * 943218893Sdim * The category number is displayed within brackets after the diagnostic text. 944218893Sdim * This option corresponds to the clang flag 945218893Sdim * \c -fdiagnostics-show-category=id. 946218893Sdim */ 947218893Sdim CXDiagnostic_DisplayCategoryId = 0x10, 948218893Sdim 949218893Sdim /** 950218893Sdim * \brief Display the category name associated with this diagnostic, if any. 951218893Sdim * 952218893Sdim * The category name is displayed within brackets after the diagnostic text. 953218893Sdim * This option corresponds to the clang flag 954218893Sdim * \c -fdiagnostics-show-category=name. 955218893Sdim */ 956218893Sdim CXDiagnostic_DisplayCategoryName = 0x20 957203955Srdivacky}; 958203955Srdivacky 959203955Srdivacky/** 960204643Srdivacky * \brief Format the given diagnostic in a manner that is suitable for display. 961204643Srdivacky * 962204643Srdivacky * This routine will format the given diagnostic to a string, rendering 963205219Srdivacky * the diagnostic according to the various options given. The 964205219Srdivacky * \c clang_defaultDiagnosticDisplayOptions() function returns the set of 965204643Srdivacky * options that most closely mimics the behavior of the clang compiler. 966204643Srdivacky * 967204643Srdivacky * \param Diagnostic The diagnostic to print. 968204643Srdivacky * 969205219Srdivacky * \param Options A set of options that control the diagnostic display, 970204643Srdivacky * created by combining \c CXDiagnosticDisplayOptions values. 971204643Srdivacky * 972204643Srdivacky * \returns A new string containing for formatted diagnostic. 973203955Srdivacky */ 974204643SrdivackyCINDEX_LINKAGE CXString clang_formatDiagnostic(CXDiagnostic Diagnostic, 975204643Srdivacky unsigned Options); 976203955Srdivacky 977203955Srdivacky/** 978204643Srdivacky * \brief Retrieve the set of display options most similar to the 979204643Srdivacky * default behavior of the clang compiler. 980203955Srdivacky * 981204643Srdivacky * \returns A set of display options suitable for use with \c 982261991Sdim * clang_formatDiagnostic(). 983203955Srdivacky */ 984204643SrdivackyCINDEX_LINKAGE unsigned clang_defaultDiagnosticDisplayOptions(void); 985203955Srdivacky 986203955Srdivacky/** 987203955Srdivacky * \brief Determine the severity of the given diagnostic. 988203955Srdivacky */ 989205219SrdivackyCINDEX_LINKAGE enum CXDiagnosticSeverity 990203955Srdivackyclang_getDiagnosticSeverity(CXDiagnostic); 991203955Srdivacky 992203955Srdivacky/** 993203955Srdivacky * \brief Retrieve the source location of the given diagnostic. 994203955Srdivacky * 995203955Srdivacky * This location is where Clang would print the caret ('^') when 996203955Srdivacky * displaying the diagnostic on the command line. 997203955Srdivacky */ 998203955SrdivackyCINDEX_LINKAGE CXSourceLocation clang_getDiagnosticLocation(CXDiagnostic); 999203955Srdivacky 1000203955Srdivacky/** 1001203955Srdivacky * \brief Retrieve the text of the given diagnostic. 1002203955Srdivacky */ 1003203955SrdivackyCINDEX_LINKAGE CXString clang_getDiagnosticSpelling(CXDiagnostic); 1004203955Srdivacky 1005203955Srdivacky/** 1006218893Sdim * \brief Retrieve the name of the command-line option that enabled this 1007218893Sdim * diagnostic. 1008218893Sdim * 1009218893Sdim * \param Diag The diagnostic to be queried. 1010218893Sdim * 1011218893Sdim * \param Disable If non-NULL, will be set to the option that disables this 1012218893Sdim * diagnostic (if any). 1013218893Sdim * 1014218893Sdim * \returns A string that contains the command-line option used to enable this 1015218893Sdim * warning, such as "-Wconversion" or "-pedantic". 1016218893Sdim */ 1017218893SdimCINDEX_LINKAGE CXString clang_getDiagnosticOption(CXDiagnostic Diag, 1018218893Sdim CXString *Disable); 1019218893Sdim 1020218893Sdim/** 1021218893Sdim * \brief Retrieve the category number for this diagnostic. 1022218893Sdim * 1023218893Sdim * Diagnostics can be categorized into groups along with other, related 1024218893Sdim * diagnostics (e.g., diagnostics under the same warning flag). This routine 1025218893Sdim * retrieves the category number for the given diagnostic. 1026218893Sdim * 1027218893Sdim * \returns The number of the category that contains this diagnostic, or zero 1028218893Sdim * if this diagnostic is uncategorized. 1029218893Sdim */ 1030218893SdimCINDEX_LINKAGE unsigned clang_getDiagnosticCategory(CXDiagnostic); 1031218893Sdim 1032218893Sdim/** 1033234353Sdim * \brief Retrieve the name of a particular diagnostic category. This 1034234353Sdim * is now deprecated. Use clang_getDiagnosticCategoryText() 1035234353Sdim * instead. 1036218893Sdim * 1037218893Sdim * \param Category A diagnostic category number, as returned by 1038218893Sdim * \c clang_getDiagnosticCategory(). 1039218893Sdim * 1040218893Sdim * \returns The name of the given diagnostic category. 1041218893Sdim */ 1042234353SdimCINDEX_DEPRECATED CINDEX_LINKAGE 1043234353SdimCXString clang_getDiagnosticCategoryName(unsigned Category); 1044234353Sdim 1045234353Sdim/** 1046234353Sdim * \brief Retrieve the diagnostic category text for a given diagnostic. 1047234353Sdim * 1048234353Sdim * \returns The text of the given diagnostic category. 1049234353Sdim */ 1050234353SdimCINDEX_LINKAGE CXString clang_getDiagnosticCategoryText(CXDiagnostic); 1051218893Sdim 1052218893Sdim/** 1053203955Srdivacky * \brief Determine the number of source ranges associated with the given 1054203955Srdivacky * diagnostic. 1055203955Srdivacky */ 1056203955SrdivackyCINDEX_LINKAGE unsigned clang_getDiagnosticNumRanges(CXDiagnostic); 1057205219Srdivacky 1058203955Srdivacky/** 1059203955Srdivacky * \brief Retrieve a source range associated with the diagnostic. 1060203955Srdivacky * 1061203955Srdivacky * A diagnostic's source ranges highlight important elements in the source 1062203955Srdivacky * code. On the command line, Clang displays source ranges by 1063205219Srdivacky * underlining them with '~' characters. 1064203955Srdivacky * 1065203955Srdivacky * \param Diagnostic the diagnostic whose range is being extracted. 1066203955Srdivacky * 1067205219Srdivacky * \param Range the zero-based index specifying which range to 1068203955Srdivacky * 1069203955Srdivacky * \returns the requested source range. 1070203955Srdivacky */ 1071205219SrdivackyCINDEX_LINKAGE CXSourceRange clang_getDiagnosticRange(CXDiagnostic Diagnostic, 1072203955Srdivacky unsigned Range); 1073203955Srdivacky 1074203955Srdivacky/** 1075203955Srdivacky * \brief Determine the number of fix-it hints associated with the 1076203955Srdivacky * given diagnostic. 1077203955Srdivacky */ 1078203955SrdivackyCINDEX_LINKAGE unsigned clang_getDiagnosticNumFixIts(CXDiagnostic Diagnostic); 1079203955Srdivacky 1080203955Srdivacky/** 1081204643Srdivacky * \brief Retrieve the replacement information for a given fix-it. 1082203955Srdivacky * 1083204643Srdivacky * Fix-its are described in terms of a source range whose contents 1084204643Srdivacky * should be replaced by a string. This approach generalizes over 1085204643Srdivacky * three kinds of operations: removal of source code (the range covers 1086204643Srdivacky * the code to be removed and the replacement string is empty), 1087204643Srdivacky * replacement of source code (the range covers the code to be 1088204643Srdivacky * replaced and the replacement string provides the new code), and 1089204643Srdivacky * insertion (both the start and end of the range point at the 1090204643Srdivacky * insertion location, and the replacement string provides the text to 1091204643Srdivacky * insert). 1092203955Srdivacky * 1093204643Srdivacky * \param Diagnostic The diagnostic whose fix-its are being queried. 1094203955Srdivacky * 1095204643Srdivacky * \param FixIt The zero-based index of the fix-it. 1096203955Srdivacky * 1097204643Srdivacky * \param ReplacementRange The source range whose contents will be 1098204643Srdivacky * replaced with the returned replacement string. Note that source 1099204643Srdivacky * ranges are half-open ranges [a, b), so the source code should be 1100204643Srdivacky * replaced from a and up to (but not including) b. 1101203955Srdivacky * 1102204643Srdivacky * \returns A string containing text that should be replace the source 1103204643Srdivacky * code indicated by the \c ReplacementRange. 1104203955Srdivacky */ 1105205219SrdivackyCINDEX_LINKAGE CXString clang_getDiagnosticFixIt(CXDiagnostic Diagnostic, 1106204643Srdivacky unsigned FixIt, 1107204643Srdivacky CXSourceRange *ReplacementRange); 1108203955Srdivacky 1109203955Srdivacky/** 1110203955Srdivacky * @} 1111203955Srdivacky */ 1112203955Srdivacky 1113203955Srdivacky/** 1114203955Srdivacky * \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation 1115203955Srdivacky * 1116203955Srdivacky * The routines in this group provide the ability to create and destroy 1117203955Srdivacky * translation units from files, either by parsing the contents of the files or 1118203955Srdivacky * by reading in a serialized representation of a translation unit. 1119203955Srdivacky * 1120203955Srdivacky * @{ 1121203955Srdivacky */ 1122205219Srdivacky 1123203955Srdivacky/** 1124203955Srdivacky * \brief Get the original translation unit source file name. 1125203955Srdivacky */ 1126203955SrdivackyCINDEX_LINKAGE CXString 1127203955Srdivackyclang_getTranslationUnitSpelling(CXTranslationUnit CTUnit); 1128203955Srdivacky 1129203955Srdivacky/** 1130203955Srdivacky * \brief Return the CXTranslationUnit for a given source file and the provided 1131203955Srdivacky * command line arguments one would pass to the compiler. 1132203955Srdivacky * 1133203955Srdivacky * Note: The 'source_filename' argument is optional. If the caller provides a 1134203955Srdivacky * NULL pointer, the name of the source file is expected to reside in the 1135203955Srdivacky * specified command line arguments. 1136203955Srdivacky * 1137203955Srdivacky * Note: When encountered in 'clang_command_line_args', the following options 1138203955Srdivacky * are ignored: 1139203955Srdivacky * 1140203955Srdivacky * '-c' 1141203955Srdivacky * '-emit-ast' 1142203955Srdivacky * '-fsyntax-only' 1143239462Sdim * '-o \<output file>' (both '-o' and '\<output file>' are ignored) 1144203955Srdivacky * 1145218893Sdim * \param CIdx The index object with which the translation unit will be 1146218893Sdim * associated. 1147203955Srdivacky * 1148239462Sdim * \param source_filename The name of the source file to load, or NULL if the 1149218893Sdim * source file is included in \p clang_command_line_args. 1150203955Srdivacky * 1151218893Sdim * \param num_clang_command_line_args The number of command-line arguments in 1152218893Sdim * \p clang_command_line_args. 1153218893Sdim * 1154218893Sdim * \param clang_command_line_args The command-line arguments that would be 1155218893Sdim * passed to the \c clang executable if it were being invoked out-of-process. 1156218893Sdim * These command-line options will be parsed and will affect how the translation 1157218893Sdim * unit is parsed. Note that the following options are ignored: '-c', 1158239462Sdim * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'. 1159218893Sdim * 1160203955Srdivacky * \param num_unsaved_files the number of unsaved file entries in \p 1161203955Srdivacky * unsaved_files. 1162203955Srdivacky * 1163203955Srdivacky * \param unsaved_files the files that have not yet been saved to disk 1164203955Srdivacky * but may be required for code completion, including the contents of 1165207619Srdivacky * those files. The contents and name of these files (as specified by 1166207619Srdivacky * CXUnsavedFile) are copied when necessary, so the client only needs to 1167207619Srdivacky * guarantee their validity until the call to this function returns. 1168203955Srdivacky */ 1169203955SrdivackyCINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnitFromSourceFile( 1170203955Srdivacky CXIndex CIdx, 1171203955Srdivacky const char *source_filename, 1172203955Srdivacky int num_clang_command_line_args, 1173212904Sdim const char * const *clang_command_line_args, 1174203955Srdivacky unsigned num_unsaved_files, 1175204643Srdivacky struct CXUnsavedFile *unsaved_files); 1176205219Srdivacky 1177203955Srdivacky/** 1178276479Sdim * \brief Same as \c clang_createTranslationUnit2, but returns 1179276479Sdim * the \c CXTranslationUnit instead of an error code. In case of an error this 1180276479Sdim * routine returns a \c NULL \c CXTranslationUnit, without further detailed 1181276479Sdim * error codes. 1182203955Srdivacky */ 1183276479SdimCINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnit( 1184276479Sdim CXIndex CIdx, 1185276479Sdim const char *ast_filename); 1186203955Srdivacky 1187203955Srdivacky/** 1188276479Sdim * \brief Create a translation unit from an AST file (\c -emit-ast). 1189276479Sdim * 1190276479Sdim * \param[out] out_TU A non-NULL pointer to store the created 1191276479Sdim * \c CXTranslationUnit. 1192276479Sdim * 1193276479Sdim * \returns Zero on success, otherwise returns an error code. 1194276479Sdim */ 1195276479SdimCINDEX_LINKAGE enum CXErrorCode clang_createTranslationUnit2( 1196276479Sdim CXIndex CIdx, 1197276479Sdim const char *ast_filename, 1198276479Sdim CXTranslationUnit *out_TU); 1199276479Sdim 1200276479Sdim/** 1201212904Sdim * \brief Flags that control the creation of translation units. 1202212904Sdim * 1203212904Sdim * The enumerators in this enumeration type are meant to be bitwise 1204212904Sdim * ORed together to specify which options should be used when 1205212904Sdim * constructing the translation unit. 1206212904Sdim */ 1207212904Sdimenum CXTranslationUnit_Flags { 1208212904Sdim /** 1209212904Sdim * \brief Used to indicate that no special translation-unit options are 1210212904Sdim * needed. 1211212904Sdim */ 1212212904Sdim CXTranslationUnit_None = 0x0, 1213212904Sdim 1214212904Sdim /** 1215212904Sdim * \brief Used to indicate that the parser should construct a "detailed" 1216212904Sdim * preprocessing record, including all macro definitions and instantiations. 1217212904Sdim * 1218212904Sdim * Constructing a detailed preprocessing record requires more memory 1219212904Sdim * and time to parse, since the information contained in the record 1220212904Sdim * is usually not retained. However, it can be useful for 1221212904Sdim * applications that require more detailed information about the 1222212904Sdim * behavior of the preprocessor. 1223212904Sdim */ 1224212904Sdim CXTranslationUnit_DetailedPreprocessingRecord = 0x01, 1225212904Sdim 1226212904Sdim /** 1227212904Sdim * \brief Used to indicate that the translation unit is incomplete. 1228212904Sdim * 1229212904Sdim * When a translation unit is considered "incomplete", semantic 1230212904Sdim * analysis that is typically performed at the end of the 1231212904Sdim * translation unit will be suppressed. For example, this suppresses 1232212904Sdim * the completion of tentative declarations in C and of 1233212904Sdim * instantiation of implicitly-instantiation function templates in 1234212904Sdim * C++. This option is typically used when parsing a header with the 1235212904Sdim * intent of producing a precompiled header. 1236212904Sdim */ 1237212904Sdim CXTranslationUnit_Incomplete = 0x02, 1238212904Sdim 1239212904Sdim /** 1240212904Sdim * \brief Used to indicate that the translation unit should be built with an 1241212904Sdim * implicit precompiled header for the preamble. 1242212904Sdim * 1243212904Sdim * An implicit precompiled header is used as an optimization when a 1244212904Sdim * particular translation unit is likely to be reparsed many times 1245212904Sdim * when the sources aren't changing that often. In this case, an 1246212904Sdim * implicit precompiled header will be built containing all of the 1247212904Sdim * initial includes at the top of the main file (what we refer to as 1248212904Sdim * the "preamble" of the file). In subsequent parses, if the 1249212904Sdim * preamble or the files in it have not changed, \c 1250212904Sdim * clang_reparseTranslationUnit() will re-use the implicit 1251212904Sdim * precompiled header to improve parsing performance. 1252212904Sdim */ 1253212904Sdim CXTranslationUnit_PrecompiledPreamble = 0x04, 1254212904Sdim 1255212904Sdim /** 1256212904Sdim * \brief Used to indicate that the translation unit should cache some 1257212904Sdim * code-completion results with each reparse of the source file. 1258212904Sdim * 1259212904Sdim * Caching of code-completion results is a performance optimization that 1260212904Sdim * introduces some overhead to reparsing but improves the performance of 1261212904Sdim * code-completion operations. 1262212904Sdim */ 1263218893Sdim CXTranslationUnit_CacheCompletionResults = 0x08, 1264243830Sdim 1265218893Sdim /** 1266243830Sdim * \brief Used to indicate that the translation unit will be serialized with 1267243830Sdim * \c clang_saveTranslationUnit. 1268218893Sdim * 1269243830Sdim * This option is typically used when parsing a header with the intent of 1270243830Sdim * producing a precompiled header. 1271218893Sdim */ 1272243830Sdim CXTranslationUnit_ForSerialization = 0x10, 1273218893Sdim 1274218893Sdim /** 1275226633Sdim * \brief DEPRECATED: Enabled chained precompiled preambles in C++. 1276218893Sdim * 1277218893Sdim * Note: this is a *temporary* option that is available only while 1278226633Sdim * we are testing C++ precompiled preamble support. It is deprecated. 1279218893Sdim */ 1280223017Sdim CXTranslationUnit_CXXChainedPCH = 0x20, 1281224145Sdim 1282224145Sdim /** 1283234353Sdim * \brief Used to indicate that function/method bodies should be skipped while 1284234353Sdim * parsing. 1285224145Sdim * 1286234353Sdim * This option can be used to search for declarations/definitions while 1287234353Sdim * ignoring the usages. 1288224145Sdim */ 1289239462Sdim CXTranslationUnit_SkipFunctionBodies = 0x40, 1290239462Sdim 1291239462Sdim /** 1292239462Sdim * \brief Used to indicate that brief documentation comments should be 1293239462Sdim * included into the set of code completions returned from this translation 1294239462Sdim * unit. 1295239462Sdim */ 1296296417Sdim CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 0x80, 1297296417Sdim 1298296417Sdim /** 1299296417Sdim * \brief Used to indicate that the precompiled preamble should be created on 1300296417Sdim * the first parse. Otherwise it will be created on the first reparse. This 1301296417Sdim * trades runtime on the first parse (serializing the preamble takes time) for 1302296417Sdim * reduced runtime on the second parse (can now reuse the preamble). 1303296417Sdim */ 1304309124Sdim CXTranslationUnit_CreatePreambleOnFirstParse = 0x100, 1305309124Sdim 1306309124Sdim /** 1307309124Sdim * \brief Do not stop processing when fatal errors are encountered. 1308309124Sdim * 1309309124Sdim * When fatal errors are encountered while parsing a translation unit, 1310309124Sdim * semantic analysis is typically stopped early when compiling code. A common 1311309124Sdim * source for fatal errors are unresolvable include files. For the 1312309124Sdim * purposes of an IDE, this is undesirable behavior and as much information 1313309124Sdim * as possible should be reported. Use this flag to enable this behavior. 1314309124Sdim */ 1315321369Sdim CXTranslationUnit_KeepGoing = 0x200, 1316321369Sdim 1317321369Sdim /** 1318321369Sdim * \brief Sets the preprocessor in a mode for parsing a single file only. 1319321369Sdim */ 1320321369Sdim CXTranslationUnit_SingleFileParse = 0x400 1321212904Sdim}; 1322212904Sdim 1323212904Sdim/** 1324212904Sdim * \brief Returns the set of flags that is suitable for parsing a translation 1325212904Sdim * unit that is being edited. 1326212904Sdim * 1327212904Sdim * The set of flags returned provide options for \c clang_parseTranslationUnit() 1328212904Sdim * to indicate that the translation unit is likely to be reparsed many times, 1329212904Sdim * either explicitly (via \c clang_reparseTranslationUnit()) or implicitly 1330212904Sdim * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag 1331212904Sdim * set contains an unspecified set of optimizations (e.g., the precompiled 1332212904Sdim * preamble) geared toward improving the performance of these routines. The 1333212904Sdim * set of optimizations enabled may change from one version to the next. 1334212904Sdim */ 1335212904SdimCINDEX_LINKAGE unsigned clang_defaultEditingTranslationUnitOptions(void); 1336276479Sdim 1337212904Sdim/** 1338276479Sdim * \brief Same as \c clang_parseTranslationUnit2, but returns 1339276479Sdim * the \c CXTranslationUnit instead of an error code. In case of an error this 1340276479Sdim * routine returns a \c NULL \c CXTranslationUnit, without further detailed 1341276479Sdim * error codes. 1342276479Sdim */ 1343276479SdimCINDEX_LINKAGE CXTranslationUnit 1344276479Sdimclang_parseTranslationUnit(CXIndex CIdx, 1345276479Sdim const char *source_filename, 1346276479Sdim const char *const *command_line_args, 1347276479Sdim int num_command_line_args, 1348276479Sdim struct CXUnsavedFile *unsaved_files, 1349276479Sdim unsigned num_unsaved_files, 1350276479Sdim unsigned options); 1351276479Sdim 1352276479Sdim/** 1353212904Sdim * \brief Parse the given source file and the translation unit corresponding 1354212904Sdim * to that file. 1355212904Sdim * 1356212904Sdim * This routine is the main entry point for the Clang C API, providing the 1357212904Sdim * ability to parse a source file into a translation unit that can then be 1358212904Sdim * queried by other functions in the API. This routine accepts a set of 1359212904Sdim * command-line arguments so that the compilation can be configured in the same 1360212904Sdim * way that the compiler is configured on the command line. 1361212904Sdim * 1362212904Sdim * \param CIdx The index object with which the translation unit will be 1363212904Sdim * associated. 1364212904Sdim * 1365212904Sdim * \param source_filename The name of the source file to load, or NULL if the 1366276479Sdim * source file is included in \c command_line_args. 1367212904Sdim * 1368212904Sdim * \param command_line_args The command-line arguments that would be 1369212904Sdim * passed to the \c clang executable if it were being invoked out-of-process. 1370212904Sdim * These command-line options will be parsed and will affect how the translation 1371212904Sdim * unit is parsed. Note that the following options are ignored: '-c', 1372239462Sdim * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'. 1373212904Sdim * 1374212904Sdim * \param num_command_line_args The number of command-line arguments in 1375276479Sdim * \c command_line_args. 1376212904Sdim * 1377212904Sdim * \param unsaved_files the files that have not yet been saved to disk 1378212904Sdim * but may be required for parsing, including the contents of 1379212904Sdim * those files. The contents and name of these files (as specified by 1380212904Sdim * CXUnsavedFile) are copied when necessary, so the client only needs to 1381212904Sdim * guarantee their validity until the call to this function returns. 1382212904Sdim * 1383212904Sdim * \param num_unsaved_files the number of unsaved file entries in \p 1384212904Sdim * unsaved_files. 1385212904Sdim * 1386212904Sdim * \param options A bitmask of options that affects how the translation unit 1387212904Sdim * is managed but not its compilation. This should be a bitwise OR of the 1388212904Sdim * CXTranslationUnit_XXX flags. 1389212904Sdim * 1390276479Sdim * \param[out] out_TU A non-NULL pointer to store the created 1391276479Sdim * \c CXTranslationUnit, describing the parsed code and containing any 1392276479Sdim * diagnostics produced by the compiler. 1393276479Sdim * 1394276479Sdim * \returns Zero on success, otherwise returns an error code. 1395212904Sdim */ 1396276479SdimCINDEX_LINKAGE enum CXErrorCode 1397276479Sdimclang_parseTranslationUnit2(CXIndex CIdx, 1398276479Sdim const char *source_filename, 1399276479Sdim const char *const *command_line_args, 1400276479Sdim int num_command_line_args, 1401276479Sdim struct CXUnsavedFile *unsaved_files, 1402276479Sdim unsigned num_unsaved_files, 1403276479Sdim unsigned options, 1404276479Sdim CXTranslationUnit *out_TU); 1405276479Sdim 1406212904Sdim/** 1407296417Sdim * \brief Same as clang_parseTranslationUnit2 but requires a full command line 1408296417Sdim * for \c command_line_args including argv[0]. This is useful if the standard 1409296417Sdim * library paths are relative to the binary. 1410296417Sdim */ 1411296417SdimCINDEX_LINKAGE enum CXErrorCode clang_parseTranslationUnit2FullArgv( 1412296417Sdim CXIndex CIdx, const char *source_filename, 1413296417Sdim const char *const *command_line_args, int num_command_line_args, 1414296417Sdim struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files, 1415296417Sdim unsigned options, CXTranslationUnit *out_TU); 1416296417Sdim 1417296417Sdim/** 1418212904Sdim * \brief Flags that control how translation units are saved. 1419212904Sdim * 1420212904Sdim * The enumerators in this enumeration type are meant to be bitwise 1421212904Sdim * ORed together to specify which options should be used when 1422212904Sdim * saving the translation unit. 1423212904Sdim */ 1424212904Sdimenum CXSaveTranslationUnit_Flags { 1425212904Sdim /** 1426212904Sdim * \brief Used to indicate that no special saving options are needed. 1427212904Sdim */ 1428212904Sdim CXSaveTranslationUnit_None = 0x0 1429212904Sdim}; 1430212904Sdim 1431212904Sdim/** 1432212904Sdim * \brief Returns the set of flags that is suitable for saving a translation 1433212904Sdim * unit. 1434212904Sdim * 1435212904Sdim * The set of flags returned provide options for 1436212904Sdim * \c clang_saveTranslationUnit() by default. The returned flag 1437212904Sdim * set contains an unspecified set of options that save translation units with 1438212904Sdim * the most commonly-requested data. 1439212904Sdim */ 1440212904SdimCINDEX_LINKAGE unsigned clang_defaultSaveOptions(CXTranslationUnit TU); 1441212904Sdim 1442212904Sdim/** 1443224145Sdim * \brief Describes the kind of error that occurred (if any) in a call to 1444224145Sdim * \c clang_saveTranslationUnit(). 1445224145Sdim */ 1446224145Sdimenum CXSaveError { 1447224145Sdim /** 1448224145Sdim * \brief Indicates that no error occurred while saving a translation unit. 1449224145Sdim */ 1450224145Sdim CXSaveError_None = 0, 1451224145Sdim 1452224145Sdim /** 1453224145Sdim * \brief Indicates that an unknown error occurred while attempting to save 1454224145Sdim * the file. 1455224145Sdim * 1456224145Sdim * This error typically indicates that file I/O failed when attempting to 1457224145Sdim * write the file. 1458224145Sdim */ 1459224145Sdim CXSaveError_Unknown = 1, 1460224145Sdim 1461224145Sdim /** 1462224145Sdim * \brief Indicates that errors during translation prevented this attempt 1463224145Sdim * to save the translation unit. 1464224145Sdim * 1465224145Sdim * Errors that prevent the translation unit from being saved can be 1466224145Sdim * extracted using \c clang_getNumDiagnostics() and \c clang_getDiagnostic(). 1467224145Sdim */ 1468224145Sdim CXSaveError_TranslationErrors = 2, 1469224145Sdim 1470224145Sdim /** 1471224145Sdim * \brief Indicates that the translation unit to be saved was somehow 1472224145Sdim * invalid (e.g., NULL). 1473224145Sdim */ 1474224145Sdim CXSaveError_InvalidTU = 3 1475224145Sdim}; 1476224145Sdim 1477224145Sdim/** 1478212904Sdim * \brief Saves a translation unit into a serialized representation of 1479212904Sdim * that translation unit on disk. 1480212904Sdim * 1481212904Sdim * Any translation unit that was parsed without error can be saved 1482212904Sdim * into a file. The translation unit can then be deserialized into a 1483212904Sdim * new \c CXTranslationUnit with \c clang_createTranslationUnit() or, 1484212904Sdim * if it is an incomplete translation unit that corresponds to a 1485212904Sdim * header, used as a precompiled header when parsing other translation 1486212904Sdim * units. 1487212904Sdim * 1488212904Sdim * \param TU The translation unit to save. 1489212904Sdim * 1490212904Sdim * \param FileName The file to which the translation unit will be saved. 1491212904Sdim * 1492212904Sdim * \param options A bitmask of options that affects how the translation unit 1493212904Sdim * is saved. This should be a bitwise OR of the 1494212904Sdim * CXSaveTranslationUnit_XXX flags. 1495212904Sdim * 1496224145Sdim * \returns A value that will match one of the enumerators of the CXSaveError 1497224145Sdim * enumeration. Zero (CXSaveError_None) indicates that the translation unit was 1498224145Sdim * saved successfully, while a non-zero value indicates that a problem occurred. 1499212904Sdim */ 1500212904SdimCINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU, 1501212904Sdim const char *FileName, 1502212904Sdim unsigned options); 1503212904Sdim 1504212904Sdim/** 1505321369Sdim * \brief Suspend a translation unit in order to free memory associated with it. 1506321369Sdim * 1507321369Sdim * A suspended translation unit uses significantly less memory but on the other 1508321369Sdim * side does not support any other calls than \c clang_reparseTranslationUnit 1509321369Sdim * to resume it or \c clang_disposeTranslationUnit to dispose it completely. 1510321369Sdim */ 1511321369SdimCINDEX_LINKAGE unsigned clang_suspendTranslationUnit(CXTranslationUnit); 1512321369Sdim 1513321369Sdim/** 1514203955Srdivacky * \brief Destroy the specified CXTranslationUnit object. 1515203955Srdivacky */ 1516203955SrdivackyCINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit); 1517205219Srdivacky 1518203955Srdivacky/** 1519212904Sdim * \brief Flags that control the reparsing of translation units. 1520212904Sdim * 1521212904Sdim * The enumerators in this enumeration type are meant to be bitwise 1522212904Sdim * ORed together to specify which options should be used when 1523212904Sdim * reparsing the translation unit. 1524212904Sdim */ 1525212904Sdimenum CXReparse_Flags { 1526212904Sdim /** 1527212904Sdim * \brief Used to indicate that no special reparsing options are needed. 1528212904Sdim */ 1529212904Sdim CXReparse_None = 0x0 1530212904Sdim}; 1531212904Sdim 1532212904Sdim/** 1533212904Sdim * \brief Returns the set of flags that is suitable for reparsing a translation 1534212904Sdim * unit. 1535212904Sdim * 1536212904Sdim * The set of flags returned provide options for 1537212904Sdim * \c clang_reparseTranslationUnit() by default. The returned flag 1538212904Sdim * set contains an unspecified set of optimizations geared toward common uses 1539212904Sdim * of reparsing. The set of optimizations enabled may change from one version 1540212904Sdim * to the next. 1541212904Sdim */ 1542212904SdimCINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU); 1543212904Sdim 1544212904Sdim/** 1545212904Sdim * \brief Reparse the source files that produced this translation unit. 1546212904Sdim * 1547212904Sdim * This routine can be used to re-parse the source files that originally 1548212904Sdim * created the given translation unit, for example because those source files 1549212904Sdim * have changed (either on disk or as passed via \p unsaved_files). The 1550212904Sdim * source code will be reparsed with the same command-line options as it 1551212904Sdim * was originally parsed. 1552212904Sdim * 1553212904Sdim * Reparsing a translation unit invalidates all cursors and source locations 1554212904Sdim * that refer into that translation unit. This makes reparsing a translation 1555212904Sdim * unit semantically equivalent to destroying the translation unit and then 1556212904Sdim * creating a new translation unit with the same command-line arguments. 1557212904Sdim * However, it may be more efficient to reparse a translation 1558212904Sdim * unit using this routine. 1559212904Sdim * 1560212904Sdim * \param TU The translation unit whose contents will be re-parsed. The 1561212904Sdim * translation unit must originally have been built with 1562212904Sdim * \c clang_createTranslationUnitFromSourceFile(). 1563212904Sdim * 1564212904Sdim * \param num_unsaved_files The number of unsaved file entries in \p 1565212904Sdim * unsaved_files. 1566212904Sdim * 1567212904Sdim * \param unsaved_files The files that have not yet been saved to disk 1568212904Sdim * but may be required for parsing, including the contents of 1569212904Sdim * those files. The contents and name of these files (as specified by 1570212904Sdim * CXUnsavedFile) are copied when necessary, so the client only needs to 1571212904Sdim * guarantee their validity until the call to this function returns. 1572212904Sdim * 1573212904Sdim * \param options A bitset of options composed of the flags in CXReparse_Flags. 1574212904Sdim * The function \c clang_defaultReparseOptions() produces a default set of 1575212904Sdim * options recommended for most uses, based on the translation unit. 1576212904Sdim * 1577276479Sdim * \returns 0 if the sources could be reparsed. A non-zero error code will be 1578212904Sdim * returned if reparsing was impossible, such that the translation unit is 1579276479Sdim * invalid. In such cases, the only valid call for \c TU is 1580276479Sdim * \c clang_disposeTranslationUnit(TU). The error codes returned by this 1581276479Sdim * routine are described by the \c CXErrorCode enum. 1582212904Sdim */ 1583212904SdimCINDEX_LINKAGE int clang_reparseTranslationUnit(CXTranslationUnit TU, 1584212904Sdim unsigned num_unsaved_files, 1585212904Sdim struct CXUnsavedFile *unsaved_files, 1586212904Sdim unsigned options); 1587221345Sdim 1588212904Sdim/** 1589221345Sdim * \brief Categorizes how memory is being used by a translation unit. 1590221345Sdim */ 1591221345Sdimenum CXTUResourceUsageKind { 1592221345Sdim CXTUResourceUsage_AST = 1, 1593221345Sdim CXTUResourceUsage_Identifiers = 2, 1594221345Sdim CXTUResourceUsage_Selectors = 3, 1595221345Sdim CXTUResourceUsage_GlobalCompletionResults = 4, 1596221345Sdim CXTUResourceUsage_SourceManagerContentCache = 5, 1597221345Sdim CXTUResourceUsage_AST_SideTables = 6, 1598221345Sdim CXTUResourceUsage_SourceManager_Membuffer_Malloc = 7, 1599221345Sdim CXTUResourceUsage_SourceManager_Membuffer_MMap = 8, 1600221345Sdim CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc = 9, 1601221345Sdim CXTUResourceUsage_ExternalASTSource_Membuffer_MMap = 10, 1602223017Sdim CXTUResourceUsage_Preprocessor = 11, 1603223017Sdim CXTUResourceUsage_PreprocessingRecord = 12, 1604226633Sdim CXTUResourceUsage_SourceManager_DataStructures = 13, 1605226633Sdim CXTUResourceUsage_Preprocessor_HeaderSearch = 14, 1606221345Sdim CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST, 1607221345Sdim CXTUResourceUsage_MEMORY_IN_BYTES_END = 1608226633Sdim CXTUResourceUsage_Preprocessor_HeaderSearch, 1609221345Sdim 1610221345Sdim CXTUResourceUsage_First = CXTUResourceUsage_AST, 1611226633Sdim CXTUResourceUsage_Last = CXTUResourceUsage_Preprocessor_HeaderSearch 1612221345Sdim}; 1613221345Sdim 1614221345Sdim/** 1615221345Sdim * \brief Returns the human-readable null-terminated C string that represents 1616221345Sdim * the name of the memory category. This string should never be freed. 1617221345Sdim */ 1618221345SdimCINDEX_LINKAGE 1619221345Sdimconst char *clang_getTUResourceUsageName(enum CXTUResourceUsageKind kind); 1620221345Sdim 1621221345Sdimtypedef struct CXTUResourceUsageEntry { 1622221345Sdim /* \brief The memory usage category. */ 1623221345Sdim enum CXTUResourceUsageKind kind; 1624221345Sdim /* \brief Amount of resources used. 1625221345Sdim The units will depend on the resource kind. */ 1626221345Sdim unsigned long amount; 1627221345Sdim} CXTUResourceUsageEntry; 1628221345Sdim 1629221345Sdim/** 1630221345Sdim * \brief The memory usage of a CXTranslationUnit, broken into categories. 1631221345Sdim */ 1632221345Sdimtypedef struct CXTUResourceUsage { 1633221345Sdim /* \brief Private data member, used for queries. */ 1634221345Sdim void *data; 1635221345Sdim 1636221345Sdim /* \brief The number of entries in the 'entries' array. */ 1637221345Sdim unsigned numEntries; 1638221345Sdim 1639221345Sdim /* \brief An array of key-value pairs, representing the breakdown of memory 1640221345Sdim usage. */ 1641221345Sdim CXTUResourceUsageEntry *entries; 1642221345Sdim 1643221345Sdim} CXTUResourceUsage; 1644221345Sdim 1645221345Sdim/** 1646221345Sdim * \brief Return the memory usage of a translation unit. This object 1647221345Sdim * should be released with clang_disposeCXTUResourceUsage(). 1648221345Sdim */ 1649221345SdimCINDEX_LINKAGE CXTUResourceUsage clang_getCXTUResourceUsage(CXTranslationUnit TU); 1650221345Sdim 1651221345SdimCINDEX_LINKAGE void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage); 1652221345Sdim 1653221345Sdim/** 1654321369Sdim * \brief Get target information for this translation unit. 1655321369Sdim * 1656321369Sdim * The CXTargetInfo object cannot outlive the CXTranslationUnit object. 1657321369Sdim */ 1658321369SdimCINDEX_LINKAGE CXTargetInfo 1659321369Sdimclang_getTranslationUnitTargetInfo(CXTranslationUnit CTUnit); 1660321369Sdim 1661321369Sdim/** 1662321369Sdim * \brief Destroy the CXTargetInfo object. 1663321369Sdim */ 1664321369SdimCINDEX_LINKAGE void 1665321369Sdimclang_TargetInfo_dispose(CXTargetInfo Info); 1666321369Sdim 1667321369Sdim/** 1668321369Sdim * \brief Get the normalized target triple as a string. 1669321369Sdim * 1670321369Sdim * Returns the empty string in case of any error. 1671321369Sdim */ 1672321369SdimCINDEX_LINKAGE CXString 1673321369Sdimclang_TargetInfo_getTriple(CXTargetInfo Info); 1674321369Sdim 1675321369Sdim/** 1676321369Sdim * \brief Get the pointer width of the target in bits. 1677321369Sdim * 1678321369Sdim * Returns -1 in case of error. 1679321369Sdim */ 1680321369SdimCINDEX_LINKAGE int 1681321369Sdimclang_TargetInfo_getPointerWidth(CXTargetInfo Info); 1682321369Sdim 1683321369Sdim/** 1684203955Srdivacky * @} 1685203955Srdivacky */ 1686205219Srdivacky 1687203955Srdivacky/** 1688202879Srdivacky * \brief Describes the kind of entity that a cursor refers to. 1689202379Srdivacky */ 1690202879Srdivackyenum CXCursorKind { 1691202879Srdivacky /* Declarations */ 1692203955Srdivacky /** 1693202879Srdivacky * \brief A declaration whose specific kind is not exposed via this 1694203955Srdivacky * interface. 1695202879Srdivacky * 1696202879Srdivacky * Unexposed declarations have the same operations as any other kind 1697202879Srdivacky * of declaration; one can extract their location information, 1698202879Srdivacky * spelling, find their definitions, etc. However, the specific kind 1699202879Srdivacky * of the declaration is not reported. 1700202879Srdivacky */ 1701202879Srdivacky CXCursor_UnexposedDecl = 1, 1702202879Srdivacky /** \brief A C or C++ struct. */ 1703203955Srdivacky CXCursor_StructDecl = 2, 1704202879Srdivacky /** \brief A C or C++ union. */ 1705202879Srdivacky CXCursor_UnionDecl = 3, 1706202879Srdivacky /** \brief A C++ class. */ 1707202879Srdivacky CXCursor_ClassDecl = 4, 1708202879Srdivacky /** \brief An enumeration. */ 1709202879Srdivacky CXCursor_EnumDecl = 5, 1710203955Srdivacky /** 1711202879Srdivacky * \brief A field (in C) or non-static data member (in C++) in a 1712202879Srdivacky * struct, union, or C++ class. 1713202879Srdivacky */ 1714202879Srdivacky CXCursor_FieldDecl = 6, 1715202879Srdivacky /** \brief An enumerator constant. */ 1716202879Srdivacky CXCursor_EnumConstantDecl = 7, 1717202879Srdivacky /** \brief A function. */ 1718202879Srdivacky CXCursor_FunctionDecl = 8, 1719202879Srdivacky /** \brief A variable. */ 1720202879Srdivacky CXCursor_VarDecl = 9, 1721202879Srdivacky /** \brief A function or method parameter. */ 1722202879Srdivacky CXCursor_ParmDecl = 10, 1723239462Sdim /** \brief An Objective-C \@interface. */ 1724202879Srdivacky CXCursor_ObjCInterfaceDecl = 11, 1725239462Sdim /** \brief An Objective-C \@interface for a category. */ 1726202879Srdivacky CXCursor_ObjCCategoryDecl = 12, 1727239462Sdim /** \brief An Objective-C \@protocol declaration. */ 1728202879Srdivacky CXCursor_ObjCProtocolDecl = 13, 1729239462Sdim /** \brief An Objective-C \@property declaration. */ 1730202879Srdivacky CXCursor_ObjCPropertyDecl = 14, 1731202879Srdivacky /** \brief An Objective-C instance variable. */ 1732202879Srdivacky CXCursor_ObjCIvarDecl = 15, 1733202879Srdivacky /** \brief An Objective-C instance method. */ 1734202879Srdivacky CXCursor_ObjCInstanceMethodDecl = 16, 1735202879Srdivacky /** \brief An Objective-C class method. */ 1736202879Srdivacky CXCursor_ObjCClassMethodDecl = 17, 1737239462Sdim /** \brief An Objective-C \@implementation. */ 1738202879Srdivacky CXCursor_ObjCImplementationDecl = 18, 1739239462Sdim /** \brief An Objective-C \@implementation for a category. */ 1740202879Srdivacky CXCursor_ObjCCategoryImplDecl = 19, 1741296417Sdim /** \brief A typedef. */ 1742202879Srdivacky CXCursor_TypedefDecl = 20, 1743207619Srdivacky /** \brief A C++ class method. */ 1744207619Srdivacky CXCursor_CXXMethod = 21, 1745208600Srdivacky /** \brief A C++ namespace. */ 1746208600Srdivacky CXCursor_Namespace = 22, 1747208600Srdivacky /** \brief A linkage specification, e.g. 'extern "C"'. */ 1748208600Srdivacky CXCursor_LinkageSpec = 23, 1749212904Sdim /** \brief A C++ constructor. */ 1750212904Sdim CXCursor_Constructor = 24, 1751212904Sdim /** \brief A C++ destructor. */ 1752212904Sdim CXCursor_Destructor = 25, 1753212904Sdim /** \brief A C++ conversion function. */ 1754212904Sdim CXCursor_ConversionFunction = 26, 1755212904Sdim /** \brief A C++ template type parameter. */ 1756212904Sdim CXCursor_TemplateTypeParameter = 27, 1757212904Sdim /** \brief A C++ non-type template parameter. */ 1758212904Sdim CXCursor_NonTypeTemplateParameter = 28, 1759212904Sdim /** \brief A C++ template template parameter. */ 1760212904Sdim CXCursor_TemplateTemplateParameter = 29, 1761212904Sdim /** \brief A C++ function template. */ 1762212904Sdim CXCursor_FunctionTemplate = 30, 1763212904Sdim /** \brief A C++ class template. */ 1764212904Sdim CXCursor_ClassTemplate = 31, 1765212904Sdim /** \brief A C++ class template partial specialization. */ 1766212904Sdim CXCursor_ClassTemplatePartialSpecialization = 32, 1767212904Sdim /** \brief A C++ namespace alias declaration. */ 1768212904Sdim CXCursor_NamespaceAlias = 33, 1769212904Sdim /** \brief A C++ using directive. */ 1770212904Sdim CXCursor_UsingDirective = 34, 1771221345Sdim /** \brief A C++ using declaration. */ 1772212904Sdim CXCursor_UsingDeclaration = 35, 1773221345Sdim /** \brief A C++ alias declaration */ 1774221345Sdim CXCursor_TypeAliasDecl = 36, 1775239462Sdim /** \brief An Objective-C \@synthesize definition. */ 1776223017Sdim CXCursor_ObjCSynthesizeDecl = 37, 1777239462Sdim /** \brief An Objective-C \@dynamic definition. */ 1778223017Sdim CXCursor_ObjCDynamicDecl = 38, 1779226633Sdim /** \brief An access specifier. */ 1780226633Sdim CXCursor_CXXAccessSpecifier = 39, 1781226633Sdim 1782208600Srdivacky CXCursor_FirstDecl = CXCursor_UnexposedDecl, 1783226633Sdim CXCursor_LastDecl = CXCursor_CXXAccessSpecifier, 1784207619Srdivacky 1785202879Srdivacky /* References */ 1786202879Srdivacky CXCursor_FirstRef = 40, /* Decl references */ 1787203955Srdivacky CXCursor_ObjCSuperClassRef = 40, 1788202879Srdivacky CXCursor_ObjCProtocolRef = 41, 1789202879Srdivacky CXCursor_ObjCClassRef = 42, 1790202879Srdivacky /** 1791202879Srdivacky * \brief A reference to a type declaration. 1792202879Srdivacky * 1793202879Srdivacky * A type reference occurs anywhere where a type is named but not 1794202879Srdivacky * declared. For example, given: 1795202879Srdivacky * 1796202879Srdivacky * \code 1797202879Srdivacky * typedef unsigned size_type; 1798202879Srdivacky * size_type size; 1799202879Srdivacky * \endcode 1800202879Srdivacky * 1801202879Srdivacky * The typedef is a declaration of size_type (CXCursor_TypedefDecl), 1802202879Srdivacky * while the type of the variable "size" is referenced. The cursor 1803202879Srdivacky * referenced by the type of size is the typedef for size_type. 1804202879Srdivacky */ 1805202879Srdivacky CXCursor_TypeRef = 43, 1806212904Sdim CXCursor_CXXBaseSpecifier = 44, 1807212904Sdim /** 1808218893Sdim * \brief A reference to a class template, function template, template 1809218893Sdim * template parameter, or class template partial specialization. 1810212904Sdim */ 1811212904Sdim CXCursor_TemplateRef = 45, 1812212904Sdim /** 1813212904Sdim * \brief A reference to a namespace or namespace alias. 1814212904Sdim */ 1815212904Sdim CXCursor_NamespaceRef = 46, 1816218893Sdim /** 1817218893Sdim * \brief A reference to a member of a struct, union, or class that occurs in 1818218893Sdim * some non-expression context, e.g., a designated initializer. 1819218893Sdim */ 1820218893Sdim CXCursor_MemberRef = 47, 1821218893Sdim /** 1822218893Sdim * \brief A reference to a labeled statement. 1823218893Sdim * 1824218893Sdim * This cursor kind is used to describe the jump to "start_over" in the 1825218893Sdim * goto statement in the following example: 1826218893Sdim * 1827218893Sdim * \code 1828218893Sdim * start_over: 1829218893Sdim * ++counter; 1830218893Sdim * 1831218893Sdim * goto start_over; 1832218893Sdim * \endcode 1833218893Sdim * 1834218893Sdim * A label reference cursor refers to a label statement. 1835218893Sdim */ 1836218893Sdim CXCursor_LabelRef = 48, 1837218893Sdim 1838218893Sdim /** 1839218893Sdim * \brief A reference to a set of overloaded functions or function templates 1840218893Sdim * that has not yet been resolved to a specific function or function template. 1841218893Sdim * 1842218893Sdim * An overloaded declaration reference cursor occurs in C++ templates where 1843218893Sdim * a dependent name refers to a function. For example: 1844218893Sdim * 1845218893Sdim * \code 1846218893Sdim * template<typename T> void swap(T&, T&); 1847218893Sdim * 1848218893Sdim * struct X { ... }; 1849218893Sdim * void swap(X&, X&); 1850218893Sdim * 1851218893Sdim * template<typename T> 1852218893Sdim * void reverse(T* first, T* last) { 1853218893Sdim * while (first < last - 1) { 1854218893Sdim * swap(*first, *--last); 1855218893Sdim * ++first; 1856218893Sdim * } 1857218893Sdim * } 1858218893Sdim * 1859218893Sdim * struct Y { }; 1860218893Sdim * void swap(Y&, Y&); 1861218893Sdim * \endcode 1862218893Sdim * 1863218893Sdim * Here, the identifier "swap" is associated with an overloaded declaration 1864218893Sdim * reference. In the template definition, "swap" refers to either of the two 1865218893Sdim * "swap" functions declared above, so both results will be available. At 1866218893Sdim * instantiation time, "swap" may also refer to other functions found via 1867218893Sdim * argument-dependent lookup (e.g., the "swap" function at the end of the 1868218893Sdim * example). 1869218893Sdim * 1870218893Sdim * The functions \c clang_getNumOverloadedDecls() and 1871218893Sdim * \c clang_getOverloadedDecl() can be used to retrieve the definitions 1872218893Sdim * referenced by this cursor. 1873218893Sdim */ 1874218893Sdim CXCursor_OverloadedDeclRef = 49, 1875218893Sdim 1876234353Sdim /** 1877234353Sdim * \brief A reference to a variable that occurs in some non-expression 1878234353Sdim * context, e.g., a C++ lambda capture list. 1879234353Sdim */ 1880234353Sdim CXCursor_VariableRef = 50, 1881234353Sdim 1882234353Sdim CXCursor_LastRef = CXCursor_VariableRef, 1883203955Srdivacky 1884202879Srdivacky /* Error conditions */ 1885202879Srdivacky CXCursor_FirstInvalid = 70, 1886202879Srdivacky CXCursor_InvalidFile = 70, 1887202879Srdivacky CXCursor_NoDeclFound = 71, 1888202879Srdivacky CXCursor_NotImplemented = 72, 1889205408Srdivacky CXCursor_InvalidCode = 73, 1890205408Srdivacky CXCursor_LastInvalid = CXCursor_InvalidCode, 1891203955Srdivacky 1892202879Srdivacky /* Expressions */ 1893202879Srdivacky CXCursor_FirstExpr = 100, 1894203955Srdivacky 1895202879Srdivacky /** 1896202879Srdivacky * \brief An expression whose specific kind is not exposed via this 1897203955Srdivacky * interface. 1898202879Srdivacky * 1899202879Srdivacky * Unexposed expressions have the same operations as any other kind 1900202879Srdivacky * of expression; one can extract their location information, 1901202879Srdivacky * spelling, children, etc. However, the specific kind of the 1902202879Srdivacky * expression is not reported. 1903202879Srdivacky */ 1904202879Srdivacky CXCursor_UnexposedExpr = 100, 1905203955Srdivacky 1906202879Srdivacky /** 1907202879Srdivacky * \brief An expression that refers to some value declaration, such 1908276479Sdim * as a function, variable, or enumerator. 1909202879Srdivacky */ 1910202879Srdivacky CXCursor_DeclRefExpr = 101, 1911203955Srdivacky 1912202879Srdivacky /** 1913202879Srdivacky * \brief An expression that refers to a member of a struct, union, 1914202879Srdivacky * class, Objective-C class, etc. 1915202879Srdivacky */ 1916202879Srdivacky CXCursor_MemberRefExpr = 102, 1917203955Srdivacky 1918202879Srdivacky /** \brief An expression that calls a function. */ 1919202879Srdivacky CXCursor_CallExpr = 103, 1920203955Srdivacky 1921202879Srdivacky /** \brief An expression that sends a message to an Objective-C 1922202879Srdivacky object or class. */ 1923202879Srdivacky CXCursor_ObjCMessageExpr = 104, 1924203955Srdivacky 1925207619Srdivacky /** \brief An expression that represents a block literal. */ 1926207619Srdivacky CXCursor_BlockExpr = 105, 1927207619Srdivacky 1928226633Sdim /** \brief An integer literal. 1929226633Sdim */ 1930226633Sdim CXCursor_IntegerLiteral = 106, 1931207619Srdivacky 1932226633Sdim /** \brief A floating point number literal. 1933226633Sdim */ 1934226633Sdim CXCursor_FloatingLiteral = 107, 1935226633Sdim 1936226633Sdim /** \brief An imaginary number literal. 1937226633Sdim */ 1938226633Sdim CXCursor_ImaginaryLiteral = 108, 1939226633Sdim 1940226633Sdim /** \brief A string literal. 1941226633Sdim */ 1942226633Sdim CXCursor_StringLiteral = 109, 1943226633Sdim 1944226633Sdim /** \brief A character literal. 1945226633Sdim */ 1946226633Sdim CXCursor_CharacterLiteral = 110, 1947226633Sdim 1948226633Sdim /** \brief A parenthesized expression, e.g. "(1)". 1949226633Sdim * 1950226633Sdim * This AST node is only formed if full location information is requested. 1951226633Sdim */ 1952226633Sdim CXCursor_ParenExpr = 111, 1953226633Sdim 1954226633Sdim /** \brief This represents the unary-expression's (except sizeof and 1955226633Sdim * alignof). 1956226633Sdim */ 1957226633Sdim CXCursor_UnaryOperator = 112, 1958226633Sdim 1959226633Sdim /** \brief [C99 6.5.2.1] Array Subscripting. 1960226633Sdim */ 1961226633Sdim CXCursor_ArraySubscriptExpr = 113, 1962226633Sdim 1963226633Sdim /** \brief A builtin binary operation expression such as "x + y" or 1964226633Sdim * "x <= y". 1965226633Sdim */ 1966226633Sdim CXCursor_BinaryOperator = 114, 1967226633Sdim 1968226633Sdim /** \brief Compound assignment such as "+=". 1969226633Sdim */ 1970226633Sdim CXCursor_CompoundAssignOperator = 115, 1971226633Sdim 1972226633Sdim /** \brief The ?: ternary operator. 1973226633Sdim */ 1974226633Sdim CXCursor_ConditionalOperator = 116, 1975226633Sdim 1976226633Sdim /** \brief An explicit cast in C (C99 6.5.4) or a C-style cast in C++ 1977226633Sdim * (C++ [expr.cast]), which uses the syntax (Type)expr. 1978226633Sdim * 1979226633Sdim * For example: (int)f. 1980226633Sdim */ 1981226633Sdim CXCursor_CStyleCastExpr = 117, 1982226633Sdim 1983226633Sdim /** \brief [C99 6.5.2.5] 1984226633Sdim */ 1985226633Sdim CXCursor_CompoundLiteralExpr = 118, 1986226633Sdim 1987226633Sdim /** \brief Describes an C or C++ initializer list. 1988226633Sdim */ 1989226633Sdim CXCursor_InitListExpr = 119, 1990226633Sdim 1991226633Sdim /** \brief The GNU address of label extension, representing &&label. 1992226633Sdim */ 1993226633Sdim CXCursor_AddrLabelExpr = 120, 1994226633Sdim 1995226633Sdim /** \brief This is the GNU Statement Expression extension: ({int X=4; X;}) 1996226633Sdim */ 1997226633Sdim CXCursor_StmtExpr = 121, 1998226633Sdim 1999234353Sdim /** \brief Represents a C11 generic selection. 2000226633Sdim */ 2001226633Sdim CXCursor_GenericSelectionExpr = 122, 2002226633Sdim 2003226633Sdim /** \brief Implements the GNU __null extension, which is a name for a null 2004226633Sdim * pointer constant that has integral type (e.g., int or long) and is the same 2005226633Sdim * size and alignment as a pointer. 2006226633Sdim * 2007226633Sdim * The __null extension is typically only used by system headers, which define 2008226633Sdim * NULL as __null in C++ rather than using 0 (which is an integer that may not 2009226633Sdim * match the size of a pointer). 2010226633Sdim */ 2011226633Sdim CXCursor_GNUNullExpr = 123, 2012226633Sdim 2013226633Sdim /** \brief C++'s static_cast<> expression. 2014226633Sdim */ 2015226633Sdim CXCursor_CXXStaticCastExpr = 124, 2016226633Sdim 2017226633Sdim /** \brief C++'s dynamic_cast<> expression. 2018226633Sdim */ 2019226633Sdim CXCursor_CXXDynamicCastExpr = 125, 2020226633Sdim 2021226633Sdim /** \brief C++'s reinterpret_cast<> expression. 2022226633Sdim */ 2023226633Sdim CXCursor_CXXReinterpretCastExpr = 126, 2024226633Sdim 2025226633Sdim /** \brief C++'s const_cast<> expression. 2026226633Sdim */ 2027226633Sdim CXCursor_CXXConstCastExpr = 127, 2028226633Sdim 2029226633Sdim /** \brief Represents an explicit C++ type conversion that uses "functional" 2030226633Sdim * notion (C++ [expr.type.conv]). 2031226633Sdim * 2032226633Sdim * Example: 2033226633Sdim * \code 2034226633Sdim * x = int(0.5); 2035226633Sdim * \endcode 2036226633Sdim */ 2037226633Sdim CXCursor_CXXFunctionalCastExpr = 128, 2038226633Sdim 2039226633Sdim /** \brief A C++ typeid expression (C++ [expr.typeid]). 2040226633Sdim */ 2041226633Sdim CXCursor_CXXTypeidExpr = 129, 2042226633Sdim 2043226633Sdim /** \brief [C++ 2.13.5] C++ Boolean Literal. 2044226633Sdim */ 2045226633Sdim CXCursor_CXXBoolLiteralExpr = 130, 2046226633Sdim 2047226633Sdim /** \brief [C++0x 2.14.7] C++ Pointer Literal. 2048226633Sdim */ 2049226633Sdim CXCursor_CXXNullPtrLiteralExpr = 131, 2050226633Sdim 2051226633Sdim /** \brief Represents the "this" expression in C++ 2052226633Sdim */ 2053226633Sdim CXCursor_CXXThisExpr = 132, 2054226633Sdim 2055226633Sdim /** \brief [C++ 15] C++ Throw Expression. 2056226633Sdim * 2057226633Sdim * This handles 'throw' and 'throw' assignment-expression. When 2058226633Sdim * assignment-expression isn't present, Op will be null. 2059226633Sdim */ 2060226633Sdim CXCursor_CXXThrowExpr = 133, 2061226633Sdim 2062226633Sdim /** \brief A new expression for memory allocation and constructor calls, e.g: 2063226633Sdim * "new CXXNewExpr(foo)". 2064226633Sdim */ 2065226633Sdim CXCursor_CXXNewExpr = 134, 2066226633Sdim 2067226633Sdim /** \brief A delete expression for memory deallocation and destructor calls, 2068226633Sdim * e.g. "delete[] pArray". 2069226633Sdim */ 2070226633Sdim CXCursor_CXXDeleteExpr = 135, 2071226633Sdim 2072309124Sdim /** \brief A unary expression. (noexcept, sizeof, or other traits) 2073226633Sdim */ 2074226633Sdim CXCursor_UnaryExpr = 136, 2075226633Sdim 2076234353Sdim /** \brief An Objective-C string literal i.e. @"foo". 2077226633Sdim */ 2078226633Sdim CXCursor_ObjCStringLiteral = 137, 2079226633Sdim 2080239462Sdim /** \brief An Objective-C \@encode expression. 2081226633Sdim */ 2082226633Sdim CXCursor_ObjCEncodeExpr = 138, 2083226633Sdim 2084239462Sdim /** \brief An Objective-C \@selector expression. 2085226633Sdim */ 2086226633Sdim CXCursor_ObjCSelectorExpr = 139, 2087226633Sdim 2088239462Sdim /** \brief An Objective-C \@protocol expression. 2089226633Sdim */ 2090226633Sdim CXCursor_ObjCProtocolExpr = 140, 2091226633Sdim 2092226633Sdim /** \brief An Objective-C "bridged" cast expression, which casts between 2093226633Sdim * Objective-C pointers and C pointers, transferring ownership in the process. 2094226633Sdim * 2095226633Sdim * \code 2096226633Sdim * NSString *str = (__bridge_transfer NSString *)CFCreateString(); 2097226633Sdim * \endcode 2098226633Sdim */ 2099226633Sdim CXCursor_ObjCBridgedCastExpr = 141, 2100226633Sdim 2101226633Sdim /** \brief Represents a C++0x pack expansion that produces a sequence of 2102226633Sdim * expressions. 2103226633Sdim * 2104226633Sdim * A pack expansion expression contains a pattern (which itself is an 2105226633Sdim * expression) followed by an ellipsis. For example: 2106226633Sdim * 2107226633Sdim * \code 2108226633Sdim * template<typename F, typename ...Types> 2109226633Sdim * void forward(F f, Types &&...args) { 2110226633Sdim * f(static_cast<Types&&>(args)...); 2111226633Sdim * } 2112226633Sdim * \endcode 2113226633Sdim */ 2114226633Sdim CXCursor_PackExpansionExpr = 142, 2115226633Sdim 2116226633Sdim /** \brief Represents an expression that computes the length of a parameter 2117226633Sdim * pack. 2118226633Sdim * 2119226633Sdim * \code 2120226633Sdim * template<typename ...Types> 2121226633Sdim * struct count { 2122226633Sdim * static const unsigned value = sizeof...(Types); 2123226633Sdim * }; 2124226633Sdim * \endcode 2125226633Sdim */ 2126226633Sdim CXCursor_SizeOfPackExpr = 143, 2127226633Sdim 2128234353Sdim /* \brief Represents a C++ lambda expression that produces a local function 2129234353Sdim * object. 2130234353Sdim * 2131234353Sdim * \code 2132234353Sdim * void abssort(float *x, unsigned N) { 2133234353Sdim * std::sort(x, x + N, 2134234353Sdim * [](float a, float b) { 2135234353Sdim * return std::abs(a) < std::abs(b); 2136234353Sdim * }); 2137234353Sdim * } 2138234353Sdim * \endcode 2139234353Sdim */ 2140234353Sdim CXCursor_LambdaExpr = 144, 2141234353Sdim 2142234353Sdim /** \brief Objective-c Boolean Literal. 2143234353Sdim */ 2144234353Sdim CXCursor_ObjCBoolLiteralExpr = 145, 2145226633Sdim 2146276479Sdim /** \brief Represents the "self" expression in an Objective-C method. 2147251662Sdim */ 2148251662Sdim CXCursor_ObjCSelfExpr = 146, 2149234353Sdim 2150296417Sdim /** \brief OpenMP 4.0 [2.4, Array Section]. 2151296417Sdim */ 2152296417Sdim CXCursor_OMPArraySectionExpr = 147, 2153251662Sdim 2154309124Sdim /** \brief Represents an @available(...) check. 2155309124Sdim */ 2156309124Sdim CXCursor_ObjCAvailabilityCheckExpr = 148, 2157296417Sdim 2158309124Sdim CXCursor_LastExpr = CXCursor_ObjCAvailabilityCheckExpr, 2159309124Sdim 2160202879Srdivacky /* Statements */ 2161202879Srdivacky CXCursor_FirstStmt = 200, 2162202879Srdivacky /** 2163202879Srdivacky * \brief A statement whose specific kind is not exposed via this 2164202879Srdivacky * interface. 2165202879Srdivacky * 2166202879Srdivacky * Unexposed statements have the same operations as any other kind of 2167202879Srdivacky * statement; one can extract their location information, spelling, 2168202879Srdivacky * children, etc. However, the specific kind of the statement is not 2169202879Srdivacky * reported. 2170202879Srdivacky */ 2171202879Srdivacky CXCursor_UnexposedStmt = 200, 2172218893Sdim 2173218893Sdim /** \brief A labelled statement in a function. 2174218893Sdim * 2175218893Sdim * This cursor kind is used to describe the "start_over:" label statement in 2176218893Sdim * the following example: 2177218893Sdim * 2178218893Sdim * \code 2179218893Sdim * start_over: 2180218893Sdim * ++counter; 2181218893Sdim * \endcode 2182218893Sdim * 2183218893Sdim */ 2184218893Sdim CXCursor_LabelStmt = 201, 2185203955Srdivacky 2186226633Sdim /** \brief A group of statements like { stmt stmt }. 2187226633Sdim * 2188226633Sdim * This cursor kind is used to describe compound statements, e.g. function 2189226633Sdim * bodies. 2190226633Sdim */ 2191226633Sdim CXCursor_CompoundStmt = 202, 2192226633Sdim 2193261991Sdim /** \brief A case statement. 2194226633Sdim */ 2195226633Sdim CXCursor_CaseStmt = 203, 2196226633Sdim 2197226633Sdim /** \brief A default statement. 2198226633Sdim */ 2199226633Sdim CXCursor_DefaultStmt = 204, 2200226633Sdim 2201226633Sdim /** \brief An if statement 2202226633Sdim */ 2203226633Sdim CXCursor_IfStmt = 205, 2204226633Sdim 2205226633Sdim /** \brief A switch statement. 2206226633Sdim */ 2207226633Sdim CXCursor_SwitchStmt = 206, 2208226633Sdim 2209226633Sdim /** \brief A while statement. 2210226633Sdim */ 2211226633Sdim CXCursor_WhileStmt = 207, 2212226633Sdim 2213226633Sdim /** \brief A do statement. 2214226633Sdim */ 2215226633Sdim CXCursor_DoStmt = 208, 2216226633Sdim 2217226633Sdim /** \brief A for statement. 2218226633Sdim */ 2219226633Sdim CXCursor_ForStmt = 209, 2220226633Sdim 2221226633Sdim /** \brief A goto statement. 2222226633Sdim */ 2223226633Sdim CXCursor_GotoStmt = 210, 2224226633Sdim 2225226633Sdim /** \brief An indirect goto statement. 2226226633Sdim */ 2227226633Sdim CXCursor_IndirectGotoStmt = 211, 2228226633Sdim 2229226633Sdim /** \brief A continue statement. 2230226633Sdim */ 2231226633Sdim CXCursor_ContinueStmt = 212, 2232226633Sdim 2233226633Sdim /** \brief A break statement. 2234226633Sdim */ 2235226633Sdim CXCursor_BreakStmt = 213, 2236226633Sdim 2237226633Sdim /** \brief A return statement. 2238226633Sdim */ 2239226633Sdim CXCursor_ReturnStmt = 214, 2240226633Sdim 2241243830Sdim /** \brief A GCC inline assembly statement extension. 2242226633Sdim */ 2243243830Sdim CXCursor_GCCAsmStmt = 215, 2244243830Sdim CXCursor_AsmStmt = CXCursor_GCCAsmStmt, 2245226633Sdim 2246239462Sdim /** \brief Objective-C's overall \@try-\@catch-\@finally statement. 2247226633Sdim */ 2248226633Sdim CXCursor_ObjCAtTryStmt = 216, 2249226633Sdim 2250239462Sdim /** \brief Objective-C's \@catch statement. 2251226633Sdim */ 2252226633Sdim CXCursor_ObjCAtCatchStmt = 217, 2253226633Sdim 2254239462Sdim /** \brief Objective-C's \@finally statement. 2255226633Sdim */ 2256226633Sdim CXCursor_ObjCAtFinallyStmt = 218, 2257226633Sdim 2258239462Sdim /** \brief Objective-C's \@throw statement. 2259226633Sdim */ 2260226633Sdim CXCursor_ObjCAtThrowStmt = 219, 2261226633Sdim 2262239462Sdim /** \brief Objective-C's \@synchronized statement. 2263226633Sdim */ 2264226633Sdim CXCursor_ObjCAtSynchronizedStmt = 220, 2265226633Sdim 2266226633Sdim /** \brief Objective-C's autorelease pool statement. 2267226633Sdim */ 2268226633Sdim CXCursor_ObjCAutoreleasePoolStmt = 221, 2269226633Sdim 2270226633Sdim /** \brief Objective-C's collection statement. 2271226633Sdim */ 2272226633Sdim CXCursor_ObjCForCollectionStmt = 222, 2273226633Sdim 2274226633Sdim /** \brief C++'s catch statement. 2275226633Sdim */ 2276226633Sdim CXCursor_CXXCatchStmt = 223, 2277226633Sdim 2278226633Sdim /** \brief C++'s try statement. 2279226633Sdim */ 2280226633Sdim CXCursor_CXXTryStmt = 224, 2281226633Sdim 2282226633Sdim /** \brief C++'s for (* : *) statement. 2283226633Sdim */ 2284226633Sdim CXCursor_CXXForRangeStmt = 225, 2285226633Sdim 2286226633Sdim /** \brief Windows Structured Exception Handling's try statement. 2287226633Sdim */ 2288226633Sdim CXCursor_SEHTryStmt = 226, 2289226633Sdim 2290226633Sdim /** \brief Windows Structured Exception Handling's except statement. 2291226633Sdim */ 2292226633Sdim CXCursor_SEHExceptStmt = 227, 2293226633Sdim 2294226633Sdim /** \brief Windows Structured Exception Handling's finally statement. 2295226633Sdim */ 2296226633Sdim CXCursor_SEHFinallyStmt = 228, 2297226633Sdim 2298239462Sdim /** \brief A MS inline assembly statement extension. 2299239462Sdim */ 2300239462Sdim CXCursor_MSAsmStmt = 229, 2301239462Sdim 2302280031Sdim /** \brief The null statement ";": C99 6.8.3p3. 2303226633Sdim * 2304226633Sdim * This cursor kind is used to describe the null statement. 2305226633Sdim */ 2306226633Sdim CXCursor_NullStmt = 230, 2307226633Sdim 2308226633Sdim /** \brief Adaptor class for mixing declarations with statements and 2309226633Sdim * expressions. 2310226633Sdim */ 2311226633Sdim CXCursor_DeclStmt = 231, 2312226633Sdim 2313261991Sdim /** \brief OpenMP parallel directive. 2314261991Sdim */ 2315261991Sdim CXCursor_OMPParallelDirective = 232, 2316226633Sdim 2317280031Sdim /** \brief OpenMP SIMD directive. 2318276479Sdim */ 2319276479Sdim CXCursor_OMPSimdDirective = 233, 2320261991Sdim 2321276479Sdim /** \brief OpenMP for directive. 2322276479Sdim */ 2323276479Sdim CXCursor_OMPForDirective = 234, 2324276479Sdim 2325276479Sdim /** \brief OpenMP sections directive. 2326276479Sdim */ 2327276479Sdim CXCursor_OMPSectionsDirective = 235, 2328276479Sdim 2329276479Sdim /** \brief OpenMP section directive. 2330276479Sdim */ 2331276479Sdim CXCursor_OMPSectionDirective = 236, 2332276479Sdim 2333276479Sdim /** \brief OpenMP single directive. 2334276479Sdim */ 2335276479Sdim CXCursor_OMPSingleDirective = 237, 2336276479Sdim 2337276479Sdim /** \brief OpenMP parallel for directive. 2338276479Sdim */ 2339276479Sdim CXCursor_OMPParallelForDirective = 238, 2340276479Sdim 2341276479Sdim /** \brief OpenMP parallel sections directive. 2342276479Sdim */ 2343276479Sdim CXCursor_OMPParallelSectionsDirective = 239, 2344276479Sdim 2345276479Sdim /** \brief OpenMP task directive. 2346276479Sdim */ 2347276479Sdim CXCursor_OMPTaskDirective = 240, 2348276479Sdim 2349276479Sdim /** \brief OpenMP master directive. 2350276479Sdim */ 2351276479Sdim CXCursor_OMPMasterDirective = 241, 2352276479Sdim 2353276479Sdim /** \brief OpenMP critical directive. 2354276479Sdim */ 2355276479Sdim CXCursor_OMPCriticalDirective = 242, 2356276479Sdim 2357276479Sdim /** \brief OpenMP taskyield directive. 2358276479Sdim */ 2359276479Sdim CXCursor_OMPTaskyieldDirective = 243, 2360276479Sdim 2361276479Sdim /** \brief OpenMP barrier directive. 2362276479Sdim */ 2363276479Sdim CXCursor_OMPBarrierDirective = 244, 2364276479Sdim 2365276479Sdim /** \brief OpenMP taskwait directive. 2366276479Sdim */ 2367276479Sdim CXCursor_OMPTaskwaitDirective = 245, 2368276479Sdim 2369276479Sdim /** \brief OpenMP flush directive. 2370276479Sdim */ 2371276479Sdim CXCursor_OMPFlushDirective = 246, 2372276479Sdim 2373276479Sdim /** \brief Windows Structured Exception Handling's leave statement. 2374276479Sdim */ 2375276479Sdim CXCursor_SEHLeaveStmt = 247, 2376276479Sdim 2377280031Sdim /** \brief OpenMP ordered directive. 2378280031Sdim */ 2379280031Sdim CXCursor_OMPOrderedDirective = 248, 2380276479Sdim 2381280031Sdim /** \brief OpenMP atomic directive. 2382280031Sdim */ 2383280031Sdim CXCursor_OMPAtomicDirective = 249, 2384280031Sdim 2385280031Sdim /** \brief OpenMP for SIMD directive. 2386280031Sdim */ 2387280031Sdim CXCursor_OMPForSimdDirective = 250, 2388280031Sdim 2389280031Sdim /** \brief OpenMP parallel for SIMD directive. 2390280031Sdim */ 2391280031Sdim CXCursor_OMPParallelForSimdDirective = 251, 2392280031Sdim 2393280031Sdim /** \brief OpenMP target directive. 2394280031Sdim */ 2395280031Sdim CXCursor_OMPTargetDirective = 252, 2396280031Sdim 2397280031Sdim /** \brief OpenMP teams directive. 2398280031Sdim */ 2399280031Sdim CXCursor_OMPTeamsDirective = 253, 2400280031Sdim 2401288943Sdim /** \brief OpenMP taskgroup directive. 2402288943Sdim */ 2403296417Sdim CXCursor_OMPTaskgroupDirective = 254, 2404280031Sdim 2405288943Sdim /** \brief OpenMP cancellation point directive. 2406288943Sdim */ 2407296417Sdim CXCursor_OMPCancellationPointDirective = 255, 2408288943Sdim 2409288943Sdim /** \brief OpenMP cancel directive. 2410288943Sdim */ 2411296417Sdim CXCursor_OMPCancelDirective = 256, 2412288943Sdim 2413296417Sdim /** \brief OpenMP target data directive. 2414296417Sdim */ 2415296417Sdim CXCursor_OMPTargetDataDirective = 257, 2416288943Sdim 2417296417Sdim /** \brief OpenMP taskloop directive. 2418296417Sdim */ 2419296417Sdim CXCursor_OMPTaskLoopDirective = 258, 2420296417Sdim 2421296417Sdim /** \brief OpenMP taskloop simd directive. 2422296417Sdim */ 2423296417Sdim CXCursor_OMPTaskLoopSimdDirective = 259, 2424296417Sdim 2425309124Sdim /** \brief OpenMP distribute directive. 2426296417Sdim */ 2427296417Sdim CXCursor_OMPDistributeDirective = 260, 2428296417Sdim 2429309124Sdim /** \brief OpenMP target enter data directive. 2430309124Sdim */ 2431309124Sdim CXCursor_OMPTargetEnterDataDirective = 261, 2432296417Sdim 2433309124Sdim /** \brief OpenMP target exit data directive. 2434309124Sdim */ 2435309124Sdim CXCursor_OMPTargetExitDataDirective = 262, 2436309124Sdim 2437309124Sdim /** \brief OpenMP target parallel directive. 2438309124Sdim */ 2439309124Sdim CXCursor_OMPTargetParallelDirective = 263, 2440309124Sdim 2441309124Sdim /** \brief OpenMP target parallel for directive. 2442309124Sdim */ 2443309124Sdim CXCursor_OMPTargetParallelForDirective = 264, 2444309124Sdim 2445309124Sdim /** \brief OpenMP target update directive. 2446309124Sdim */ 2447309124Sdim CXCursor_OMPTargetUpdateDirective = 265, 2448309124Sdim 2449309124Sdim /** \brief OpenMP distribute parallel for directive. 2450309124Sdim */ 2451309124Sdim CXCursor_OMPDistributeParallelForDirective = 266, 2452309124Sdim 2453309124Sdim /** \brief OpenMP distribute parallel for simd directive. 2454309124Sdim */ 2455309124Sdim CXCursor_OMPDistributeParallelForSimdDirective = 267, 2456309124Sdim 2457309124Sdim /** \brief OpenMP distribute simd directive. 2458309124Sdim */ 2459309124Sdim CXCursor_OMPDistributeSimdDirective = 268, 2460309124Sdim 2461309124Sdim /** \brief OpenMP target parallel for simd directive. 2462309124Sdim */ 2463309124Sdim CXCursor_OMPTargetParallelForSimdDirective = 269, 2464309124Sdim 2465314564Sdim /** \brief OpenMP target simd directive. 2466314564Sdim */ 2467314564Sdim CXCursor_OMPTargetSimdDirective = 270, 2468309124Sdim 2469314564Sdim /** \brief OpenMP teams distribute directive. 2470314564Sdim */ 2471314564Sdim CXCursor_OMPTeamsDistributeDirective = 271, 2472314564Sdim 2473314564Sdim /** \brief OpenMP teams distribute simd directive. 2474314564Sdim */ 2475314564Sdim CXCursor_OMPTeamsDistributeSimdDirective = 272, 2476314564Sdim 2477314564Sdim /** \brief OpenMP teams distribute parallel for simd directive. 2478314564Sdim */ 2479314564Sdim CXCursor_OMPTeamsDistributeParallelForSimdDirective = 273, 2480314564Sdim 2481314564Sdim /** \brief OpenMP teams distribute parallel for directive. 2482314564Sdim */ 2483314564Sdim CXCursor_OMPTeamsDistributeParallelForDirective = 274, 2484314564Sdim 2485314564Sdim /** \brief OpenMP target teams directive. 2486314564Sdim */ 2487314564Sdim CXCursor_OMPTargetTeamsDirective = 275, 2488314564Sdim 2489314564Sdim /** \brief OpenMP target teams distribute directive. 2490314564Sdim */ 2491314564Sdim CXCursor_OMPTargetTeamsDistributeDirective = 276, 2492314564Sdim 2493314564Sdim /** \brief OpenMP target teams distribute parallel for directive. 2494314564Sdim */ 2495314564Sdim CXCursor_OMPTargetTeamsDistributeParallelForDirective = 277, 2496314564Sdim 2497314564Sdim /** \brief OpenMP target teams distribute parallel for simd directive. 2498314564Sdim */ 2499314564Sdim CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective = 278, 2500314564Sdim 2501314564Sdim /** \brief OpenMP target teams distribute simd directive. 2502314564Sdim */ 2503314564Sdim CXCursor_OMPTargetTeamsDistributeSimdDirective = 279, 2504314564Sdim 2505314564Sdim CXCursor_LastStmt = CXCursor_OMPTargetTeamsDistributeSimdDirective, 2506314564Sdim 2507202879Srdivacky /** 2508202879Srdivacky * \brief Cursor that represents the translation unit itself. 2509202879Srdivacky * 2510202879Srdivacky * The translation unit cursor exists primarily to act as the root 2511202879Srdivacky * cursor for traversing the contents of a translation unit. 2512202879Srdivacky */ 2513204643Srdivacky CXCursor_TranslationUnit = 300, 2514204643Srdivacky 2515204643Srdivacky /* Attributes */ 2516204643Srdivacky CXCursor_FirstAttr = 400, 2517204643Srdivacky /** 2518204643Srdivacky * \brief An attribute whose specific kind is not exposed via this 2519204643Srdivacky * interface. 2520204643Srdivacky */ 2521204643Srdivacky CXCursor_UnexposedAttr = 400, 2522204643Srdivacky 2523204643Srdivacky CXCursor_IBActionAttr = 401, 2524204643Srdivacky CXCursor_IBOutletAttr = 402, 2525208600Srdivacky CXCursor_IBOutletCollectionAttr = 403, 2526226633Sdim CXCursor_CXXFinalAttr = 404, 2527226633Sdim CXCursor_CXXOverrideAttr = 405, 2528226633Sdim CXCursor_AnnotateAttr = 406, 2529234353Sdim CXCursor_AsmLabelAttr = 407, 2530261991Sdim CXCursor_PackedAttr = 408, 2531276479Sdim CXCursor_PureAttr = 409, 2532276479Sdim CXCursor_ConstAttr = 410, 2533276479Sdim CXCursor_NoDuplicateAttr = 411, 2534276479Sdim CXCursor_CUDAConstantAttr = 412, 2535276479Sdim CXCursor_CUDADeviceAttr = 413, 2536276479Sdim CXCursor_CUDAGlobalAttr = 414, 2537276479Sdim CXCursor_CUDAHostAttr = 415, 2538280031Sdim CXCursor_CUDASharedAttr = 416, 2539296417Sdim CXCursor_VisibilityAttr = 417, 2540296417Sdim CXCursor_DLLExport = 418, 2541296417Sdim CXCursor_DLLImport = 419, 2542296417Sdim CXCursor_LastAttr = CXCursor_DLLImport, 2543276479Sdim 2544205408Srdivacky /* Preprocessing */ 2545205408Srdivacky CXCursor_PreprocessingDirective = 500, 2546205408Srdivacky CXCursor_MacroDefinition = 501, 2547224145Sdim CXCursor_MacroExpansion = 502, 2548224145Sdim CXCursor_MacroInstantiation = CXCursor_MacroExpansion, 2549218893Sdim CXCursor_InclusionDirective = 503, 2550205408Srdivacky CXCursor_FirstPreprocessing = CXCursor_PreprocessingDirective, 2551243830Sdim CXCursor_LastPreprocessing = CXCursor_InclusionDirective, 2552243830Sdim 2553243830Sdim /* Extra Declarations */ 2554243830Sdim /** 2555243830Sdim * \brief A module import declaration. 2556243830Sdim */ 2557243830Sdim CXCursor_ModuleImportDecl = 600, 2558296417Sdim CXCursor_TypeAliasTemplateDecl = 601, 2559309124Sdim /** 2560309124Sdim * \brief A static_assert or _Static_assert node 2561309124Sdim */ 2562309124Sdim CXCursor_StaticAssert = 602, 2563314564Sdim /** 2564314564Sdim * \brief a friend declaration. 2565314564Sdim */ 2566314564Sdim CXCursor_FriendDecl = 603, 2567243830Sdim CXCursor_FirstExtraDecl = CXCursor_ModuleImportDecl, 2568314564Sdim CXCursor_LastExtraDecl = CXCursor_FriendDecl, 2569288943Sdim 2570288943Sdim /** 2571288943Sdim * \brief A code completion overload candidate. 2572288943Sdim */ 2573288943Sdim CXCursor_OverloadCandidate = 700 2574202879Srdivacky}; 2575202379Srdivacky 2576202879Srdivacky/** 2577202879Srdivacky * \brief A cursor representing some element in the abstract syntax tree for 2578202879Srdivacky * a translation unit. 2579202879Srdivacky * 2580203955Srdivacky * The cursor abstraction unifies the different kinds of entities in a 2581202879Srdivacky * program--declaration, statements, expressions, references to declarations, 2582202879Srdivacky * etc.--under a single "cursor" abstraction with a common set of operations. 2583202879Srdivacky * Common operation for a cursor include: getting the physical location in 2584202879Srdivacky * a source file where the cursor points, getting the name associated with a 2585202879Srdivacky * cursor, and retrieving cursors for any child nodes of a particular cursor. 2586202879Srdivacky * 2587202879Srdivacky * Cursors can be produced in two specific ways. 2588202879Srdivacky * clang_getTranslationUnitCursor() produces a cursor for a translation unit, 2589202879Srdivacky * from which one can use clang_visitChildren() to explore the rest of the 2590202879Srdivacky * translation unit. clang_getCursor() maps from a physical source location 2591202879Srdivacky * to the entity that resides at that location, allowing one to map from the 2592202879Srdivacky * source code into the AST. 2593198092Srdivacky */ 2594202879Srdivackytypedef struct { 2595202879Srdivacky enum CXCursorKind kind; 2596226633Sdim int xdata; 2597249423Sdim const void *data[3]; 2598203955Srdivacky} CXCursor; 2599202879Srdivacky 2600198398Srdivacky/** 2601202879Srdivacky * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations 2602202879Srdivacky * 2603202879Srdivacky * @{ 2604198398Srdivacky */ 2605203955Srdivacky 2606202879Srdivacky/** 2607202879Srdivacky * \brief Retrieve the NULL cursor, which represents no entity. 2608202879Srdivacky */ 2609199482SrdivackyCINDEX_LINKAGE CXCursor clang_getNullCursor(void); 2610203955Srdivacky 2611202879Srdivacky/** 2612202879Srdivacky * \brief Retrieve the cursor that represents the given translation unit. 2613202879Srdivacky * 2614202879Srdivacky * The translation unit cursor can be used to start traversing the 2615202879Srdivacky * various declarations within the given translation unit. 2616202879Srdivacky */ 2617202879SrdivackyCINDEX_LINKAGE CXCursor clang_getTranslationUnitCursor(CXTranslationUnit); 2618198092Srdivacky 2619202879Srdivacky/** 2620202879Srdivacky * \brief Determine whether two cursors are equivalent. 2621202879Srdivacky */ 2622202879SrdivackyCINDEX_LINKAGE unsigned clang_equalCursors(CXCursor, CXCursor); 2623203955Srdivacky 2624202879Srdivacky/** 2625243830Sdim * \brief Returns non-zero if \p cursor is null. 2626226633Sdim */ 2627243830SdimCINDEX_LINKAGE int clang_Cursor_isNull(CXCursor cursor); 2628226633Sdim 2629226633Sdim/** 2630218893Sdim * \brief Compute a hash value for the given cursor. 2631218893Sdim */ 2632218893SdimCINDEX_LINKAGE unsigned clang_hashCursor(CXCursor); 2633218893Sdim 2634218893Sdim/** 2635202879Srdivacky * \brief Retrieve the kind of the given cursor. 2636202879Srdivacky */ 2637198893SrdivackyCINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor); 2638202879Srdivacky 2639202879Srdivacky/** 2640202879Srdivacky * \brief Determine whether the given cursor kind represents a declaration. 2641202879Srdivacky */ 2642198893SrdivackyCINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind); 2643202879Srdivacky 2644202879Srdivacky/** 2645202879Srdivacky * \brief Determine whether the given cursor kind represents a simple 2646202879Srdivacky * reference. 2647202879Srdivacky * 2648202879Srdivacky * Note that other kinds of cursors (such as expressions) can also refer to 2649202879Srdivacky * other cursors. Use clang_getCursorReferenced() to determine whether a 2650202879Srdivacky * particular cursor refers to another entity. 2651202879Srdivacky */ 2652198893SrdivackyCINDEX_LINKAGE unsigned clang_isReference(enum CXCursorKind); 2653202879Srdivacky 2654202879Srdivacky/** 2655202879Srdivacky * \brief Determine whether the given cursor kind represents an expression. 2656202879Srdivacky */ 2657202879SrdivackyCINDEX_LINKAGE unsigned clang_isExpression(enum CXCursorKind); 2658202879Srdivacky 2659202879Srdivacky/** 2660202879Srdivacky * \brief Determine whether the given cursor kind represents a statement. 2661202879Srdivacky */ 2662202879SrdivackyCINDEX_LINKAGE unsigned clang_isStatement(enum CXCursorKind); 2663202879Srdivacky 2664202879Srdivacky/** 2665224145Sdim * \brief Determine whether the given cursor kind represents an attribute. 2666224145Sdim */ 2667224145SdimCINDEX_LINKAGE unsigned clang_isAttribute(enum CXCursorKind); 2668224145Sdim 2669224145Sdim/** 2670309124Sdim * \brief Determine whether the given cursor has any attributes. 2671309124Sdim */ 2672309124SdimCINDEX_LINKAGE unsigned clang_Cursor_hasAttrs(CXCursor C); 2673309124Sdim 2674309124Sdim/** 2675203955Srdivacky * \brief Determine whether the given cursor kind represents an invalid 2676202879Srdivacky * cursor. 2677203955Srdivacky */ 2678198893SrdivackyCINDEX_LINKAGE unsigned clang_isInvalid(enum CXCursorKind); 2679198398Srdivacky 2680202879Srdivacky/** 2681203955Srdivacky * \brief Determine whether the given cursor kind represents a translation 2682203955Srdivacky * unit. 2683202879Srdivacky */ 2684202879SrdivackyCINDEX_LINKAGE unsigned clang_isTranslationUnit(enum CXCursorKind); 2685203955Srdivacky 2686204962Srdivacky/*** 2687205408Srdivacky * \brief Determine whether the given cursor represents a preprocessing 2688205408Srdivacky * element, such as a preprocessor directive or macro instantiation. 2689205408Srdivacky */ 2690205408SrdivackyCINDEX_LINKAGE unsigned clang_isPreprocessing(enum CXCursorKind); 2691205408Srdivacky 2692205408Srdivacky/*** 2693204962Srdivacky * \brief Determine whether the given cursor represents a currently 2694204962Srdivacky * unexposed piece of the AST (e.g., CXCursor_UnexposedStmt). 2695204962Srdivacky */ 2696204962SrdivackyCINDEX_LINKAGE unsigned clang_isUnexposed(enum CXCursorKind); 2697204962Srdivacky 2698202879Srdivacky/** 2699204643Srdivacky * \brief Describe the linkage of the entity referred to by a cursor. 2700204643Srdivacky */ 2701204643Srdivackyenum CXLinkageKind { 2702204643Srdivacky /** \brief This value indicates that no linkage information is available 2703204643Srdivacky * for a provided CXCursor. */ 2704204643Srdivacky CXLinkage_Invalid, 2705204643Srdivacky /** 2706204643Srdivacky * \brief This is the linkage for variables, parameters, and so on that 2707204643Srdivacky * have automatic storage. This covers normal (non-extern) local variables. 2708204643Srdivacky */ 2709204643Srdivacky CXLinkage_NoLinkage, 2710204643Srdivacky /** \brief This is the linkage for static variables and static functions. */ 2711204643Srdivacky CXLinkage_Internal, 2712204643Srdivacky /** \brief This is the linkage for entities with external linkage that live 2713204643Srdivacky * in C++ anonymous namespaces.*/ 2714204643Srdivacky CXLinkage_UniqueExternal, 2715204643Srdivacky /** \brief This is the linkage for entities with true, external linkage. */ 2716204643Srdivacky CXLinkage_External 2717204643Srdivacky}; 2718204643Srdivacky 2719204643Srdivacky/** 2720207619Srdivacky * \brief Determine the linkage of the entity referred to by a given cursor. 2721204643Srdivacky */ 2722204643SrdivackyCINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor); 2723204643Srdivacky 2724296417Sdimenum CXVisibilityKind { 2725296417Sdim /** \brief This value indicates that no visibility information is available 2726296417Sdim * for a provided CXCursor. */ 2727296417Sdim CXVisibility_Invalid, 2728296417Sdim 2729296417Sdim /** \brief Symbol not seen by the linker. */ 2730296417Sdim CXVisibility_Hidden, 2731296417Sdim /** \brief Symbol seen by the linker but resolves to a symbol inside this object. */ 2732296417Sdim CXVisibility_Protected, 2733296417Sdim /** \brief Symbol seen by the linker and acts like a normal symbol. */ 2734296417Sdim CXVisibility_Default 2735296417Sdim}; 2736296417Sdim 2737204643Srdivacky/** 2738296417Sdim * \brief Describe the visibility of the entity referred to by a cursor. 2739296417Sdim * 2740296417Sdim * This returns the default visibility if not explicitly specified by 2741296417Sdim * a visibility attribute. The default visibility may be changed by 2742296417Sdim * commandline arguments. 2743296417Sdim * 2744296417Sdim * \param cursor The cursor to query. 2745296417Sdim * 2746296417Sdim * \returns The visibility of the cursor. 2747296417Sdim */ 2748296417SdimCINDEX_LINKAGE enum CXVisibilityKind clang_getCursorVisibility(CXCursor cursor); 2749296417Sdim 2750296417Sdim/** 2751239462Sdim * \brief Determine the availability of the entity that this cursor refers to, 2752239462Sdim * taking the current target platform into account. 2753212904Sdim * 2754212904Sdim * \param cursor The cursor to query. 2755212904Sdim * 2756212904Sdim * \returns The availability of the cursor. 2757212904Sdim */ 2758212904SdimCINDEX_LINKAGE enum CXAvailabilityKind 2759212904Sdimclang_getCursorAvailability(CXCursor cursor); 2760212904Sdim 2761212904Sdim/** 2762239462Sdim * Describes the availability of a given entity on a particular platform, e.g., 2763239462Sdim * a particular class might only be available on Mac OS 10.7 or newer. 2764239462Sdim */ 2765239462Sdimtypedef struct CXPlatformAvailability { 2766239462Sdim /** 2767239462Sdim * \brief A string that describes the platform for which this structure 2768239462Sdim * provides availability information. 2769239462Sdim * 2770309124Sdim * Possible values are "ios" or "macos". 2771239462Sdim */ 2772239462Sdim CXString Platform; 2773239462Sdim /** 2774239462Sdim * \brief The version number in which this entity was introduced. 2775239462Sdim */ 2776239462Sdim CXVersion Introduced; 2777239462Sdim /** 2778239462Sdim * \brief The version number in which this entity was deprecated (but is 2779239462Sdim * still available). 2780239462Sdim */ 2781239462Sdim CXVersion Deprecated; 2782239462Sdim /** 2783239462Sdim * \brief The version number in which this entity was obsoleted, and therefore 2784239462Sdim * is no longer available. 2785239462Sdim */ 2786239462Sdim CXVersion Obsoleted; 2787239462Sdim /** 2788239462Sdim * \brief Whether the entity is unconditionally unavailable on this platform. 2789239462Sdim */ 2790239462Sdim int Unavailable; 2791239462Sdim /** 2792239462Sdim * \brief An optional message to provide to a user of this API, e.g., to 2793239462Sdim * suggest replacement APIs. 2794239462Sdim */ 2795239462Sdim CXString Message; 2796239462Sdim} CXPlatformAvailability; 2797239462Sdim 2798239462Sdim/** 2799239462Sdim * \brief Determine the availability of the entity that this cursor refers to 2800239462Sdim * on any platforms for which availability information is known. 2801239462Sdim * 2802239462Sdim * \param cursor The cursor to query. 2803239462Sdim * 2804239462Sdim * \param always_deprecated If non-NULL, will be set to indicate whether the 2805239462Sdim * entity is deprecated on all platforms. 2806239462Sdim * 2807239462Sdim * \param deprecated_message If non-NULL, will be set to the message text 2808239462Sdim * provided along with the unconditional deprecation of this entity. The client 2809239462Sdim * is responsible for deallocating this string. 2810239462Sdim * 2811239462Sdim * \param always_unavailable If non-NULL, will be set to indicate whether the 2812239462Sdim * entity is unavailable on all platforms. 2813239462Sdim * 2814239462Sdim * \param unavailable_message If non-NULL, will be set to the message text 2815239462Sdim * provided along with the unconditional unavailability of this entity. The 2816239462Sdim * client is responsible for deallocating this string. 2817239462Sdim * 2818239462Sdim * \param availability If non-NULL, an array of CXPlatformAvailability instances 2819239462Sdim * that will be populated with platform availability information, up to either 2820239462Sdim * the number of platforms for which availability information is available (as 2821239462Sdim * returned by this function) or \c availability_size, whichever is smaller. 2822239462Sdim * 2823239462Sdim * \param availability_size The number of elements available in the 2824239462Sdim * \c availability array. 2825239462Sdim * 2826239462Sdim * \returns The number of platforms (N) for which availability information is 2827239462Sdim * available (which is unrelated to \c availability_size). 2828239462Sdim * 2829239462Sdim * Note that the client is responsible for calling 2830239462Sdim * \c clang_disposeCXPlatformAvailability to free each of the 2831239462Sdim * platform-availability structures returned. There are 2832239462Sdim * \c min(N, availability_size) such structures. 2833239462Sdim */ 2834239462SdimCINDEX_LINKAGE int 2835239462Sdimclang_getCursorPlatformAvailability(CXCursor cursor, 2836239462Sdim int *always_deprecated, 2837239462Sdim CXString *deprecated_message, 2838239462Sdim int *always_unavailable, 2839239462Sdim CXString *unavailable_message, 2840239462Sdim CXPlatformAvailability *availability, 2841239462Sdim int availability_size); 2842239462Sdim 2843239462Sdim/** 2844239462Sdim * \brief Free the memory associated with a \c CXPlatformAvailability structure. 2845239462Sdim */ 2846239462SdimCINDEX_LINKAGE void 2847239462Sdimclang_disposeCXPlatformAvailability(CXPlatformAvailability *availability); 2848239462Sdim 2849239462Sdim/** 2850207619Srdivacky * \brief Describe the "language" of the entity referred to by a cursor. 2851207619Srdivacky */ 2852276479Sdimenum CXLanguageKind { 2853207619Srdivacky CXLanguage_Invalid = 0, 2854207619Srdivacky CXLanguage_C, 2855207619Srdivacky CXLanguage_ObjC, 2856207619Srdivacky CXLanguage_CPlusPlus 2857207619Srdivacky}; 2858207619Srdivacky 2859207619Srdivacky/** 2860207619Srdivacky * \brief Determine the "language" of the entity referred to by a given cursor. 2861207619Srdivacky */ 2862207619SrdivackyCINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor); 2863207619Srdivacky 2864226633Sdim/** 2865327952Sdim * \brief Describe the "thread-local storage (TLS) kind" of the declaration 2866327952Sdim * referred to by a cursor. 2867327952Sdim */ 2868327952Sdimenum CXTLSKind { 2869327952Sdim CXTLS_None = 0, 2870327952Sdim CXTLS_Dynamic, 2871327952Sdim CXTLS_Static 2872327952Sdim}; 2873327952Sdim 2874327952Sdim/** 2875327952Sdim * \brief Determine the "thread-local storage (TLS) kind" of the declaration 2876327952Sdim * referred to by a cursor. 2877327952Sdim */ 2878327952SdimCINDEX_LINKAGE enum CXTLSKind clang_getCursorTLSKind(CXCursor cursor); 2879327952Sdim 2880327952Sdim/** 2881226633Sdim * \brief Returns the translation unit that a cursor originated from. 2882226633Sdim */ 2883226633SdimCINDEX_LINKAGE CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor); 2884218893Sdim 2885207619Srdivacky/** 2886218893Sdim * \brief A fast container representing a set of CXCursors. 2887218893Sdim */ 2888218893Sdimtypedef struct CXCursorSetImpl *CXCursorSet; 2889218893Sdim 2890218893Sdim/** 2891218893Sdim * \brief Creates an empty CXCursorSet. 2892218893Sdim */ 2893249423SdimCINDEX_LINKAGE CXCursorSet clang_createCXCursorSet(void); 2894218893Sdim 2895218893Sdim/** 2896218893Sdim * \brief Disposes a CXCursorSet and releases its associated memory. 2897218893Sdim */ 2898218893SdimCINDEX_LINKAGE void clang_disposeCXCursorSet(CXCursorSet cset); 2899218893Sdim 2900218893Sdim/** 2901218893Sdim * \brief Queries a CXCursorSet to see if it contains a specific CXCursor. 2902218893Sdim * 2903218893Sdim * \returns non-zero if the set contains the specified cursor. 2904218893Sdim*/ 2905218893SdimCINDEX_LINKAGE unsigned clang_CXCursorSet_contains(CXCursorSet cset, 2906218893Sdim CXCursor cursor); 2907218893Sdim 2908218893Sdim/** 2909218893Sdim * \brief Inserts a CXCursor into a CXCursorSet. 2910218893Sdim * 2911218893Sdim * \returns zero if the CXCursor was already in the set, and non-zero otherwise. 2912218893Sdim*/ 2913218893SdimCINDEX_LINKAGE unsigned clang_CXCursorSet_insert(CXCursorSet cset, 2914218893Sdim CXCursor cursor); 2915218893Sdim 2916218893Sdim/** 2917218893Sdim * \brief Determine the semantic parent of the given cursor. 2918218893Sdim * 2919218893Sdim * The semantic parent of a cursor is the cursor that semantically contains 2920218893Sdim * the given \p cursor. For many declarations, the lexical and semantic parents 2921218893Sdim * are equivalent (the lexical parent is returned by 2922218893Sdim * \c clang_getCursorLexicalParent()). They diverge when declarations or 2923218893Sdim * definitions are provided out-of-line. For example: 2924218893Sdim * 2925218893Sdim * \code 2926218893Sdim * class C { 2927218893Sdim * void f(); 2928218893Sdim * }; 2929218893Sdim * 2930218893Sdim * void C::f() { } 2931218893Sdim * \endcode 2932218893Sdim * 2933276479Sdim * In the out-of-line definition of \c C::f, the semantic parent is 2934218893Sdim * the class \c C, of which this function is a member. The lexical parent is 2935218893Sdim * the place where the declaration actually occurs in the source code; in this 2936276479Sdim * case, the definition occurs in the translation unit. In general, the 2937218893Sdim * lexical parent for a given entity can change without affecting the semantics 2938218893Sdim * of the program, and the lexical parent of different declarations of the 2939218893Sdim * same entity may be different. Changing the semantic parent of a declaration, 2940218893Sdim * on the other hand, can have a major impact on semantics, and redeclarations 2941218893Sdim * of a particular entity should all have the same semantic context. 2942218893Sdim * 2943218893Sdim * In the example above, both declarations of \c C::f have \c C as their 2944218893Sdim * semantic context, while the lexical context of the first \c C::f is \c C 2945218893Sdim * and the lexical context of the second \c C::f is the translation unit. 2946218893Sdim * 2947218893Sdim * For global declarations, the semantic parent is the translation unit. 2948218893Sdim */ 2949218893SdimCINDEX_LINKAGE CXCursor clang_getCursorSemanticParent(CXCursor cursor); 2950218893Sdim 2951218893Sdim/** 2952218893Sdim * \brief Determine the lexical parent of the given cursor. 2953218893Sdim * 2954218893Sdim * The lexical parent of a cursor is the cursor in which the given \p cursor 2955218893Sdim * was actually written. For many declarations, the lexical and semantic parents 2956218893Sdim * are equivalent (the semantic parent is returned by 2957218893Sdim * \c clang_getCursorSemanticParent()). They diverge when declarations or 2958218893Sdim * definitions are provided out-of-line. For example: 2959218893Sdim * 2960218893Sdim * \code 2961218893Sdim * class C { 2962218893Sdim * void f(); 2963218893Sdim * }; 2964218893Sdim * 2965218893Sdim * void C::f() { } 2966218893Sdim * \endcode 2967218893Sdim * 2968276479Sdim * In the out-of-line definition of \c C::f, the semantic parent is 2969218893Sdim * the class \c C, of which this function is a member. The lexical parent is 2970218893Sdim * the place where the declaration actually occurs in the source code; in this 2971276479Sdim * case, the definition occurs in the translation unit. In general, the 2972218893Sdim * lexical parent for a given entity can change without affecting the semantics 2973218893Sdim * of the program, and the lexical parent of different declarations of the 2974218893Sdim * same entity may be different. Changing the semantic parent of a declaration, 2975218893Sdim * on the other hand, can have a major impact on semantics, and redeclarations 2976218893Sdim * of a particular entity should all have the same semantic context. 2977218893Sdim * 2978218893Sdim * In the example above, both declarations of \c C::f have \c C as their 2979218893Sdim * semantic context, while the lexical context of the first \c C::f is \c C 2980218893Sdim * and the lexical context of the second \c C::f is the translation unit. 2981218893Sdim * 2982218893Sdim * For declarations written in the global scope, the lexical parent is 2983218893Sdim * the translation unit. 2984218893Sdim */ 2985218893SdimCINDEX_LINKAGE CXCursor clang_getCursorLexicalParent(CXCursor cursor); 2986218893Sdim 2987218893Sdim/** 2988218893Sdim * \brief Determine the set of methods that are overridden by the given 2989218893Sdim * method. 2990218893Sdim * 2991218893Sdim * In both Objective-C and C++, a method (aka virtual member function, 2992218893Sdim * in C++) can override a virtual method in a base class. For 2993218893Sdim * Objective-C, a method is said to override any method in the class's 2994234353Sdim * base class, its protocols, or its categories' protocols, that has the same 2995234353Sdim * selector and is of the same kind (class or instance). 2996234353Sdim * If no such method exists, the search continues to the class's superclass, 2997234353Sdim * its protocols, and its categories, and so on. A method from an Objective-C 2998234353Sdim * implementation is considered to override the same methods as its 2999234353Sdim * corresponding method in the interface. 3000218893Sdim * 3001218893Sdim * For C++, a virtual member function overrides any virtual member 3002218893Sdim * function with the same signature that occurs in its base 3003218893Sdim * classes. With multiple inheritance, a virtual member function can 3004218893Sdim * override several virtual member functions coming from different 3005218893Sdim * base classes. 3006218893Sdim * 3007218893Sdim * In all cases, this function determines the immediate overridden 3008218893Sdim * method, rather than all of the overridden methods. For example, if 3009218893Sdim * a method is originally declared in a class A, then overridden in B 3010218893Sdim * (which in inherits from A) and also in C (which inherited from B), 3011218893Sdim * then the only overridden method returned from this function when 3012218893Sdim * invoked on C's method will be B's method. The client may then 3013218893Sdim * invoke this function again, given the previously-found overridden 3014218893Sdim * methods, to map out the complete method-override set. 3015218893Sdim * 3016218893Sdim * \param cursor A cursor representing an Objective-C or C++ 3017218893Sdim * method. This routine will compute the set of methods that this 3018218893Sdim * method overrides. 3019218893Sdim * 3020218893Sdim * \param overridden A pointer whose pointee will be replaced with a 3021218893Sdim * pointer to an array of cursors, representing the set of overridden 3022218893Sdim * methods. If there are no overridden methods, the pointee will be 3023218893Sdim * set to NULL. The pointee must be freed via a call to 3024218893Sdim * \c clang_disposeOverriddenCursors(). 3025218893Sdim * 3026218893Sdim * \param num_overridden A pointer to the number of overridden 3027218893Sdim * functions, will be set to the number of overridden functions in the 3028218893Sdim * array pointed to by \p overridden. 3029218893Sdim */ 3030218893SdimCINDEX_LINKAGE void clang_getOverriddenCursors(CXCursor cursor, 3031218893Sdim CXCursor **overridden, 3032218893Sdim unsigned *num_overridden); 3033218893Sdim 3034218893Sdim/** 3035218893Sdim * \brief Free the set of overridden cursors returned by \c 3036218893Sdim * clang_getOverriddenCursors(). 3037218893Sdim */ 3038218893SdimCINDEX_LINKAGE void clang_disposeOverriddenCursors(CXCursor *overridden); 3039218893Sdim 3040218893Sdim/** 3041218893Sdim * \brief Retrieve the file that is included by the given inclusion directive 3042218893Sdim * cursor. 3043218893Sdim */ 3044218893SdimCINDEX_LINKAGE CXFile clang_getIncludedFile(CXCursor cursor); 3045218893Sdim 3046218893Sdim/** 3047202879Srdivacky * @} 3048202879Srdivacky */ 3049203955Srdivacky 3050202879Srdivacky/** 3051202879Srdivacky * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code 3052202879Srdivacky * 3053202879Srdivacky * Cursors represent a location within the Abstract Syntax Tree (AST). These 3054202879Srdivacky * routines help map between cursors and the physical locations where the 3055202879Srdivacky * described entities occur in the source code. The mapping is provided in 3056202879Srdivacky * both directions, so one can map from source code to the AST and back. 3057202879Srdivacky * 3058202879Srdivacky * @{ 3059202879Srdivacky */ 3060203955Srdivacky 3061202879Srdivacky/** 3062202879Srdivacky * \brief Map a source location to the cursor that describes the entity at that 3063202879Srdivacky * location in the source code. 3064202879Srdivacky * 3065202879Srdivacky * clang_getCursor() maps an arbitrary source location within a translation 3066202879Srdivacky * unit down to the most specific cursor that describes the entity at that 3067203955Srdivacky * location. For example, given an expression \c x + y, invoking 3068202879Srdivacky * clang_getCursor() with a source location pointing to "x" will return the 3069203955Srdivacky * cursor for "x"; similarly for "y". If the cursor points anywhere between 3070202879Srdivacky * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor() 3071202879Srdivacky * will return a cursor referring to the "+" expression. 3072202879Srdivacky * 3073202879Srdivacky * \returns a cursor representing the entity at the given source location, or 3074202879Srdivacky * a NULL cursor if no such entity can be found. 3075202879Srdivacky */ 3076202879SrdivackyCINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, CXSourceLocation); 3077203955Srdivacky 3078202879Srdivacky/** 3079202879Srdivacky * \brief Retrieve the physical location of the source constructor referenced 3080202879Srdivacky * by the given cursor. 3081202879Srdivacky * 3082202879Srdivacky * The location of a declaration is typically the location of the name of that 3083203955Srdivacky * declaration, where the name of that declaration would occur if it is 3084203955Srdivacky * unnamed, or some keyword that introduces that particular declaration. 3085203955Srdivacky * The location of a reference is where that reference occurs within the 3086202879Srdivacky * source code. 3087202879Srdivacky */ 3088202879SrdivackyCINDEX_LINKAGE CXSourceLocation clang_getCursorLocation(CXCursor); 3089199482Srdivacky 3090202879Srdivacky/** 3091202879Srdivacky * \brief Retrieve the physical extent of the source construct referenced by 3092202879Srdivacky * the given cursor. 3093202879Srdivacky * 3094202879Srdivacky * The extent of a cursor starts with the file/line/column pointing at the 3095202879Srdivacky * first character within the source construct that the cursor refers to and 3096276479Sdim * ends with the last character within that source construct. For a 3097202879Srdivacky * declaration, the extent covers the declaration itself. For a reference, 3098202879Srdivacky * the extent covers the location of the reference (e.g., where the referenced 3099202879Srdivacky * entity was actually used). 3100202879Srdivacky */ 3101202879SrdivackyCINDEX_LINKAGE CXSourceRange clang_getCursorExtent(CXCursor); 3102202879Srdivacky 3103202879Srdivacky/** 3104202879Srdivacky * @} 3105202879Srdivacky */ 3106212904Sdim 3107202879Srdivacky/** 3108208600Srdivacky * \defgroup CINDEX_TYPES Type information for CXCursors 3109208600Srdivacky * 3110208600Srdivacky * @{ 3111208600Srdivacky */ 3112208600Srdivacky 3113208600Srdivacky/** 3114208600Srdivacky * \brief Describes the kind of type 3115208600Srdivacky */ 3116208600Srdivackyenum CXTypeKind { 3117208600Srdivacky /** 3118276479Sdim * \brief Represents an invalid type (e.g., where no type is available). 3119208600Srdivacky */ 3120208600Srdivacky CXType_Invalid = 0, 3121208600Srdivacky 3122208600Srdivacky /** 3123208600Srdivacky * \brief A type whose specific kind is not exposed via this 3124208600Srdivacky * interface. 3125208600Srdivacky */ 3126208600Srdivacky CXType_Unexposed = 1, 3127208600Srdivacky 3128208600Srdivacky /* Builtin types */ 3129208600Srdivacky CXType_Void = 2, 3130208600Srdivacky CXType_Bool = 3, 3131208600Srdivacky CXType_Char_U = 4, 3132208600Srdivacky CXType_UChar = 5, 3133208600Srdivacky CXType_Char16 = 6, 3134208600Srdivacky CXType_Char32 = 7, 3135208600Srdivacky CXType_UShort = 8, 3136208600Srdivacky CXType_UInt = 9, 3137208600Srdivacky CXType_ULong = 10, 3138208600Srdivacky CXType_ULongLong = 11, 3139208600Srdivacky CXType_UInt128 = 12, 3140208600Srdivacky CXType_Char_S = 13, 3141208600Srdivacky CXType_SChar = 14, 3142208600Srdivacky CXType_WChar = 15, 3143208600Srdivacky CXType_Short = 16, 3144208600Srdivacky CXType_Int = 17, 3145208600Srdivacky CXType_Long = 18, 3146208600Srdivacky CXType_LongLong = 19, 3147208600Srdivacky CXType_Int128 = 20, 3148208600Srdivacky CXType_Float = 21, 3149208600Srdivacky CXType_Double = 22, 3150208600Srdivacky CXType_LongDouble = 23, 3151208600Srdivacky CXType_NullPtr = 24, 3152208600Srdivacky CXType_Overload = 25, 3153208600Srdivacky CXType_Dependent = 26, 3154208600Srdivacky CXType_ObjCId = 27, 3155208600Srdivacky CXType_ObjCClass = 28, 3156208600Srdivacky CXType_ObjCSel = 29, 3157309124Sdim CXType_Float128 = 30, 3158321369Sdim CXType_Half = 31, 3159327952Sdim CXType_Float16 = 32, 3160208600Srdivacky CXType_FirstBuiltin = CXType_Void, 3161327952Sdim CXType_LastBuiltin = CXType_Float16, 3162208600Srdivacky 3163208600Srdivacky CXType_Complex = 100, 3164208600Srdivacky CXType_Pointer = 101, 3165208600Srdivacky CXType_BlockPointer = 102, 3166208600Srdivacky CXType_LValueReference = 103, 3167208600Srdivacky CXType_RValueReference = 104, 3168208600Srdivacky CXType_Record = 105, 3169208600Srdivacky CXType_Enum = 106, 3170208600Srdivacky CXType_Typedef = 107, 3171208600Srdivacky CXType_ObjCInterface = 108, 3172210299Sed CXType_ObjCObjectPointer = 109, 3173210299Sed CXType_FunctionNoProto = 110, 3174226633Sdim CXType_FunctionProto = 111, 3175234353Sdim CXType_ConstantArray = 112, 3176261991Sdim CXType_Vector = 113, 3177261991Sdim CXType_IncompleteArray = 114, 3178261991Sdim CXType_VariableArray = 115, 3179261991Sdim CXType_DependentSizedArray = 116, 3180296417Sdim CXType_MemberPointer = 117, 3181309124Sdim CXType_Auto = 118, 3182309124Sdim 3183309124Sdim /** 3184309124Sdim * \brief Represents a type that was referred to using an elaborated type keyword. 3185309124Sdim * 3186309124Sdim * E.g., struct S, or via a qualified name, e.g., N::M::type, or both. 3187309124Sdim */ 3188321369Sdim CXType_Elaborated = 119, 3189321369Sdim 3190321369Sdim /* OpenCL PipeType. */ 3191321369Sdim CXType_Pipe = 120, 3192321369Sdim 3193321369Sdim /* OpenCL builtin types. */ 3194321369Sdim CXType_OCLImage1dRO = 121, 3195321369Sdim CXType_OCLImage1dArrayRO = 122, 3196321369Sdim CXType_OCLImage1dBufferRO = 123, 3197321369Sdim CXType_OCLImage2dRO = 124, 3198321369Sdim CXType_OCLImage2dArrayRO = 125, 3199321369Sdim CXType_OCLImage2dDepthRO = 126, 3200321369Sdim CXType_OCLImage2dArrayDepthRO = 127, 3201321369Sdim CXType_OCLImage2dMSAARO = 128, 3202321369Sdim CXType_OCLImage2dArrayMSAARO = 129, 3203321369Sdim CXType_OCLImage2dMSAADepthRO = 130, 3204321369Sdim CXType_OCLImage2dArrayMSAADepthRO = 131, 3205321369Sdim CXType_OCLImage3dRO = 132, 3206321369Sdim CXType_OCLImage1dWO = 133, 3207321369Sdim CXType_OCLImage1dArrayWO = 134, 3208321369Sdim CXType_OCLImage1dBufferWO = 135, 3209321369Sdim CXType_OCLImage2dWO = 136, 3210321369Sdim CXType_OCLImage2dArrayWO = 137, 3211321369Sdim CXType_OCLImage2dDepthWO = 138, 3212321369Sdim CXType_OCLImage2dArrayDepthWO = 139, 3213321369Sdim CXType_OCLImage2dMSAAWO = 140, 3214321369Sdim CXType_OCLImage2dArrayMSAAWO = 141, 3215321369Sdim CXType_OCLImage2dMSAADepthWO = 142, 3216321369Sdim CXType_OCLImage2dArrayMSAADepthWO = 143, 3217321369Sdim CXType_OCLImage3dWO = 144, 3218321369Sdim CXType_OCLImage1dRW = 145, 3219321369Sdim CXType_OCLImage1dArrayRW = 146, 3220321369Sdim CXType_OCLImage1dBufferRW = 147, 3221321369Sdim CXType_OCLImage2dRW = 148, 3222321369Sdim CXType_OCLImage2dArrayRW = 149, 3223321369Sdim CXType_OCLImage2dDepthRW = 150, 3224321369Sdim CXType_OCLImage2dArrayDepthRW = 151, 3225321369Sdim CXType_OCLImage2dMSAARW = 152, 3226321369Sdim CXType_OCLImage2dArrayMSAARW = 153, 3227321369Sdim CXType_OCLImage2dMSAADepthRW = 154, 3228321369Sdim CXType_OCLImage2dArrayMSAADepthRW = 155, 3229321369Sdim CXType_OCLImage3dRW = 156, 3230321369Sdim CXType_OCLSampler = 157, 3231321369Sdim CXType_OCLEvent = 158, 3232321369Sdim CXType_OCLQueue = 159, 3233321369Sdim CXType_OCLReserveID = 160 3234208600Srdivacky}; 3235208600Srdivacky 3236208600Srdivacky/** 3237234353Sdim * \brief Describes the calling convention of a function type 3238234353Sdim */ 3239234353Sdimenum CXCallingConv { 3240234353Sdim CXCallingConv_Default = 0, 3241234353Sdim CXCallingConv_C = 1, 3242234353Sdim CXCallingConv_X86StdCall = 2, 3243234353Sdim CXCallingConv_X86FastCall = 3, 3244234353Sdim CXCallingConv_X86ThisCall = 4, 3245234353Sdim CXCallingConv_X86Pascal = 5, 3246234353Sdim CXCallingConv_AAPCS = 6, 3247234353Sdim CXCallingConv_AAPCS_VFP = 7, 3248314564Sdim CXCallingConv_X86RegCall = 8, 3249249423Sdim CXCallingConv_IntelOclBicc = 9, 3250321369Sdim CXCallingConv_Win64 = 10, 3251322740Sdim /* Alias for compatibility with older versions of API. */ 3252322740Sdim CXCallingConv_X86_64Win64 = CXCallingConv_Win64, 3253256030Sdim CXCallingConv_X86_64SysV = 11, 3254280031Sdim CXCallingConv_X86VectorCall = 12, 3255309124Sdim CXCallingConv_Swift = 13, 3256309124Sdim CXCallingConv_PreserveMost = 14, 3257309124Sdim CXCallingConv_PreserveAll = 15, 3258234353Sdim 3259234353Sdim CXCallingConv_Invalid = 100, 3260234353Sdim CXCallingConv_Unexposed = 200 3261234353Sdim}; 3262234353Sdim 3263234353Sdim/** 3264208600Srdivacky * \brief The type of an element in the abstract syntax tree. 3265208600Srdivacky * 3266208600Srdivacky */ 3267208600Srdivackytypedef struct { 3268208600Srdivacky enum CXTypeKind kind; 3269208600Srdivacky void *data[2]; 3270208600Srdivacky} CXType; 3271208600Srdivacky 3272208600Srdivacky/** 3273208600Srdivacky * \brief Retrieve the type of a CXCursor (if any). 3274208600Srdivacky */ 3275208600SrdivackyCINDEX_LINKAGE CXType clang_getCursorType(CXCursor C); 3276208600Srdivacky 3277208600Srdivacky/** 3278249423Sdim * \brief Pretty-print the underlying type using the rules of the 3279249423Sdim * language of the translation unit from which it came. 3280249423Sdim * 3281249423Sdim * If the type is invalid, an empty string is returned. 3282249423Sdim */ 3283249423SdimCINDEX_LINKAGE CXString clang_getTypeSpelling(CXType CT); 3284249423Sdim 3285249423Sdim/** 3286234353Sdim * \brief Retrieve the underlying type of a typedef declaration. 3287234353Sdim * 3288234353Sdim * If the cursor does not reference a typedef declaration, an invalid type is 3289234353Sdim * returned. 3290234353Sdim */ 3291234353SdimCINDEX_LINKAGE CXType clang_getTypedefDeclUnderlyingType(CXCursor C); 3292234353Sdim 3293234353Sdim/** 3294234353Sdim * \brief Retrieve the integer type of an enum declaration. 3295234353Sdim * 3296234353Sdim * If the cursor does not reference an enum declaration, an invalid type is 3297234353Sdim * returned. 3298234353Sdim */ 3299234353SdimCINDEX_LINKAGE CXType clang_getEnumDeclIntegerType(CXCursor C); 3300234353Sdim 3301234353Sdim/** 3302234353Sdim * \brief Retrieve the integer value of an enum constant declaration as a signed 3303234353Sdim * long long. 3304234353Sdim * 3305234353Sdim * If the cursor does not reference an enum constant declaration, LLONG_MIN is returned. 3306234353Sdim * Since this is also potentially a valid constant value, the kind of the cursor 3307234353Sdim * must be verified before calling this function. 3308234353Sdim */ 3309234353SdimCINDEX_LINKAGE long long clang_getEnumConstantDeclValue(CXCursor C); 3310234353Sdim 3311234353Sdim/** 3312234353Sdim * \brief Retrieve the integer value of an enum constant declaration as an unsigned 3313234353Sdim * long long. 3314234353Sdim * 3315234353Sdim * If the cursor does not reference an enum constant declaration, ULLONG_MAX is returned. 3316234353Sdim * Since this is also potentially a valid constant value, the kind of the cursor 3317234353Sdim * must be verified before calling this function. 3318234353Sdim */ 3319234353SdimCINDEX_LINKAGE unsigned long long clang_getEnumConstantDeclUnsignedValue(CXCursor C); 3320234353Sdim 3321234353Sdim/** 3322249423Sdim * \brief Retrieve the bit width of a bit field declaration as an integer. 3323249423Sdim * 3324249423Sdim * If a cursor that is not a bit field declaration is passed in, -1 is returned. 3325249423Sdim */ 3326249423SdimCINDEX_LINKAGE int clang_getFieldDeclBitWidth(CXCursor C); 3327249423Sdim 3328249423Sdim/** 3329234353Sdim * \brief Retrieve the number of non-variadic arguments associated with a given 3330234353Sdim * cursor. 3331234353Sdim * 3332249423Sdim * The number of arguments can be determined for calls as well as for 3333249423Sdim * declarations of functions or methods. For other cursors -1 is returned. 3334234353Sdim */ 3335234353SdimCINDEX_LINKAGE int clang_Cursor_getNumArguments(CXCursor C); 3336234353Sdim 3337234353Sdim/** 3338234353Sdim * \brief Retrieve the argument cursor of a function or method. 3339234353Sdim * 3340249423Sdim * The argument cursor can be determined for calls as well as for declarations 3341249423Sdim * of functions or methods. For other cursors and for invalid indices, an 3342249423Sdim * invalid cursor is returned. 3343234353Sdim */ 3344234353SdimCINDEX_LINKAGE CXCursor clang_Cursor_getArgument(CXCursor C, unsigned i); 3345234353Sdim 3346234353Sdim/** 3347280031Sdim * \brief Describes the kind of a template argument. 3348280031Sdim * 3349280031Sdim * See the definition of llvm::clang::TemplateArgument::ArgKind for full 3350280031Sdim * element descriptions. 3351280031Sdim */ 3352280031Sdimenum CXTemplateArgumentKind { 3353280031Sdim CXTemplateArgumentKind_Null, 3354280031Sdim CXTemplateArgumentKind_Type, 3355280031Sdim CXTemplateArgumentKind_Declaration, 3356280031Sdim CXTemplateArgumentKind_NullPtr, 3357280031Sdim CXTemplateArgumentKind_Integral, 3358280031Sdim CXTemplateArgumentKind_Template, 3359280031Sdim CXTemplateArgumentKind_TemplateExpansion, 3360280031Sdim CXTemplateArgumentKind_Expression, 3361280031Sdim CXTemplateArgumentKind_Pack, 3362280031Sdim /* Indicates an error case, preventing the kind from being deduced. */ 3363280031Sdim CXTemplateArgumentKind_Invalid 3364280031Sdim}; 3365280031Sdim 3366280031Sdim/** 3367280031Sdim *\brief Returns the number of template args of a function decl representing a 3368280031Sdim * template specialization. 3369280031Sdim * 3370280031Sdim * If the argument cursor cannot be converted into a template function 3371280031Sdim * declaration, -1 is returned. 3372280031Sdim * 3373280031Sdim * For example, for the following declaration and specialization: 3374280031Sdim * template <typename T, int kInt, bool kBool> 3375280031Sdim * void foo() { ... } 3376280031Sdim * 3377280031Sdim * template <> 3378280031Sdim * void foo<float, -7, true>(); 3379280031Sdim * 3380280031Sdim * The value 3 would be returned from this call. 3381280031Sdim */ 3382280031SdimCINDEX_LINKAGE int clang_Cursor_getNumTemplateArguments(CXCursor C); 3383280031Sdim 3384280031Sdim/** 3385280031Sdim * \brief Retrieve the kind of the I'th template argument of the CXCursor C. 3386280031Sdim * 3387280031Sdim * If the argument CXCursor does not represent a FunctionDecl, an invalid 3388280031Sdim * template argument kind is returned. 3389280031Sdim * 3390280031Sdim * For example, for the following declaration and specialization: 3391280031Sdim * template <typename T, int kInt, bool kBool> 3392280031Sdim * void foo() { ... } 3393280031Sdim * 3394280031Sdim * template <> 3395280031Sdim * void foo<float, -7, true>(); 3396280031Sdim * 3397280031Sdim * For I = 0, 1, and 2, Type, Integral, and Integral will be returned, 3398280031Sdim * respectively. 3399280031Sdim */ 3400280031SdimCINDEX_LINKAGE enum CXTemplateArgumentKind clang_Cursor_getTemplateArgumentKind( 3401280031Sdim CXCursor C, unsigned I); 3402280031Sdim 3403280031Sdim/** 3404280031Sdim * \brief Retrieve a CXType representing the type of a TemplateArgument of a 3405280031Sdim * function decl representing a template specialization. 3406280031Sdim * 3407280031Sdim * If the argument CXCursor does not represent a FunctionDecl whose I'th 3408280031Sdim * template argument has a kind of CXTemplateArgKind_Integral, an invalid type 3409280031Sdim * is returned. 3410280031Sdim * 3411280031Sdim * For example, for the following declaration and specialization: 3412280031Sdim * template <typename T, int kInt, bool kBool> 3413280031Sdim * void foo() { ... } 3414280031Sdim * 3415280031Sdim * template <> 3416280031Sdim * void foo<float, -7, true>(); 3417280031Sdim * 3418280031Sdim * If called with I = 0, "float", will be returned. 3419280031Sdim * Invalid types will be returned for I == 1 or 2. 3420280031Sdim */ 3421280031SdimCINDEX_LINKAGE CXType clang_Cursor_getTemplateArgumentType(CXCursor C, 3422280031Sdim unsigned I); 3423280031Sdim 3424280031Sdim/** 3425280031Sdim * \brief Retrieve the value of an Integral TemplateArgument (of a function 3426280031Sdim * decl representing a template specialization) as a signed long long. 3427280031Sdim * 3428280031Sdim * It is undefined to call this function on a CXCursor that does not represent a 3429280031Sdim * FunctionDecl or whose I'th template argument is not an integral value. 3430280031Sdim * 3431280031Sdim * For example, for the following declaration and specialization: 3432280031Sdim * template <typename T, int kInt, bool kBool> 3433280031Sdim * void foo() { ... } 3434280031Sdim * 3435280031Sdim * template <> 3436280031Sdim * void foo<float, -7, true>(); 3437280031Sdim * 3438280031Sdim * If called with I = 1 or 2, -7 or true will be returned, respectively. 3439280031Sdim * For I == 0, this function's behavior is undefined. 3440280031Sdim */ 3441280031SdimCINDEX_LINKAGE long long clang_Cursor_getTemplateArgumentValue(CXCursor C, 3442280031Sdim unsigned I); 3443280031Sdim 3444280031Sdim/** 3445280031Sdim * \brief Retrieve the value of an Integral TemplateArgument (of a function 3446280031Sdim * decl representing a template specialization) as an unsigned long long. 3447280031Sdim * 3448280031Sdim * It is undefined to call this function on a CXCursor that does not represent a 3449280031Sdim * FunctionDecl or whose I'th template argument is not an integral value. 3450280031Sdim * 3451280031Sdim * For example, for the following declaration and specialization: 3452280031Sdim * template <typename T, int kInt, bool kBool> 3453280031Sdim * void foo() { ... } 3454280031Sdim * 3455280031Sdim * template <> 3456280031Sdim * void foo<float, 2147483649, true>(); 3457280031Sdim * 3458280031Sdim * If called with I = 1 or 2, 2147483649 or true will be returned, respectively. 3459280031Sdim * For I == 0, this function's behavior is undefined. 3460280031Sdim */ 3461280031SdimCINDEX_LINKAGE unsigned long long clang_Cursor_getTemplateArgumentUnsignedValue( 3462280031Sdim CXCursor C, unsigned I); 3463280031Sdim 3464280031Sdim/** 3465239462Sdim * \brief Determine whether two CXTypes represent the same type. 3466208600Srdivacky * 3467239462Sdim * \returns non-zero if the CXTypes represent the same type and 3468239462Sdim * zero otherwise. 3469208600Srdivacky */ 3470208600SrdivackyCINDEX_LINKAGE unsigned clang_equalTypes(CXType A, CXType B); 3471208600Srdivacky 3472208600Srdivacky/** 3473208600Srdivacky * \brief Return the canonical type for a CXType. 3474208600Srdivacky * 3475208600Srdivacky * Clang's type system explicitly models typedefs and all the ways 3476208600Srdivacky * a specific type can be represented. The canonical type is the underlying 3477208600Srdivacky * type with all the "sugar" removed. For example, if 'T' is a typedef 3478208600Srdivacky * for 'int', the canonical type for 'T' would be 'int'. 3479208600Srdivacky */ 3480208600SrdivackyCINDEX_LINKAGE CXType clang_getCanonicalType(CXType T); 3481208600Srdivacky 3482208600Srdivacky/** 3483239462Sdim * \brief Determine whether a CXType has the "const" qualifier set, 3484239462Sdim * without looking through typedefs that may have added "const" at a 3485239462Sdim * different level. 3486218893Sdim */ 3487218893SdimCINDEX_LINKAGE unsigned clang_isConstQualifiedType(CXType T); 3488218893Sdim 3489218893Sdim/** 3490309124Sdim * \brief Determine whether a CXCursor that is a macro, is 3491309124Sdim * function like. 3492309124Sdim */ 3493309124SdimCINDEX_LINKAGE unsigned clang_Cursor_isMacroFunctionLike(CXCursor C); 3494309124Sdim 3495309124Sdim/** 3496309124Sdim * \brief Determine whether a CXCursor that is a macro, is a 3497309124Sdim * builtin one. 3498309124Sdim */ 3499309124SdimCINDEX_LINKAGE unsigned clang_Cursor_isMacroBuiltin(CXCursor C); 3500309124Sdim 3501309124Sdim/** 3502309124Sdim * \brief Determine whether a CXCursor that is a function declaration, is an 3503309124Sdim * inline declaration. 3504309124Sdim */ 3505309124SdimCINDEX_LINKAGE unsigned clang_Cursor_isFunctionInlined(CXCursor C); 3506309124Sdim 3507309124Sdim/** 3508239462Sdim * \brief Determine whether a CXType has the "volatile" qualifier set, 3509239462Sdim * without looking through typedefs that may have added "volatile" at 3510239462Sdim * a different level. 3511218893Sdim */ 3512218893SdimCINDEX_LINKAGE unsigned clang_isVolatileQualifiedType(CXType T); 3513218893Sdim 3514218893Sdim/** 3515239462Sdim * \brief Determine whether a CXType has the "restrict" qualifier set, 3516239462Sdim * without looking through typedefs that may have added "restrict" at a 3517239462Sdim * different level. 3518218893Sdim */ 3519218893SdimCINDEX_LINKAGE unsigned clang_isRestrictQualifiedType(CXType T); 3520218893Sdim 3521218893Sdim/** 3522321369Sdim * \brief Returns the address space of the given type. 3523321369Sdim */ 3524321369SdimCINDEX_LINKAGE unsigned clang_getAddressSpace(CXType T); 3525321369Sdim 3526321369Sdim/** 3527321369Sdim * \brief Returns the typedef name of the given type. 3528321369Sdim */ 3529321369SdimCINDEX_LINKAGE CXString clang_getTypedefName(CXType CT); 3530321369Sdim 3531321369Sdim/** 3532208600Srdivacky * \brief For pointer types, returns the type of the pointee. 3533208600Srdivacky */ 3534208600SrdivackyCINDEX_LINKAGE CXType clang_getPointeeType(CXType T); 3535208600Srdivacky 3536208600Srdivacky/** 3537208600Srdivacky * \brief Return the cursor for the declaration of the given type. 3538208600Srdivacky */ 3539208600SrdivackyCINDEX_LINKAGE CXCursor clang_getTypeDeclaration(CXType T); 3540208600Srdivacky 3541218893Sdim/** 3542218893Sdim * Returns the Objective-C type encoding for the specified declaration. 3543218893Sdim */ 3544218893SdimCINDEX_LINKAGE CXString clang_getDeclObjCTypeEncoding(CXCursor C); 3545208600Srdivacky 3546208600Srdivacky/** 3547309124Sdim * Returns the Objective-C type encoding for the specified CXType. 3548309124Sdim */ 3549309124SdimCINDEX_LINKAGE CXString clang_Type_getObjCEncoding(CXType type); 3550309124Sdim 3551309124Sdim/** 3552208600Srdivacky * \brief Retrieve the spelling of a given CXTypeKind. 3553208600Srdivacky */ 3554208600SrdivackyCINDEX_LINKAGE CXString clang_getTypeKindSpelling(enum CXTypeKind K); 3555208600Srdivacky 3556208600Srdivacky/** 3557234353Sdim * \brief Retrieve the calling convention associated with a function type. 3558234353Sdim * 3559234353Sdim * If a non-function type is passed in, CXCallingConv_Invalid is returned. 3560234353Sdim */ 3561234353SdimCINDEX_LINKAGE enum CXCallingConv clang_getFunctionTypeCallingConv(CXType T); 3562234353Sdim 3563234353Sdim/** 3564276479Sdim * \brief Retrieve the return type associated with a function type. 3565234353Sdim * 3566234353Sdim * If a non-function type is passed in, an invalid type is returned. 3567210299Sed */ 3568210299SedCINDEX_LINKAGE CXType clang_getResultType(CXType T); 3569210299Sed 3570210299Sed/** 3571321369Sdim * \brief Retrieve the exception specification type associated with a function type. 3572321369Sdim * 3573321369Sdim * If a non-function type is passed in, an error code of -1 is returned. 3574321369Sdim */ 3575321369SdimCINDEX_LINKAGE int clang_getExceptionSpecificationType(CXType T); 3576321369Sdim 3577321369Sdim/** 3578276479Sdim * \brief Retrieve the number of non-variadic parameters associated with a 3579239462Sdim * function type. 3580234353Sdim * 3581234353Sdim * If a non-function type is passed in, -1 is returned. 3582210299Sed */ 3583234353SdimCINDEX_LINKAGE int clang_getNumArgTypes(CXType T); 3584234353Sdim 3585234353Sdim/** 3586276479Sdim * \brief Retrieve the type of a parameter of a function type. 3587234353Sdim * 3588239462Sdim * If a non-function type is passed in or the function does not have enough 3589239462Sdim * parameters, an invalid type is returned. 3590234353Sdim */ 3591234353SdimCINDEX_LINKAGE CXType clang_getArgType(CXType T, unsigned i); 3592234353Sdim 3593234353Sdim/** 3594234353Sdim * \brief Return 1 if the CXType is a variadic function type, and 0 otherwise. 3595234353Sdim */ 3596234353SdimCINDEX_LINKAGE unsigned clang_isFunctionTypeVariadic(CXType T); 3597234353Sdim 3598234353Sdim/** 3599276479Sdim * \brief Retrieve the return type associated with a given cursor. 3600234353Sdim * 3601234353Sdim * This only returns a valid type if the cursor refers to a function or method. 3602234353Sdim */ 3603210299SedCINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C); 3604210299Sed 3605210299Sed/** 3606321369Sdim * \brief Retrieve the exception specification type associated with a given cursor. 3607321369Sdim * 3608321369Sdim * This only returns a valid result if the cursor refers to a function or method. 3609321369Sdim */ 3610321369SdimCINDEX_LINKAGE int clang_getCursorExceptionSpecificationType(CXCursor C); 3611321369Sdim 3612321369Sdim/** 3613212904Sdim * \brief Return 1 if the CXType is a POD (plain old data) type, and 0 3614212904Sdim * otherwise. 3615212904Sdim */ 3616212904SdimCINDEX_LINKAGE unsigned clang_isPODType(CXType T); 3617212904Sdim 3618212904Sdim/** 3619234353Sdim * \brief Return the element type of an array, complex, or vector type. 3620234353Sdim * 3621234353Sdim * If a type is passed in that is not an array, complex, or vector type, 3622234353Sdim * an invalid type is returned. 3623234353Sdim */ 3624234353SdimCINDEX_LINKAGE CXType clang_getElementType(CXType T); 3625234353Sdim 3626234353Sdim/** 3627234353Sdim * \brief Return the number of elements of an array or vector type. 3628234353Sdim * 3629234353Sdim * If a type is passed in that is not an array or vector type, 3630234353Sdim * -1 is returned. 3631234353Sdim */ 3632234353SdimCINDEX_LINKAGE long long clang_getNumElements(CXType T); 3633234353Sdim 3634234353Sdim/** 3635226633Sdim * \brief Return the element type of an array type. 3636226633Sdim * 3637226633Sdim * If a non-array type is passed in, an invalid type is returned. 3638226633Sdim */ 3639226633SdimCINDEX_LINKAGE CXType clang_getArrayElementType(CXType T); 3640226633Sdim 3641226633Sdim/** 3642239462Sdim * \brief Return the array size of a constant array. 3643226633Sdim * 3644226633Sdim * If a non-array type is passed in, -1 is returned. 3645226633Sdim */ 3646226633SdimCINDEX_LINKAGE long long clang_getArraySize(CXType T); 3647226633Sdim 3648226633Sdim/** 3649309124Sdim * \brief Retrieve the type named by the qualified-id. 3650309124Sdim * 3651309124Sdim * If a non-elaborated type is passed in, an invalid type is returned. 3652309124Sdim */ 3653309124SdimCINDEX_LINKAGE CXType clang_Type_getNamedType(CXType T); 3654309124Sdim 3655309124Sdim/** 3656321369Sdim * \brief Determine if a typedef is 'transparent' tag. 3657321369Sdim * 3658321369Sdim * A typedef is considered 'transparent' if it shares a name and spelling 3659321369Sdim * location with its underlying tag type, as is the case with the NS_ENUM macro. 3660321369Sdim * 3661321369Sdim * \returns non-zero if transparent and zero otherwise. 3662321369Sdim */ 3663321369SdimCINDEX_LINKAGE unsigned clang_Type_isTransparentTagTypedef(CXType T); 3664321369Sdim 3665321369Sdim/** 3666251662Sdim * \brief List the possible error codes for \c clang_Type_getSizeOf, 3667251662Sdim * \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf and 3668251662Sdim * \c clang_Cursor_getOffsetOf. 3669251662Sdim * 3670251662Sdim * A value of this enumeration type can be returned if the target type is not 3671251662Sdim * a valid argument to sizeof, alignof or offsetof. 3672251662Sdim */ 3673251662Sdimenum CXTypeLayoutError { 3674251662Sdim /** 3675251662Sdim * \brief Type is of kind CXType_Invalid. 3676251662Sdim */ 3677251662Sdim CXTypeLayoutError_Invalid = -1, 3678251662Sdim /** 3679251662Sdim * \brief The type is an incomplete Type. 3680251662Sdim */ 3681251662Sdim CXTypeLayoutError_Incomplete = -2, 3682251662Sdim /** 3683251662Sdim * \brief The type is a dependent Type. 3684251662Sdim */ 3685251662Sdim CXTypeLayoutError_Dependent = -3, 3686251662Sdim /** 3687251662Sdim * \brief The type is not a constant size type. 3688251662Sdim */ 3689251662Sdim CXTypeLayoutError_NotConstantSize = -4, 3690251662Sdim /** 3691251662Sdim * \brief The Field name is not valid for this record. 3692251662Sdim */ 3693251662Sdim CXTypeLayoutError_InvalidFieldName = -5 3694251662Sdim}; 3695251662Sdim 3696251662Sdim/** 3697251662Sdim * \brief Return the alignment of a type in bytes as per C++[expr.alignof] 3698251662Sdim * standard. 3699251662Sdim * 3700251662Sdim * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned. 3701251662Sdim * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete 3702251662Sdim * is returned. 3703251662Sdim * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is 3704251662Sdim * returned. 3705251662Sdim * If the type declaration is not a constant size type, 3706251662Sdim * CXTypeLayoutError_NotConstantSize is returned. 3707251662Sdim */ 3708251662SdimCINDEX_LINKAGE long long clang_Type_getAlignOf(CXType T); 3709251662Sdim 3710251662Sdim/** 3711261991Sdim * \brief Return the class type of an member pointer type. 3712261991Sdim * 3713261991Sdim * If a non-member-pointer type is passed in, an invalid type is returned. 3714261991Sdim */ 3715261991SdimCINDEX_LINKAGE CXType clang_Type_getClassType(CXType T); 3716261991Sdim 3717261991Sdim/** 3718251662Sdim * \brief Return the size of a type in bytes as per C++[expr.sizeof] standard. 3719251662Sdim * 3720251662Sdim * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned. 3721251662Sdim * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete 3722251662Sdim * is returned. 3723251662Sdim * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is 3724251662Sdim * returned. 3725251662Sdim */ 3726251662SdimCINDEX_LINKAGE long long clang_Type_getSizeOf(CXType T); 3727251662Sdim 3728251662Sdim/** 3729251662Sdim * \brief Return the offset of a field named S in a record of type T in bits 3730251662Sdim * as it would be returned by __offsetof__ as per C++11[18.2p4] 3731251662Sdim * 3732251662Sdim * If the cursor is not a record field declaration, CXTypeLayoutError_Invalid 3733251662Sdim * is returned. 3734251662Sdim * If the field's type declaration is an incomplete type, 3735251662Sdim * CXTypeLayoutError_Incomplete is returned. 3736251662Sdim * If the field's type declaration is a dependent type, 3737251662Sdim * CXTypeLayoutError_Dependent is returned. 3738251662Sdim * If the field's name S is not found, 3739251662Sdim * CXTypeLayoutError_InvalidFieldName is returned. 3740251662Sdim */ 3741251662SdimCINDEX_LINKAGE long long clang_Type_getOffsetOf(CXType T, const char *S); 3742251662Sdim 3743288943Sdim/** 3744288943Sdim * \brief Return the offset of the field represented by the Cursor. 3745288943Sdim * 3746288943Sdim * If the cursor is not a field declaration, -1 is returned. 3747288943Sdim * If the cursor semantic parent is not a record field declaration, 3748288943Sdim * CXTypeLayoutError_Invalid is returned. 3749288943Sdim * If the field's type declaration is an incomplete type, 3750288943Sdim * CXTypeLayoutError_Incomplete is returned. 3751288943Sdim * If the field's type declaration is a dependent type, 3752288943Sdim * CXTypeLayoutError_Dependent is returned. 3753288943Sdim * If the field's name S is not found, 3754288943Sdim * CXTypeLayoutError_InvalidFieldName is returned. 3755288943Sdim */ 3756288943SdimCINDEX_LINKAGE long long clang_Cursor_getOffsetOfField(CXCursor C); 3757288943Sdim 3758288943Sdim/** 3759288943Sdim * \brief Determine whether the given cursor represents an anonymous record 3760288943Sdim * declaration. 3761288943Sdim */ 3762288943SdimCINDEX_LINKAGE unsigned clang_Cursor_isAnonymous(CXCursor C); 3763288943Sdim 3764261991Sdimenum CXRefQualifierKind { 3765261991Sdim /** \brief No ref-qualifier was provided. */ 3766261991Sdim CXRefQualifier_None = 0, 3767261991Sdim /** \brief An lvalue ref-qualifier was provided (\c &). */ 3768261991Sdim CXRefQualifier_LValue, 3769261991Sdim /** \brief An rvalue ref-qualifier was provided (\c &&). */ 3770261991Sdim CXRefQualifier_RValue 3771261991Sdim}; 3772261991Sdim 3773251662Sdim/** 3774314564Sdim * \brief Returns the number of template arguments for given template 3775314564Sdim * specialization, or -1 if type \c T is not a template specialization. 3776276479Sdim */ 3777276479SdimCINDEX_LINKAGE int clang_Type_getNumTemplateArguments(CXType T); 3778276479Sdim 3779276479Sdim/** 3780276479Sdim * \brief Returns the type template argument of a template class specialization 3781276479Sdim * at given index. 3782276479Sdim * 3783276479Sdim * This function only returns template type arguments and does not handle 3784276479Sdim * template template arguments or variadic packs. 3785276479Sdim */ 3786276479SdimCINDEX_LINKAGE CXType clang_Type_getTemplateArgumentAsType(CXType T, unsigned i); 3787276479Sdim 3788276479Sdim/** 3789261991Sdim * \brief Retrieve the ref-qualifier kind of a function or method. 3790261991Sdim * 3791261991Sdim * The ref-qualifier is returned for C++ functions or methods. For other types 3792261991Sdim * or non-C++ declarations, CXRefQualifier_None is returned. 3793261991Sdim */ 3794261991SdimCINDEX_LINKAGE enum CXRefQualifierKind clang_Type_getCXXRefQualifier(CXType T); 3795261991Sdim 3796261991Sdim/** 3797251662Sdim * \brief Returns non-zero if the cursor specifies a Record member that is a 3798251662Sdim * bitfield. 3799251662Sdim */ 3800251662SdimCINDEX_LINKAGE unsigned clang_Cursor_isBitField(CXCursor C); 3801251662Sdim 3802251662Sdim/** 3803212904Sdim * \brief Returns 1 if the base class specified by the cursor with kind 3804212904Sdim * CX_CXXBaseSpecifier is virtual. 3805212904Sdim */ 3806212904SdimCINDEX_LINKAGE unsigned clang_isVirtualBase(CXCursor); 3807212904Sdim 3808212904Sdim/** 3809212904Sdim * \brief Represents the C++ access control level to a base class for a 3810212904Sdim * cursor with kind CX_CXXBaseSpecifier. 3811212904Sdim */ 3812212904Sdimenum CX_CXXAccessSpecifier { 3813212904Sdim CX_CXXInvalidAccessSpecifier, 3814212904Sdim CX_CXXPublic, 3815212904Sdim CX_CXXProtected, 3816212904Sdim CX_CXXPrivate 3817212904Sdim}; 3818212904Sdim 3819212904Sdim/** 3820251662Sdim * \brief Returns the access control level for the referenced object. 3821251662Sdim * 3822251662Sdim * If the cursor refers to a C++ declaration, its access control level within its 3823251662Sdim * parent scope is returned. Otherwise, if the cursor refers to a base specifier or 3824251662Sdim * access specifier, the specifier itself is returned. 3825212904Sdim */ 3826212904SdimCINDEX_LINKAGE enum CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor); 3827212904Sdim 3828212904Sdim/** 3829280031Sdim * \brief Represents the storage classes as declared in the source. CX_SC_Invalid 3830280031Sdim * was added for the case that the passed cursor in not a declaration. 3831280031Sdim */ 3832280031Sdimenum CX_StorageClass { 3833280031Sdim CX_SC_Invalid, 3834280031Sdim CX_SC_None, 3835280031Sdim CX_SC_Extern, 3836280031Sdim CX_SC_Static, 3837280031Sdim CX_SC_PrivateExtern, 3838280031Sdim CX_SC_OpenCLWorkGroupLocal, 3839280031Sdim CX_SC_Auto, 3840280031Sdim CX_SC_Register 3841280031Sdim}; 3842280031Sdim 3843280031Sdim/** 3844280031Sdim * \brief Returns the storage class for a function or variable declaration. 3845280031Sdim * 3846280031Sdim * If the passed in Cursor is not a function or variable declaration, 3847280031Sdim * CX_SC_Invalid is returned else the storage class. 3848280031Sdim */ 3849280031SdimCINDEX_LINKAGE enum CX_StorageClass clang_Cursor_getStorageClass(CXCursor); 3850280031Sdim 3851280031Sdim/** 3852218893Sdim * \brief Determine the number of overloaded declarations referenced by a 3853218893Sdim * \c CXCursor_OverloadedDeclRef cursor. 3854218893Sdim * 3855218893Sdim * \param cursor The cursor whose overloaded declarations are being queried. 3856218893Sdim * 3857218893Sdim * \returns The number of overloaded declarations referenced by \c cursor. If it 3858218893Sdim * is not a \c CXCursor_OverloadedDeclRef cursor, returns 0. 3859218893Sdim */ 3860218893SdimCINDEX_LINKAGE unsigned clang_getNumOverloadedDecls(CXCursor cursor); 3861218893Sdim 3862218893Sdim/** 3863218893Sdim * \brief Retrieve a cursor for one of the overloaded declarations referenced 3864218893Sdim * by a \c CXCursor_OverloadedDeclRef cursor. 3865218893Sdim * 3866218893Sdim * \param cursor The cursor whose overloaded declarations are being queried. 3867218893Sdim * 3868218893Sdim * \param index The zero-based index into the set of overloaded declarations in 3869218893Sdim * the cursor. 3870218893Sdim * 3871218893Sdim * \returns A cursor representing the declaration referenced by the given 3872218893Sdim * \c cursor at the specified \c index. If the cursor does not have an 3873218893Sdim * associated set of overloaded declarations, or if the index is out of bounds, 3874218893Sdim * returns \c clang_getNullCursor(); 3875218893Sdim */ 3876218893SdimCINDEX_LINKAGE CXCursor clang_getOverloadedDecl(CXCursor cursor, 3877218893Sdim unsigned index); 3878218893Sdim 3879218893Sdim/** 3880208600Srdivacky * @} 3881208600Srdivacky */ 3882212904Sdim 3883212904Sdim/** 3884212904Sdim * \defgroup CINDEX_ATTRIBUTES Information for attributes 3885212904Sdim * 3886212904Sdim * @{ 3887212904Sdim */ 3888208600Srdivacky 3889208600Srdivacky/** 3890212904Sdim * \brief For cursors representing an iboutletcollection attribute, 3891212904Sdim * this function returns the collection element type. 3892212904Sdim * 3893212904Sdim */ 3894212904SdimCINDEX_LINKAGE CXType clang_getIBOutletCollectionType(CXCursor); 3895212904Sdim 3896212904Sdim/** 3897212904Sdim * @} 3898212904Sdim */ 3899212904Sdim 3900212904Sdim/** 3901202879Srdivacky * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors 3902202879Srdivacky * 3903202879Srdivacky * These routines provide the ability to traverse the abstract syntax tree 3904202879Srdivacky * using cursors. 3905202879Srdivacky * 3906202879Srdivacky * @{ 3907202879Srdivacky */ 3908203955Srdivacky 3909202879Srdivacky/** 3910202879Srdivacky * \brief Describes how the traversal of the children of a particular 3911202879Srdivacky * cursor should proceed after visiting a particular child cursor. 3912202879Srdivacky * 3913202879Srdivacky * A value of this enumeration type should be returned by each 3914202879Srdivacky * \c CXCursorVisitor to indicate how clang_visitChildren() proceed. 3915202879Srdivacky */ 3916202879Srdivackyenum CXChildVisitResult { 3917202879Srdivacky /** 3918203955Srdivacky * \brief Terminates the cursor traversal. 3919202879Srdivacky */ 3920202879Srdivacky CXChildVisit_Break, 3921203955Srdivacky /** 3922202879Srdivacky * \brief Continues the cursor traversal with the next sibling of 3923202879Srdivacky * the cursor just visited, without visiting its children. 3924202879Srdivacky */ 3925202879Srdivacky CXChildVisit_Continue, 3926202879Srdivacky /** 3927202879Srdivacky * \brief Recursively traverse the children of this cursor, using 3928202879Srdivacky * the same visitor and client data. 3929202879Srdivacky */ 3930202879Srdivacky CXChildVisit_Recurse 3931202879Srdivacky}; 3932202879Srdivacky 3933202879Srdivacky/** 3934202879Srdivacky * \brief Visitor invoked for each cursor found by a traversal. 3935202879Srdivacky * 3936202879Srdivacky * This visitor function will be invoked for each cursor found by 3937202879Srdivacky * clang_visitCursorChildren(). Its first argument is the cursor being 3938202879Srdivacky * visited, its second argument is the parent visitor for that cursor, 3939202879Srdivacky * and its third argument is the client data provided to 3940202879Srdivacky * clang_visitCursorChildren(). 3941202879Srdivacky * 3942202879Srdivacky * The visitor should return one of the \c CXChildVisitResult values 3943202879Srdivacky * to direct clang_visitCursorChildren(). 3944202879Srdivacky */ 3945203955Srdivackytypedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor, 3946203955Srdivacky CXCursor parent, 3947202879Srdivacky CXClientData client_data); 3948202879Srdivacky 3949202879Srdivacky/** 3950202879Srdivacky * \brief Visit the children of a particular cursor. 3951202879Srdivacky * 3952202879Srdivacky * This function visits all the direct children of the given cursor, 3953202879Srdivacky * invoking the given \p visitor function with the cursors of each 3954202879Srdivacky * visited child. The traversal may be recursive, if the visitor returns 3955202879Srdivacky * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if 3956202879Srdivacky * the visitor returns \c CXChildVisit_Break. 3957202879Srdivacky * 3958202879Srdivacky * \param parent the cursor whose child may be visited. All kinds of 3959203955Srdivacky * cursors can be visited, including invalid cursors (which, by 3960202879Srdivacky * definition, have no children). 3961202879Srdivacky * 3962202879Srdivacky * \param visitor the visitor function that will be invoked for each 3963202879Srdivacky * child of \p parent. 3964202879Srdivacky * 3965202879Srdivacky * \param client_data pointer data supplied by the client, which will 3966202879Srdivacky * be passed to the visitor each time it is invoked. 3967202879Srdivacky * 3968202879Srdivacky * \returns a non-zero value if the traversal was terminated 3969202879Srdivacky * prematurely by the visitor returning \c CXChildVisit_Break. 3970202879Srdivacky */ 3971203955SrdivackyCINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent, 3972202879Srdivacky CXCursorVisitor visitor, 3973202879Srdivacky CXClientData client_data); 3974218893Sdim#ifdef __has_feature 3975218893Sdim# if __has_feature(blocks) 3976218893Sdim/** 3977218893Sdim * \brief Visitor invoked for each cursor found by a traversal. 3978218893Sdim * 3979218893Sdim * This visitor block will be invoked for each cursor found by 3980218893Sdim * clang_visitChildrenWithBlock(). Its first argument is the cursor being 3981218893Sdim * visited, its second argument is the parent visitor for that cursor. 3982218893Sdim * 3983218893Sdim * The visitor should return one of the \c CXChildVisitResult values 3984218893Sdim * to direct clang_visitChildrenWithBlock(). 3985218893Sdim */ 3986218893Sdimtypedef enum CXChildVisitResult 3987218893Sdim (^CXCursorVisitorBlock)(CXCursor cursor, CXCursor parent); 3988203955Srdivacky 3989202879Srdivacky/** 3990218893Sdim * Visits the children of a cursor using the specified block. Behaves 3991218893Sdim * identically to clang_visitChildren() in all other respects. 3992218893Sdim */ 3993309124SdimCINDEX_LINKAGE unsigned clang_visitChildrenWithBlock(CXCursor parent, 3994309124Sdim CXCursorVisitorBlock block); 3995218893Sdim# endif 3996218893Sdim#endif 3997218893Sdim 3998218893Sdim/** 3999202879Srdivacky * @} 4000202879Srdivacky */ 4001203955Srdivacky 4002202879Srdivacky/** 4003202879Srdivacky * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST 4004202879Srdivacky * 4005203955Srdivacky * These routines provide the ability to determine references within and 4006202879Srdivacky * across translation units, by providing the names of the entities referenced 4007202879Srdivacky * by cursors, follow reference cursors to the declarations they reference, 4008202879Srdivacky * and associate declarations with their definitions. 4009202879Srdivacky * 4010202879Srdivacky * @{ 4011202879Srdivacky */ 4012203955Srdivacky 4013202879Srdivacky/** 4014202879Srdivacky * \brief Retrieve a Unified Symbol Resolution (USR) for the entity referenced 4015202879Srdivacky * by the given cursor. 4016202879Srdivacky * 4017202879Srdivacky * A Unified Symbol Resolution (USR) is a string that identifies a particular 4018202879Srdivacky * entity (function, class, variable, etc.) within a program. USRs can be 4019202879Srdivacky * compared across translation units to determine, e.g., when references in 4020202879Srdivacky * one translation refer to an entity defined in another translation unit. 4021202879Srdivacky */ 4022202879SrdivackyCINDEX_LINKAGE CXString clang_getCursorUSR(CXCursor); 4023202879Srdivacky 4024202879Srdivacky/** 4025205219Srdivacky * \brief Construct a USR for a specified Objective-C class. 4026205219Srdivacky */ 4027205219SrdivackyCINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name); 4028205219Srdivacky 4029205219Srdivacky/** 4030205219Srdivacky * \brief Construct a USR for a specified Objective-C category. 4031205219Srdivacky */ 4032205219SrdivackyCINDEX_LINKAGE CXString 4033205219Srdivacky clang_constructUSR_ObjCCategory(const char *class_name, 4034205219Srdivacky const char *category_name); 4035205219Srdivacky 4036205219Srdivacky/** 4037205219Srdivacky * \brief Construct a USR for a specified Objective-C protocol. 4038205219Srdivacky */ 4039205219SrdivackyCINDEX_LINKAGE CXString 4040205219Srdivacky clang_constructUSR_ObjCProtocol(const char *protocol_name); 4041205219Srdivacky 4042205219Srdivacky/** 4043205219Srdivacky * \brief Construct a USR for a specified Objective-C instance variable and 4044205219Srdivacky * the USR for its containing class. 4045205219Srdivacky */ 4046205219SrdivackyCINDEX_LINKAGE CXString clang_constructUSR_ObjCIvar(const char *name, 4047205219Srdivacky CXString classUSR); 4048205219Srdivacky 4049205219Srdivacky/** 4050205219Srdivacky * \brief Construct a USR for a specified Objective-C method and 4051205219Srdivacky * the USR for its containing class. 4052205219Srdivacky */ 4053205219SrdivackyCINDEX_LINKAGE CXString clang_constructUSR_ObjCMethod(const char *name, 4054205219Srdivacky unsigned isInstanceMethod, 4055205219Srdivacky CXString classUSR); 4056205219Srdivacky 4057205219Srdivacky/** 4058205219Srdivacky * \brief Construct a USR for a specified Objective-C property and the USR 4059205219Srdivacky * for its containing class. 4060205219Srdivacky */ 4061205219SrdivackyCINDEX_LINKAGE CXString clang_constructUSR_ObjCProperty(const char *property, 4062205219Srdivacky CXString classUSR); 4063205219Srdivacky 4064205219Srdivacky/** 4065202879Srdivacky * \brief Retrieve a name for the entity referenced by this cursor. 4066202879Srdivacky */ 4067199482SrdivackyCINDEX_LINKAGE CXString clang_getCursorSpelling(CXCursor); 4068198398Srdivacky 4069218893Sdim/** 4070234353Sdim * \brief Retrieve a range for a piece that forms the cursors spelling name. 4071234353Sdim * Most of the times there is only one range for the complete spelling but for 4072276479Sdim * Objective-C methods and Objective-C message expressions, there are multiple 4073276479Sdim * pieces for each selector identifier. 4074234353Sdim * 4075234353Sdim * \param pieceIndex the index of the spelling name piece. If this is greater 4076234353Sdim * than the actual number of pieces, it will return a NULL (invalid) range. 4077234353Sdim * 4078234353Sdim * \param options Reserved. 4079234353Sdim */ 4080234353SdimCINDEX_LINKAGE CXSourceRange clang_Cursor_getSpellingNameRange(CXCursor, 4081234353Sdim unsigned pieceIndex, 4082234353Sdim unsigned options); 4083234353Sdim 4084234353Sdim/** 4085218893Sdim * \brief Retrieve the display name for the entity referenced by this cursor. 4086218893Sdim * 4087218893Sdim * The display name contains extra information that helps identify the cursor, 4088218893Sdim * such as the parameters of a function or template or the arguments of a 4089218893Sdim * class template specialization. 4090218893Sdim */ 4091218893SdimCINDEX_LINKAGE CXString clang_getCursorDisplayName(CXCursor); 4092218893Sdim 4093202879Srdivacky/** \brief For a cursor that is a reference, retrieve a cursor representing the 4094202879Srdivacky * entity that it references. 4095202879Srdivacky * 4096202879Srdivacky * Reference cursors refer to other entities in the AST. For example, an 4097202879Srdivacky * Objective-C superclass reference cursor refers to an Objective-C class. 4098203955Srdivacky * This function produces the cursor for the Objective-C class from the 4099202879Srdivacky * cursor for the superclass reference. If the input cursor is a declaration or 4100202879Srdivacky * definition, it returns that declaration or definition unchanged. 4101203955Srdivacky * Otherwise, returns the NULL cursor. 4102202879Srdivacky */ 4103202879SrdivackyCINDEX_LINKAGE CXCursor clang_getCursorReferenced(CXCursor); 4104202879Srdivacky 4105203955Srdivacky/** 4106202879Srdivacky * \brief For a cursor that is either a reference to or a declaration 4107202879Srdivacky * of some entity, retrieve a cursor that describes the definition of 4108202879Srdivacky * that entity. 4109202879Srdivacky * 4110202879Srdivacky * Some entities can be declared multiple times within a translation 4111202879Srdivacky * unit, but only one of those declarations can also be a 4112202879Srdivacky * definition. For example, given: 4113202879Srdivacky * 4114202879Srdivacky * \code 4115202879Srdivacky * int f(int, int); 4116202879Srdivacky * int g(int x, int y) { return f(x, y); } 4117202879Srdivacky * int f(int a, int b) { return a + b; } 4118202879Srdivacky * int f(int, int); 4119202879Srdivacky * \endcode 4120202879Srdivacky * 4121202879Srdivacky * there are three declarations of the function "f", but only the 4122202879Srdivacky * second one is a definition. The clang_getCursorDefinition() 4123202879Srdivacky * function will take any cursor pointing to a declaration of "f" 4124202879Srdivacky * (the first or fourth lines of the example) or a cursor referenced 4125202879Srdivacky * that uses "f" (the call to "f' inside "g") and will return a 4126202879Srdivacky * declaration cursor pointing to the definition (the second "f" 4127202879Srdivacky * declaration). 4128202879Srdivacky * 4129202879Srdivacky * If given a cursor for which there is no corresponding definition, 4130202879Srdivacky * e.g., because there is no definition of that entity within this 4131202879Srdivacky * translation unit, returns a NULL cursor. 4132202879Srdivacky */ 4133202879SrdivackyCINDEX_LINKAGE CXCursor clang_getCursorDefinition(CXCursor); 4134202879Srdivacky 4135203955Srdivacky/** 4136202879Srdivacky * \brief Determine whether the declaration pointed to by this cursor 4137202879Srdivacky * is also a definition of that entity. 4138202879Srdivacky */ 4139202879SrdivackyCINDEX_LINKAGE unsigned clang_isCursorDefinition(CXCursor); 4140202879Srdivacky 4141202879Srdivacky/** 4142218893Sdim * \brief Retrieve the canonical cursor corresponding to the given cursor. 4143218893Sdim * 4144218893Sdim * In the C family of languages, many kinds of entities can be declared several 4145218893Sdim * times within a single translation unit. For example, a structure type can 4146218893Sdim * be forward-declared (possibly multiple times) and later defined: 4147218893Sdim * 4148218893Sdim * \code 4149218893Sdim * struct X; 4150218893Sdim * struct X; 4151218893Sdim * struct X { 4152218893Sdim * int member; 4153218893Sdim * }; 4154218893Sdim * \endcode 4155218893Sdim * 4156218893Sdim * The declarations and the definition of \c X are represented by three 4157218893Sdim * different cursors, all of which are declarations of the same underlying 4158218893Sdim * entity. One of these cursor is considered the "canonical" cursor, which 4159218893Sdim * is effectively the representative for the underlying entity. One can 4160218893Sdim * determine if two cursors are declarations of the same underlying entity by 4161218893Sdim * comparing their canonical cursors. 4162218893Sdim * 4163218893Sdim * \returns The canonical cursor for the entity referred to by the given cursor. 4164218893Sdim */ 4165218893SdimCINDEX_LINKAGE CXCursor clang_getCanonicalCursor(CXCursor); 4166218893Sdim 4167218893Sdim/** 4168276479Sdim * \brief If the cursor points to a selector identifier in an Objective-C 4169276479Sdim * method or message expression, this returns the selector index. 4170234353Sdim * 4171239462Sdim * After getting a cursor with #clang_getCursor, this can be called to 4172234353Sdim * determine if the location points to a selector identifier. 4173234353Sdim * 4174276479Sdim * \returns The selector index if the cursor is an Objective-C method or message 4175234353Sdim * expression and the cursor is pointing to a selector identifier, or -1 4176234353Sdim * otherwise. 4177234353Sdim */ 4178234353SdimCINDEX_LINKAGE int clang_Cursor_getObjCSelectorIndex(CXCursor); 4179234353Sdim 4180234353Sdim/** 4181276479Sdim * \brief Given a cursor pointing to a C++ method call or an Objective-C 4182276479Sdim * message, returns non-zero if the method/message is "dynamic", meaning: 4183239462Sdim * 4184239462Sdim * For a C++ method: the call is virtual. 4185276479Sdim * For an Objective-C message: the receiver is an object instance, not 'super' 4186276479Sdim * or a specific class. 4187239462Sdim * 4188239462Sdim * If the method/message is "static" or the cursor does not point to a 4189239462Sdim * method/message, it will return zero. 4190239462Sdim */ 4191239462SdimCINDEX_LINKAGE int clang_Cursor_isDynamicCall(CXCursor C); 4192239462Sdim 4193239462Sdim/** 4194321369Sdim * \brief Given a cursor pointing to an Objective-C message or property 4195321369Sdim * reference, or C++ method call, returns the CXType of the receiver. 4196243830Sdim */ 4197243830SdimCINDEX_LINKAGE CXType clang_Cursor_getReceiverType(CXCursor C); 4198243830Sdim 4199243830Sdim/** 4200251662Sdim * \brief Property attributes for a \c CXCursor_ObjCPropertyDecl. 4201251662Sdim */ 4202251662Sdimtypedef enum { 4203251662Sdim CXObjCPropertyAttr_noattr = 0x00, 4204251662Sdim CXObjCPropertyAttr_readonly = 0x01, 4205251662Sdim CXObjCPropertyAttr_getter = 0x02, 4206251662Sdim CXObjCPropertyAttr_assign = 0x04, 4207251662Sdim CXObjCPropertyAttr_readwrite = 0x08, 4208251662Sdim CXObjCPropertyAttr_retain = 0x10, 4209251662Sdim CXObjCPropertyAttr_copy = 0x20, 4210251662Sdim CXObjCPropertyAttr_nonatomic = 0x40, 4211251662Sdim CXObjCPropertyAttr_setter = 0x80, 4212251662Sdim CXObjCPropertyAttr_atomic = 0x100, 4213251662Sdim CXObjCPropertyAttr_weak = 0x200, 4214251662Sdim CXObjCPropertyAttr_strong = 0x400, 4215309124Sdim CXObjCPropertyAttr_unsafe_unretained = 0x800, 4216309124Sdim CXObjCPropertyAttr_class = 0x1000 4217251662Sdim} CXObjCPropertyAttrKind; 4218251662Sdim 4219251662Sdim/** 4220251662Sdim * \brief Given a cursor that represents a property declaration, return the 4221251662Sdim * associated property attributes. The bits are formed from 4222251662Sdim * \c CXObjCPropertyAttrKind. 4223251662Sdim * 4224251662Sdim * \param reserved Reserved for future use, pass 0. 4225251662Sdim */ 4226251662SdimCINDEX_LINKAGE unsigned clang_Cursor_getObjCPropertyAttributes(CXCursor C, 4227251662Sdim unsigned reserved); 4228251662Sdim 4229251662Sdim/** 4230251662Sdim * \brief 'Qualifiers' written next to the return and parameter types in 4231276479Sdim * Objective-C method declarations. 4232251662Sdim */ 4233251662Sdimtypedef enum { 4234251662Sdim CXObjCDeclQualifier_None = 0x0, 4235251662Sdim CXObjCDeclQualifier_In = 0x1, 4236251662Sdim CXObjCDeclQualifier_Inout = 0x2, 4237251662Sdim CXObjCDeclQualifier_Out = 0x4, 4238251662Sdim CXObjCDeclQualifier_Bycopy = 0x8, 4239251662Sdim CXObjCDeclQualifier_Byref = 0x10, 4240251662Sdim CXObjCDeclQualifier_Oneway = 0x20 4241251662Sdim} CXObjCDeclQualifierKind; 4242251662Sdim 4243251662Sdim/** 4244276479Sdim * \brief Given a cursor that represents an Objective-C method or parameter 4245276479Sdim * declaration, return the associated Objective-C qualifiers for the return 4246276479Sdim * type or the parameter respectively. The bits are formed from 4247276479Sdim * CXObjCDeclQualifierKind. 4248251662Sdim */ 4249251662SdimCINDEX_LINKAGE unsigned clang_Cursor_getObjCDeclQualifiers(CXCursor C); 4250251662Sdim 4251251662Sdim/** 4252276479Sdim * \brief Given a cursor that represents an Objective-C method or property 4253321369Sdim * declaration, return non-zero if the declaration was affected by "\@optional". 4254321369Sdim * Returns zero if the cursor is not such a declaration or it is "\@required". 4255261991Sdim */ 4256261991SdimCINDEX_LINKAGE unsigned clang_Cursor_isObjCOptional(CXCursor C); 4257261991Sdim 4258261991Sdim/** 4259251662Sdim * \brief Returns non-zero if the given cursor is a variadic function or method. 4260251662Sdim */ 4261251662SdimCINDEX_LINKAGE unsigned clang_Cursor_isVariadic(CXCursor C); 4262251662Sdim 4263251662Sdim/** 4264321369Sdim * \brief Returns non-zero if the given cursor points to a symbol marked with 4265321369Sdim * external_source_symbol attribute. 4266321369Sdim * 4267321369Sdim * \param language If non-NULL, and the attribute is present, will be set to 4268321369Sdim * the 'language' string from the attribute. 4269321369Sdim * 4270321369Sdim * \param definedIn If non-NULL, and the attribute is present, will be set to 4271321369Sdim * the 'definedIn' string from the attribute. 4272321369Sdim * 4273321369Sdim * \param isGenerated If non-NULL, and the attribute is present, will be set to 4274321369Sdim * non-zero if the 'generated_declaration' is set in the attribute. 4275321369Sdim */ 4276321369SdimCINDEX_LINKAGE unsigned clang_Cursor_isExternalSymbol(CXCursor C, 4277321369Sdim CXString *language, CXString *definedIn, 4278321369Sdim unsigned *isGenerated); 4279321369Sdim 4280321369Sdim/** 4281239462Sdim * \brief Given a cursor that represents a declaration, return the associated 4282239462Sdim * comment's source range. The range may include multiple consecutive comments 4283239462Sdim * with whitespace in between. 4284239462Sdim */ 4285239462SdimCINDEX_LINKAGE CXSourceRange clang_Cursor_getCommentRange(CXCursor C); 4286239462Sdim 4287239462Sdim/** 4288239462Sdim * \brief Given a cursor that represents a declaration, return the associated 4289239462Sdim * comment text, including comment markers. 4290239462Sdim */ 4291239462SdimCINDEX_LINKAGE CXString clang_Cursor_getRawCommentText(CXCursor C); 4292239462Sdim 4293239462Sdim/** 4294239462Sdim * \brief Given a cursor that represents a documentable entity (e.g., 4295239462Sdim * declaration), return the associated \\brief paragraph; otherwise return the 4296239462Sdim * first paragraph. 4297239462Sdim */ 4298239462SdimCINDEX_LINKAGE CXString clang_Cursor_getBriefCommentText(CXCursor C); 4299239462Sdim 4300239462Sdim/** 4301202879Srdivacky * @} 4302202879Srdivacky */ 4303203955Srdivacky 4304280031Sdim/** \defgroup CINDEX_MANGLE Name Mangling API Functions 4305280031Sdim * 4306280031Sdim * @{ 4307280031Sdim */ 4308280031Sdim 4309203955Srdivacky/** 4310280031Sdim * \brief Retrieve the CXString representing the mangled name of the cursor. 4311280031Sdim */ 4312280031SdimCINDEX_LINKAGE CXString clang_Cursor_getMangling(CXCursor); 4313280031Sdim 4314280031Sdim/** 4315296417Sdim * \brief Retrieve the CXStrings representing the mangled symbols of the C++ 4316296417Sdim * constructor or destructor at the cursor. 4317296417Sdim */ 4318296417SdimCINDEX_LINKAGE CXStringSet *clang_Cursor_getCXXManglings(CXCursor); 4319296417Sdim 4320296417Sdim/** 4321327952Sdim * \brief Retrieve the CXStrings representing the mangled symbols of the ObjC 4322327952Sdim * class interface or implementation at the cursor. 4323327952Sdim */ 4324327952SdimCINDEX_LINKAGE CXStringSet *clang_Cursor_getObjCManglings(CXCursor); 4325327952Sdim 4326327952Sdim/** 4327280031Sdim * @} 4328280031Sdim */ 4329280031Sdim 4330280031Sdim/** 4331243830Sdim * \defgroup CINDEX_MODULE Module introspection 4332243830Sdim * 4333243830Sdim * The functions in this group provide access to information about modules. 4334243830Sdim * 4335243830Sdim * @{ 4336243830Sdim */ 4337243830Sdim 4338243830Sdimtypedef void *CXModule; 4339243830Sdim 4340243830Sdim/** 4341243830Sdim * \brief Given a CXCursor_ModuleImportDecl cursor, return the associated module. 4342243830Sdim */ 4343243830SdimCINDEX_LINKAGE CXModule clang_Cursor_getModule(CXCursor C); 4344243830Sdim 4345243830Sdim/** 4346276479Sdim * \brief Given a CXFile header file, return the module that contains it, if one 4347276479Sdim * exists. 4348276479Sdim */ 4349276479SdimCINDEX_LINKAGE CXModule clang_getModuleForFile(CXTranslationUnit, CXFile); 4350276479Sdim 4351276479Sdim/** 4352243830Sdim * \param Module a module object. 4353243830Sdim * 4354251662Sdim * \returns the module file where the provided module object came from. 4355251662Sdim */ 4356251662SdimCINDEX_LINKAGE CXFile clang_Module_getASTFile(CXModule Module); 4357251662Sdim 4358251662Sdim/** 4359251662Sdim * \param Module a module object. 4360251662Sdim * 4361243830Sdim * \returns the parent of a sub-module or NULL if the given module is top-level, 4362243830Sdim * e.g. for 'std.vector' it will return the 'std' module. 4363243830Sdim */ 4364243830SdimCINDEX_LINKAGE CXModule clang_Module_getParent(CXModule Module); 4365243830Sdim 4366243830Sdim/** 4367243830Sdim * \param Module a module object. 4368243830Sdim * 4369243830Sdim * \returns the name of the module, e.g. for the 'std.vector' sub-module it 4370243830Sdim * will return "vector". 4371243830Sdim */ 4372243830SdimCINDEX_LINKAGE CXString clang_Module_getName(CXModule Module); 4373243830Sdim 4374243830Sdim/** 4375243830Sdim * \param Module a module object. 4376243830Sdim * 4377243830Sdim * \returns the full name of the module, e.g. "std.vector". 4378243830Sdim */ 4379243830SdimCINDEX_LINKAGE CXString clang_Module_getFullName(CXModule Module); 4380243830Sdim 4381243830Sdim/** 4382243830Sdim * \param Module a module object. 4383243830Sdim * 4384276479Sdim * \returns non-zero if the module is a system one. 4385276479Sdim */ 4386276479SdimCINDEX_LINKAGE int clang_Module_isSystem(CXModule Module); 4387276479Sdim 4388276479Sdim/** 4389276479Sdim * \param Module a module object. 4390276479Sdim * 4391243830Sdim * \returns the number of top level headers associated with this module. 4392243830Sdim */ 4393249423SdimCINDEX_LINKAGE unsigned clang_Module_getNumTopLevelHeaders(CXTranslationUnit, 4394249423Sdim CXModule Module); 4395243830Sdim 4396243830Sdim/** 4397243830Sdim * \param Module a module object. 4398243830Sdim * 4399243830Sdim * \param Index top level header index (zero-based). 4400243830Sdim * 4401243830Sdim * \returns the specified top level header associated with the module. 4402243830Sdim */ 4403243830SdimCINDEX_LINKAGE 4404249423SdimCXFile clang_Module_getTopLevelHeader(CXTranslationUnit, 4405249423Sdim CXModule Module, unsigned Index); 4406243830Sdim 4407243830Sdim/** 4408243830Sdim * @} 4409243830Sdim */ 4410243830Sdim 4411243830Sdim/** 4412208600Srdivacky * \defgroup CINDEX_CPP C++ AST introspection 4413208600Srdivacky * 4414208600Srdivacky * The routines in this group provide access information in the ASTs specific 4415208600Srdivacky * to C++ language features. 4416208600Srdivacky * 4417208600Srdivacky * @{ 4418208600Srdivacky */ 4419208600Srdivacky 4420208600Srdivacky/** 4421309124Sdim * \brief Determine if a C++ constructor is a converting constructor. 4422309124Sdim */ 4423309124SdimCINDEX_LINKAGE unsigned clang_CXXConstructor_isConvertingConstructor(CXCursor C); 4424309124Sdim 4425309124Sdim/** 4426309124Sdim * \brief Determine if a C++ constructor is a copy constructor. 4427309124Sdim */ 4428309124SdimCINDEX_LINKAGE unsigned clang_CXXConstructor_isCopyConstructor(CXCursor C); 4429309124Sdim 4430309124Sdim/** 4431309124Sdim * \brief Determine if a C++ constructor is the default constructor. 4432309124Sdim */ 4433309124SdimCINDEX_LINKAGE unsigned clang_CXXConstructor_isDefaultConstructor(CXCursor C); 4434309124Sdim 4435309124Sdim/** 4436309124Sdim * \brief Determine if a C++ constructor is a move constructor. 4437309124Sdim */ 4438309124SdimCINDEX_LINKAGE unsigned clang_CXXConstructor_isMoveConstructor(CXCursor C); 4439309124Sdim 4440309124Sdim/** 4441296417Sdim * \brief Determine if a C++ field is declared 'mutable'. 4442296417Sdim */ 4443296417SdimCINDEX_LINKAGE unsigned clang_CXXField_isMutable(CXCursor C); 4444296417Sdim 4445296417Sdim/** 4446309124Sdim * \brief Determine if a C++ method is declared '= default'. 4447309124Sdim */ 4448309124SdimCINDEX_LINKAGE unsigned clang_CXXMethod_isDefaulted(CXCursor C); 4449309124Sdim 4450309124Sdim/** 4451261991Sdim * \brief Determine if a C++ member function or member function template is 4452261991Sdim * pure virtual. 4453261991Sdim */ 4454261991SdimCINDEX_LINKAGE unsigned clang_CXXMethod_isPureVirtual(CXCursor C); 4455261991Sdim 4456261991Sdim/** 4457212904Sdim * \brief Determine if a C++ member function or member function template is 4458212904Sdim * declared 'static'. 4459208600Srdivacky */ 4460208600SrdivackyCINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C); 4461208600Srdivacky 4462208600Srdivacky/** 4463223017Sdim * \brief Determine if a C++ member function or member function template is 4464223017Sdim * explicitly declared 'virtual' or if it overrides a virtual method from 4465223017Sdim * one of the base classes. 4466223017Sdim */ 4467223017SdimCINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual(CXCursor C); 4468223017Sdim 4469223017Sdim/** 4470327952Sdim * \brief Determine if a C++ record is abstract, i.e. whether a class or struct 4471327952Sdim * has a pure virtual member function. 4472327952Sdim */ 4473327952SdimCINDEX_LINKAGE unsigned clang_CXXRecord_isAbstract(CXCursor C); 4474327952Sdim 4475327952Sdim/** 4476321369Sdim * \brief Determine if an enum declaration refers to a scoped enum. 4477321369Sdim */ 4478321369SdimCINDEX_LINKAGE unsigned clang_EnumDecl_isScoped(CXCursor C); 4479321369Sdim 4480321369Sdim/** 4481276479Sdim * \brief Determine if a C++ member function or member function template is 4482276479Sdim * declared 'const'. 4483276479Sdim */ 4484276479SdimCINDEX_LINKAGE unsigned clang_CXXMethod_isConst(CXCursor C); 4485276479Sdim 4486276479Sdim/** 4487212904Sdim * \brief Given a cursor that represents a template, determine 4488212904Sdim * the cursor kind of the specializations would be generated by instantiating 4489212904Sdim * the template. 4490212904Sdim * 4491212904Sdim * This routine can be used to determine what flavor of function template, 4492212904Sdim * class template, or class template partial specialization is stored in the 4493212904Sdim * cursor. For example, it can describe whether a class template cursor is 4494212904Sdim * declared with "struct", "class" or "union". 4495212904Sdim * 4496212904Sdim * \param C The cursor to query. This cursor should represent a template 4497212904Sdim * declaration. 4498212904Sdim * 4499212904Sdim * \returns The cursor kind of the specializations that would be generated 4500212904Sdim * by instantiating the template \p C. If \p C is not a template, returns 4501212904Sdim * \c CXCursor_NoDeclFound. 4502212904Sdim */ 4503212904SdimCINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind(CXCursor C); 4504212904Sdim 4505212904Sdim/** 4506212904Sdim * \brief Given a cursor that may represent a specialization or instantiation 4507212904Sdim * of a template, retrieve the cursor that represents the template that it 4508212904Sdim * specializes or from which it was instantiated. 4509212904Sdim * 4510212904Sdim * This routine determines the template involved both for explicit 4511212904Sdim * specializations of templates and for implicit instantiations of the template, 4512212904Sdim * both of which are referred to as "specializations". For a class template 4513212904Sdim * specialization (e.g., \c std::vector<bool>), this routine will return 4514212904Sdim * either the primary template (\c std::vector) or, if the specialization was 4515212904Sdim * instantiated from a class template partial specialization, the class template 4516212904Sdim * partial specialization. For a class template partial specialization and a 4517212904Sdim * function template specialization (including instantiations), this 4518212904Sdim * this routine will return the specialized template. 4519212904Sdim * 4520212904Sdim * For members of a class template (e.g., member functions, member classes, or 4521212904Sdim * static data members), returns the specialized or instantiated member. 4522212904Sdim * Although not strictly "templates" in the C++ language, members of class 4523212904Sdim * templates have the same notions of specializations and instantiations that 4524212904Sdim * templates do, so this routine treats them similarly. 4525212904Sdim * 4526212904Sdim * \param C A cursor that may be a specialization of a template or a member 4527212904Sdim * of a template. 4528212904Sdim * 4529212904Sdim * \returns If the given cursor is a specialization or instantiation of a 4530212904Sdim * template or a member thereof, the template or member that it specializes or 4531212904Sdim * from which it was instantiated. Otherwise, returns a NULL cursor. 4532212904Sdim */ 4533212904SdimCINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate(CXCursor C); 4534226633Sdim 4535226633Sdim/** 4536226633Sdim * \brief Given a cursor that references something else, return the source range 4537226633Sdim * covering that reference. 4538226633Sdim * 4539226633Sdim * \param C A cursor pointing to a member reference, a declaration reference, or 4540226633Sdim * an operator call. 4541226633Sdim * \param NameFlags A bitset with three independent flags: 4542226633Sdim * CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and 4543226633Sdim * CXNameRange_WantSinglePiece. 4544226633Sdim * \param PieceIndex For contiguous names or when passing the flag 4545226633Sdim * CXNameRange_WantSinglePiece, only one piece with index 0 is 4546226633Sdim * available. When the CXNameRange_WantSinglePiece flag is not passed for a 4547239462Sdim * non-contiguous names, this index can be used to retrieve the individual 4548226633Sdim * pieces of the name. See also CXNameRange_WantSinglePiece. 4549226633Sdim * 4550226633Sdim * \returns The piece of the name pointed to by the given cursor. If there is no 4551226633Sdim * name, or if the PieceIndex is out-of-range, a null-cursor will be returned. 4552226633Sdim */ 4553226633SdimCINDEX_LINKAGE CXSourceRange clang_getCursorReferenceNameRange(CXCursor C, 4554226633Sdim unsigned NameFlags, 4555226633Sdim unsigned PieceIndex); 4556226633Sdim 4557226633Sdimenum CXNameRefFlags { 4558226633Sdim /** 4559226633Sdim * \brief Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the 4560226633Sdim * range. 4561226633Sdim */ 4562226633Sdim CXNameRange_WantQualifier = 0x1, 4563212904Sdim 4564226633Sdim /** 4565239462Sdim * \brief Include the explicit template arguments, e.g. \<int> in x.f<int>, 4566239462Sdim * in the range. 4567226633Sdim */ 4568226633Sdim CXNameRange_WantTemplateArgs = 0x2, 4569226633Sdim 4570226633Sdim /** 4571226633Sdim * \brief If the name is non-contiguous, return the full spanning range. 4572226633Sdim * 4573226633Sdim * Non-contiguous names occur in Objective-C when a selector with two or more 4574226633Sdim * parameters is used, or in C++ when using an operator: 4575226633Sdim * \code 4576276479Sdim * [object doSomething:here withValue:there]; // Objective-C 4577226633Sdim * return some_vector[1]; // C++ 4578226633Sdim * \endcode 4579226633Sdim */ 4580226633Sdim CXNameRange_WantSinglePiece = 0x4 4581226633Sdim}; 4582226633Sdim 4583212904Sdim/** 4584208600Srdivacky * @} 4585208600Srdivacky */ 4586208600Srdivacky 4587208600Srdivacky/** 4588203955Srdivacky * \defgroup CINDEX_LEX Token extraction and manipulation 4589203955Srdivacky * 4590203955Srdivacky * The routines in this group provide access to the tokens within a 4591203955Srdivacky * translation unit, along with a semantic mapping of those tokens to 4592203955Srdivacky * their corresponding cursors. 4593203955Srdivacky * 4594203955Srdivacky * @{ 4595203955Srdivacky */ 4596203955Srdivacky 4597203955Srdivacky/** 4598203955Srdivacky * \brief Describes a kind of token. 4599203955Srdivacky */ 4600203955Srdivackytypedef enum CXTokenKind { 4601203955Srdivacky /** 4602203955Srdivacky * \brief A token that contains some kind of punctuation. 4603203955Srdivacky */ 4604203955Srdivacky CXToken_Punctuation, 4605205219Srdivacky 4606203955Srdivacky /** 4607203955Srdivacky * \brief A language keyword. 4608203955Srdivacky */ 4609203955Srdivacky CXToken_Keyword, 4610205219Srdivacky 4611203955Srdivacky /** 4612203955Srdivacky * \brief An identifier (that is not a keyword). 4613203955Srdivacky */ 4614203955Srdivacky CXToken_Identifier, 4615205219Srdivacky 4616203955Srdivacky /** 4617203955Srdivacky * \brief A numeric, string, or character literal. 4618203955Srdivacky */ 4619203955Srdivacky CXToken_Literal, 4620205219Srdivacky 4621203955Srdivacky /** 4622203955Srdivacky * \brief A comment. 4623203955Srdivacky */ 4624203955Srdivacky CXToken_Comment 4625203955Srdivacky} CXTokenKind; 4626203955Srdivacky 4627202879Srdivacky/** 4628203955Srdivacky * \brief Describes a single preprocessing token. 4629203955Srdivacky */ 4630203955Srdivackytypedef struct { 4631203955Srdivacky unsigned int_data[4]; 4632203955Srdivacky void *ptr_data; 4633203955Srdivacky} CXToken; 4634203955Srdivacky 4635203955Srdivacky/** 4636203955Srdivacky * \brief Determine the kind of the given token. 4637203955Srdivacky */ 4638203955SrdivackyCINDEX_LINKAGE CXTokenKind clang_getTokenKind(CXToken); 4639205219Srdivacky 4640203955Srdivacky/** 4641203955Srdivacky * \brief Determine the spelling of the given token. 4642203955Srdivacky * 4643203955Srdivacky * The spelling of a token is the textual representation of that token, e.g., 4644203955Srdivacky * the text of an identifier or keyword. 4645203955Srdivacky */ 4646203955SrdivackyCINDEX_LINKAGE CXString clang_getTokenSpelling(CXTranslationUnit, CXToken); 4647205219Srdivacky 4648203955Srdivacky/** 4649203955Srdivacky * \brief Retrieve the source location of the given token. 4650203955Srdivacky */ 4651205219SrdivackyCINDEX_LINKAGE CXSourceLocation clang_getTokenLocation(CXTranslationUnit, 4652203955Srdivacky CXToken); 4653205219Srdivacky 4654203955Srdivacky/** 4655203955Srdivacky * \brief Retrieve a source range that covers the given token. 4656203955Srdivacky */ 4657203955SrdivackyCINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken); 4658203955Srdivacky 4659203955Srdivacky/** 4660203955Srdivacky * \brief Tokenize the source code described by the given range into raw 4661203955Srdivacky * lexical tokens. 4662203955Srdivacky * 4663203955Srdivacky * \param TU the translation unit whose text is being tokenized. 4664203955Srdivacky * 4665203955Srdivacky * \param Range the source range in which text should be tokenized. All of the 4666203955Srdivacky * tokens produced by tokenization will fall within this source range, 4667203955Srdivacky * 4668203955Srdivacky * \param Tokens this pointer will be set to point to the array of tokens 4669203955Srdivacky * that occur within the given source range. The returned pointer must be 4670203955Srdivacky * freed with clang_disposeTokens() before the translation unit is destroyed. 4671203955Srdivacky * 4672203955Srdivacky * \param NumTokens will be set to the number of tokens in the \c *Tokens 4673203955Srdivacky * array. 4674203955Srdivacky * 4675203955Srdivacky */ 4676203955SrdivackyCINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range, 4677203955Srdivacky CXToken **Tokens, unsigned *NumTokens); 4678205219Srdivacky 4679203955Srdivacky/** 4680203955Srdivacky * \brief Annotate the given set of tokens by providing cursors for each token 4681203955Srdivacky * that can be mapped to a specific entity within the abstract syntax tree. 4682203955Srdivacky * 4683203955Srdivacky * This token-annotation routine is equivalent to invoking 4684203955Srdivacky * clang_getCursor() for the source locations of each of the 4685203955Srdivacky * tokens. The cursors provided are filtered, so that only those 4686203955Srdivacky * cursors that have a direct correspondence to the token are 4687203955Srdivacky * accepted. For example, given a function call \c f(x), 4688203955Srdivacky * clang_getCursor() would provide the following cursors: 4689203955Srdivacky * 4690203955Srdivacky * * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'. 4691203955Srdivacky * * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'. 4692203955Srdivacky * * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'. 4693203955Srdivacky * 4694203955Srdivacky * Only the first and last of these cursors will occur within the 4695203955Srdivacky * annotate, since the tokens "f" and "x' directly refer to a function 4696203955Srdivacky * and a variable, respectively, but the parentheses are just a small 4697203955Srdivacky * part of the full syntax of the function call expression, which is 4698203955Srdivacky * not provided as an annotation. 4699203955Srdivacky * 4700203955Srdivacky * \param TU the translation unit that owns the given tokens. 4701203955Srdivacky * 4702203955Srdivacky * \param Tokens the set of tokens to annotate. 4703203955Srdivacky * 4704203955Srdivacky * \param NumTokens the number of tokens in \p Tokens. 4705203955Srdivacky * 4706203955Srdivacky * \param Cursors an array of \p NumTokens cursors, whose contents will be 4707203955Srdivacky * replaced with the cursors corresponding to each token. 4708203955Srdivacky */ 4709203955SrdivackyCINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU, 4710203955Srdivacky CXToken *Tokens, unsigned NumTokens, 4711203955Srdivacky CXCursor *Cursors); 4712205219Srdivacky 4713203955Srdivacky/** 4714203955Srdivacky * \brief Free the given set of tokens. 4715203955Srdivacky */ 4716205219SrdivackyCINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU, 4717203955Srdivacky CXToken *Tokens, unsigned NumTokens); 4718205219Srdivacky 4719203955Srdivacky/** 4720203955Srdivacky * @} 4721203955Srdivacky */ 4722205219Srdivacky 4723203955Srdivacky/** 4724202879Srdivacky * \defgroup CINDEX_DEBUG Debugging facilities 4725202879Srdivacky * 4726202879Srdivacky * These routines are used for testing and debugging, only, and should not 4727202879Srdivacky * be relied upon. 4728202879Srdivacky * 4729202879Srdivacky * @{ 4730202879Srdivacky */ 4731203955Srdivacky 4732198092Srdivacky/* for debug/testing */ 4733204643SrdivackyCINDEX_LINKAGE CXString clang_getCursorKindSpelling(enum CXCursorKind Kind); 4734203955SrdivackyCINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(CXCursor, 4735203955Srdivacky const char **startBuf, 4736198092Srdivacky const char **endBuf, 4737198092Srdivacky unsigned *startLine, 4738198092Srdivacky unsigned *startColumn, 4739198092Srdivacky unsigned *endLine, 4740198092Srdivacky unsigned *endColumn); 4741204643SrdivackyCINDEX_LINKAGE void clang_enableStackTraces(void); 4742218893SdimCINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void*), void *user_data, 4743218893Sdim unsigned stack_size); 4744218893Sdim 4745202879Srdivacky/** 4746202879Srdivacky * @} 4747198092Srdivacky */ 4748203955Srdivacky 4749199482Srdivacky/** 4750202879Srdivacky * \defgroup CINDEX_CODE_COMPLET Code completion 4751202879Srdivacky * 4752202879Srdivacky * Code completion involves taking an (incomplete) source file, along with 4753202879Srdivacky * knowledge of where the user is actively editing that file, and suggesting 4754202879Srdivacky * syntactically- and semantically-valid constructs that the user might want to 4755202879Srdivacky * use at that particular point in the source code. These data structures and 4756202879Srdivacky * routines provide support for code completion. 4757202879Srdivacky * 4758202879Srdivacky * @{ 4759202879Srdivacky */ 4760203955Srdivacky 4761202879Srdivacky/** 4762199482Srdivacky * \brief A semantic string that describes a code-completion result. 4763199482Srdivacky * 4764199482Srdivacky * A semantic string that describes the formatting of a code-completion 4765199482Srdivacky * result as a single "template" of text that should be inserted into the 4766199482Srdivacky * source buffer when a particular code-completion result is selected. 4767199482Srdivacky * Each semantic string is made up of some number of "chunks", each of which 4768199482Srdivacky * contains some text along with a description of what that text means, e.g., 4769199482Srdivacky * the name of the entity being referenced, whether the text chunk is part of 4770199482Srdivacky * the template, or whether it is a "placeholder" that the user should replace 4771199482Srdivacky * with actual code,of a specific kind. See \c CXCompletionChunkKind for a 4772203955Srdivacky * description of the different kinds of chunks. 4773199482Srdivacky */ 4774199482Srdivackytypedef void *CXCompletionString; 4775203955Srdivacky 4776199482Srdivacky/** 4777199482Srdivacky * \brief A single result of code completion. 4778199482Srdivacky */ 4779199482Srdivackytypedef struct { 4780199482Srdivacky /** 4781203955Srdivacky * \brief The kind of entity that this completion refers to. 4782199482Srdivacky * 4783203955Srdivacky * The cursor kind will be a macro, keyword, or a declaration (one of the 4784199482Srdivacky * *Decl cursor kinds), describing the entity that the completion is 4785199482Srdivacky * referring to. 4786199482Srdivacky * 4787199482Srdivacky * \todo In the future, we would like to provide a full cursor, to allow 4788199482Srdivacky * the client to extract additional information from declaration. 4789199482Srdivacky */ 4790199482Srdivacky enum CXCursorKind CursorKind; 4791203955Srdivacky 4792203955Srdivacky /** 4793199482Srdivacky * \brief The code-completion string that describes how to insert this 4794199482Srdivacky * code-completion result into the editing buffer. 4795199482Srdivacky */ 4796199482Srdivacky CXCompletionString CompletionString; 4797199482Srdivacky} CXCompletionResult; 4798199482Srdivacky 4799199482Srdivacky/** 4800199482Srdivacky * \brief Describes a single piece of text within a code-completion string. 4801199482Srdivacky * 4802203955Srdivacky * Each "chunk" within a code-completion string (\c CXCompletionString) is 4803203955Srdivacky * either a piece of text with a specific "kind" that describes how that text 4804199482Srdivacky * should be interpreted by the client or is another completion string. 4805199482Srdivacky */ 4806199482Srdivackyenum CXCompletionChunkKind { 4807199482Srdivacky /** 4808199482Srdivacky * \brief A code-completion string that describes "optional" text that 4809199482Srdivacky * could be a part of the template (but is not required). 4810199482Srdivacky * 4811199482Srdivacky * The Optional chunk is the only kind of chunk that has a code-completion 4812203955Srdivacky * string for its representation, which is accessible via 4813199482Srdivacky * \c clang_getCompletionChunkCompletionString(). The code-completion string 4814199482Srdivacky * describes an additional part of the template that is completely optional. 4815199482Srdivacky * For example, optional chunks can be used to describe the placeholders for 4816199482Srdivacky * arguments that match up with defaulted function parameters, e.g. given: 4817199482Srdivacky * 4818199482Srdivacky * \code 4819199482Srdivacky * void f(int x, float y = 3.14, double z = 2.71828); 4820199482Srdivacky * \endcode 4821199482Srdivacky * 4822199482Srdivacky * The code-completion string for this function would contain: 4823199482Srdivacky * - a TypedText chunk for "f". 4824199482Srdivacky * - a LeftParen chunk for "(". 4825199482Srdivacky * - a Placeholder chunk for "int x" 4826199482Srdivacky * - an Optional chunk containing the remaining defaulted arguments, e.g., 4827199482Srdivacky * - a Comma chunk for "," 4828204643Srdivacky * - a Placeholder chunk for "float y" 4829199482Srdivacky * - an Optional chunk containing the last defaulted argument: 4830199482Srdivacky * - a Comma chunk for "," 4831199482Srdivacky * - a Placeholder chunk for "double z" 4832199482Srdivacky * - a RightParen chunk for ")" 4833199482Srdivacky * 4834204643Srdivacky * There are many ways to handle Optional chunks. Two simple approaches are: 4835199482Srdivacky * - Completely ignore optional chunks, in which case the template for the 4836199482Srdivacky * function "f" would only include the first parameter ("int x"). 4837199482Srdivacky * - Fully expand all optional chunks, in which case the template for the 4838199482Srdivacky * function "f" would have all of the parameters. 4839199482Srdivacky */ 4840199482Srdivacky CXCompletionChunk_Optional, 4841199482Srdivacky /** 4842199482Srdivacky * \brief Text that a user would be expected to type to get this 4843203955Srdivacky * code-completion result. 4844199482Srdivacky * 4845203955Srdivacky * There will be exactly one "typed text" chunk in a semantic string, which 4846203955Srdivacky * will typically provide the spelling of a keyword or the name of a 4847199482Srdivacky * declaration that could be used at the current code point. Clients are 4848199482Srdivacky * expected to filter the code-completion results based on the text in this 4849199482Srdivacky * chunk. 4850199482Srdivacky */ 4851199482Srdivacky CXCompletionChunk_TypedText, 4852199482Srdivacky /** 4853199482Srdivacky * \brief Text that should be inserted as part of a code-completion result. 4854199482Srdivacky * 4855199482Srdivacky * A "text" chunk represents text that is part of the template to be 4856199482Srdivacky * inserted into user code should this particular code-completion result 4857199482Srdivacky * be selected. 4858199482Srdivacky */ 4859199482Srdivacky CXCompletionChunk_Text, 4860199482Srdivacky /** 4861199482Srdivacky * \brief Placeholder text that should be replaced by the user. 4862199482Srdivacky * 4863199482Srdivacky * A "placeholder" chunk marks a place where the user should insert text 4864199482Srdivacky * into the code-completion template. For example, placeholders might mark 4865199482Srdivacky * the function parameters for a function declaration, to indicate that the 4866199482Srdivacky * user should provide arguments for each of those parameters. The actual 4867199482Srdivacky * text in a placeholder is a suggestion for the text to display before 4868199482Srdivacky * the user replaces the placeholder with real code. 4869199482Srdivacky */ 4870199482Srdivacky CXCompletionChunk_Placeholder, 4871199482Srdivacky /** 4872199482Srdivacky * \brief Informative text that should be displayed but never inserted as 4873199482Srdivacky * part of the template. 4874203955Srdivacky * 4875199482Srdivacky * An "informative" chunk contains annotations that can be displayed to 4876199482Srdivacky * help the user decide whether a particular code-completion result is the 4877199482Srdivacky * right option, but which is not part of the actual template to be inserted 4878199482Srdivacky * by code completion. 4879199482Srdivacky */ 4880199482Srdivacky CXCompletionChunk_Informative, 4881199482Srdivacky /** 4882199482Srdivacky * \brief Text that describes the current parameter when code-completion is 4883199482Srdivacky * referring to function call, message send, or template specialization. 4884199482Srdivacky * 4885199482Srdivacky * A "current parameter" chunk occurs when code-completion is providing 4886199482Srdivacky * information about a parameter corresponding to the argument at the 4887199482Srdivacky * code-completion point. For example, given a function 4888199482Srdivacky * 4889199482Srdivacky * \code 4890199482Srdivacky * int add(int x, int y); 4891199482Srdivacky * \endcode 4892199482Srdivacky * 4893199482Srdivacky * and the source code \c add(, where the code-completion point is after the 4894199482Srdivacky * "(", the code-completion string will contain a "current parameter" chunk 4895199482Srdivacky * for "int x", indicating that the current argument will initialize that 4896199482Srdivacky * parameter. After typing further, to \c add(17, (where the code-completion 4897203955Srdivacky * point is after the ","), the code-completion string will contain a 4898199482Srdivacky * "current paremeter" chunk to "int y". 4899199482Srdivacky */ 4900199482Srdivacky CXCompletionChunk_CurrentParameter, 4901199482Srdivacky /** 4902199482Srdivacky * \brief A left parenthesis ('('), used to initiate a function call or 4903199482Srdivacky * signal the beginning of a function parameter list. 4904199482Srdivacky */ 4905199482Srdivacky CXCompletionChunk_LeftParen, 4906199482Srdivacky /** 4907199482Srdivacky * \brief A right parenthesis (')'), used to finish a function call or 4908199482Srdivacky * signal the end of a function parameter list. 4909199482Srdivacky */ 4910199482Srdivacky CXCompletionChunk_RightParen, 4911199482Srdivacky /** 4912199482Srdivacky * \brief A left bracket ('['). 4913199482Srdivacky */ 4914199482Srdivacky CXCompletionChunk_LeftBracket, 4915199482Srdivacky /** 4916199482Srdivacky * \brief A right bracket (']'). 4917199482Srdivacky */ 4918199482Srdivacky CXCompletionChunk_RightBracket, 4919199482Srdivacky /** 4920199482Srdivacky * \brief A left brace ('{'). 4921199482Srdivacky */ 4922199482Srdivacky CXCompletionChunk_LeftBrace, 4923199482Srdivacky /** 4924199482Srdivacky * \brief A right brace ('}'). 4925199482Srdivacky */ 4926199482Srdivacky CXCompletionChunk_RightBrace, 4927199482Srdivacky /** 4928199482Srdivacky * \brief A left angle bracket ('<'). 4929199482Srdivacky */ 4930199482Srdivacky CXCompletionChunk_LeftAngle, 4931199482Srdivacky /** 4932199482Srdivacky * \brief A right angle bracket ('>'). 4933199482Srdivacky */ 4934199482Srdivacky CXCompletionChunk_RightAngle, 4935199482Srdivacky /** 4936199482Srdivacky * \brief A comma separator (','). 4937199482Srdivacky */ 4938201361Srdivacky CXCompletionChunk_Comma, 4939201361Srdivacky /** 4940203955Srdivacky * \brief Text that specifies the result type of a given result. 4941201361Srdivacky * 4942201361Srdivacky * This special kind of informative chunk is not meant to be inserted into 4943203955Srdivacky * the text buffer. Rather, it is meant to illustrate the type that an 4944201361Srdivacky * expression using the given completion string would have. 4945201361Srdivacky */ 4946202379Srdivacky CXCompletionChunk_ResultType, 4947202379Srdivacky /** 4948202379Srdivacky * \brief A colon (':'). 4949202379Srdivacky */ 4950202379Srdivacky CXCompletionChunk_Colon, 4951202379Srdivacky /** 4952202379Srdivacky * \brief A semicolon (';'). 4953202379Srdivacky */ 4954202379Srdivacky CXCompletionChunk_SemiColon, 4955202379Srdivacky /** 4956202379Srdivacky * \brief An '=' sign. 4957202379Srdivacky */ 4958202379Srdivacky CXCompletionChunk_Equal, 4959202379Srdivacky /** 4960202379Srdivacky * Horizontal space (' '). 4961202379Srdivacky */ 4962202379Srdivacky CXCompletionChunk_HorizontalSpace, 4963202379Srdivacky /** 4964321369Sdim * Vertical space ('\\n'), after which it is generally a good idea to 4965202379Srdivacky * perform indentation. 4966202379Srdivacky */ 4967202379Srdivacky CXCompletionChunk_VerticalSpace 4968199482Srdivacky}; 4969203955Srdivacky 4970199482Srdivacky/** 4971199482Srdivacky * \brief Determine the kind of a particular chunk within a completion string. 4972199482Srdivacky * 4973199482Srdivacky * \param completion_string the completion string to query. 4974199482Srdivacky * 4975199482Srdivacky * \param chunk_number the 0-based index of the chunk in the completion string. 4976199482Srdivacky * 4977199482Srdivacky * \returns the kind of the chunk at the index \c chunk_number. 4978199482Srdivacky */ 4979203955SrdivackyCINDEX_LINKAGE enum CXCompletionChunkKind 4980199482Srdivackyclang_getCompletionChunkKind(CXCompletionString completion_string, 4981199482Srdivacky unsigned chunk_number); 4982203955Srdivacky 4983199482Srdivacky/** 4984203955Srdivacky * \brief Retrieve the text associated with a particular chunk within a 4985199482Srdivacky * completion string. 4986199482Srdivacky * 4987199482Srdivacky * \param completion_string the completion string to query. 4988199482Srdivacky * 4989199482Srdivacky * \param chunk_number the 0-based index of the chunk in the completion string. 4990199482Srdivacky * 4991199482Srdivacky * \returns the text associated with the chunk at index \c chunk_number. 4992199482Srdivacky */ 4993204643SrdivackyCINDEX_LINKAGE CXString 4994199482Srdivackyclang_getCompletionChunkText(CXCompletionString completion_string, 4995199482Srdivacky unsigned chunk_number); 4996199482Srdivacky 4997199482Srdivacky/** 4998203955Srdivacky * \brief Retrieve the completion string associated with a particular chunk 4999199482Srdivacky * within a completion string. 5000199482Srdivacky * 5001199482Srdivacky * \param completion_string the completion string to query. 5002199482Srdivacky * 5003199482Srdivacky * \param chunk_number the 0-based index of the chunk in the completion string. 5004199482Srdivacky * 5005199482Srdivacky * \returns the completion string associated with the chunk at index 5006226633Sdim * \c chunk_number. 5007199482Srdivacky */ 5008199482SrdivackyCINDEX_LINKAGE CXCompletionString 5009199482Srdivackyclang_getCompletionChunkCompletionString(CXCompletionString completion_string, 5010199482Srdivacky unsigned chunk_number); 5011203955Srdivacky 5012199482Srdivacky/** 5013199482Srdivacky * \brief Retrieve the number of chunks in the given code-completion string. 5014199482Srdivacky */ 5015199482SrdivackyCINDEX_LINKAGE unsigned 5016199482Srdivackyclang_getNumCompletionChunks(CXCompletionString completion_string); 5017199482Srdivacky 5018199482Srdivacky/** 5019208600Srdivacky * \brief Determine the priority of this code completion. 5020208600Srdivacky * 5021208600Srdivacky * The priority of a code completion indicates how likely it is that this 5022208600Srdivacky * particular completion is the completion that the user will select. The 5023208600Srdivacky * priority is selected by various internal heuristics. 5024208600Srdivacky * 5025208600Srdivacky * \param completion_string The completion string to query. 5026208600Srdivacky * 5027208600Srdivacky * \returns The priority of this completion string. Smaller values indicate 5028208600Srdivacky * higher-priority (more likely) completions. 5029208600Srdivacky */ 5030208600SrdivackyCINDEX_LINKAGE unsigned 5031208600Srdivackyclang_getCompletionPriority(CXCompletionString completion_string); 5032208600Srdivacky 5033208600Srdivacky/** 5034212904Sdim * \brief Determine the availability of the entity that this code-completion 5035212904Sdim * string refers to. 5036212904Sdim * 5037212904Sdim * \param completion_string The completion string to query. 5038212904Sdim * 5039212904Sdim * \returns The availability of the completion string. 5040212904Sdim */ 5041212904SdimCINDEX_LINKAGE enum CXAvailabilityKind 5042212904Sdimclang_getCompletionAvailability(CXCompletionString completion_string); 5043212904Sdim 5044212904Sdim/** 5045226633Sdim * \brief Retrieve the number of annotations associated with the given 5046226633Sdim * completion string. 5047226633Sdim * 5048226633Sdim * \param completion_string the completion string to query. 5049226633Sdim * 5050226633Sdim * \returns the number of annotations associated with the given completion 5051226633Sdim * string. 5052226633Sdim */ 5053226633SdimCINDEX_LINKAGE unsigned 5054226633Sdimclang_getCompletionNumAnnotations(CXCompletionString completion_string); 5055226633Sdim 5056226633Sdim/** 5057226633Sdim * \brief Retrieve the annotation associated with the given completion string. 5058226633Sdim * 5059226633Sdim * \param completion_string the completion string to query. 5060226633Sdim * 5061226633Sdim * \param annotation_number the 0-based index of the annotation of the 5062226633Sdim * completion string. 5063226633Sdim * 5064226633Sdim * \returns annotation string associated with the completion at index 5065226633Sdim * \c annotation_number, or a NULL string if that annotation is not available. 5066226633Sdim */ 5067226633SdimCINDEX_LINKAGE CXString 5068226633Sdimclang_getCompletionAnnotation(CXCompletionString completion_string, 5069226633Sdim unsigned annotation_number); 5070226633Sdim 5071226633Sdim/** 5072234353Sdim * \brief Retrieve the parent context of the given completion string. 5073234353Sdim * 5074234353Sdim * The parent context of a completion string is the semantic parent of 5075234353Sdim * the declaration (if any) that the code completion represents. For example, 5076234353Sdim * a code completion for an Objective-C method would have the method's class 5077234353Sdim * or protocol as its context. 5078234353Sdim * 5079234353Sdim * \param completion_string The code completion string whose parent is 5080234353Sdim * being queried. 5081234353Sdim * 5082243830Sdim * \param kind DEPRECATED: always set to CXCursor_NotImplemented if non-NULL. 5083234353Sdim * 5084239462Sdim * \returns The name of the completion parent, e.g., "NSObject" if 5085234353Sdim * the completion string represents a method in the NSObject class. 5086234353Sdim */ 5087234353SdimCINDEX_LINKAGE CXString 5088234353Sdimclang_getCompletionParent(CXCompletionString completion_string, 5089234353Sdim enum CXCursorKind *kind); 5090239462Sdim 5091234353Sdim/** 5092239462Sdim * \brief Retrieve the brief documentation comment attached to the declaration 5093239462Sdim * that corresponds to the given completion string. 5094239462Sdim */ 5095239462SdimCINDEX_LINKAGE CXString 5096239462Sdimclang_getCompletionBriefComment(CXCompletionString completion_string); 5097239462Sdim 5098239462Sdim/** 5099226633Sdim * \brief Retrieve a completion string for an arbitrary declaration or macro 5100226633Sdim * definition cursor. 5101226633Sdim * 5102226633Sdim * \param cursor The cursor to query. 5103226633Sdim * 5104226633Sdim * \returns A non-context-sensitive completion string for declaration and macro 5105226633Sdim * definition cursors, or NULL for other kinds of cursors. 5106226633Sdim */ 5107226633SdimCINDEX_LINKAGE CXCompletionString 5108226633Sdimclang_getCursorCompletionString(CXCursor cursor); 5109226633Sdim 5110226633Sdim/** 5111201361Srdivacky * \brief Contains the results of code-completion. 5112201361Srdivacky * 5113201361Srdivacky * This data structure contains the results of code completion, as 5114218893Sdim * produced by \c clang_codeCompleteAt(). Its contents must be freed by 5115201361Srdivacky * \c clang_disposeCodeCompleteResults. 5116201361Srdivacky */ 5117201361Srdivackytypedef struct { 5118201361Srdivacky /** 5119201361Srdivacky * \brief The code-completion results. 5120201361Srdivacky */ 5121201361Srdivacky CXCompletionResult *Results; 5122201361Srdivacky 5123201361Srdivacky /** 5124201361Srdivacky * \brief The number of code-completion results stored in the 5125201361Srdivacky * \c Results array. 5126201361Srdivacky */ 5127201361Srdivacky unsigned NumResults; 5128201361Srdivacky} CXCodeCompleteResults; 5129201361Srdivacky 5130201361Srdivacky/** 5131212904Sdim * \brief Flags that can be passed to \c clang_codeCompleteAt() to 5132212904Sdim * modify its behavior. 5133212904Sdim * 5134212904Sdim * The enumerators in this enumeration can be bitwise-OR'd together to 5135212904Sdim * provide multiple options to \c clang_codeCompleteAt(). 5136212904Sdim */ 5137212904Sdimenum CXCodeComplete_Flags { 5138212904Sdim /** 5139212904Sdim * \brief Whether to include macros within the set of code 5140212904Sdim * completions returned. 5141212904Sdim */ 5142212904Sdim CXCodeComplete_IncludeMacros = 0x01, 5143212904Sdim 5144212904Sdim /** 5145212904Sdim * \brief Whether to include code patterns for language constructs 5146212904Sdim * within the set of code completions, e.g., for loops. 5147212904Sdim */ 5148239462Sdim CXCodeComplete_IncludeCodePatterns = 0x02, 5149239462Sdim 5150239462Sdim /** 5151239462Sdim * \brief Whether to include brief documentation within the set of code 5152239462Sdim * completions returned. 5153239462Sdim */ 5154239462Sdim CXCodeComplete_IncludeBriefComments = 0x04 5155212904Sdim}; 5156212904Sdim 5157212904Sdim/** 5158224145Sdim * \brief Bits that represent the context under which completion is occurring. 5159224145Sdim * 5160224145Sdim * The enumerators in this enumeration may be bitwise-OR'd together if multiple 5161224145Sdim * contexts are occurring simultaneously. 5162224145Sdim */ 5163224145Sdimenum CXCompletionContext { 5164224145Sdim /** 5165224145Sdim * \brief The context for completions is unexposed, as only Clang results 5166224145Sdim * should be included. (This is equivalent to having no context bits set.) 5167224145Sdim */ 5168224145Sdim CXCompletionContext_Unexposed = 0, 5169224145Sdim 5170224145Sdim /** 5171224145Sdim * \brief Completions for any possible type should be included in the results. 5172224145Sdim */ 5173224145Sdim CXCompletionContext_AnyType = 1 << 0, 5174224145Sdim 5175224145Sdim /** 5176224145Sdim * \brief Completions for any possible value (variables, function calls, etc.) 5177224145Sdim * should be included in the results. 5178224145Sdim */ 5179224145Sdim CXCompletionContext_AnyValue = 1 << 1, 5180224145Sdim /** 5181224145Sdim * \brief Completions for values that resolve to an Objective-C object should 5182224145Sdim * be included in the results. 5183224145Sdim */ 5184224145Sdim CXCompletionContext_ObjCObjectValue = 1 << 2, 5185224145Sdim /** 5186224145Sdim * \brief Completions for values that resolve to an Objective-C selector 5187224145Sdim * should be included in the results. 5188224145Sdim */ 5189224145Sdim CXCompletionContext_ObjCSelectorValue = 1 << 3, 5190224145Sdim /** 5191224145Sdim * \brief Completions for values that resolve to a C++ class type should be 5192224145Sdim * included in the results. 5193224145Sdim */ 5194224145Sdim CXCompletionContext_CXXClassTypeValue = 1 << 4, 5195224145Sdim 5196224145Sdim /** 5197224145Sdim * \brief Completions for fields of the member being accessed using the dot 5198224145Sdim * operator should be included in the results. 5199224145Sdim */ 5200224145Sdim CXCompletionContext_DotMemberAccess = 1 << 5, 5201224145Sdim /** 5202224145Sdim * \brief Completions for fields of the member being accessed using the arrow 5203224145Sdim * operator should be included in the results. 5204224145Sdim */ 5205224145Sdim CXCompletionContext_ArrowMemberAccess = 1 << 6, 5206224145Sdim /** 5207224145Sdim * \brief Completions for properties of the Objective-C object being accessed 5208224145Sdim * using the dot operator should be included in the results. 5209224145Sdim */ 5210224145Sdim CXCompletionContext_ObjCPropertyAccess = 1 << 7, 5211224145Sdim 5212224145Sdim /** 5213224145Sdim * \brief Completions for enum tags should be included in the results. 5214224145Sdim */ 5215224145Sdim CXCompletionContext_EnumTag = 1 << 8, 5216224145Sdim /** 5217224145Sdim * \brief Completions for union tags should be included in the results. 5218224145Sdim */ 5219224145Sdim CXCompletionContext_UnionTag = 1 << 9, 5220224145Sdim /** 5221224145Sdim * \brief Completions for struct tags should be included in the results. 5222224145Sdim */ 5223224145Sdim CXCompletionContext_StructTag = 1 << 10, 5224224145Sdim 5225224145Sdim /** 5226224145Sdim * \brief Completions for C++ class names should be included in the results. 5227224145Sdim */ 5228224145Sdim CXCompletionContext_ClassTag = 1 << 11, 5229224145Sdim /** 5230224145Sdim * \brief Completions for C++ namespaces and namespace aliases should be 5231224145Sdim * included in the results. 5232224145Sdim */ 5233224145Sdim CXCompletionContext_Namespace = 1 << 12, 5234224145Sdim /** 5235224145Sdim * \brief Completions for C++ nested name specifiers should be included in 5236224145Sdim * the results. 5237224145Sdim */ 5238224145Sdim CXCompletionContext_NestedNameSpecifier = 1 << 13, 5239224145Sdim 5240224145Sdim /** 5241224145Sdim * \brief Completions for Objective-C interfaces (classes) should be included 5242224145Sdim * in the results. 5243224145Sdim */ 5244224145Sdim CXCompletionContext_ObjCInterface = 1 << 14, 5245224145Sdim /** 5246224145Sdim * \brief Completions for Objective-C protocols should be included in 5247224145Sdim * the results. 5248224145Sdim */ 5249224145Sdim CXCompletionContext_ObjCProtocol = 1 << 15, 5250224145Sdim /** 5251224145Sdim * \brief Completions for Objective-C categories should be included in 5252224145Sdim * the results. 5253224145Sdim */ 5254224145Sdim CXCompletionContext_ObjCCategory = 1 << 16, 5255224145Sdim /** 5256224145Sdim * \brief Completions for Objective-C instance messages should be included 5257224145Sdim * in the results. 5258224145Sdim */ 5259224145Sdim CXCompletionContext_ObjCInstanceMessage = 1 << 17, 5260224145Sdim /** 5261224145Sdim * \brief Completions for Objective-C class messages should be included in 5262224145Sdim * the results. 5263224145Sdim */ 5264224145Sdim CXCompletionContext_ObjCClassMessage = 1 << 18, 5265224145Sdim /** 5266224145Sdim * \brief Completions for Objective-C selector names should be included in 5267224145Sdim * the results. 5268224145Sdim */ 5269224145Sdim CXCompletionContext_ObjCSelectorName = 1 << 19, 5270224145Sdim 5271224145Sdim /** 5272224145Sdim * \brief Completions for preprocessor macro names should be included in 5273224145Sdim * the results. 5274224145Sdim */ 5275224145Sdim CXCompletionContext_MacroName = 1 << 20, 5276224145Sdim 5277224145Sdim /** 5278224145Sdim * \brief Natural language completions should be included in the results. 5279224145Sdim */ 5280224145Sdim CXCompletionContext_NaturalLanguage = 1 << 21, 5281224145Sdim 5282224145Sdim /** 5283224145Sdim * \brief The current context is unknown, so set all contexts. 5284224145Sdim */ 5285224145Sdim CXCompletionContext_Unknown = ((1 << 22) - 1) 5286224145Sdim}; 5287224145Sdim 5288224145Sdim/** 5289212904Sdim * \brief Returns a default set of code-completion options that can be 5290212904Sdim * passed to\c clang_codeCompleteAt(). 5291212904Sdim */ 5292212904SdimCINDEX_LINKAGE unsigned clang_defaultCodeCompleteOptions(void); 5293212904Sdim 5294212904Sdim/** 5295212904Sdim * \brief Perform code completion at a given location in a translation unit. 5296212904Sdim * 5297212904Sdim * This function performs code completion at a particular file, line, and 5298212904Sdim * column within source code, providing results that suggest potential 5299212904Sdim * code snippets based on the context of the completion. The basic model 5300212904Sdim * for code completion is that Clang will parse a complete source file, 5301212904Sdim * performing syntax checking up to the location where code-completion has 5302212904Sdim * been requested. At that point, a special code-completion token is passed 5303212904Sdim * to the parser, which recognizes this token and determines, based on the 5304212904Sdim * current location in the C/Objective-C/C++ grammar and the state of 5305212904Sdim * semantic analysis, what completions to provide. These completions are 5306212904Sdim * returned via a new \c CXCodeCompleteResults structure. 5307212904Sdim * 5308212904Sdim * Code completion itself is meant to be triggered by the client when the 5309212904Sdim * user types punctuation characters or whitespace, at which point the 5310212904Sdim * code-completion location will coincide with the cursor. For example, if \c p 5311212904Sdim * is a pointer, code-completion might be triggered after the "-" and then 5312212904Sdim * after the ">" in \c p->. When the code-completion location is afer the ">", 5313212904Sdim * the completion results will provide, e.g., the members of the struct that 5314212904Sdim * "p" points to. The client is responsible for placing the cursor at the 5315212904Sdim * beginning of the token currently being typed, then filtering the results 5316212904Sdim * based on the contents of the token. For example, when code-completing for 5317212904Sdim * the expression \c p->get, the client should provide the location just after 5318212904Sdim * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the 5319212904Sdim * client can filter the results based on the current token text ("get"), only 5320212904Sdim * showing those results that start with "get". The intent of this interface 5321212904Sdim * is to separate the relatively high-latency acquisition of code-completion 5322212904Sdim * results from the filtering of results on a per-character basis, which must 5323212904Sdim * have a lower latency. 5324212904Sdim * 5325212904Sdim * \param TU The translation unit in which code-completion should 5326212904Sdim * occur. The source files for this translation unit need not be 5327212904Sdim * completely up-to-date (and the contents of those source files may 5328212904Sdim * be overridden via \p unsaved_files). Cursors referring into the 5329212904Sdim * translation unit may be invalidated by this invocation. 5330212904Sdim * 5331212904Sdim * \param complete_filename The name of the source file where code 5332212904Sdim * completion should be performed. This filename may be any file 5333212904Sdim * included in the translation unit. 5334212904Sdim * 5335212904Sdim * \param complete_line The line at which code-completion should occur. 5336212904Sdim * 5337212904Sdim * \param complete_column The column at which code-completion should occur. 5338212904Sdim * Note that the column should point just after the syntactic construct that 5339212904Sdim * initiated code completion, and not in the middle of a lexical token. 5340212904Sdim * 5341309124Sdim * \param unsaved_files the Files that have not yet been saved to disk 5342212904Sdim * but may be required for parsing or code completion, including the 5343212904Sdim * contents of those files. The contents and name of these files (as 5344212904Sdim * specified by CXUnsavedFile) are copied when necessary, so the 5345212904Sdim * client only needs to guarantee their validity until the call to 5346212904Sdim * this function returns. 5347212904Sdim * 5348212904Sdim * \param num_unsaved_files The number of unsaved file entries in \p 5349212904Sdim * unsaved_files. 5350212904Sdim * 5351212904Sdim * \param options Extra options that control the behavior of code 5352212904Sdim * completion, expressed as a bitwise OR of the enumerators of the 5353212904Sdim * CXCodeComplete_Flags enumeration. The 5354212904Sdim * \c clang_defaultCodeCompleteOptions() function returns a default set 5355212904Sdim * of code-completion options. 5356212904Sdim * 5357212904Sdim * \returns If successful, a new \c CXCodeCompleteResults structure 5358212904Sdim * containing code-completion results, which should eventually be 5359212904Sdim * freed with \c clang_disposeCodeCompleteResults(). If code 5360212904Sdim * completion fails, returns NULL. 5361212904Sdim */ 5362212904SdimCINDEX_LINKAGE 5363212904SdimCXCodeCompleteResults *clang_codeCompleteAt(CXTranslationUnit TU, 5364212904Sdim const char *complete_filename, 5365212904Sdim unsigned complete_line, 5366212904Sdim unsigned complete_column, 5367212904Sdim struct CXUnsavedFile *unsaved_files, 5368212904Sdim unsigned num_unsaved_files, 5369212904Sdim unsigned options); 5370212904Sdim 5371212904Sdim/** 5372212904Sdim * \brief Sort the code-completion results in case-insensitive alphabetical 5373212904Sdim * order. 5374212904Sdim * 5375212904Sdim * \param Results The set of results to sort. 5376212904Sdim * \param NumResults The number of results in \p Results. 5377212904Sdim */ 5378212904SdimCINDEX_LINKAGE 5379212904Sdimvoid clang_sortCodeCompletionResults(CXCompletionResult *Results, 5380212904Sdim unsigned NumResults); 5381212904Sdim 5382212904Sdim/** 5383201361Srdivacky * \brief Free the given set of code-completion results. 5384201361Srdivacky */ 5385203955SrdivackyCINDEX_LINKAGE 5386201361Srdivackyvoid clang_disposeCodeCompleteResults(CXCodeCompleteResults *Results); 5387212904Sdim 5388202879Srdivacky/** 5389204643Srdivacky * \brief Determine the number of diagnostics produced prior to the 5390204643Srdivacky * location where code completion was performed. 5391204643Srdivacky */ 5392205219SrdivackyCINDEX_LINKAGE 5393204643Srdivackyunsigned clang_codeCompleteGetNumDiagnostics(CXCodeCompleteResults *Results); 5394204643Srdivacky 5395204643Srdivacky/** 5396204643Srdivacky * \brief Retrieve a diagnostic associated with the given code completion. 5397204643Srdivacky * 5398239462Sdim * \param Results the code completion results to query. 5399204643Srdivacky * \param Index the zero-based diagnostic number to retrieve. 5400204643Srdivacky * 5401204643Srdivacky * \returns the requested diagnostic. This diagnostic must be freed 5402204643Srdivacky * via a call to \c clang_disposeDiagnostic(). 5403204643Srdivacky */ 5404205219SrdivackyCINDEX_LINKAGE 5405204643SrdivackyCXDiagnostic clang_codeCompleteGetDiagnostic(CXCodeCompleteResults *Results, 5406204643Srdivacky unsigned Index); 5407204643Srdivacky 5408204643Srdivacky/** 5409276479Sdim * \brief Determines what completions are appropriate for the context 5410224145Sdim * the given code completion. 5411224145Sdim * 5412224145Sdim * \param Results the code completion results to query 5413224145Sdim * 5414224145Sdim * \returns the kinds of completions that are appropriate for use 5415224145Sdim * along with the given code completion results. 5416224145Sdim */ 5417224145SdimCINDEX_LINKAGE 5418224145Sdimunsigned long long clang_codeCompleteGetContexts( 5419224145Sdim CXCodeCompleteResults *Results); 5420226633Sdim 5421226633Sdim/** 5422226633Sdim * \brief Returns the cursor kind for the container for the current code 5423226633Sdim * completion context. The container is only guaranteed to be set for 5424226633Sdim * contexts where a container exists (i.e. member accesses or Objective-C 5425226633Sdim * message sends); if there is not a container, this function will return 5426226633Sdim * CXCursor_InvalidCode. 5427226633Sdim * 5428226633Sdim * \param Results the code completion results to query 5429226633Sdim * 5430226633Sdim * \param IsIncomplete on return, this value will be false if Clang has complete 5431226633Sdim * information about the container. If Clang does not have complete 5432226633Sdim * information, this value will be true. 5433226633Sdim * 5434226633Sdim * \returns the container kind, or CXCursor_InvalidCode if there is not a 5435226633Sdim * container 5436226633Sdim */ 5437226633SdimCINDEX_LINKAGE 5438226633Sdimenum CXCursorKind clang_codeCompleteGetContainerKind( 5439226633Sdim CXCodeCompleteResults *Results, 5440226633Sdim unsigned *IsIncomplete); 5441226633Sdim 5442226633Sdim/** 5443226633Sdim * \brief Returns the USR for the container for the current code completion 5444226633Sdim * context. If there is not a container for the current context, this 5445226633Sdim * function will return the empty string. 5446226633Sdim * 5447226633Sdim * \param Results the code completion results to query 5448226633Sdim * 5449226633Sdim * \returns the USR for the container 5450226633Sdim */ 5451226633SdimCINDEX_LINKAGE 5452226633SdimCXString clang_codeCompleteGetContainerUSR(CXCodeCompleteResults *Results); 5453296417Sdim 5454224145Sdim/** 5455226633Sdim * \brief Returns the currently-entered selector for an Objective-C message 5456226633Sdim * send, formatted like "initWithFoo:bar:". Only guaranteed to return a 5457226633Sdim * non-empty string for CXCompletionContext_ObjCInstanceMessage and 5458226633Sdim * CXCompletionContext_ObjCClassMessage. 5459226633Sdim * 5460226633Sdim * \param Results the code completion results to query 5461226633Sdim * 5462226633Sdim * \returns the selector (or partial selector) that has been entered thus far 5463226633Sdim * for an Objective-C message send. 5464226633Sdim */ 5465226633SdimCINDEX_LINKAGE 5466226633SdimCXString clang_codeCompleteGetObjCSelector(CXCodeCompleteResults *Results); 5467226633Sdim 5468226633Sdim/** 5469202879Srdivacky * @} 5470202879Srdivacky */ 5471203955Srdivacky 5472202879Srdivacky/** 5473202879Srdivacky * \defgroup CINDEX_MISC Miscellaneous utility functions 5474202879Srdivacky * 5475202879Srdivacky * @{ 5476202879Srdivacky */ 5477202879Srdivacky 5478202879Srdivacky/** 5479203955Srdivacky * \brief Return a version string, suitable for showing to a user, but not 5480203955Srdivacky * intended to be parsed (the format is not guaranteed to be stable). 5481203955Srdivacky */ 5482249423SdimCINDEX_LINKAGE CXString clang_getClangVersion(void); 5483203955Srdivacky 5484221345Sdim/** 5485221345Sdim * \brief Enable/disable crash recovery. 5486221345Sdim * 5487239462Sdim * \param isEnabled Flag to indicate if crash recovery is enabled. A non-zero 5488239462Sdim * value enables crash recovery, while 0 disables it. 5489221345Sdim */ 5490221345SdimCINDEX_LINKAGE void clang_toggleCrashRecovery(unsigned isEnabled); 5491221345Sdim 5492203955Srdivacky /** 5493205219Srdivacky * \brief Visitor invoked for each file in a translation unit 5494203955Srdivacky * (used with clang_getInclusions()). 5495203955Srdivacky * 5496203955Srdivacky * This visitor function will be invoked by clang_getInclusions() for each 5497239462Sdim * file included (either at the top-level or by \#include directives) within 5498203955Srdivacky * a translation unit. The first argument is the file being included, and 5499203955Srdivacky * the second and third arguments provide the inclusion stack. The 5500203955Srdivacky * array is sorted in order of immediate inclusion. For example, 5501203955Srdivacky * the first element refers to the location that included 'included_file'. 5502203955Srdivacky */ 5503203955Srdivackytypedef void (*CXInclusionVisitor)(CXFile included_file, 5504203955Srdivacky CXSourceLocation* inclusion_stack, 5505203955Srdivacky unsigned include_len, 5506203955Srdivacky CXClientData client_data); 5507203955Srdivacky 5508203955Srdivacky/** 5509203955Srdivacky * \brief Visit the set of preprocessor inclusions in a translation unit. 5510203955Srdivacky * The visitor function is called with the provided data for every included 5511203955Srdivacky * file. This does not include headers included by the PCH file (unless one 5512203955Srdivacky * is inspecting the inclusions in the PCH file itself). 5513203955Srdivacky */ 5514203955SrdivackyCINDEX_LINKAGE void clang_getInclusions(CXTranslationUnit tu, 5515203955Srdivacky CXInclusionVisitor visitor, 5516203955Srdivacky CXClientData client_data); 5517203955Srdivacky 5518309124Sdimtypedef enum { 5519309124Sdim CXEval_Int = 1 , 5520309124Sdim CXEval_Float = 2, 5521309124Sdim CXEval_ObjCStrLiteral = 3, 5522309124Sdim CXEval_StrLiteral = 4, 5523309124Sdim CXEval_CFStr = 5, 5524309124Sdim CXEval_Other = 6, 5525309124Sdim 5526309124Sdim CXEval_UnExposed = 0 5527309124Sdim 5528309124Sdim} CXEvalResultKind ; 5529309124Sdim 5530203955Srdivacky/** 5531309124Sdim * \brief Evaluation result of a cursor 5532309124Sdim */ 5533309124Sdimtypedef void * CXEvalResult; 5534309124Sdim 5535309124Sdim/** 5536309124Sdim * \brief If cursor is a statement declaration tries to evaluate the 5537309124Sdim * statement and if its variable, tries to evaluate its initializer, 5538309124Sdim * into its corresponding type. 5539309124Sdim */ 5540309124SdimCINDEX_LINKAGE CXEvalResult clang_Cursor_Evaluate(CXCursor C); 5541309124Sdim 5542309124Sdim/** 5543309124Sdim * \brief Returns the kind of the evaluated result. 5544309124Sdim */ 5545309124SdimCINDEX_LINKAGE CXEvalResultKind clang_EvalResult_getKind(CXEvalResult E); 5546309124Sdim 5547309124Sdim/** 5548309124Sdim * \brief Returns the evaluation result as integer if the 5549309124Sdim * kind is Int. 5550309124Sdim */ 5551309124SdimCINDEX_LINKAGE int clang_EvalResult_getAsInt(CXEvalResult E); 5552309124Sdim 5553309124Sdim/** 5554314564Sdim * \brief Returns the evaluation result as a long long integer if the 5555314564Sdim * kind is Int. This prevents overflows that may happen if the result is 5556314564Sdim * returned with clang_EvalResult_getAsInt. 5557314564Sdim */ 5558314564SdimCINDEX_LINKAGE long long clang_EvalResult_getAsLongLong(CXEvalResult E); 5559314564Sdim 5560314564Sdim/** 5561314564Sdim * \brief Returns a non-zero value if the kind is Int and the evaluation 5562314564Sdim * result resulted in an unsigned integer. 5563314564Sdim */ 5564314564SdimCINDEX_LINKAGE unsigned clang_EvalResult_isUnsignedInt(CXEvalResult E); 5565314564Sdim 5566314564Sdim/** 5567314564Sdim * \brief Returns the evaluation result as an unsigned integer if 5568314564Sdim * the kind is Int and clang_EvalResult_isUnsignedInt is non-zero. 5569314564Sdim */ 5570314564SdimCINDEX_LINKAGE unsigned long long clang_EvalResult_getAsUnsigned(CXEvalResult E); 5571314564Sdim 5572314564Sdim/** 5573309124Sdim * \brief Returns the evaluation result as double if the 5574309124Sdim * kind is double. 5575309124Sdim */ 5576309124SdimCINDEX_LINKAGE double clang_EvalResult_getAsDouble(CXEvalResult E); 5577309124Sdim 5578309124Sdim/** 5579309124Sdim * \brief Returns the evaluation result as a constant string if the 5580309124Sdim * kind is other than Int or float. User must not free this pointer, 5581309124Sdim * instead call clang_EvalResult_dispose on the CXEvalResult returned 5582309124Sdim * by clang_Cursor_Evaluate. 5583309124Sdim */ 5584309124SdimCINDEX_LINKAGE const char* clang_EvalResult_getAsStr(CXEvalResult E); 5585309124Sdim 5586309124Sdim/** 5587309124Sdim * \brief Disposes the created Eval memory. 5588309124Sdim */ 5589309124SdimCINDEX_LINKAGE void clang_EvalResult_dispose(CXEvalResult E); 5590309124Sdim/** 5591202879Srdivacky * @} 5592202879Srdivacky */ 5593203955Srdivacky 5594224145Sdim/** \defgroup CINDEX_REMAPPING Remapping functions 5595224145Sdim * 5596224145Sdim * @{ 5597224145Sdim */ 5598224145Sdim 5599202879Srdivacky/** 5600224145Sdim * \brief A remapping of original source files and their translated files. 5601224145Sdim */ 5602224145Sdimtypedef void *CXRemapping; 5603224145Sdim 5604224145Sdim/** 5605224145Sdim * \brief Retrieve a remapping. 5606224145Sdim * 5607224145Sdim * \param path the path that contains metadata about remappings. 5608224145Sdim * 5609224145Sdim * \returns the requested remapping. This remapping must be freed 5610224145Sdim * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred. 5611224145Sdim */ 5612224145SdimCINDEX_LINKAGE CXRemapping clang_getRemappings(const char *path); 5613224145Sdim 5614224145Sdim/** 5615234353Sdim * \brief Retrieve a remapping. 5616234353Sdim * 5617234353Sdim * \param filePaths pointer to an array of file paths containing remapping info. 5618234353Sdim * 5619234353Sdim * \param numFiles number of file paths. 5620234353Sdim * 5621234353Sdim * \returns the requested remapping. This remapping must be freed 5622234353Sdim * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred. 5623234353Sdim */ 5624234353SdimCINDEX_LINKAGE 5625234353SdimCXRemapping clang_getRemappingsFromFileList(const char **filePaths, 5626234353Sdim unsigned numFiles); 5627234353Sdim 5628234353Sdim/** 5629224145Sdim * \brief Determine the number of remappings. 5630224145Sdim */ 5631224145SdimCINDEX_LINKAGE unsigned clang_remap_getNumFiles(CXRemapping); 5632224145Sdim 5633224145Sdim/** 5634224145Sdim * \brief Get the original and the associated filename from the remapping. 5635224145Sdim * 5636224145Sdim * \param original If non-NULL, will be set to the original filename. 5637224145Sdim * 5638224145Sdim * \param transformed If non-NULL, will be set to the filename that the original 5639224145Sdim * is associated with. 5640224145Sdim */ 5641224145SdimCINDEX_LINKAGE void clang_remap_getFilenames(CXRemapping, unsigned index, 5642224145Sdim CXString *original, CXString *transformed); 5643224145Sdim 5644224145Sdim/** 5645224145Sdim * \brief Dispose the remapping. 5646224145Sdim */ 5647224145SdimCINDEX_LINKAGE void clang_remap_dispose(CXRemapping); 5648224145Sdim 5649224145Sdim/** 5650202879Srdivacky * @} 5651202879Srdivacky */ 5652203955Srdivacky 5653226633Sdim/** \defgroup CINDEX_HIGH Higher level API functions 5654226633Sdim * 5655226633Sdim * @{ 5656226633Sdim */ 5657226633Sdim 5658226633Sdimenum CXVisitorResult { 5659226633Sdim CXVisit_Break, 5660226633Sdim CXVisit_Continue 5661226633Sdim}; 5662226633Sdim 5663309124Sdimtypedef struct CXCursorAndRangeVisitor { 5664226633Sdim void *context; 5665226633Sdim enum CXVisitorResult (*visit)(void *context, CXCursor, CXSourceRange); 5666226633Sdim} CXCursorAndRangeVisitor; 5667226633Sdim 5668249423Sdimtypedef enum { 5669249423Sdim /** 5670249423Sdim * \brief Function returned successfully. 5671249423Sdim */ 5672249423Sdim CXResult_Success = 0, 5673249423Sdim /** 5674249423Sdim * \brief One of the parameters was invalid for the function. 5675249423Sdim */ 5676249423Sdim CXResult_Invalid = 1, 5677249423Sdim /** 5678249423Sdim * \brief The function was terminated by a callback (e.g. it returned 5679249423Sdim * CXVisit_Break) 5680249423Sdim */ 5681249423Sdim CXResult_VisitBreak = 2 5682249423Sdim 5683249423Sdim} CXResult; 5684249423Sdim 5685224145Sdim/** 5686226633Sdim * \brief Find references of a declaration in a specific file. 5687226633Sdim * 5688226633Sdim * \param cursor pointing to a declaration or a reference of one. 5689226633Sdim * 5690226633Sdim * \param file to search for references. 5691226633Sdim * 5692226633Sdim * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for 5693226633Sdim * each reference found. 5694226633Sdim * The CXSourceRange will point inside the file; if the reference is inside 5695226633Sdim * a macro (and not a macro argument) the CXSourceRange will be invalid. 5696249423Sdim * 5697249423Sdim * \returns one of the CXResult enumerators. 5698226633Sdim */ 5699249423SdimCINDEX_LINKAGE CXResult clang_findReferencesInFile(CXCursor cursor, CXFile file, 5700226633Sdim CXCursorAndRangeVisitor visitor); 5701226633Sdim 5702249423Sdim/** 5703249423Sdim * \brief Find #import/#include directives in a specific file. 5704249423Sdim * 5705249423Sdim * \param TU translation unit containing the file to query. 5706249423Sdim * 5707249423Sdim * \param file to search for #import/#include directives. 5708249423Sdim * 5709249423Sdim * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for 5710249423Sdim * each directive found. 5711249423Sdim * 5712249423Sdim * \returns one of the CXResult enumerators. 5713249423Sdim */ 5714249423SdimCINDEX_LINKAGE CXResult clang_findIncludesInFile(CXTranslationUnit TU, 5715249423Sdim CXFile file, 5716249423Sdim CXCursorAndRangeVisitor visitor); 5717249423Sdim 5718226633Sdim#ifdef __has_feature 5719226633Sdim# if __has_feature(blocks) 5720226633Sdim 5721226633Sdimtypedef enum CXVisitorResult 5722226633Sdim (^CXCursorAndRangeVisitorBlock)(CXCursor, CXSourceRange); 5723226633Sdim 5724226633SdimCINDEX_LINKAGE 5725249423SdimCXResult clang_findReferencesInFileWithBlock(CXCursor, CXFile, 5726249423Sdim CXCursorAndRangeVisitorBlock); 5727226633Sdim 5728249423SdimCINDEX_LINKAGE 5729249423SdimCXResult clang_findIncludesInFileWithBlock(CXTranslationUnit, CXFile, 5730249423Sdim CXCursorAndRangeVisitorBlock); 5731249423Sdim 5732226633Sdim# endif 5733226633Sdim#endif 5734226633Sdim 5735226633Sdim/** 5736234353Sdim * \brief The client's data object that is associated with a CXFile. 5737234353Sdim */ 5738234353Sdimtypedef void *CXIdxClientFile; 5739234353Sdim 5740234353Sdim/** 5741234353Sdim * \brief The client's data object that is associated with a semantic entity. 5742234353Sdim */ 5743234353Sdimtypedef void *CXIdxClientEntity; 5744234353Sdim 5745234353Sdim/** 5746234353Sdim * \brief The client's data object that is associated with a semantic container 5747234353Sdim * of entities. 5748234353Sdim */ 5749234353Sdimtypedef void *CXIdxClientContainer; 5750234353Sdim 5751234353Sdim/** 5752234353Sdim * \brief The client's data object that is associated with an AST file (PCH 5753234353Sdim * or module). 5754234353Sdim */ 5755234353Sdimtypedef void *CXIdxClientASTFile; 5756234353Sdim 5757234353Sdim/** 5758234353Sdim * \brief Source location passed to index callbacks. 5759234353Sdim */ 5760234353Sdimtypedef struct { 5761234353Sdim void *ptr_data[2]; 5762234353Sdim unsigned int_data; 5763234353Sdim} CXIdxLoc; 5764234353Sdim 5765234353Sdim/** 5766239462Sdim * \brief Data for ppIncludedFile callback. 5767234353Sdim */ 5768234353Sdimtypedef struct { 5769234353Sdim /** 5770239462Sdim * \brief Location of '#' in the \#include/\#import directive. 5771234353Sdim */ 5772234353Sdim CXIdxLoc hashLoc; 5773234353Sdim /** 5774239462Sdim * \brief Filename as written in the \#include/\#import directive. 5775234353Sdim */ 5776234353Sdim const char *filename; 5777234353Sdim /** 5778239462Sdim * \brief The actual file that the \#include/\#import directive resolved to. 5779234353Sdim */ 5780234353Sdim CXFile file; 5781234353Sdim int isImport; 5782234353Sdim int isAngled; 5783243830Sdim /** 5784243830Sdim * \brief Non-zero if the directive was automatically turned into a module 5785243830Sdim * import. 5786243830Sdim */ 5787243830Sdim int isModuleImport; 5788234353Sdim} CXIdxIncludedFileInfo; 5789234353Sdim 5790234353Sdim/** 5791239462Sdim * \brief Data for IndexerCallbacks#importedASTFile. 5792234353Sdim */ 5793234353Sdimtypedef struct { 5794243830Sdim /** 5795243830Sdim * \brief Top level AST file containing the imported PCH, module or submodule. 5796243830Sdim */ 5797234353Sdim CXFile file; 5798234353Sdim /** 5799243830Sdim * \brief The imported module or NULL if the AST file is a PCH. 5800234353Sdim */ 5801243830Sdim CXModule module; 5802243830Sdim /** 5803243830Sdim * \brief Location where the file is imported. Applicable only for modules. 5804243830Sdim */ 5805234353Sdim CXIdxLoc loc; 5806234353Sdim /** 5807243830Sdim * \brief Non-zero if an inclusion directive was automatically turned into 5808243830Sdim * a module import. Applicable only for modules. 5809234353Sdim */ 5810243830Sdim int isImplicit; 5811243830Sdim 5812234353Sdim} CXIdxImportedASTFileInfo; 5813234353Sdim 5814234353Sdimtypedef enum { 5815234353Sdim CXIdxEntity_Unexposed = 0, 5816234353Sdim CXIdxEntity_Typedef = 1, 5817234353Sdim CXIdxEntity_Function = 2, 5818234353Sdim CXIdxEntity_Variable = 3, 5819234353Sdim CXIdxEntity_Field = 4, 5820234353Sdim CXIdxEntity_EnumConstant = 5, 5821234353Sdim 5822234353Sdim CXIdxEntity_ObjCClass = 6, 5823234353Sdim CXIdxEntity_ObjCProtocol = 7, 5824234353Sdim CXIdxEntity_ObjCCategory = 8, 5825234353Sdim 5826234353Sdim CXIdxEntity_ObjCInstanceMethod = 9, 5827234353Sdim CXIdxEntity_ObjCClassMethod = 10, 5828234353Sdim CXIdxEntity_ObjCProperty = 11, 5829234353Sdim CXIdxEntity_ObjCIvar = 12, 5830234353Sdim 5831234353Sdim CXIdxEntity_Enum = 13, 5832234353Sdim CXIdxEntity_Struct = 14, 5833234353Sdim CXIdxEntity_Union = 15, 5834234353Sdim 5835234353Sdim CXIdxEntity_CXXClass = 16, 5836234353Sdim CXIdxEntity_CXXNamespace = 17, 5837234353Sdim CXIdxEntity_CXXNamespaceAlias = 18, 5838234353Sdim CXIdxEntity_CXXStaticVariable = 19, 5839234353Sdim CXIdxEntity_CXXStaticMethod = 20, 5840234353Sdim CXIdxEntity_CXXInstanceMethod = 21, 5841234353Sdim CXIdxEntity_CXXConstructor = 22, 5842234353Sdim CXIdxEntity_CXXDestructor = 23, 5843234353Sdim CXIdxEntity_CXXConversionFunction = 24, 5844243830Sdim CXIdxEntity_CXXTypeAlias = 25, 5845243830Sdim CXIdxEntity_CXXInterface = 26 5846234353Sdim 5847234353Sdim} CXIdxEntityKind; 5848234353Sdim 5849234353Sdimtypedef enum { 5850234353Sdim CXIdxEntityLang_None = 0, 5851234353Sdim CXIdxEntityLang_C = 1, 5852234353Sdim CXIdxEntityLang_ObjC = 2, 5853321369Sdim CXIdxEntityLang_CXX = 3, 5854321369Sdim CXIdxEntityLang_Swift = 4 5855234353Sdim} CXIdxEntityLanguage; 5856234353Sdim 5857234353Sdim/** 5858234353Sdim * \brief Extra C++ template information for an entity. This can apply to: 5859234353Sdim * CXIdxEntity_Function 5860234353Sdim * CXIdxEntity_CXXClass 5861234353Sdim * CXIdxEntity_CXXStaticMethod 5862234353Sdim * CXIdxEntity_CXXInstanceMethod 5863234353Sdim * CXIdxEntity_CXXConstructor 5864234353Sdim * CXIdxEntity_CXXConversionFunction 5865234353Sdim * CXIdxEntity_CXXTypeAlias 5866234353Sdim */ 5867234353Sdimtypedef enum { 5868234353Sdim CXIdxEntity_NonTemplate = 0, 5869234353Sdim CXIdxEntity_Template = 1, 5870234353Sdim CXIdxEntity_TemplatePartialSpecialization = 2, 5871234353Sdim CXIdxEntity_TemplateSpecialization = 3 5872234353Sdim} CXIdxEntityCXXTemplateKind; 5873234353Sdim 5874234353Sdimtypedef enum { 5875234353Sdim CXIdxAttr_Unexposed = 0, 5876234353Sdim CXIdxAttr_IBAction = 1, 5877234353Sdim CXIdxAttr_IBOutlet = 2, 5878234353Sdim CXIdxAttr_IBOutletCollection = 3 5879234353Sdim} CXIdxAttrKind; 5880234353Sdim 5881234353Sdimtypedef struct { 5882234353Sdim CXIdxAttrKind kind; 5883234353Sdim CXCursor cursor; 5884234353Sdim CXIdxLoc loc; 5885234353Sdim} CXIdxAttrInfo; 5886234353Sdim 5887234353Sdimtypedef struct { 5888234353Sdim CXIdxEntityKind kind; 5889234353Sdim CXIdxEntityCXXTemplateKind templateKind; 5890234353Sdim CXIdxEntityLanguage lang; 5891234353Sdim const char *name; 5892234353Sdim const char *USR; 5893234353Sdim CXCursor cursor; 5894234353Sdim const CXIdxAttrInfo *const *attributes; 5895234353Sdim unsigned numAttributes; 5896234353Sdim} CXIdxEntityInfo; 5897234353Sdim 5898234353Sdimtypedef struct { 5899234353Sdim CXCursor cursor; 5900234353Sdim} CXIdxContainerInfo; 5901234353Sdim 5902234353Sdimtypedef struct { 5903234353Sdim const CXIdxAttrInfo *attrInfo; 5904234353Sdim const CXIdxEntityInfo *objcClass; 5905234353Sdim CXCursor classCursor; 5906234353Sdim CXIdxLoc classLoc; 5907234353Sdim} CXIdxIBOutletCollectionAttrInfo; 5908234353Sdim 5909249423Sdimtypedef enum { 5910249423Sdim CXIdxDeclFlag_Skipped = 0x1 5911249423Sdim} CXIdxDeclInfoFlags; 5912249423Sdim 5913234353Sdimtypedef struct { 5914234353Sdim const CXIdxEntityInfo *entityInfo; 5915234353Sdim CXCursor cursor; 5916234353Sdim CXIdxLoc loc; 5917234353Sdim const CXIdxContainerInfo *semanticContainer; 5918234353Sdim /** 5919239462Sdim * \brief Generally same as #semanticContainer but can be different in 5920234353Sdim * cases like out-of-line C++ member functions. 5921234353Sdim */ 5922234353Sdim const CXIdxContainerInfo *lexicalContainer; 5923234353Sdim int isRedeclaration; 5924234353Sdim int isDefinition; 5925234353Sdim int isContainer; 5926234353Sdim const CXIdxContainerInfo *declAsContainer; 5927234353Sdim /** 5928234353Sdim * \brief Whether the declaration exists in code or was created implicitly 5929276479Sdim * by the compiler, e.g. implicit Objective-C methods for properties. 5930234353Sdim */ 5931234353Sdim int isImplicit; 5932234353Sdim const CXIdxAttrInfo *const *attributes; 5933234353Sdim unsigned numAttributes; 5934249423Sdim 5935249423Sdim unsigned flags; 5936249423Sdim 5937234353Sdim} CXIdxDeclInfo; 5938234353Sdim 5939234353Sdimtypedef enum { 5940234353Sdim CXIdxObjCContainer_ForwardRef = 0, 5941234353Sdim CXIdxObjCContainer_Interface = 1, 5942234353Sdim CXIdxObjCContainer_Implementation = 2 5943234353Sdim} CXIdxObjCContainerKind; 5944234353Sdim 5945234353Sdimtypedef struct { 5946234353Sdim const CXIdxDeclInfo *declInfo; 5947234353Sdim CXIdxObjCContainerKind kind; 5948234353Sdim} CXIdxObjCContainerDeclInfo; 5949234353Sdim 5950234353Sdimtypedef struct { 5951234353Sdim const CXIdxEntityInfo *base; 5952234353Sdim CXCursor cursor; 5953234353Sdim CXIdxLoc loc; 5954234353Sdim} CXIdxBaseClassInfo; 5955234353Sdim 5956234353Sdimtypedef struct { 5957234353Sdim const CXIdxEntityInfo *protocol; 5958234353Sdim CXCursor cursor; 5959234353Sdim CXIdxLoc loc; 5960234353Sdim} CXIdxObjCProtocolRefInfo; 5961234353Sdim 5962234353Sdimtypedef struct { 5963234353Sdim const CXIdxObjCProtocolRefInfo *const *protocols; 5964234353Sdim unsigned numProtocols; 5965234353Sdim} CXIdxObjCProtocolRefListInfo; 5966234353Sdim 5967234353Sdimtypedef struct { 5968234353Sdim const CXIdxObjCContainerDeclInfo *containerInfo; 5969234353Sdim const CXIdxBaseClassInfo *superInfo; 5970234353Sdim const CXIdxObjCProtocolRefListInfo *protocols; 5971234353Sdim} CXIdxObjCInterfaceDeclInfo; 5972234353Sdim 5973234353Sdimtypedef struct { 5974234353Sdim const CXIdxObjCContainerDeclInfo *containerInfo; 5975234353Sdim const CXIdxEntityInfo *objcClass; 5976234353Sdim CXCursor classCursor; 5977234353Sdim CXIdxLoc classLoc; 5978234353Sdim const CXIdxObjCProtocolRefListInfo *protocols; 5979234353Sdim} CXIdxObjCCategoryDeclInfo; 5980234353Sdim 5981234353Sdimtypedef struct { 5982234353Sdim const CXIdxDeclInfo *declInfo; 5983234353Sdim const CXIdxEntityInfo *getter; 5984234353Sdim const CXIdxEntityInfo *setter; 5985234353Sdim} CXIdxObjCPropertyDeclInfo; 5986234353Sdim 5987234353Sdimtypedef struct { 5988234353Sdim const CXIdxDeclInfo *declInfo; 5989234353Sdim const CXIdxBaseClassInfo *const *bases; 5990234353Sdim unsigned numBases; 5991234353Sdim} CXIdxCXXClassDeclInfo; 5992234353Sdim 5993234353Sdim/** 5994239462Sdim * \brief Data for IndexerCallbacks#indexEntityReference. 5995234353Sdim */ 5996234353Sdimtypedef enum { 5997234353Sdim /** 5998234353Sdim * \brief The entity is referenced directly in user's code. 5999234353Sdim */ 6000234353Sdim CXIdxEntityRef_Direct = 1, 6001234353Sdim /** 6002276479Sdim * \brief An implicit reference, e.g. a reference of an Objective-C method 6003276479Sdim * via the dot syntax. 6004234353Sdim */ 6005234353Sdim CXIdxEntityRef_Implicit = 2 6006234353Sdim} CXIdxEntityRefKind; 6007234353Sdim 6008234353Sdim/** 6009239462Sdim * \brief Data for IndexerCallbacks#indexEntityReference. 6010234353Sdim */ 6011234353Sdimtypedef struct { 6012234353Sdim CXIdxEntityRefKind kind; 6013234353Sdim /** 6014234353Sdim * \brief Reference cursor. 6015234353Sdim */ 6016234353Sdim CXCursor cursor; 6017234353Sdim CXIdxLoc loc; 6018234353Sdim /** 6019234353Sdim * \brief The entity that gets referenced. 6020234353Sdim */ 6021234353Sdim const CXIdxEntityInfo *referencedEntity; 6022234353Sdim /** 6023234353Sdim * \brief Immediate "parent" of the reference. For example: 6024234353Sdim * 6025234353Sdim * \code 6026234353Sdim * Foo *var; 6027234353Sdim * \endcode 6028234353Sdim * 6029234353Sdim * The parent of reference of type 'Foo' is the variable 'var'. 6030234353Sdim * For references inside statement bodies of functions/methods, 6031234353Sdim * the parentEntity will be the function/method. 6032234353Sdim */ 6033234353Sdim const CXIdxEntityInfo *parentEntity; 6034234353Sdim /** 6035234353Sdim * \brief Lexical container context of the reference. 6036234353Sdim */ 6037234353Sdim const CXIdxContainerInfo *container; 6038234353Sdim} CXIdxEntityRefInfo; 6039234353Sdim 6040239462Sdim/** 6041239462Sdim * \brief A group of callbacks used by #clang_indexSourceFile and 6042239462Sdim * #clang_indexTranslationUnit. 6043239462Sdim */ 6044234353Sdimtypedef struct { 6045234353Sdim /** 6046234353Sdim * \brief Called periodically to check whether indexing should be aborted. 6047234353Sdim * Should return 0 to continue, and non-zero to abort. 6048234353Sdim */ 6049234353Sdim int (*abortQuery)(CXClientData client_data, void *reserved); 6050234353Sdim 6051234353Sdim /** 6052234353Sdim * \brief Called at the end of indexing; passes the complete diagnostic set. 6053234353Sdim */ 6054234353Sdim void (*diagnostic)(CXClientData client_data, 6055234353Sdim CXDiagnosticSet, void *reserved); 6056234353Sdim 6057234353Sdim CXIdxClientFile (*enteredMainFile)(CXClientData client_data, 6058239462Sdim CXFile mainFile, void *reserved); 6059234353Sdim 6060234353Sdim /** 6061239462Sdim * \brief Called when a file gets \#included/\#imported. 6062234353Sdim */ 6063234353Sdim CXIdxClientFile (*ppIncludedFile)(CXClientData client_data, 6064234353Sdim const CXIdxIncludedFileInfo *); 6065234353Sdim 6066234353Sdim /** 6067234353Sdim * \brief Called when a AST file (PCH or module) gets imported. 6068234353Sdim * 6069234353Sdim * AST files will not get indexed (there will not be callbacks to index all 6070234353Sdim * the entities in an AST file). The recommended action is that, if the AST 6071243830Sdim * file is not already indexed, to initiate a new indexing job specific to 6072243830Sdim * the AST file. 6073234353Sdim */ 6074234353Sdim CXIdxClientASTFile (*importedASTFile)(CXClientData client_data, 6075234353Sdim const CXIdxImportedASTFileInfo *); 6076234353Sdim 6077234353Sdim /** 6078234353Sdim * \brief Called at the beginning of indexing a translation unit. 6079234353Sdim */ 6080234353Sdim CXIdxClientContainer (*startedTranslationUnit)(CXClientData client_data, 6081234353Sdim void *reserved); 6082234353Sdim 6083234353Sdim void (*indexDeclaration)(CXClientData client_data, 6084234353Sdim const CXIdxDeclInfo *); 6085234353Sdim 6086234353Sdim /** 6087234353Sdim * \brief Called to index a reference of an entity. 6088234353Sdim */ 6089234353Sdim void (*indexEntityReference)(CXClientData client_data, 6090234353Sdim const CXIdxEntityRefInfo *); 6091234353Sdim 6092234353Sdim} IndexerCallbacks; 6093234353Sdim 6094234353SdimCINDEX_LINKAGE int clang_index_isEntityObjCContainerKind(CXIdxEntityKind); 6095234353SdimCINDEX_LINKAGE const CXIdxObjCContainerDeclInfo * 6096234353Sdimclang_index_getObjCContainerDeclInfo(const CXIdxDeclInfo *); 6097234353Sdim 6098234353SdimCINDEX_LINKAGE const CXIdxObjCInterfaceDeclInfo * 6099234353Sdimclang_index_getObjCInterfaceDeclInfo(const CXIdxDeclInfo *); 6100234353Sdim 6101234353SdimCINDEX_LINKAGE 6102234353Sdimconst CXIdxObjCCategoryDeclInfo * 6103234353Sdimclang_index_getObjCCategoryDeclInfo(const CXIdxDeclInfo *); 6104234353Sdim 6105234353SdimCINDEX_LINKAGE const CXIdxObjCProtocolRefListInfo * 6106234353Sdimclang_index_getObjCProtocolRefListInfo(const CXIdxDeclInfo *); 6107234353Sdim 6108234353SdimCINDEX_LINKAGE const CXIdxObjCPropertyDeclInfo * 6109234353Sdimclang_index_getObjCPropertyDeclInfo(const CXIdxDeclInfo *); 6110234353Sdim 6111234353SdimCINDEX_LINKAGE const CXIdxIBOutletCollectionAttrInfo * 6112234353Sdimclang_index_getIBOutletCollectionAttrInfo(const CXIdxAttrInfo *); 6113234353Sdim 6114234353SdimCINDEX_LINKAGE const CXIdxCXXClassDeclInfo * 6115234353Sdimclang_index_getCXXClassDeclInfo(const CXIdxDeclInfo *); 6116234353Sdim 6117234353Sdim/** 6118234353Sdim * \brief For retrieving a custom CXIdxClientContainer attached to a 6119234353Sdim * container. 6120234353Sdim */ 6121234353SdimCINDEX_LINKAGE CXIdxClientContainer 6122234353Sdimclang_index_getClientContainer(const CXIdxContainerInfo *); 6123234353Sdim 6124234353Sdim/** 6125234353Sdim * \brief For setting a custom CXIdxClientContainer attached to a 6126234353Sdim * container. 6127234353Sdim */ 6128234353SdimCINDEX_LINKAGE void 6129234353Sdimclang_index_setClientContainer(const CXIdxContainerInfo *,CXIdxClientContainer); 6130234353Sdim 6131234353Sdim/** 6132234353Sdim * \brief For retrieving a custom CXIdxClientEntity attached to an entity. 6133234353Sdim */ 6134234353SdimCINDEX_LINKAGE CXIdxClientEntity 6135234353Sdimclang_index_getClientEntity(const CXIdxEntityInfo *); 6136234353Sdim 6137234353Sdim/** 6138234353Sdim * \brief For setting a custom CXIdxClientEntity attached to an entity. 6139234353Sdim */ 6140234353SdimCINDEX_LINKAGE void 6141234353Sdimclang_index_setClientEntity(const CXIdxEntityInfo *, CXIdxClientEntity); 6142234353Sdim 6143234353Sdim/** 6144249423Sdim * \brief An indexing action/session, to be applied to one or multiple 6145249423Sdim * translation units. 6146234353Sdim */ 6147234353Sdimtypedef void *CXIndexAction; 6148234353Sdim 6149234353Sdim/** 6150249423Sdim * \brief An indexing action/session, to be applied to one or multiple 6151249423Sdim * translation units. 6152234353Sdim * 6153234353Sdim * \param CIdx The index object with which the index action will be associated. 6154234353Sdim */ 6155234353SdimCINDEX_LINKAGE CXIndexAction clang_IndexAction_create(CXIndex CIdx); 6156234353Sdim 6157234353Sdim/** 6158234353Sdim * \brief Destroy the given index action. 6159234353Sdim * 6160234353Sdim * The index action must not be destroyed until all of the translation units 6161234353Sdim * created within that index action have been destroyed. 6162234353Sdim */ 6163234353SdimCINDEX_LINKAGE void clang_IndexAction_dispose(CXIndexAction); 6164234353Sdim 6165234353Sdimtypedef enum { 6166234353Sdim /** 6167234353Sdim * \brief Used to indicate that no special indexing options are needed. 6168234353Sdim */ 6169234353Sdim CXIndexOpt_None = 0x0, 6170234353Sdim 6171234353Sdim /** 6172239462Sdim * \brief Used to indicate that IndexerCallbacks#indexEntityReference should 6173239462Sdim * be invoked for only one reference of an entity per source file that does 6174239462Sdim * not also include a declaration/definition of the entity. 6175234353Sdim */ 6176234353Sdim CXIndexOpt_SuppressRedundantRefs = 0x1, 6177234353Sdim 6178234353Sdim /** 6179234353Sdim * \brief Function-local symbols should be indexed. If this is not set 6180234353Sdim * function-local symbols will be ignored. 6181234353Sdim */ 6182234353Sdim CXIndexOpt_IndexFunctionLocalSymbols = 0x2, 6183234353Sdim 6184234353Sdim /** 6185234353Sdim * \brief Implicit function/class template instantiations should be indexed. 6186234353Sdim * If this is not set, implicit instantiations will be ignored. 6187234353Sdim */ 6188234353Sdim CXIndexOpt_IndexImplicitTemplateInstantiations = 0x4, 6189234353Sdim 6190234353Sdim /** 6191234353Sdim * \brief Suppress all compiler warnings when parsing for indexing. 6192234353Sdim */ 6193249423Sdim CXIndexOpt_SuppressWarnings = 0x8, 6194249423Sdim 6195249423Sdim /** 6196249423Sdim * \brief Skip a function/method body that was already parsed during an 6197276479Sdim * indexing session associated with a \c CXIndexAction object. 6198249423Sdim * Bodies in system headers are always skipped. 6199249423Sdim */ 6200249423Sdim CXIndexOpt_SkipParsedBodiesInSession = 0x10 6201249423Sdim 6202234353Sdim} CXIndexOptFlags; 6203234353Sdim 6204234353Sdim/** 6205234353Sdim * \brief Index the given source file and the translation unit corresponding 6206239462Sdim * to that file via callbacks implemented through #IndexerCallbacks. 6207234353Sdim * 6208234353Sdim * \param client_data pointer data supplied by the client, which will 6209234353Sdim * be passed to the invoked callbacks. 6210234353Sdim * 6211234353Sdim * \param index_callbacks Pointer to indexing callbacks that the client 6212234353Sdim * implements. 6213234353Sdim * 6214239462Sdim * \param index_callbacks_size Size of #IndexerCallbacks structure that gets 6215234353Sdim * passed in index_callbacks. 6216234353Sdim * 6217234353Sdim * \param index_options A bitmask of options that affects how indexing is 6218234353Sdim * performed. This should be a bitwise OR of the CXIndexOpt_XXX flags. 6219234353Sdim * 6220276479Sdim * \param[out] out_TU pointer to store a \c CXTranslationUnit that can be 6221276479Sdim * reused after indexing is finished. Set to \c NULL if you do not require it. 6222234353Sdim * 6223276479Sdim * \returns 0 on success or if there were errors from which the compiler could 6224288943Sdim * recover. If there is a failure from which there is no recovery, returns 6225276479Sdim * a non-zero \c CXErrorCode. 6226234353Sdim * 6227239462Sdim * The rest of the parameters are the same as #clang_parseTranslationUnit. 6228234353Sdim */ 6229234353SdimCINDEX_LINKAGE int clang_indexSourceFile(CXIndexAction, 6230234353Sdim CXClientData client_data, 6231234353Sdim IndexerCallbacks *index_callbacks, 6232234353Sdim unsigned index_callbacks_size, 6233234353Sdim unsigned index_options, 6234234353Sdim const char *source_filename, 6235234353Sdim const char * const *command_line_args, 6236234353Sdim int num_command_line_args, 6237234353Sdim struct CXUnsavedFile *unsaved_files, 6238234353Sdim unsigned num_unsaved_files, 6239234353Sdim CXTranslationUnit *out_TU, 6240234353Sdim unsigned TU_options); 6241234353Sdim 6242234353Sdim/** 6243296417Sdim * \brief Same as clang_indexSourceFile but requires a full command line 6244296417Sdim * for \c command_line_args including argv[0]. This is useful if the standard 6245296417Sdim * library paths are relative to the binary. 6246296417Sdim */ 6247296417SdimCINDEX_LINKAGE int clang_indexSourceFileFullArgv( 6248296417Sdim CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks, 6249296417Sdim unsigned index_callbacks_size, unsigned index_options, 6250296417Sdim const char *source_filename, const char *const *command_line_args, 6251296417Sdim int num_command_line_args, struct CXUnsavedFile *unsaved_files, 6252296417Sdim unsigned num_unsaved_files, CXTranslationUnit *out_TU, unsigned TU_options); 6253296417Sdim 6254296417Sdim/** 6255234353Sdim * \brief Index the given translation unit via callbacks implemented through 6256239462Sdim * #IndexerCallbacks. 6257234353Sdim * 6258234353Sdim * The order of callback invocations is not guaranteed to be the same as 6259234353Sdim * when indexing a source file. The high level order will be: 6260234353Sdim * 6261234353Sdim * -Preprocessor callbacks invocations 6262234353Sdim * -Declaration/reference callbacks invocations 6263234353Sdim * -Diagnostic callback invocations 6264234353Sdim * 6265239462Sdim * The parameters are the same as #clang_indexSourceFile. 6266234353Sdim * 6267288943Sdim * \returns If there is a failure from which there is no recovery, returns 6268234353Sdim * non-zero, otherwise returns 0. 6269234353Sdim */ 6270234353SdimCINDEX_LINKAGE int clang_indexTranslationUnit(CXIndexAction, 6271234353Sdim CXClientData client_data, 6272234353Sdim IndexerCallbacks *index_callbacks, 6273234353Sdim unsigned index_callbacks_size, 6274234353Sdim unsigned index_options, 6275234353Sdim CXTranslationUnit); 6276234353Sdim 6277234353Sdim/** 6278234353Sdim * \brief Retrieve the CXIdxFile, file, line, column, and offset represented by 6279234353Sdim * the given CXIdxLoc. 6280234353Sdim * 6281234353Sdim * If the location refers into a macro expansion, retrieves the 6282234353Sdim * location of the macro expansion and if it refers into a macro argument 6283234353Sdim * retrieves the location of the argument. 6284234353Sdim */ 6285234353SdimCINDEX_LINKAGE void clang_indexLoc_getFileLocation(CXIdxLoc loc, 6286234353Sdim CXIdxClientFile *indexFile, 6287234353Sdim CXFile *file, 6288234353Sdim unsigned *line, 6289234353Sdim unsigned *column, 6290234353Sdim unsigned *offset); 6291234353Sdim 6292234353Sdim/** 6293234353Sdim * \brief Retrieve the CXSourceLocation represented by the given CXIdxLoc. 6294234353Sdim */ 6295234353SdimCINDEX_LINKAGE 6296234353SdimCXSourceLocation clang_indexLoc_getCXSourceLocation(CXIdxLoc loc); 6297234353Sdim 6298234353Sdim/** 6299288943Sdim * \brief Visitor invoked for each field found by a traversal. 6300288943Sdim * 6301288943Sdim * This visitor function will be invoked for each field found by 6302288943Sdim * \c clang_Type_visitFields. Its first argument is the cursor being 6303288943Sdim * visited, its second argument is the client data provided to 6304288943Sdim * \c clang_Type_visitFields. 6305288943Sdim * 6306288943Sdim * The visitor should return one of the \c CXVisitorResult values 6307288943Sdim * to direct \c clang_Type_visitFields. 6308288943Sdim */ 6309288943Sdimtypedef enum CXVisitorResult (*CXFieldVisitor)(CXCursor C, 6310288943Sdim CXClientData client_data); 6311288943Sdim 6312288943Sdim/** 6313288943Sdim * \brief Visit the fields of a particular type. 6314288943Sdim * 6315288943Sdim * This function visits all the direct fields of the given cursor, 6316288943Sdim * invoking the given \p visitor function with the cursors of each 6317288943Sdim * visited field. The traversal may be ended prematurely, if 6318288943Sdim * the visitor returns \c CXFieldVisit_Break. 6319288943Sdim * 6320288943Sdim * \param T the record type whose field may be visited. 6321288943Sdim * 6322288943Sdim * \param visitor the visitor function that will be invoked for each 6323288943Sdim * field of \p T. 6324288943Sdim * 6325288943Sdim * \param client_data pointer data supplied by the client, which will 6326288943Sdim * be passed to the visitor each time it is invoked. 6327288943Sdim * 6328288943Sdim * \returns a non-zero value if the traversal was terminated 6329288943Sdim * prematurely by the visitor returning \c CXFieldVisit_Break. 6330288943Sdim */ 6331288943SdimCINDEX_LINKAGE unsigned clang_Type_visitFields(CXType T, 6332288943Sdim CXFieldVisitor visitor, 6333288943Sdim CXClientData client_data); 6334288943Sdim 6335288943Sdim/** 6336224145Sdim * @} 6337224145Sdim */ 6338224145Sdim 6339226633Sdim/** 6340226633Sdim * @} 6341226633Sdim */ 6342226633Sdim 6343198092Srdivacky#ifdef __cplusplus 6344198092Srdivacky} 6345198092Srdivacky#endif 6346198092Srdivacky#endif 6347