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