Index.h revision a2a9d6e4e5b6001b86b7dfc5db1ea296ce29a3d3
1d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek/*===-- clang-c/Index.h - Indexing Public C Interface -------------*- C -*-===*\ 2d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek|* *| 3d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek|* The LLVM Compiler Infrastructure *| 4d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek|* *| 5d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek|* This file is distributed under the University of Illinois Open Source *| 6d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek|* License. See LICENSE.TXT for details. *| 7d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek|* *| 8d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek|*===----------------------------------------------------------------------===*| 9d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek|* *| 10d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek|* This header provides a public inferface to a Clang library for extracting *| 11d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek|* high-level symbol information from source files without exposing the full *| 12d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek|* Clang C++ API. *| 13d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek|* *| 14d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek\*===----------------------------------------------------------------------===*/ 15d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek 16d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek#ifndef CLANG_C_INDEX_H 17d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek#define CLANG_C_INDEX_H 18d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek 1988145034694ed5267fa6fa5febc54fadc02bd479Steve Naroff#include <sys/stat.h> 203d31560343856c573376a04558a7111e7afad4f7Chandler Carruth#include <time.h> 2188145034694ed5267fa6fa5febc54fadc02bd479Steve Naroff 22d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek#ifdef __cplusplus 23d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenekextern "C" { 24d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek#endif 25d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek 2688145034694ed5267fa6fa5febc54fadc02bd479Steve Naroff/* MSVC DLL import/export. */ 272e06fc877a633abea3b40a64950c7316dac29ca8John Thompson#ifdef _MSC_VER 282e06fc877a633abea3b40a64950c7316dac29ca8John Thompson #ifdef _CINDEX_LIB_ 292e06fc877a633abea3b40a64950c7316dac29ca8John Thompson #define CINDEX_LINKAGE __declspec(dllexport) 302e06fc877a633abea3b40a64950c7316dac29ca8John Thompson #else 312e06fc877a633abea3b40a64950c7316dac29ca8John Thompson #define CINDEX_LINKAGE __declspec(dllimport) 322e06fc877a633abea3b40a64950c7316dac29ca8John Thompson #endif 332e06fc877a633abea3b40a64950c7316dac29ca8John Thompson#else 342e06fc877a633abea3b40a64950c7316dac29ca8John Thompson #define CINDEX_LINKAGE 352e06fc877a633abea3b40a64950c7316dac29ca8John Thompson#endif 362e06fc877a633abea3b40a64950c7316dac29ca8John Thompson 3720d416c36b46dd19ee0b1ea2d0266ae43be86e51Douglas Gregor/** \defgroup CINDEX C Interface to Clang 3820d416c36b46dd19ee0b1ea2d0266ae43be86e51Douglas Gregor * 391efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * The C Interface to Clang provides a relatively small API that exposes 40f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * facilities for parsing source code into an abstract syntax tree (AST), 41f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * loading already-parsed ASTs, traversing the AST, associating 42f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * physical source locations with elements within the AST, and other 43f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * facilities that support Clang-based development tools. 44f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * 451efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * This C interface to Clang will never provide all of the information 46f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * representation stored in Clang's C++ AST, nor should it: the intent is to 47f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * maintain an API that is relatively stable from one release to the next, 48f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * providing only the basic functionality needed to support development tools. 491efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * 501efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * To avoid namespace pollution, data types are prefixed with "CX" and 51f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * functions are prefixed with "clang_". 5220d416c36b46dd19ee0b1ea2d0266ae43be86e51Douglas Gregor * 5320d416c36b46dd19ee0b1ea2d0266ae43be86e51Douglas Gregor * @{ 5420d416c36b46dd19ee0b1ea2d0266ae43be86e51Douglas Gregor */ 551efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 567f17376e0931a337d544b75d9030bc92763be287Douglas Gregor/** 577f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * \brief An "index" that consists of a set of translation units that would 587f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * typically be linked together into an executable or library. 597f17376e0931a337d544b75d9030bc92763be287Douglas Gregor */ 607f17376e0931a337d544b75d9030bc92763be287Douglas Gregortypedef void *CXIndex; 61600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff 627f17376e0931a337d544b75d9030bc92763be287Douglas Gregor/** 637f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * \brief A single translation unit, which resides in an index. 647f17376e0931a337d544b75d9030bc92763be287Douglas Gregor */ 6550398199fb10e196a8d92fbf7a062dbe42ed88fdSteve Narofftypedef void *CXTranslationUnit; /* A translation unit instance. */ 66600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff 677f17376e0931a337d544b75d9030bc92763be287Douglas Gregor/** 68c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Opaque pointer representing client data that will be passed through 69c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * to various callbacks and visitors. 707f17376e0931a337d544b75d9030bc92763be287Douglas Gregor */ 71c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregortypedef void *CXClientData; 721efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 73735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor/** 74735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor * \brief Provides the contents of a file that has not yet been saved to disk. 75735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor * 76735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor * Each CXUnsavedFile instance provides the name of a file on the 77735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor * system along with the current contents of that file that have not 78735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor * yet been saved to disk. 79735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor */ 80735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregorstruct CXUnsavedFile { 811efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar /** 821efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \brief The file whose contents have not yet been saved. 83735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor * 84735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor * This file must already exist in the file system. 85735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor */ 86735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor const char *Filename; 87735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor 881efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar /** 89735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor * \brief A null-terminated buffer containing the unsaved contents 90735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor * of this file. 91735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor */ 92735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor const char *Contents; 93735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor 94735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor /** 95735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor * \brief The length of the unsaved contents of this buffer, not 96735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor * counting the NULL at the end of the buffer. 97735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor */ 98735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor unsigned long Length; 99735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor}; 100735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor 1017f17376e0931a337d544b75d9030bc92763be287Douglas Gregor/** 1027f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * \defgroup CINDEX_STRING String manipulation routines 1037f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * 1047f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * @{ 1057f17376e0931a337d544b75d9030bc92763be287Douglas Gregor */ 1061efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 1077f17376e0931a337d544b75d9030bc92763be287Douglas Gregor/** 1087f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * \brief A character string. 1097f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * 1107f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * The \c CXString type is used to return strings from the interface when 1117f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * the ownership of that string might different from one call to the next. 1127f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * Use \c clang_getCString() to retrieve the string data and, once finished 1137f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * with the string data, call \c clang_disposeString() to free the string. 114ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff */ 115ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Narofftypedef struct { 116ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff const char *Spelling; 117ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff /* A 1 value indicates the clang_ indexing API needed to allocate the string 118ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff (and it must be freed by clang_disposeString()). */ 119ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff int MustFreeString; 120ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff} CXString; 121ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff 1227f17376e0931a337d544b75d9030bc92763be287Douglas Gregor/** 1237f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * \brief Retrieve the character data associated with the given string. 1247f17376e0931a337d544b75d9030bc92763be287Douglas Gregor */ 125ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve NaroffCINDEX_LINKAGE const char *clang_getCString(CXString string); 126ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff 1277f17376e0931a337d544b75d9030bc92763be287Douglas Gregor/** 1287f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * \brief Free the given string, 1297f17376e0931a337d544b75d9030bc92763be287Douglas Gregor */ 130ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve NaroffCINDEX_LINKAGE void clang_disposeString(CXString string); 131ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff 1327f17376e0931a337d544b75d9030bc92763be287Douglas Gregor/** 1337f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * @} 1347f17376e0931a337d544b75d9030bc92763be287Douglas Gregor */ 1351efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 1361efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar/** 137e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * \brief clang_createIndex() provides a shared context for creating 138e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * translation units. It provides two options: 139e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * 140e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local" 141e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * declarations (when loading any new translation units). A "local" declaration 1421efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * is one that belongs in the translation unit itself and not in a precompiled 143e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * header that was used by the translation unit. If zero, all declarations 144e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * will be enumerated. 145e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * 146b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * Here is an example: 147b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * 148936ea3b590117d2cd73b1b92621d06c4a7edbe60Douglas Gregor * // excludeDeclsFromPCH = 1 149936ea3b590117d2cd73b1b92621d06c4a7edbe60Douglas Gregor * Idx = clang_createIndex(1); 150b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * 151b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * // IndexTest.pch was produced with the following command: 152b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch" 153b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * TU = clang_createTranslationUnit(Idx, "IndexTest.pch"); 154b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * 155b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * // This will load all the symbols from 'IndexTest.pch' 1561efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * clang_visitChildren(clang_getTranslationUnitCursor(TU), 157002a528ab0189fc60cfbf9328962c96ccbe567eeDouglas Gregor * TranslationUnitVisitor, 0); 158b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * clang_disposeTranslationUnit(TU); 159b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * 160b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * // This will load all the symbols from 'IndexTest.c', excluding symbols 161b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * // from 'IndexTest.pch'. 162fd9f23464bfd35314c87c4df410f3937d59eb96dDaniel Dunbar * char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" }; 163fd9f23464bfd35314c87c4df410f3937d59eb96dDaniel Dunbar * TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args, 164fd9f23464bfd35314c87c4df410f3937d59eb96dDaniel Dunbar * 0, 0); 165b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0Douglas Gregor * clang_visitChildren(clang_getTranslationUnitCursor(TU), 166b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0Douglas Gregor * TranslationUnitVisitor, 0); 167b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * clang_disposeTranslationUnit(TU); 168b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * 169b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * This process of creating the 'pch', loading it separately, and using it (via 170b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks 171b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * (which gives the indexer the same performance benefit as the compiler). 172e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff */ 173936ea3b590117d2cd73b1b92621d06c4a7edbe60Douglas GregorCINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH); 1740087e1a12b67b6bb032a72ea485a863daeccf55bDouglas Gregor 1750087e1a12b67b6bb032a72ea485a863daeccf55bDouglas Gregor/** 1760087e1a12b67b6bb032a72ea485a863daeccf55bDouglas Gregor * \brief Destroy the given index. 1770087e1a12b67b6bb032a72ea485a863daeccf55bDouglas Gregor * 1780087e1a12b67b6bb032a72ea485a863daeccf55bDouglas Gregor * The index must not be destroyed until all of the translation units created 1790087e1a12b67b6bb032a72ea485a863daeccf55bDouglas Gregor * within that index have been destroyed. 1800087e1a12b67b6bb032a72ea485a863daeccf55bDouglas Gregor */ 1818506dde586459887b7e14e23a30af8ac5be5adb6Daniel DunbarCINDEX_LINKAGE void clang_disposeIndex(CXIndex index); 1821efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 1831efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar/** 1841efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \brief Request that AST's be generated externally for API calls which parse 1858506dde586459887b7e14e23a30af8ac5be5adb6Daniel Dunbar * source code on the fly, e.g. \see createTranslationUnitFromSourceFile. 1868506dde586459887b7e14e23a30af8ac5be5adb6Daniel Dunbar * 1878506dde586459887b7e14e23a30af8ac5be5adb6Daniel Dunbar * Note: This is for debugging purposes only, and may be removed at a later 1888506dde586459887b7e14e23a30af8ac5be5adb6Daniel Dunbar * date. 1898506dde586459887b7e14e23a30af8ac5be5adb6Daniel Dunbar * 1908506dde586459887b7e14e23a30af8ac5be5adb6Daniel Dunbar * \param index - The index to update. 1918506dde586459887b7e14e23a30af8ac5be5adb6Daniel Dunbar * \param value - The new flag value. 1928506dde586459887b7e14e23a30af8ac5be5adb6Daniel Dunbar */ 1938506dde586459887b7e14e23a30af8ac5be5adb6Daniel DunbarCINDEX_LINKAGE void clang_setUseExternalASTGeneration(CXIndex index, 1948506dde586459887b7e14e23a30af8ac5be5adb6Daniel Dunbar int value); 195f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor/** 196c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \defgroup CINDEX_FILES File manipulation routines 197f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * 198f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * @{ 199f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor */ 2001efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 201f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor/** 202f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * \brief A particular source file that is part of a translation unit. 203f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor */ 204f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregortypedef void *CXFile; 2051efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 206f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor 207f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor/** 208f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * \brief Retrieve the complete file and path name of the given file. 20988145034694ed5267fa6fa5febc54fadc02bd479Steve Naroff */ 21008b0e8daeb683686b876d72674962ad96df21d45Douglas GregorCINDEX_LINKAGE const char *clang_getFileName(CXFile SFile); 2111efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 212f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor/** 213f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * \brief Retrieve the last modification time of the given file. 214f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor */ 21508b0e8daeb683686b876d72674962ad96df21d45Douglas GregorCINDEX_LINKAGE time_t clang_getFileTime(CXFile SFile); 21688145034694ed5267fa6fa5febc54fadc02bd479Steve Naroff 2173c7313d96cd4a18cd8c1fcd3ddd8128c2fcbe58fDouglas Gregor/** 218b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * \brief Retrieve a file handle within the given translation unit. 219b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * 220b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * \param tu the translation unit 2211efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * 222b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * \param file_name the name of the file. 223b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * 224b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * \returns the file handle for the named file in the translation unit \p tu, 225b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * or a NULL file handle if the file was not a part of this translation unit. 226b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor */ 2271efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel DunbarCINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu, 228b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor const char *file_name); 2291efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 230b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor/** 231f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * @} 232f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor */ 233f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor 234f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor/** 235f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * \defgroup CINDEX_LOCATIONS Physical source locations 236f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * 237f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * Clang represents physical source locations in its abstract syntax tree in 238f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * great detail, with file, line, and column information for the majority of 239f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * the tokens parsed in the source code. These data types and functions are 240f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * used to represent source location information, either for a particular 241f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * point in the program or for a range of points in the program, and extract 242f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * specific location information from those data types. 243f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * 244f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * @{ 245f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor */ 2461efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 247f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor/** 2481db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor * \brief Identifies a specific source location within a translation 2491db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor * unit. 2501db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor * 2511db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor * Use clang_getInstantiationLocation() to map a source location to a 2521db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor * particular file, line, and column. 2533c7313d96cd4a18cd8c1fcd3ddd8128c2fcbe58fDouglas Gregor */ 2543c7313d96cd4a18cd8c1fcd3ddd8128c2fcbe58fDouglas Gregortypedef struct { 2555352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor void *ptr_data[2]; 2561db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor unsigned int_data; 2573c7313d96cd4a18cd8c1fcd3ddd8128c2fcbe58fDouglas Gregor} CXSourceLocation; 258fe6fd3d41a7f48317d6856c9327b6cead32c3498Ted Kremenek 2593c7313d96cd4a18cd8c1fcd3ddd8128c2fcbe58fDouglas Gregor/** 2601db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor * \brief Identifies a range of source locations in the source code. 2613c7313d96cd4a18cd8c1fcd3ddd8128c2fcbe58fDouglas Gregor * 2621db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor * Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the 2631db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor * starting and end locations from a source range, respectively. 2643c7313d96cd4a18cd8c1fcd3ddd8128c2fcbe58fDouglas Gregor */ 2653c7313d96cd4a18cd8c1fcd3ddd8128c2fcbe58fDouglas Gregortypedef struct { 2665352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor void *ptr_data[2]; 2671db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor unsigned begin_int_data; 2681db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor unsigned end_int_data; 2693c7313d96cd4a18cd8c1fcd3ddd8128c2fcbe58fDouglas Gregor} CXSourceRange; 270fe6fd3d41a7f48317d6856c9327b6cead32c3498Ted Kremenek 2711db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor/** 272b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * \brief Retrieve a NULL (invalid) source location. 273b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor */ 274b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas GregorCINDEX_LINKAGE CXSourceLocation clang_getNullLocation(); 2751efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 276b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor/** 277b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * \determine Determine whether two source locations, which must refer into 2781efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * the same translation unit, refer to exactly the same point in the source 279b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * code. 280b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * 281b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * \returns non-zero if the source locations refer to the same location, zero 282b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * if they refer to different locations. 283b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor */ 284b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas GregorCINDEX_LINKAGE unsigned clang_equalLocations(CXSourceLocation loc1, 285b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor CXSourceLocation loc2); 2861efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 287b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor/** 2881efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \brief Retrieves the source location associated with a given file/line/column 2891efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * in a particular translation unit. 290b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor */ 291b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas GregorCINDEX_LINKAGE CXSourceLocation clang_getLocation(CXTranslationUnit tu, 292b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor CXFile file, 293b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor unsigned line, 294b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor unsigned column); 2951efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 296b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor/** 2975352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Retrieve a NULL (invalid) source range. 2985352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 2995352ac06d8f6194825bb2a99ffa009b61bafb503Douglas GregorCINDEX_LINKAGE CXSourceRange clang_getNullRange(); 3005352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 3015352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/** 302b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * \brief Retrieve a source range given the beginning and ending source 303b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * locations. 304b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor */ 305b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas GregorCINDEX_LINKAGE CXSourceRange clang_getRange(CXSourceLocation begin, 306b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor CXSourceLocation end); 3071efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 308b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor/** 30946766dc31c09d89024de5aba9e22112a56eadbdfDouglas Gregor * \brief Retrieve the file, line, column, and offset represented by 31046766dc31c09d89024de5aba9e22112a56eadbdfDouglas Gregor * the given source location. 3111db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor * 3121efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \param location the location within a source file that will be decomposed 3131efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * into its parts. 3141db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor * 3151efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \param file [out] if non-NULL, will be set to the file to which the given 3161db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor * source location points. 3171db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor * 3181efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \param line [out] if non-NULL, will be set to the line to which the given 3191db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor * source location points. 3201db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor * 3211efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \param column [out] if non-NULL, will be set to the column to which the given 3221efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * source location points. 32346766dc31c09d89024de5aba9e22112a56eadbdfDouglas Gregor * 32446766dc31c09d89024de5aba9e22112a56eadbdfDouglas Gregor * \param offset [out] if non-NULL, will be set to the offset into the 32546766dc31c09d89024de5aba9e22112a56eadbdfDouglas Gregor * buffer to which the given source location points. 3261db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor */ 3271db19dea8d221f27be46332d668d1e2decb7f1abDouglas GregorCINDEX_LINKAGE void clang_getInstantiationLocation(CXSourceLocation location, 3281db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor CXFile *file, 3291db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor unsigned *line, 33046766dc31c09d89024de5aba9e22112a56eadbdfDouglas Gregor unsigned *column, 33146766dc31c09d89024de5aba9e22112a56eadbdfDouglas Gregor unsigned *offset); 332e69517ce61638f12c9abe4605753a45275ac4e37Douglas Gregor 333e69517ce61638f12c9abe4605753a45275ac4e37Douglas Gregor/** 3341efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \brief Retrieve a source location representing the first character within a 3351efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * source range. 3361db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor */ 3371db19dea8d221f27be46332d668d1e2decb7f1abDouglas GregorCINDEX_LINKAGE CXSourceLocation clang_getRangeStart(CXSourceRange range); 3381db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor 3391db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor/** 3401efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \brief Retrieve a source location representing the last character within a 3411efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * source range. 3421db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor */ 3431db19dea8d221f27be46332d668d1e2decb7f1abDouglas GregorCINDEX_LINKAGE CXSourceLocation clang_getRangeEnd(CXSourceRange range); 3441db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor 345f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor/** 346f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * @} 347f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor */ 348c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor 349c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 3505352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \defgroup CINDEX_DIAG Diagnostic reporting 3515352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 3525352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * @{ 3535352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 3545352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 3555352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/** 3565352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Describes the severity of a particular diagnostic. 3575352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 3585352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregorenum CXDiagnosticSeverity { 3595352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor /** 3605352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief A diagnostic that has been suppressed, e.g., by a command-line 3615352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * option. 3625352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 3635352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor CXDiagnostic_Ignored = 0, 3645352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 3655352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor /** 3665352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief This diagnostic is a note that should be attached to the 3675352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * previous (non-note) diagnostic. 3685352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 3695352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor CXDiagnostic_Note = 1, 3705352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 3715352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor /** 3725352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief This diagnostic indicates suspicious code that may not be 3735352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * wrong. 3745352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 3755352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor CXDiagnostic_Warning = 2, 3765352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 3775352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor /** 3785352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief This diagnostic indicates that the code is ill-formed. 3795352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 3805352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor CXDiagnostic_Error = 3, 3815352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 3825352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor /** 3835352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief This diagnostic indicates that the code is ill-formed such 3845352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * that future parser recovery is unlikely to produce useful 3855352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * results. 3865352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 3875352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor CXDiagnostic_Fatal = 4 3885352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor}; 3895352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 3905352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/** 3915352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Describes the kind of fix-it hint expressed within a 3925352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * diagnostic. 3935352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 3945352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregorenum CXFixItKind { 3955352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor /** 3965352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief A fix-it hint that inserts code at a particular position. 3975352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 3985352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor CXFixIt_Insertion = 0, 3995352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 4005352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor /** 4015352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief A fix-it hint that removes code within a range. 4025352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 4035352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor CXFixIt_Removal = 1, 4045352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 4055352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor /** 4065352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief A fix-it hint that replaces the code within a range with another 4075352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * string. 4085352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 4095352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor CXFixIt_Replacement = 2 4105352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor}; 4115352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 4125352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/** 4135352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief A single diagnostic, containing the diagnostic's severity, 4145352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * location, text, source ranges, and fix-it hints. 4155352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 4165352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregortypedef void *CXDiagnostic; 4175352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 4185352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/** 4195352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Callback function invoked for each diagnostic emitted during 4205352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * translation. 4215352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 4225352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \param Diagnostic the diagnostic emitted during translation. This 4235352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * diagnostic pointer is only valid during the execution of the 4245352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * callback. 4255352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 4265352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \param ClientData the callback client data. 4275352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 4285352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregortypedef void (*CXDiagnosticCallback)(CXDiagnostic Diagnostic, 4295352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor CXClientData ClientData); 4305352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 4315352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/** 4325352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Determine the severity of the given diagnostic. 4335352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 4345352ac06d8f6194825bb2a99ffa009b61bafb503Douglas GregorCINDEX_LINKAGE enum CXDiagnosticSeverity 4355352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregorclang_getDiagnosticSeverity(CXDiagnostic); 4365352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 4375352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/** 4385352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Retrieve the source location of the given diagnostic. 4395352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 4405352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * This location is where Clang would print the caret ('^') when 4415352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * displaying the diagnostic on the command line. 4425352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 4435352ac06d8f6194825bb2a99ffa009b61bafb503Douglas GregorCINDEX_LINKAGE CXSourceLocation clang_getDiagnosticLocation(CXDiagnostic); 4445352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 4455352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/** 4465352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Retrieve the text of the given diagnostic. 4475352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 4485352ac06d8f6194825bb2a99ffa009b61bafb503Douglas GregorCINDEX_LINKAGE CXString clang_getDiagnosticSpelling(CXDiagnostic); 449a3890baf1256ff26081306c7fef70202f8223f41Douglas Gregor 450a3890baf1256ff26081306c7fef70202f8223f41Douglas Gregor/** 451a3890baf1256ff26081306c7fef70202f8223f41Douglas Gregor * \brief Determine the number of source ranges associated with the given 452a3890baf1256ff26081306c7fef70202f8223f41Douglas Gregor * diagnostic. 453a3890baf1256ff26081306c7fef70202f8223f41Douglas Gregor */ 454a3890baf1256ff26081306c7fef70202f8223f41Douglas GregorCINDEX_LINKAGE unsigned clang_getDiagnosticNumRanges(CXDiagnostic); 4555352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 4565352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/** 457a3890baf1256ff26081306c7fef70202f8223f41Douglas Gregor * \brief Retrieve a source range associated with the diagnostic. 4585352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 459a3890baf1256ff26081306c7fef70202f8223f41Douglas Gregor * A diagnostic's source ranges highlight important elements in the source 4605352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * code. On the command line, Clang displays source ranges by 4615352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * underlining them with '~' characters. 4625352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 463a3890baf1256ff26081306c7fef70202f8223f41Douglas Gregor * \param Diagnostic the diagnostic whose range is being extracted. 4645352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 465a3890baf1256ff26081306c7fef70202f8223f41Douglas Gregor * \param Range the zero-based index specifying which range to 4665352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 467a3890baf1256ff26081306c7fef70202f8223f41Douglas Gregor * \returns the requested source range. 4685352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 469a3890baf1256ff26081306c7fef70202f8223f41Douglas GregorCINDEX_LINKAGE CXSourceRange clang_getDiagnosticRange(CXDiagnostic Diagnostic, 470a3890baf1256ff26081306c7fef70202f8223f41Douglas Gregor unsigned Range); 4715352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 4725352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/** 4735352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Determine the number of fix-it hints associated with the 4745352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * given diagnostic. 4755352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 4765352ac06d8f6194825bb2a99ffa009b61bafb503Douglas GregorCINDEX_LINKAGE unsigned clang_getDiagnosticNumFixIts(CXDiagnostic Diagnostic); 4775352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 4785352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/** 4795352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Retrieve the kind of the given fix-it. 4805352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 4815352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \param Diagnostic the diagnostic whose fix-its are being queried. 4825352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 4835352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \param FixIt the zero-based index of the fix-it to query. 4845352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 4855352ac06d8f6194825bb2a99ffa009b61bafb503Douglas GregorCINDEX_LINKAGE enum CXFixItKind 4865352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregorclang_getDiagnosticFixItKind(CXDiagnostic Diagnostic, unsigned FixIt); 4875352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 4885352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/** 4895352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Retrieve the insertion information for an insertion fix-it. 4905352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 4915352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * For a fix-it that describes an insertion into a text buffer, 4925352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * retrieve the source location where the text should be inserted and 4935352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * the text to be inserted. 4945352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 4955352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \param Diagnostic the diagnostic whose fix-its are being queried. 4965352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 4975352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \param FixIt the zero-based index of the insertion fix-it. 4985352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 4995352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \param Location will be set to the location where text should be 5005352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * inserted. 5015352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 5025352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \returns the text string to insert at the given location. 5035352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 5045352ac06d8f6194825bb2a99ffa009b61bafb503Douglas GregorCINDEX_LINKAGE CXString 5055352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregorclang_getDiagnosticFixItInsertion(CXDiagnostic Diagnostic, unsigned FixIt, 5065352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor CXSourceLocation *Location); 5075352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 5085352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/** 5095352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Retrieve the removal information for a removal fix-it. 5105352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 5115352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * For a fix-it that describes a removal from a text buffer, retrieve 5125352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * the source range that should be removed. 5135352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 5145352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \param Diagnostic the diagnostic whose fix-its are being queried. 5155352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 5165352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \param FixIt the zero-based index of the removal fix-it. 5175352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 5185352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \returns a source range describing the text that should be removed 5195352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * from the buffer. 5205352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 5215352ac06d8f6194825bb2a99ffa009b61bafb503Douglas GregorCINDEX_LINKAGE CXSourceRange 5225352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregorclang_getDiagnosticFixItRemoval(CXDiagnostic Diagnostic, unsigned FixIt); 5235352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 5245352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/** 5255352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Retrieve the replacement information for an replacement fix-it. 5265352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 5275352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * For a fix-it that describes replacement of text in the text buffer 5285352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * with alternative text. 5295352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 5305352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \param Diagnostic the diagnostic whose fix-its are being queried. 5315352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 5325352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \param FixIt the zero-based index of the replacement fix-it. 5335352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 5345352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \param Range will be set to the source range whose text should be 5355352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * replaced with the returned text. 5365352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 5375352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \returns the text string to use as replacement text. 5385352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 5395352ac06d8f6194825bb2a99ffa009b61bafb503Douglas GregorCINDEX_LINKAGE CXString 5405352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregorclang_getDiagnosticFixItReplacement(CXDiagnostic Diagnostic, unsigned FixIt, 5415352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor CXSourceRange *Range); 5425352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 5435352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/** 5445352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * @} 5455352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 5465352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 5475352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/** 5485352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation 5495352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 5505352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * The routines in this group provide the ability to create and destroy 5515352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * translation units from files, either by parsing the contents of the files or 5525352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * by reading in a serialized representation of a translation unit. 5535352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 5545352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * @{ 5555352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 5565352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 5575352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/** 5585352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Get the original translation unit source file name. 5595352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 5605352ac06d8f6194825bb2a99ffa009b61bafb503Douglas GregorCINDEX_LINKAGE CXString 5615352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregorclang_getTranslationUnitSpelling(CXTranslationUnit CTUnit); 5625352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 5635352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/** 5645352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Return the CXTranslationUnit for a given source file and the provided 5655352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * command line arguments one would pass to the compiler. 5665352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 5675352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * Note: The 'source_filename' argument is optional. If the caller provides a 5685352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * NULL pointer, the name of the source file is expected to reside in the 5695352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * specified command line arguments. 5705352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 5715352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * Note: When encountered in 'clang_command_line_args', the following options 5725352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * are ignored: 5735352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 5745352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * '-c' 5755352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * '-emit-ast' 5765352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * '-fsyntax-only' 5775352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * '-o <output file>' (both '-o' and '<output file>' are ignored) 5785352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 5795352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 5805352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \param source_filename - The name of the source file to load, or NULL if the 5815352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * source file is included in clang_command_line_args. 5825352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 5835352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \param num_unsaved_files the number of unsaved file entries in \p 5845352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * unsaved_files. 5855352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 5865352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \param unsaved_files the files that have not yet been saved to disk 5875352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * but may be required for code completion, including the contents of 5885352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * those files. 5895352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 5905352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \param diag_callback callback function that will receive any diagnostics 5915352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * emitted while processing this source file. If NULL, diagnostics will be 5925352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * suppressed. 5935352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 5945352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \param diag_client_data client data that will be passed to the diagnostic 5955352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * callback function. 5965352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 5975352ac06d8f6194825bb2a99ffa009b61bafb503Douglas GregorCINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnitFromSourceFile( 5985352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor CXIndex CIdx, 5995352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor const char *source_filename, 6005352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor int num_clang_command_line_args, 6015352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor const char **clang_command_line_args, 6025352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor unsigned num_unsaved_files, 6035352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor struct CXUnsavedFile *unsaved_files, 6045352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor CXDiagnosticCallback diag_callback, 6055352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor CXClientData diag_client_data); 6065352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 6075352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/** 6085352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Create a translation unit from an AST file (-emit-ast). 6095352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 6105352ac06d8f6194825bb2a99ffa009b61bafb503Douglas GregorCINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnit(CXIndex, 6115352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor const char *ast_filename, 6125352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor CXDiagnosticCallback diag_callback, 6135352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor CXClientData diag_client_data); 6145352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 6155352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/** 6165352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Destroy the specified CXTranslationUnit object. 6175352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 6185352ac06d8f6194825bb2a99ffa009b61bafb503Douglas GregorCINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit); 6195352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 6205352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/** 6215352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * @} 6225352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 6235352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 6245352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/** 625c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Describes the kind of entity that a cursor refers to. 626c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 627c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregorenum CXCursorKind { 628c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /* Declarations */ 629c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_FirstDecl = 1, 6301efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar /** 631c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief A declaration whose specific kind is not exposed via this 6321efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * interface. 633c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 634c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * Unexposed declarations have the same operations as any other kind 635c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * of declaration; one can extract their location information, 636c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * spelling, find their definitions, etc. However, the specific kind 637c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * of the declaration is not reported. 638c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 639c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_UnexposedDecl = 1, 640c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** \brief A C or C++ struct. */ 6411efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar CXCursor_StructDecl = 2, 642c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** \brief A C or C++ union. */ 643c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_UnionDecl = 3, 644c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** \brief A C++ class. */ 645c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_ClassDecl = 4, 646c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** \brief An enumeration. */ 647c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_EnumDecl = 5, 6481efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar /** 649c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief A field (in C) or non-static data member (in C++) in a 650c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * struct, union, or C++ class. 651c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 652c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_FieldDecl = 6, 653c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** \brief An enumerator constant. */ 654c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_EnumConstantDecl = 7, 655c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** \brief A function. */ 656c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_FunctionDecl = 8, 657c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** \brief A variable. */ 658c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_VarDecl = 9, 659c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** \brief A function or method parameter. */ 660c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_ParmDecl = 10, 661c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** \brief An Objective-C @interface. */ 662c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_ObjCInterfaceDecl = 11, 663c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** \brief An Objective-C @interface for a category. */ 664c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_ObjCCategoryDecl = 12, 665c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** \brief An Objective-C @protocol declaration. */ 666c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_ObjCProtocolDecl = 13, 667c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** \brief An Objective-C @property declaration. */ 668c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_ObjCPropertyDecl = 14, 669c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** \brief An Objective-C instance variable. */ 670c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_ObjCIvarDecl = 15, 671c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** \brief An Objective-C instance method. */ 672c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_ObjCInstanceMethodDecl = 16, 673c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** \brief An Objective-C class method. */ 674c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_ObjCClassMethodDecl = 17, 675c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** \brief An Objective-C @implementation. */ 676c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_ObjCImplementationDecl = 18, 677c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** \brief An Objective-C @implementation for a category. */ 678c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_ObjCCategoryImplDecl = 19, 679c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** \brief A typedef */ 680c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_TypedefDecl = 20, 681c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_LastDecl = 20, 6821efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 683c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /* References */ 684c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_FirstRef = 40, /* Decl references */ 6851efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar CXCursor_ObjCSuperClassRef = 40, 686c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_ObjCProtocolRef = 41, 687c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_ObjCClassRef = 42, 688c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** 689c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief A reference to a type declaration. 690c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 691c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * A type reference occurs anywhere where a type is named but not 692c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * declared. For example, given: 693c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 694c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \code 695c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * typedef unsigned size_type; 696c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * size_type size; 697c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \endcode 698c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 699c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * The typedef is a declaration of size_type (CXCursor_TypedefDecl), 700c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * while the type of the variable "size" is referenced. The cursor 701c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * referenced by the type of size is the typedef for size_type. 702c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 703c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_TypeRef = 43, 704c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_LastRef = 43, 7051efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 706c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /* Error conditions */ 707c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_FirstInvalid = 70, 708c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_InvalidFile = 70, 709c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_NoDeclFound = 71, 710c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_NotImplemented = 72, 711c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_LastInvalid = 72, 7121efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 713c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /* Expressions */ 714c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_FirstExpr = 100, 7151efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 716c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** 717c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief An expression whose specific kind is not exposed via this 7181efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * interface. 719c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 720c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * Unexposed expressions have the same operations as any other kind 721c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * of expression; one can extract their location information, 722c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * spelling, children, etc. However, the specific kind of the 723c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * expression is not reported. 724c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 725c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_UnexposedExpr = 100, 7261efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 727c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** 728c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief An expression that refers to some value declaration, such 729c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * as a function, varible, or enumerator. 730c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 731c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_DeclRefExpr = 101, 7321efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 733c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** 734c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief An expression that refers to a member of a struct, union, 735c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * class, Objective-C class, etc. 736c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 737c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_MemberRefExpr = 102, 7381efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 739c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** \brief An expression that calls a function. */ 740c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_CallExpr = 103, 7411efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 742c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** \brief An expression that sends a message to an Objective-C 743c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor object or class. */ 744c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_ObjCMessageExpr = 104, 745c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_LastExpr = 104, 7461efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 747c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /* Statements */ 748c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_FirstStmt = 200, 749c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** 750c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief A statement whose specific kind is not exposed via this 751c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * interface. 752c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 753c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * Unexposed statements have the same operations as any other kind of 754c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * statement; one can extract their location information, spelling, 755c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * children, etc. However, the specific kind of the statement is not 756c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * reported. 757c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 758c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_UnexposedStmt = 200, 759c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_LastStmt = 200, 7601efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 761c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** 762c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Cursor that represents the translation unit itself. 763c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 764c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * The translation unit cursor exists primarily to act as the root 765c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * cursor for traversing the contents of a translation unit. 766c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 767c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_TranslationUnit = 300 768c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor}; 769c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor 770c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 771c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief A cursor representing some element in the abstract syntax tree for 772c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * a translation unit. 773c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 7741efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * The cursor abstraction unifies the different kinds of entities in a 775c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * program--declaration, statements, expressions, references to declarations, 776c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * etc.--under a single "cursor" abstraction with a common set of operations. 777c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * Common operation for a cursor include: getting the physical location in 778c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * a source file where the cursor points, getting the name associated with a 779c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * cursor, and retrieving cursors for any child nodes of a particular cursor. 780c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 781c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * Cursors can be produced in two specific ways. 782c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * clang_getTranslationUnitCursor() produces a cursor for a translation unit, 783c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * from which one can use clang_visitChildren() to explore the rest of the 784c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * translation unit. clang_getCursor() maps from a physical source location 785c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * to the entity that resides at that location, allowing one to map from the 786c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * source code into the AST. 787c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 788c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregortypedef struct { 789c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor enum CXCursorKind kind; 790c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor void *data[3]; 7911efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar} CXCursor; 792c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor 793c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 794c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations 795c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 796c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @{ 797c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 7981efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 799c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 800c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Retrieve the NULL cursor, which represents no entity. 801c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 802c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE CXCursor clang_getNullCursor(void); 8031efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 804c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 805c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Retrieve the cursor that represents the given translation unit. 806c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 807c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * The translation unit cursor can be used to start traversing the 808c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * various declarations within the given translation unit. 809c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 810c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE CXCursor clang_getTranslationUnitCursor(CXTranslationUnit); 811c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor 812c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 813c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Determine whether two cursors are equivalent. 814c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 815c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE unsigned clang_equalCursors(CXCursor, CXCursor); 8161efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 817c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 818c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Retrieve the kind of the given cursor. 819c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 820c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor); 821c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor 822c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 823c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Determine whether the given cursor kind represents a declaration. 824c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 825c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind); 826c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor 827c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 828c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Determine whether the given cursor kind represents a simple 829c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * reference. 830c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 831c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * Note that other kinds of cursors (such as expressions) can also refer to 832c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * other cursors. Use clang_getCursorReferenced() to determine whether a 833c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * particular cursor refers to another entity. 834c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 835c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE unsigned clang_isReference(enum CXCursorKind); 836c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor 837c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 838c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Determine whether the given cursor kind represents an expression. 839c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 840c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE unsigned clang_isExpression(enum CXCursorKind); 841c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor 842c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 843c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Determine whether the given cursor kind represents a statement. 844c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 845c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE unsigned clang_isStatement(enum CXCursorKind); 846c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor 847c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 8481efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \brief Determine whether the given cursor kind represents an invalid 849c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * cursor. 8501efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar */ 851c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE unsigned clang_isInvalid(enum CXCursorKind); 852c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor 853c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 8541efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \brief Determine whether the given cursor kind represents a translation 8551efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * unit. 856c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 857c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE unsigned clang_isTranslationUnit(enum CXCursorKind); 8581efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 859c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 860c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @} 861c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 8621efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 863c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 864c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code 865c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 866c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * Cursors represent a location within the Abstract Syntax Tree (AST). These 867c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * routines help map between cursors and the physical locations where the 868c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * described entities occur in the source code. The mapping is provided in 869c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * both directions, so one can map from source code to the AST and back. 870c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 871c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @{ 87250398199fb10e196a8d92fbf7a062dbe42ed88fdSteve Naroff */ 8731efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 8746a6de8b4fc944ca1bfa4e47c516d049a0d627b0eSteve Naroff/** 875b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * \brief Map a source location to the cursor that describes the entity at that 876b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * location in the source code. 877b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * 878b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * clang_getCursor() maps an arbitrary source location within a translation 879b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * unit down to the most specific cursor that describes the entity at that 8801efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * location. For example, given an expression \c x + y, invoking 881b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * clang_getCursor() with a source location pointing to "x" will return the 8821efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * cursor for "x"; similarly for "y". If the cursor points anywhere between 883b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor() 884b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * will return a cursor referring to the "+" expression. 885b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * 886b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * \returns a cursor representing the entity at the given source location, or 887b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * a NULL cursor if no such entity can be found. 8886a6de8b4fc944ca1bfa4e47c516d049a0d627b0eSteve Naroff */ 889b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas GregorCINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, CXSourceLocation); 8901efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 89198258afae66bab39b0c57a3efb6b20d4fbb5746cDouglas Gregor/** 89298258afae66bab39b0c57a3efb6b20d4fbb5746cDouglas Gregor * \brief Retrieve the physical location of the source constructor referenced 89398258afae66bab39b0c57a3efb6b20d4fbb5746cDouglas Gregor * by the given cursor. 89498258afae66bab39b0c57a3efb6b20d4fbb5746cDouglas Gregor * 89598258afae66bab39b0c57a3efb6b20d4fbb5746cDouglas Gregor * The location of a declaration is typically the location of the name of that 8961efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * declaration, where the name of that declaration would occur if it is 8971efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * unnamed, or some keyword that introduces that particular declaration. 8981efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * The location of a reference is where that reference occurs within the 89998258afae66bab39b0c57a3efb6b20d4fbb5746cDouglas Gregor * source code. 90098258afae66bab39b0c57a3efb6b20d4fbb5746cDouglas Gregor */ 90198258afae66bab39b0c57a3efb6b20d4fbb5746cDouglas GregorCINDEX_LINKAGE CXSourceLocation clang_getCursorLocation(CXCursor); 902c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor 903b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor/** 904b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * \brief Retrieve the physical extent of the source construct referenced by 905a7bde20f8c6334ccc3a7ef4dd77243d0921a8497Douglas Gregor * the given cursor. 906a7bde20f8c6334ccc3a7ef4dd77243d0921a8497Douglas Gregor * 907a7bde20f8c6334ccc3a7ef4dd77243d0921a8497Douglas Gregor * The extent of a cursor starts with the file/line/column pointing at the 908a7bde20f8c6334ccc3a7ef4dd77243d0921a8497Douglas Gregor * first character within the source construct that the cursor refers to and 9091efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * ends with the last character withinin that source construct. For a 910a7bde20f8c6334ccc3a7ef4dd77243d0921a8497Douglas Gregor * declaration, the extent covers the declaration itself. For a reference, 911a7bde20f8c6334ccc3a7ef4dd77243d0921a8497Douglas Gregor * the extent covers the location of the reference (e.g., where the referenced 912a7bde20f8c6334ccc3a7ef4dd77243d0921a8497Douglas Gregor * entity was actually used). 913a7bde20f8c6334ccc3a7ef4dd77243d0921a8497Douglas Gregor */ 914a7bde20f8c6334ccc3a7ef4dd77243d0921a8497Douglas GregorCINDEX_LINKAGE CXSourceRange clang_getCursorExtent(CXCursor); 915c5d1e9375d71e66d22456e7cc52cc7c0a5c65c3fDouglas Gregor 916c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 917c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @} 918c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 9191efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 920c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 921c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors 922c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 923c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * These routines provide the ability to traverse the abstract syntax tree 924c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * using cursors. 925c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 926c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @{ 927c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 9281efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 929c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 930c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Describes how the traversal of the children of a particular 931c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * cursor should proceed after visiting a particular child cursor. 932c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 933c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * A value of this enumeration type should be returned by each 934c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \c CXCursorVisitor to indicate how clang_visitChildren() proceed. 935c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 936c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregorenum CXChildVisitResult { 937c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** 9381efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \brief Terminates the cursor traversal. 939c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 940c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXChildVisit_Break, 9411efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar /** 942c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Continues the cursor traversal with the next sibling of 943c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * the cursor just visited, without visiting its children. 944c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 945c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXChildVisit_Continue, 946c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** 947c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Recursively traverse the children of this cursor, using 948c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * the same visitor and client data. 949c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 950c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXChildVisit_Recurse 951c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor}; 952c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor 953c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 954c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Visitor invoked for each cursor found by a traversal. 955c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 956c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * This visitor function will be invoked for each cursor found by 957c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * clang_visitCursorChildren(). Its first argument is the cursor being 958c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * visited, its second argument is the parent visitor for that cursor, 959c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * and its third argument is the client data provided to 960c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * clang_visitCursorChildren(). 961c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 962c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * The visitor should return one of the \c CXChildVisitResult values 963c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * to direct clang_visitCursorChildren(). 964c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 9651efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbartypedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor, 9661efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar CXCursor parent, 967c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXClientData client_data); 968c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor 969c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 970c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Visit the children of a particular cursor. 971c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 972c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * This function visits all the direct children of the given cursor, 973c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * invoking the given \p visitor function with the cursors of each 974c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * visited child. The traversal may be recursive, if the visitor returns 975c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if 976c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * the visitor returns \c CXChildVisit_Break. 977c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 978c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \param parent the cursor whose child may be visited. All kinds of 979a57259e9d7b30bcce93f0a62eee0488738026172Daniel Dunbar * cursors can be visited, including invalid cursors (which, by 980c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * definition, have no children). 981c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 982c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \param visitor the visitor function that will be invoked for each 983c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * child of \p parent. 984c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 985c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \param client_data pointer data supplied by the client, which will 986c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * be passed to the visitor each time it is invoked. 987c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 988c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \returns a non-zero value if the traversal was terminated 989c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * prematurely by the visitor returning \c CXChildVisit_Break. 990c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 9911efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel DunbarCINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent, 992c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursorVisitor visitor, 993c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXClientData client_data); 9941efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 995c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 996c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @} 997c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 9981efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 999c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 1000c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST 1001c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 10021efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * These routines provide the ability to determine references within and 1003c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * across translation units, by providing the names of the entities referenced 1004c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * by cursors, follow reference cursors to the declarations they reference, 1005c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * and associate declarations with their definitions. 1006c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 1007c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @{ 1008c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 10091efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 1010c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 1011c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Retrieve a Unified Symbol Resolution (USR) for the entity referenced 1012c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * by the given cursor. 1013c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 1014c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * A Unified Symbol Resolution (USR) is a string that identifies a particular 1015c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * entity (function, class, variable, etc.) within a program. USRs can be 1016c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * compared across translation units to determine, e.g., when references in 1017c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * one translation refer to an entity defined in another translation unit. 1018c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 1019c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE CXString clang_getCursorUSR(CXCursor); 1020c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor 1021c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 1022c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Retrieve a name for the entity referenced by this cursor. 1023c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 1024c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE CXString clang_getCursorSpelling(CXCursor); 1025c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor 1026c5d1e9375d71e66d22456e7cc52cc7c0a5c65c3fDouglas Gregor/** \brief For a cursor that is a reference, retrieve a cursor representing the 1027c5d1e9375d71e66d22456e7cc52cc7c0a5c65c3fDouglas Gregor * entity that it references. 1028c5d1e9375d71e66d22456e7cc52cc7c0a5c65c3fDouglas Gregor * 1029c5d1e9375d71e66d22456e7cc52cc7c0a5c65c3fDouglas Gregor * Reference cursors refer to other entities in the AST. For example, an 1030c5d1e9375d71e66d22456e7cc52cc7c0a5c65c3fDouglas Gregor * Objective-C superclass reference cursor refers to an Objective-C class. 10311efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * This function produces the cursor for the Objective-C class from the 1032c5d1e9375d71e66d22456e7cc52cc7c0a5c65c3fDouglas Gregor * cursor for the superclass reference. If the input cursor is a declaration or 1033c5d1e9375d71e66d22456e7cc52cc7c0a5c65c3fDouglas Gregor * definition, it returns that declaration or definition unchanged. 10341efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * Otherwise, returns the NULL cursor. 1035c5d1e9375d71e66d22456e7cc52cc7c0a5c65c3fDouglas Gregor */ 1036c5d1e9375d71e66d22456e7cc52cc7c0a5c65c3fDouglas GregorCINDEX_LINKAGE CXCursor clang_getCursorReferenced(CXCursor); 1037b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor 10381efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar/** 1039b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * \brief For a cursor that is either a reference to or a declaration 1040b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * of some entity, retrieve a cursor that describes the definition of 1041b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * that entity. 1042b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * 1043b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * Some entities can be declared multiple times within a translation 1044b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * unit, but only one of those declarations can also be a 1045b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * definition. For example, given: 1046b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * 1047b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * \code 1048b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * int f(int, int); 1049b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * int g(int x, int y) { return f(x, y); } 1050b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * int f(int a, int b) { return a + b; } 1051b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * int f(int, int); 1052b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * \endcode 1053b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * 1054b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * there are three declarations of the function "f", but only the 1055b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * second one is a definition. The clang_getCursorDefinition() 1056b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * function will take any cursor pointing to a declaration of "f" 1057b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * (the first or fourth lines of the example) or a cursor referenced 1058b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * that uses "f" (the call to "f' inside "g") and will return a 1059b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * declaration cursor pointing to the definition (the second "f" 1060b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * declaration). 1061b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * 1062b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * If given a cursor for which there is no corresponding definition, 1063b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * e.g., because there is no definition of that entity within this 1064b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * translation unit, returns a NULL cursor. 1065b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor */ 1066b699866820102a69d83d6ac6941985c5ef4e8c40Douglas GregorCINDEX_LINKAGE CXCursor clang_getCursorDefinition(CXCursor); 1067b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor 10681efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar/** 1069b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * \brief Determine whether the declaration pointed to by this cursor 1070b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * is also a definition of that entity. 1071b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor */ 1072b699866820102a69d83d6ac6941985c5ef4e8c40Douglas GregorCINDEX_LINKAGE unsigned clang_isCursorDefinition(CXCursor); 1073b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor 1074c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 1075c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @} 1076c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 10771efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 1078c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 10790045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * \defgroup CINDEX_LEX Token extraction and manipulation 10800045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * 10810045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * The routines in this group provide access to the tokens within a 10820045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * translation unit, along with a semantic mapping of those tokens to 10830045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * their corresponding cursors. 1084fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * 1085fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * @{ 1086fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */ 1087fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor 1088fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/** 1089fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief Describes a kind of token. 1090fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */ 1091fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregortypedef enum CXTokenKind { 1092fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor /** 1093fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief A token that contains some kind of punctuation. 1094fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */ 1095fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor CXToken_Punctuation, 1096fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor 1097fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor /** 10980045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * \brief A language keyword. 1099fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */ 1100fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor CXToken_Keyword, 1101fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor 1102fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor /** 1103fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief An identifier (that is not a keyword). 1104fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */ 1105fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor CXToken_Identifier, 1106fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor 1107fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor /** 1108fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief A numeric, string, or character literal. 1109fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */ 1110fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor CXToken_Literal, 1111fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor 1112fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor /** 1113fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief A comment. 1114fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */ 1115fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor CXToken_Comment 1116fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor} CXTokenKind; 1117fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor 1118fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/** 1119fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief Describes a single preprocessing token. 1120fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */ 1121fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregortypedef struct { 1122fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor unsigned int_data[4]; 1123fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor void *ptr_data; 1124fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor} CXToken; 1125fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor 1126fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/** 1127fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief Determine the kind of the given token. 1128fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */ 1129fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas GregorCINDEX_LINKAGE CXTokenKind clang_getTokenKind(CXToken); 1130fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor 1131fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/** 1132fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief Determine the spelling of the given token. 1133fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * 1134fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * The spelling of a token is the textual representation of that token, e.g., 1135fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * the text of an identifier or keyword. 1136fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */ 1137fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas GregorCINDEX_LINKAGE CXString clang_getTokenSpelling(CXTranslationUnit, CXToken); 1138fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor 1139fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/** 1140fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief Retrieve the source location of the given token. 1141fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */ 1142fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas GregorCINDEX_LINKAGE CXSourceLocation clang_getTokenLocation(CXTranslationUnit, 1143fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor CXToken); 1144fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor 1145fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/** 1146fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief Retrieve a source range that covers the given token. 1147fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */ 1148fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas GregorCINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken); 1149fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor 1150fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/** 1151fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief Tokenize the source code described by the given range into raw 1152fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * lexical tokens. 1153fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * 1154fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \param TU the translation unit whose text is being tokenized. 1155fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * 1156fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \param Range the source range in which text should be tokenized. All of the 1157fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * tokens produced by tokenization will fall within this source range, 1158fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * 1159fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \param Tokens this pointer will be set to point to the array of tokens 1160fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * that occur within the given source range. The returned pointer must be 1161fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * freed with clang_disposeTokens() before the translation unit is destroyed. 1162fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * 1163fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \param NumTokens will be set to the number of tokens in the \c *Tokens 1164fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * array. 1165fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * 1166fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */ 1167fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas GregorCINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range, 1168fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor CXToken **Tokens, unsigned *NumTokens); 1169fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor 1170fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/** 1171fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief Annotate the given set of tokens by providing cursors for each token 1172fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * that can be mapped to a specific entity within the abstract syntax tree. 1173fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * 11740045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * This token-annotation routine is equivalent to invoking 11750045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * clang_getCursor() for the source locations of each of the 11760045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * tokens. The cursors provided are filtered, so that only those 11770045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * cursors that have a direct correspondence to the token are 11780045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * accepted. For example, given a function call \c f(x), 11790045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * clang_getCursor() would provide the following cursors: 11800045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * 11810045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'. 11820045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'. 11830045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'. 11840045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * 11850045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * Only the first and last of these cursors will occur within the 11860045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * annotate, since the tokens "f" and "x' directly refer to a function 11870045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * and a variable, respectively, but the parentheses are just a small 11880045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * part of the full syntax of the function call expression, which is 11890045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * not provided as an annotation. 1190fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * 1191fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \param TU the translation unit that owns the given tokens. 1192fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * 1193fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \param Tokens the set of tokens to annotate. 1194fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * 1195fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \param NumTokens the number of tokens in \p Tokens. 1196fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * 1197fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \param Cursors an array of \p NumTokens cursors, whose contents will be 1198fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * replaced with the cursors corresponding to each token. 1199fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */ 1200fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas GregorCINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU, 1201fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor CXToken *Tokens, unsigned NumTokens, 1202fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor CXCursor *Cursors); 1203fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor 1204fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/** 1205fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief Free the given set of tokens. 1206fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */ 1207fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas GregorCINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU, 1208fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor CXToken *Tokens, unsigned NumTokens); 1209fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor 1210fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/** 1211fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * @} 1212fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */ 1213fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor 1214fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/** 1215c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \defgroup CINDEX_DEBUG Debugging facilities 1216c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 1217c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * These routines are used for testing and debugging, only, and should not 1218c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * be relied upon. 1219c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 1220c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @{ 1221c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 12221efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 12234ade6d6eae934f796ca43c81a5aa185e456dde9bSteve Naroff/* for debug/testing */ 12241efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel DunbarCINDEX_LINKAGE const char *clang_getCursorKindSpelling(enum CXCursorKind Kind); 12251efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel DunbarCINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(CXCursor, 12261efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar const char **startBuf, 12274ade6d6eae934f796ca43c81a5aa185e456dde9bSteve Naroff const char **endBuf, 12284ade6d6eae934f796ca43c81a5aa185e456dde9bSteve Naroff unsigned *startLine, 12294ade6d6eae934f796ca43c81a5aa185e456dde9bSteve Naroff unsigned *startColumn, 12304ade6d6eae934f796ca43c81a5aa185e456dde9bSteve Naroff unsigned *endLine, 12314ade6d6eae934f796ca43c81a5aa185e456dde9bSteve Naroff unsigned *endColumn); 1232600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff 12330c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor/** 1234c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @} 1235c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 12361efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 1237c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 1238c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \defgroup CINDEX_CODE_COMPLET Code completion 1239c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 1240c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * Code completion involves taking an (incomplete) source file, along with 1241c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * knowledge of where the user is actively editing that file, and suggesting 1242c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * syntactically- and semantically-valid constructs that the user might want to 1243c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * use at that particular point in the source code. These data structures and 1244c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * routines provide support for code completion. 1245c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 1246c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @{ 1247c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 12481efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 1249c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 12500c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief A semantic string that describes a code-completion result. 12510c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 12520c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * A semantic string that describes the formatting of a code-completion 12530c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * result as a single "template" of text that should be inserted into the 12540c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * source buffer when a particular code-completion result is selected. 12550c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * Each semantic string is made up of some number of "chunks", each of which 12560c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * contains some text along with a description of what that text means, e.g., 12570c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * the name of the entity being referenced, whether the text chunk is part of 12580c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * the template, or whether it is a "placeholder" that the user should replace 12590c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * with actual code,of a specific kind. See \c CXCompletionChunkKind for a 12601efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * description of the different kinds of chunks. 12610c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 12620c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregortypedef void *CXCompletionString; 12631efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 12640c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor/** 12650c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief A single result of code completion. 12660c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 12670c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregortypedef struct { 12680c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 12691efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \brief The kind of entity that this completion refers to. 12700c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 12711efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * The cursor kind will be a macro, keyword, or a declaration (one of the 12720c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * *Decl cursor kinds), describing the entity that the completion is 12730c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * referring to. 12740c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 12750c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \todo In the future, we would like to provide a full cursor, to allow 12760c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * the client to extract additional information from declaration. 12770c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 12780c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor enum CXCursorKind CursorKind; 12791efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 12801efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar /** 12810c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief The code-completion string that describes how to insert this 12820c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * code-completion result into the editing buffer. 12830c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 12840c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionString CompletionString; 12850c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor} CXCompletionResult; 12860c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor 12870c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor/** 12880c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief Describes a single piece of text within a code-completion string. 12890c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 12901efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * Each "chunk" within a code-completion string (\c CXCompletionString) is 12911efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * either a piece of text with a specific "kind" that describes how that text 12920c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * should be interpreted by the client or is another completion string. 12930c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 12940c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregorenum CXCompletionChunkKind { 12950c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 12960c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief A code-completion string that describes "optional" text that 12970c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * could be a part of the template (but is not required). 12980c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 12990c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * The Optional chunk is the only kind of chunk that has a code-completion 13001efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * string for its representation, which is accessible via 13010c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \c clang_getCompletionChunkCompletionString(). The code-completion string 13020c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * describes an additional part of the template that is completely optional. 13030c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * For example, optional chunks can be used to describe the placeholders for 13040c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * arguments that match up with defaulted function parameters, e.g. given: 13050c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 13060c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \code 13070c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * void f(int x, float y = 3.14, double z = 2.71828); 13080c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \endcode 13090c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 13100c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * The code-completion string for this function would contain: 13110c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * - a TypedText chunk for "f". 13120c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * - a LeftParen chunk for "(". 13130c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * - a Placeholder chunk for "int x" 13140c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * - an Optional chunk containing the remaining defaulted arguments, e.g., 13150c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * - a Comma chunk for "," 13160c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * - a Placeholder chunk for "float x" 13170c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * - an Optional chunk containing the last defaulted argument: 13180c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * - a Comma chunk for "," 13190c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * - a Placeholder chunk for "double z" 13200c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * - a RightParen chunk for ")" 13210c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 13220c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * There are many ways two handle Optional chunks. Two simple approaches are: 13230c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * - Completely ignore optional chunks, in which case the template for the 13240c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * function "f" would only include the first parameter ("int x"). 13250c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * - Fully expand all optional chunks, in which case the template for the 13260c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * function "f" would have all of the parameters. 13270c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 13280c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_Optional, 13290c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 13300c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief Text that a user would be expected to type to get this 13311efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * code-completion result. 13320c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 13331efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * There will be exactly one "typed text" chunk in a semantic string, which 13341efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * will typically provide the spelling of a keyword or the name of a 13350c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * declaration that could be used at the current code point. Clients are 13360c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * expected to filter the code-completion results based on the text in this 13370c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * chunk. 13380c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 13390c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_TypedText, 13400c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 13410c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief Text that should be inserted as part of a code-completion result. 13420c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 13430c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * A "text" chunk represents text that is part of the template to be 13440c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * inserted into user code should this particular code-completion result 13450c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * be selected. 13460c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 13470c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_Text, 13480c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 13490c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief Placeholder text that should be replaced by the user. 13500c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 13510c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * A "placeholder" chunk marks a place where the user should insert text 13520c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * into the code-completion template. For example, placeholders might mark 13530c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * the function parameters for a function declaration, to indicate that the 13540c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * user should provide arguments for each of those parameters. The actual 13550c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * text in a placeholder is a suggestion for the text to display before 13560c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * the user replaces the placeholder with real code. 13570c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 13580c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_Placeholder, 13590c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 13600c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief Informative text that should be displayed but never inserted as 13610c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * part of the template. 13621efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * 13630c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * An "informative" chunk contains annotations that can be displayed to 13640c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * help the user decide whether a particular code-completion result is the 13650c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * right option, but which is not part of the actual template to be inserted 13660c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * by code completion. 13670c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 13680c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_Informative, 13690c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 13700c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief Text that describes the current parameter when code-completion is 13710c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * referring to function call, message send, or template specialization. 13720c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 13730c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * A "current parameter" chunk occurs when code-completion is providing 13740c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * information about a parameter corresponding to the argument at the 13750c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * code-completion point. For example, given a function 13760c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 13770c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \code 13780c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * int add(int x, int y); 13790c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \endcode 13800c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 13810c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * and the source code \c add(, where the code-completion point is after the 13820c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * "(", the code-completion string will contain a "current parameter" chunk 13830c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * for "int x", indicating that the current argument will initialize that 13840c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * parameter. After typing further, to \c add(17, (where the code-completion 13851efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * point is after the ","), the code-completion string will contain a 13860c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * "current paremeter" chunk to "int y". 13870c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 13880c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_CurrentParameter, 13890c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 13900c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief A left parenthesis ('('), used to initiate a function call or 13910c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * signal the beginning of a function parameter list. 13920c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 13930c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_LeftParen, 13940c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 13950c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief A right parenthesis (')'), used to finish a function call or 13960c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * signal the end of a function parameter list. 13970c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 13980c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_RightParen, 13990c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 14000c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief A left bracket ('['). 14010c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 14020c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_LeftBracket, 14030c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 14040c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief A right bracket (']'). 14050c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 14060c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_RightBracket, 14070c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 14080c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief A left brace ('{'). 14090c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 14100c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_LeftBrace, 14110c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 14120c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief A right brace ('}'). 14130c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 14140c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_RightBrace, 14150c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 14160c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief A left angle bracket ('<'). 14170c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 14180c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_LeftAngle, 14190c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 14200c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief A right angle bracket ('>'). 14210c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 14220c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_RightAngle, 14230c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 14240c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief A comma separator (','). 14250c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 1426ff5ce6eefc7c253ef6edf4d4bfc996fdd82d09aaDouglas Gregor CXCompletionChunk_Comma, 1427ff5ce6eefc7c253ef6edf4d4bfc996fdd82d09aaDouglas Gregor /** 14281efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \brief Text that specifies the result type of a given result. 1429ff5ce6eefc7c253ef6edf4d4bfc996fdd82d09aaDouglas Gregor * 1430ff5ce6eefc7c253ef6edf4d4bfc996fdd82d09aaDouglas Gregor * This special kind of informative chunk is not meant to be inserted into 14311efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * the text buffer. Rather, it is meant to illustrate the type that an 1432ff5ce6eefc7c253ef6edf4d4bfc996fdd82d09aaDouglas Gregor * expression using the given completion string would have. 1433ff5ce6eefc7c253ef6edf4d4bfc996fdd82d09aaDouglas Gregor */ 143401dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor CXCompletionChunk_ResultType, 143501dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor /** 143601dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor * \brief A colon (':'). 143701dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor */ 143801dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor CXCompletionChunk_Colon, 143901dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor /** 144001dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor * \brief A semicolon (';'). 144101dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor */ 144201dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor CXCompletionChunk_SemiColon, 144301dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor /** 144401dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor * \brief An '=' sign. 144501dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor */ 144601dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor CXCompletionChunk_Equal, 144701dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor /** 144801dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor * Horizontal space (' '). 144901dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor */ 145001dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor CXCompletionChunk_HorizontalSpace, 145101dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor /** 145201dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor * Vertical space ('\n'), after which it is generally a good idea to 145301dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor * perform indentation. 145401dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor */ 145501dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor CXCompletionChunk_VerticalSpace 14560c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor}; 14571efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 14580c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor/** 14590c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief Determine the kind of a particular chunk within a completion string. 14600c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 14610c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param completion_string the completion string to query. 14620c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 14630c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param chunk_number the 0-based index of the chunk in the completion string. 14640c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 14650c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \returns the kind of the chunk at the index \c chunk_number. 14660c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 14671efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel DunbarCINDEX_LINKAGE enum CXCompletionChunkKind 14680c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregorclang_getCompletionChunkKind(CXCompletionString completion_string, 14690c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor unsigned chunk_number); 14701efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 14710c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor/** 14721efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \brief Retrieve the text associated with a particular chunk within a 14730c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * completion string. 14740c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 14750c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param completion_string the completion string to query. 14760c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 14770c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param chunk_number the 0-based index of the chunk in the completion string. 14780c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 14790c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \returns the text associated with the chunk at index \c chunk_number. 14800c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 14810c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas GregorCINDEX_LINKAGE const char * 14820c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregorclang_getCompletionChunkText(CXCompletionString completion_string, 14830c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor unsigned chunk_number); 14840c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor 14850c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor/** 14861efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \brief Retrieve the completion string associated with a particular chunk 14870c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * within a completion string. 14880c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 14890c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param completion_string the completion string to query. 14900c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 14910c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param chunk_number the 0-based index of the chunk in the completion string. 14920c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 14930c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \returns the completion string associated with the chunk at index 14940c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \c chunk_number, or NULL if that chunk is not represented by a completion 14950c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * string. 14960c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 14970c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas GregorCINDEX_LINKAGE CXCompletionString 14980c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregorclang_getCompletionChunkCompletionString(CXCompletionString completion_string, 14990c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor unsigned chunk_number); 15001efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 15010c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor/** 15020c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief Retrieve the number of chunks in the given code-completion string. 15030c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 15040c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas GregorCINDEX_LINKAGE unsigned 15050c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregorclang_getNumCompletionChunks(CXCompletionString completion_string); 15060c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor 15070c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor/** 1508ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor * \brief Contains the results of code-completion. 1509ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor * 1510ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor * This data structure contains the results of code completion, as 15111efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * produced by \c clang_codeComplete. Its contents must be freed by 1512ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor * \c clang_disposeCodeCompleteResults. 1513ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor */ 1514ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregortypedef struct { 1515ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor /** 1516ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor * \brief The code-completion results. 1517ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor */ 1518ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor CXCompletionResult *Results; 1519ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor 1520ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor /** 1521ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor * \brief The number of code-completion results stored in the 1522ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor * \c Results array. 1523ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor */ 1524ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor unsigned NumResults; 1525ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor} CXCodeCompleteResults; 1526ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor 1527ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor/** 15280c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief Perform code completion at a given location in a source file. 15290c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 15300c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * This function performs code completion at a particular file, line, and 15310c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * column within source code, providing results that suggest potential 15320c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * code snippets based on the context of the completion. The basic model 15330c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * for code completion is that Clang will parse a complete source file, 15340c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * performing syntax checking up to the location where code-completion has 15350c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * been requested. At that point, a special code-completion token is passed 15360c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * to the parser, which recognizes this token and determines, based on the 15371efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * current location in the C/Objective-C/C++ grammar and the state of 15380c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * semantic analysis, what completions to provide. These completions are 1539ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor * returned via a new \c CXCodeCompleteResults structure. 15400c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 15410c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * Code completion itself is meant to be triggered by the client when the 15421efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * user types punctuation characters or whitespace, at which point the 15430c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * code-completion location will coincide with the cursor. For example, if \c p 15440c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * is a pointer, code-completion might be triggered after the "-" and then 15450c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * after the ">" in \c p->. When the code-completion location is afer the ">", 15460c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * the completion results will provide, e.g., the members of the struct that 15470c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * "p" points to. The client is responsible for placing the cursor at the 15480c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * beginning of the token currently being typed, then filtering the results 15490c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * based on the contents of the token. For example, when code-completing for 15500c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * the expression \c p->get, the client should provide the location just after 15510c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the 15520c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * client can filter the results based on the current token text ("get"), only 15530c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * showing those results that start with "get". The intent of this interface 1554ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor * is to separate the relatively high-latency acquisition of code-completion 15550c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * results from the filtering of results on a per-character basis, which must 15560c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * have a lower latency. 15570c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 15580c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param CIdx the \c CXIndex instance that will be used to perform code 15590c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * completion. 15600c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 15618506dde586459887b7e14e23a30af8ac5be5adb6Daniel Dunbar * \param source_filename the name of the source file that should be parsed to 15628506dde586459887b7e14e23a30af8ac5be5adb6Daniel Dunbar * perform code-completion. This source file must be the same as or include the 15638506dde586459887b7e14e23a30af8ac5be5adb6Daniel Dunbar * filename described by \p complete_filename, or no code-completion results 15648506dde586459887b7e14e23a30af8ac5be5adb6Daniel Dunbar * will be produced. NOTE: One can also specify NULL for this argument if the 15658506dde586459887b7e14e23a30af8ac5be5adb6Daniel Dunbar * source file is included in command_line_args. 15660c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 15670c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param num_command_line_args the number of command-line arguments stored in 15680c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \p command_line_args. 15690c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 15700c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param command_line_args the command-line arguments to pass to the Clang 15711efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * compiler to build the given source file. This should include all of the 15720c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * necessary include paths, language-dialect switches, precompiled header 15731efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * includes, etc., but should not include any information specific to 15740c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * code completion. 15750c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 1576735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor * \param num_unsaved_files the number of unsaved file entries in \p 1577735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor * unsaved_files. 1578735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor * 1579735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor * \param unsaved_files the files that have not yet been saved to disk 1580735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor * but may be required for code completion, including the contents of 1581735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor * those files. 1582735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor * 15830c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param complete_filename the name of the source file where code completion 15840c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * should be performed. In many cases, this name will be the same as the 15851efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * source filename. However, the completion filename may also be a file 15861efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * included by the source file, which is required when producing 15870c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * code-completion results for a header. 15880c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 15890c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param complete_line the line at which code-completion should occur. 15900c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 15911efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \param complete_column the column at which code-completion should occur. 15920c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * Note that the column should point just after the syntactic construct that 15930c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * initiated code completion, and not in the middle of a lexical token. 15940c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 1595936ea3b590117d2cd73b1b92621d06c4a7edbe60Douglas Gregor * \param diag_callback callback function that will receive any diagnostics 1596936ea3b590117d2cd73b1b92621d06c4a7edbe60Douglas Gregor * emitted while processing this source file. If NULL, diagnostics will be 1597936ea3b590117d2cd73b1b92621d06c4a7edbe60Douglas Gregor * suppressed. 1598936ea3b590117d2cd73b1b92621d06c4a7edbe60Douglas Gregor * 1599936ea3b590117d2cd73b1b92621d06c4a7edbe60Douglas Gregor * \param diag_client_data client data that will be passed to the diagnostic 1600936ea3b590117d2cd73b1b92621d06c4a7edbe60Douglas Gregor * callback function. 1601936ea3b590117d2cd73b1b92621d06c4a7edbe60Douglas Gregor * 1602ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor * \returns if successful, a new CXCodeCompleteResults structure 1603ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor * containing code-completion results, which should eventually be 1604ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor * freed with \c clang_disposeCodeCompleteResults(). If code 1605ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor * completion fails, returns NULL. 1606ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor */ 16071efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel DunbarCINDEX_LINKAGE 16081efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel DunbarCXCodeCompleteResults *clang_codeComplete(CXIndex CIdx, 1609ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor const char *source_filename, 16101efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar int num_command_line_args, 1611ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor const char **command_line_args, 1612ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor unsigned num_unsaved_files, 1613ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor struct CXUnsavedFile *unsaved_files, 1614ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor const char *complete_filename, 1615ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor unsigned complete_line, 1616936ea3b590117d2cd73b1b92621d06c4a7edbe60Douglas Gregor unsigned complete_column, 1617936ea3b590117d2cd73b1b92621d06c4a7edbe60Douglas Gregor CXDiagnosticCallback diag_callback, 1618936ea3b590117d2cd73b1b92621d06c4a7edbe60Douglas Gregor CXClientData diag_client_data); 16191efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 1620ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor/** 1621ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor * \brief Free the given set of code-completion results. 16220c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 16231efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel DunbarCINDEX_LINKAGE 1624ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregorvoid clang_disposeCodeCompleteResults(CXCodeCompleteResults *Results); 16251efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 162620d416c36b46dd19ee0b1ea2d0266ae43be86e51Douglas Gregor/** 162720d416c36b46dd19ee0b1ea2d0266ae43be86e51Douglas Gregor * @} 162820d416c36b46dd19ee0b1ea2d0266ae43be86e51Douglas Gregor */ 16291efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 16301efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 163104bb716aea8fd2372ac10b0c640cabc5e5caa615Ted Kremenek/** 163204bb716aea8fd2372ac10b0c640cabc5e5caa615Ted Kremenek * \defgroup CINDEX_MISC Miscellaneous utility functions 163304bb716aea8fd2372ac10b0c640cabc5e5caa615Ted Kremenek * 163404bb716aea8fd2372ac10b0c640cabc5e5caa615Ted Kremenek * @{ 163504bb716aea8fd2372ac10b0c640cabc5e5caa615Ted Kremenek */ 163623e1ad09bb68f929212e0ff51206258d06e7f6cfTed Kremenek 163723e1ad09bb68f929212e0ff51206258d06e7f6cfTed Kremenek/** 163823e1ad09bb68f929212e0ff51206258d06e7f6cfTed Kremenek * \brief Return a version string, suitable for showing to a user, but not 163923e1ad09bb68f929212e0ff51206258d06e7f6cfTed Kremenek * intended to be parsed (the format is not guaranteed to be stable). 164023e1ad09bb68f929212e0ff51206258d06e7f6cfTed Kremenek */ 1641a2a9d6e4e5b6001b86b7dfc5db1ea296ce29a3d3Ted KremenekCINDEX_LINKAGE CXString clang_getClangVersion(); 164204bb716aea8fd2372ac10b0c640cabc5e5caa615Ted Kremenek 164304bb716aea8fd2372ac10b0c640cabc5e5caa615Ted Kremenek/** 164416b55a71695a33c094383295cc7b7a2080e098daTed Kremenek * \brief Return a version string, suitable for showing to a user, but not 164516b55a71695a33c094383295cc7b7a2080e098daTed Kremenek * intended to be parsed (the format is not guaranteed to be stable). 164616b55a71695a33c094383295cc7b7a2080e098daTed Kremenek */ 164716b55a71695a33c094383295cc7b7a2080e098daTed Kremenek 164816b55a71695a33c094383295cc7b7a2080e098daTed Kremenek 164916b55a71695a33c094383295cc7b7a2080e098daTed Kremenek /** 165016b55a71695a33c094383295cc7b7a2080e098daTed Kremenek * \brief Visitor invoked for each file in a translation unit 165116b55a71695a33c094383295cc7b7a2080e098daTed Kremenek * (used with clang_getInclusions()). 165216b55a71695a33c094383295cc7b7a2080e098daTed Kremenek * 165316b55a71695a33c094383295cc7b7a2080e098daTed Kremenek * This visitor function will be invoked by clang_getInclusions() for each 165416b55a71695a33c094383295cc7b7a2080e098daTed Kremenek * file included (either at the top-level or by #include directives) within 165516b55a71695a33c094383295cc7b7a2080e098daTed Kremenek * a translation unit. The first argument is the file being included, and 165616b55a71695a33c094383295cc7b7a2080e098daTed Kremenek * the second and third arguments provide the inclusion stack. The 165716b55a71695a33c094383295cc7b7a2080e098daTed Kremenek * array is sorted in order of immediate inclusion. For example, 165816b55a71695a33c094383295cc7b7a2080e098daTed Kremenek * the first element refers to the location that included 'included_file'. 165916b55a71695a33c094383295cc7b7a2080e098daTed Kremenek */ 166016b55a71695a33c094383295cc7b7a2080e098daTed Kremenektypedef void (*CXInclusionVisitor)(CXFile included_file, 166116b55a71695a33c094383295cc7b7a2080e098daTed Kremenek CXSourceLocation* inclusion_stack, 166216b55a71695a33c094383295cc7b7a2080e098daTed Kremenek unsigned include_len, 166316b55a71695a33c094383295cc7b7a2080e098daTed Kremenek CXClientData client_data); 166416b55a71695a33c094383295cc7b7a2080e098daTed Kremenek 166516b55a71695a33c094383295cc7b7a2080e098daTed Kremenek/** 166616b55a71695a33c094383295cc7b7a2080e098daTed Kremenek * \brief Visit the set of preprocessor inclusions in a translation unit. 166716b55a71695a33c094383295cc7b7a2080e098daTed Kremenek * The visitor function is called with the provided data for every included 166816b55a71695a33c094383295cc7b7a2080e098daTed Kremenek * file. This does not include headers included by the PCH file (unless one 166916b55a71695a33c094383295cc7b7a2080e098daTed Kremenek * is inspecting the inclusions in the PCH file itself). 167016b55a71695a33c094383295cc7b7a2080e098daTed Kremenek */ 167116b55a71695a33c094383295cc7b7a2080e098daTed KremenekCINDEX_LINKAGE void clang_getInclusions(CXTranslationUnit tu, 167216b55a71695a33c094383295cc7b7a2080e098daTed Kremenek CXInclusionVisitor visitor, 167316b55a71695a33c094383295cc7b7a2080e098daTed Kremenek CXClientData client_data); 167416b55a71695a33c094383295cc7b7a2080e098daTed Kremenek 167516b55a71695a33c094383295cc7b7a2080e098daTed Kremenek/** 167604bb716aea8fd2372ac10b0c640cabc5e5caa615Ted Kremenek * @} 167704bb716aea8fd2372ac10b0c640cabc5e5caa615Ted Kremenek */ 16781efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 1679c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 1680c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @} 1681c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 16821efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 1683d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek#ifdef __cplusplus 1684d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek} 1685d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek#endif 1686d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek#endif 1687d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek 1688