Index.h revision dd3e5549e3c11e217078938aacf72f042eea5343
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> 210a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor#include <stdio.h> 2288145034694ed5267fa6fa5febc54fadc02bd479Steve Naroff 23d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek#ifdef __cplusplus 24d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenekextern "C" { 25d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek#endif 26d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek 2788145034694ed5267fa6fa5febc54fadc02bd479Steve Naroff/* MSVC DLL import/export. */ 282e06fc877a633abea3b40a64950c7316dac29ca8John Thompson#ifdef _MSC_VER 292e06fc877a633abea3b40a64950c7316dac29ca8John Thompson #ifdef _CINDEX_LIB_ 302e06fc877a633abea3b40a64950c7316dac29ca8John Thompson #define CINDEX_LINKAGE __declspec(dllexport) 312e06fc877a633abea3b40a64950c7316dac29ca8John Thompson #else 322e06fc877a633abea3b40a64950c7316dac29ca8John Thompson #define CINDEX_LINKAGE __declspec(dllimport) 332e06fc877a633abea3b40a64950c7316dac29ca8John Thompson #endif 342e06fc877a633abea3b40a64950c7316dac29ca8John Thompson#else 352e06fc877a633abea3b40a64950c7316dac29ca8John Thompson #define CINDEX_LINKAGE 362e06fc877a633abea3b40a64950c7316dac29ca8John Thompson#endif 372e06fc877a633abea3b40a64950c7316dac29ca8John Thompson 3887fb9404cd962b78c98947d75d68be1691c4e737Douglas Gregor/** \defgroup CINDEX libclang: C Interface to Clang 3920d416c36b46dd19ee0b1ea2d0266ae43be86e51Douglas Gregor * 401efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * The C Interface to Clang provides a relatively small API that exposes 41f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * facilities for parsing source code into an abstract syntax tree (AST), 42f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * loading already-parsed ASTs, traversing the AST, associating 43f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * physical source locations with elements within the AST, and other 44f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * facilities that support Clang-based development tools. 45f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * 461efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * This C interface to Clang will never provide all of the information 47f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * representation stored in Clang's C++ AST, nor should it: the intent is to 48f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * maintain an API that is relatively stable from one release to the next, 49f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * providing only the basic functionality needed to support development tools. 501efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * 511efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * To avoid namespace pollution, data types are prefixed with "CX" and 52f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * functions are prefixed with "clang_". 5320d416c36b46dd19ee0b1ea2d0266ae43be86e51Douglas Gregor * 5420d416c36b46dd19ee0b1ea2d0266ae43be86e51Douglas Gregor * @{ 5520d416c36b46dd19ee0b1ea2d0266ae43be86e51Douglas Gregor */ 561efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 577f17376e0931a337d544b75d9030bc92763be287Douglas Gregor/** 587f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * \brief An "index" that consists of a set of translation units that would 597f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * typically be linked together into an executable or library. 607f17376e0931a337d544b75d9030bc92763be287Douglas Gregor */ 617f17376e0931a337d544b75d9030bc92763be287Douglas Gregortypedef void *CXIndex; 62600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff 637f17376e0931a337d544b75d9030bc92763be287Douglas Gregor/** 647f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * \brief A single translation unit, which resides in an index. 657f17376e0931a337d544b75d9030bc92763be287Douglas Gregor */ 660a90d32523bfe5fa63e11b648686c9699f786d15Ted Kremenektypedef struct CXTranslationUnitImpl *CXTranslationUnit; 67600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff 687f17376e0931a337d544b75d9030bc92763be287Douglas Gregor/** 69c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Opaque pointer representing client data that will be passed through 70c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * to various callbacks and visitors. 717f17376e0931a337d544b75d9030bc92763be287Douglas Gregor */ 72c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregortypedef void *CXClientData; 731efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 74735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor/** 75735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor * \brief Provides the contents of a file that has not yet been saved to disk. 76735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor * 77735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor * Each CXUnsavedFile instance provides the name of a file on the 78735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor * system along with the current contents of that file that have not 79735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor * yet been saved to disk. 80735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor */ 81735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregorstruct CXUnsavedFile { 821efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar /** 831efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \brief The file whose contents have not yet been saved. 84735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor * 85735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor * This file must already exist in the file system. 86735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor */ 87735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor const char *Filename; 88735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor 891efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar /** 90c8dfe5ece04e683106eb96c58a2999f70b53ac21Douglas Gregor * \brief A buffer containing the unsaved contents of this file. 91735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor */ 92735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor const char *Contents; 93735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor 94735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor /** 95c8dfe5ece04e683106eb96c58a2999f70b53ac21Douglas Gregor * \brief The length of the unsaved contents of this buffer. 96735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor */ 97735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor unsigned long Length; 98735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor}; 99735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor 100076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne/** 101076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne * \brief Describes the availability of a particular entity, which indicates 102076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne * whether the use of this entity will result in a warning or error due to 103076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne * it being deprecated or unavailable. 104076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne */ 10558ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregorenum CXAvailabilityKind { 106076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne /** 107076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne * \brief The entity is available. 108076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne */ 10958ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor CXAvailability_Available, 110076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne /** 111076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne * \brief The entity is available, but has been deprecated (and its use is 112076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne * not recommended). 113076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne */ 11458ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor CXAvailability_Deprecated, 115076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne /** 116076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne * \brief The entity is not available; any use of it will be an error. 117076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne */ 11858ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor CXAvailability_NotAvailable 11958ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor}; 12058ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor 1217f17376e0931a337d544b75d9030bc92763be287Douglas Gregor/** 1227f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * \defgroup CINDEX_STRING String manipulation routines 1237f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * 1247f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * @{ 1257f17376e0931a337d544b75d9030bc92763be287Douglas Gregor */ 1261efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 1277f17376e0931a337d544b75d9030bc92763be287Douglas Gregor/** 1287f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * \brief A character string. 1297f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * 1307f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * The \c CXString type is used to return strings from the interface when 1317f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * the ownership of that string might different from one call to the next. 1327f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * Use \c clang_getCString() to retrieve the string data and, once finished 1337f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * with the string data, call \c clang_disposeString() to free the string. 134ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff */ 135ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Narofftypedef struct { 136a60ed47da13393796d8552b9fdca12abbb3eea42Ted Kremenek void *data; 137ed122735639d83c10f18c28c7fd117bfcd0f62cbTed Kremenek unsigned private_flags; 138ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff} CXString; 139ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff 1407f17376e0931a337d544b75d9030bc92763be287Douglas Gregor/** 1417f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * \brief Retrieve the character data associated with the given string. 1427f17376e0931a337d544b75d9030bc92763be287Douglas Gregor */ 143ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve NaroffCINDEX_LINKAGE const char *clang_getCString(CXString string); 144ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff 1457f17376e0931a337d544b75d9030bc92763be287Douglas Gregor/** 1467f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * \brief Free the given string, 1477f17376e0931a337d544b75d9030bc92763be287Douglas Gregor */ 148ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve NaroffCINDEX_LINKAGE void clang_disposeString(CXString string); 149ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff 1507f17376e0931a337d544b75d9030bc92763be287Douglas Gregor/** 1517f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * @} 1527f17376e0931a337d544b75d9030bc92763be287Douglas Gregor */ 1531efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 1541efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar/** 155e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * \brief clang_createIndex() provides a shared context for creating 156e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * translation units. It provides two options: 157e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * 158e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local" 159e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * declarations (when loading any new translation units). A "local" declaration 1601efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * is one that belongs in the translation unit itself and not in a precompiled 161e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * header that was used by the translation unit. If zero, all declarations 162e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * will be enumerated. 163e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * 164b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * Here is an example: 165b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * 1660a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * // excludeDeclsFromPCH = 1, displayDiagnostics=1 1670a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * Idx = clang_createIndex(1, 1); 168b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * 169b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * // IndexTest.pch was produced with the following command: 170b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch" 171b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * TU = clang_createTranslationUnit(Idx, "IndexTest.pch"); 172b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * 173b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * // This will load all the symbols from 'IndexTest.pch' 1741efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * clang_visitChildren(clang_getTranslationUnitCursor(TU), 175002a528ab0189fc60cfbf9328962c96ccbe567eeDouglas Gregor * TranslationUnitVisitor, 0); 176b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * clang_disposeTranslationUnit(TU); 177b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * 178b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * // This will load all the symbols from 'IndexTest.c', excluding symbols 179b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * // from 'IndexTest.pch'. 180fd9f23464bfd35314c87c4df410f3937d59eb96dDaniel Dunbar * char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" }; 181fd9f23464bfd35314c87c4df410f3937d59eb96dDaniel Dunbar * TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args, 182fd9f23464bfd35314c87c4df410f3937d59eb96dDaniel Dunbar * 0, 0); 183b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0Douglas Gregor * clang_visitChildren(clang_getTranslationUnitCursor(TU), 184b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0Douglas Gregor * TranslationUnitVisitor, 0); 185b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * clang_disposeTranslationUnit(TU); 186b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * 187b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * This process of creating the 'pch', loading it separately, and using it (via 188b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks 189b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * (which gives the indexer the same performance benefit as the compiler). 190e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff */ 1910a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas GregorCINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH, 1920a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor int displayDiagnostics); 193896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek 1940087e1a12b67b6bb032a72ea485a863daeccf55bDouglas Gregor/** 1950087e1a12b67b6bb032a72ea485a863daeccf55bDouglas Gregor * \brief Destroy the given index. 1960087e1a12b67b6bb032a72ea485a863daeccf55bDouglas Gregor * 1970087e1a12b67b6bb032a72ea485a863daeccf55bDouglas Gregor * The index must not be destroyed until all of the translation units created 1980087e1a12b67b6bb032a72ea485a863daeccf55bDouglas Gregor * within that index have been destroyed. 1990087e1a12b67b6bb032a72ea485a863daeccf55bDouglas Gregor */ 2008506dde586459887b7e14e23a30af8ac5be5adb6Daniel DunbarCINDEX_LINKAGE void clang_disposeIndex(CXIndex index); 2011efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 2021efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar/** 203c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \defgroup CINDEX_FILES File manipulation routines 204f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * 205f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * @{ 206f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor */ 2071efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 208f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor/** 209f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * \brief A particular source file that is part of a translation unit. 210f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor */ 211f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregortypedef void *CXFile; 2121efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 213f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor 214f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor/** 215f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * \brief Retrieve the complete file and path name of the given file. 21688145034694ed5267fa6fa5febc54fadc02bd479Steve Naroff */ 21774844072411bae91d5dbb89955d200cbe1e0a1c8Ted KremenekCINDEX_LINKAGE CXString clang_getFileName(CXFile SFile); 2181efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 219f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor/** 220f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * \brief Retrieve the last modification time of the given file. 221f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor */ 22208b0e8daeb683686b876d72674962ad96df21d45Douglas GregorCINDEX_LINKAGE time_t clang_getFileTime(CXFile SFile); 22388145034694ed5267fa6fa5febc54fadc02bd479Steve Naroff 2243c7313d96cd4a18cd8c1fcd3ddd8128c2fcbe58fDouglas Gregor/** 225dd3e5549e3c11e217078938aacf72f042eea5343Douglas Gregor * \brief Determine whether the given header is guarded against 226dd3e5549e3c11e217078938aacf72f042eea5343Douglas Gregor * multiple inclusions, either with the conventional 227dd3e5549e3c11e217078938aacf72f042eea5343Douglas Gregor * #ifndef/#define/#endif macro guards or with #pragma once. 228dd3e5549e3c11e217078938aacf72f042eea5343Douglas Gregor */ 229dd3e5549e3c11e217078938aacf72f042eea5343Douglas GregorCINDEX_LINKAGE unsigned 230dd3e5549e3c11e217078938aacf72f042eea5343Douglas Gregorclang_isFileMultipleIncludeGuarded(CXTranslationUnit tu, CXFile file); 231dd3e5549e3c11e217078938aacf72f042eea5343Douglas Gregor 232dd3e5549e3c11e217078938aacf72f042eea5343Douglas Gregor/** 233b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * \brief Retrieve a file handle within the given translation unit. 234b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * 235b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * \param tu the translation unit 2361efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * 237b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * \param file_name the name of the file. 238b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * 239b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * \returns the file handle for the named file in the translation unit \p tu, 240b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * or a NULL file handle if the file was not a part of this translation unit. 241b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor */ 2421efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel DunbarCINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu, 243b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor const char *file_name); 2441efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 245b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor/** 246f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * @} 247f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor */ 248f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor 249f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor/** 250f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * \defgroup CINDEX_LOCATIONS Physical source locations 251f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * 252f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * Clang represents physical source locations in its abstract syntax tree in 253f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * great detail, with file, line, and column information for the majority of 254f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * the tokens parsed in the source code. These data types and functions are 255f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * used to represent source location information, either for a particular 256f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * point in the program or for a range of points in the program, and extract 257f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * specific location information from those data types. 258f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * 259f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * @{ 260f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor */ 2611efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 262f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor/** 2631db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor * \brief Identifies a specific source location within a translation 2641db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor * unit. 2651db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor * 266a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * Use clang_getInstantiationLocation() or clang_getSpellingLocation() 267a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * to map a source location to a particular file, line, and column. 2683c7313d96cd4a18cd8c1fcd3ddd8128c2fcbe58fDouglas Gregor */ 2693c7313d96cd4a18cd8c1fcd3ddd8128c2fcbe58fDouglas Gregortypedef struct { 2705352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor void *ptr_data[2]; 2711db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor unsigned int_data; 2723c7313d96cd4a18cd8c1fcd3ddd8128c2fcbe58fDouglas Gregor} CXSourceLocation; 273fe6fd3d41a7f48317d6856c9327b6cead32c3498Ted Kremenek 2743c7313d96cd4a18cd8c1fcd3ddd8128c2fcbe58fDouglas Gregor/** 275d52864bd33c66aacc84133460d8c9c0dfcdd5c18Daniel Dunbar * \brief Identifies a half-open character range in the source code. 2763c7313d96cd4a18cd8c1fcd3ddd8128c2fcbe58fDouglas Gregor * 2771db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor * Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the 2781db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor * starting and end locations from a source range, respectively. 2793c7313d96cd4a18cd8c1fcd3ddd8128c2fcbe58fDouglas Gregor */ 2803c7313d96cd4a18cd8c1fcd3ddd8128c2fcbe58fDouglas Gregortypedef struct { 2815352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor void *ptr_data[2]; 2821db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor unsigned begin_int_data; 2831db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor unsigned end_int_data; 2843c7313d96cd4a18cd8c1fcd3ddd8128c2fcbe58fDouglas Gregor} CXSourceRange; 285fe6fd3d41a7f48317d6856c9327b6cead32c3498Ted Kremenek 2861db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor/** 287b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * \brief Retrieve a NULL (invalid) source location. 288b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor */ 289b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas GregorCINDEX_LINKAGE CXSourceLocation clang_getNullLocation(); 2901efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 291b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor/** 292b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * \determine Determine whether two source locations, which must refer into 2931efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * the same translation unit, refer to exactly the same point in the source 294b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * code. 295b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * 296b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * \returns non-zero if the source locations refer to the same location, zero 297b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * if they refer to different locations. 298b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor */ 299b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas GregorCINDEX_LINKAGE unsigned clang_equalLocations(CXSourceLocation loc1, 300b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor CXSourceLocation loc2); 3011efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 302b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor/** 3031efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \brief Retrieves the source location associated with a given file/line/column 3041efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * in a particular translation unit. 305b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor */ 306b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas GregorCINDEX_LINKAGE CXSourceLocation clang_getLocation(CXTranslationUnit tu, 307b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor CXFile file, 308b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor unsigned line, 309b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor unsigned column); 31083889a7f1f338e343ef72aeeef9c27f7b62c0f0fDavid Chisnall/** 31183889a7f1f338e343ef72aeeef9c27f7b62c0f0fDavid Chisnall * \brief Retrieves the source location associated with a given character offset 31283889a7f1f338e343ef72aeeef9c27f7b62c0f0fDavid Chisnall * in a particular translation unit. 31383889a7f1f338e343ef72aeeef9c27f7b62c0f0fDavid Chisnall */ 31483889a7f1f338e343ef72aeeef9c27f7b62c0f0fDavid ChisnallCINDEX_LINKAGE CXSourceLocation clang_getLocationForOffset(CXTranslationUnit tu, 31583889a7f1f338e343ef72aeeef9c27f7b62c0f0fDavid Chisnall CXFile file, 31683889a7f1f338e343ef72aeeef9c27f7b62c0f0fDavid Chisnall unsigned offset); 3171efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 318b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor/** 3195352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Retrieve a NULL (invalid) source range. 3205352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 3215352ac06d8f6194825bb2a99ffa009b61bafb503Douglas GregorCINDEX_LINKAGE CXSourceRange clang_getNullRange(); 322896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek 3235352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/** 324b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * \brief Retrieve a source range given the beginning and ending source 325b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * locations. 326b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor */ 327b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas GregorCINDEX_LINKAGE CXSourceRange clang_getRange(CXSourceLocation begin, 328b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor CXSourceLocation end); 3291efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 330b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor/** 33146766dc31c09d89024de5aba9e22112a56eadbdfDouglas Gregor * \brief Retrieve the file, line, column, and offset represented by 33246766dc31c09d89024de5aba9e22112a56eadbdfDouglas Gregor * the given source location. 3331db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor * 334a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * If the location refers into a macro instantiation, retrieves the 335a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * location of the macro instantiation. 336a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * 3371efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \param location the location within a source file that will be decomposed 3381efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * into its parts. 3391db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor * 3401efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \param file [out] if non-NULL, will be set to the file to which the given 3411db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor * source location points. 3421db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor * 3431efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \param line [out] if non-NULL, will be set to the line to which the given 3441db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor * source location points. 3451db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor * 3461efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \param column [out] if non-NULL, will be set to the column to which the given 3471efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * source location points. 34846766dc31c09d89024de5aba9e22112a56eadbdfDouglas Gregor * 34946766dc31c09d89024de5aba9e22112a56eadbdfDouglas Gregor * \param offset [out] if non-NULL, will be set to the offset into the 35046766dc31c09d89024de5aba9e22112a56eadbdfDouglas Gregor * buffer to which the given source location points. 3511db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor */ 3521db19dea8d221f27be46332d668d1e2decb7f1abDouglas GregorCINDEX_LINKAGE void clang_getInstantiationLocation(CXSourceLocation location, 3531db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor CXFile *file, 3541db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor unsigned *line, 35546766dc31c09d89024de5aba9e22112a56eadbdfDouglas Gregor unsigned *column, 35646766dc31c09d89024de5aba9e22112a56eadbdfDouglas Gregor unsigned *offset); 357e69517ce61638f12c9abe4605753a45275ac4e37Douglas Gregor 358e69517ce61638f12c9abe4605753a45275ac4e37Douglas Gregor/** 359a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * \brief Retrieve the file, line, column, and offset represented by 360a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * the given source location. 361a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * 362a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * If the location refers into a macro instantiation, return where the 363a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * location was originally spelled in the source file. 364a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * 365a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * \param location the location within a source file that will be decomposed 366a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * into its parts. 367a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * 368a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * \param file [out] if non-NULL, will be set to the file to which the given 369a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * source location points. 370a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * 371a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * \param line [out] if non-NULL, will be set to the line to which the given 372a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * source location points. 373a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * 374a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * \param column [out] if non-NULL, will be set to the column to which the given 375a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * source location points. 376a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * 377a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * \param offset [out] if non-NULL, will be set to the offset into the 378a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * buffer to which the given source location points. 379a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor */ 380a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas GregorCINDEX_LINKAGE void clang_getSpellingLocation(CXSourceLocation location, 381a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor CXFile *file, 382a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor unsigned *line, 383a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor unsigned *column, 384a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor unsigned *offset); 385a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor 386a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor/** 3871efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \brief Retrieve a source location representing the first character within a 3881efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * source range. 3891db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor */ 3901db19dea8d221f27be46332d668d1e2decb7f1abDouglas GregorCINDEX_LINKAGE CXSourceLocation clang_getRangeStart(CXSourceRange range); 3911db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor 3921db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor/** 3931efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \brief Retrieve a source location representing the last character within a 3941efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * source range. 3951db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor */ 3961db19dea8d221f27be46332d668d1e2decb7f1abDouglas GregorCINDEX_LINKAGE CXSourceLocation clang_getRangeEnd(CXSourceRange range); 3971db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor 398f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor/** 399f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * @} 400f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor */ 401c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor 402c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 4035352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \defgroup CINDEX_DIAG Diagnostic reporting 4045352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 4055352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * @{ 4065352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 4075352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 4085352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/** 4095352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Describes the severity of a particular diagnostic. 4105352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 4115352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregorenum CXDiagnosticSeverity { 4125352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor /** 413896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek * \brief A diagnostic that has been suppressed, e.g., by a command-line 4145352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * option. 4155352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 4165352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor CXDiagnostic_Ignored = 0, 417896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek 4185352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor /** 4195352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief This diagnostic is a note that should be attached to the 4205352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * previous (non-note) diagnostic. 4215352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 4225352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor CXDiagnostic_Note = 1, 4235352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 4245352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor /** 4255352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief This diagnostic indicates suspicious code that may not be 4265352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * wrong. 4275352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 4285352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor CXDiagnostic_Warning = 2, 4295352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 4305352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor /** 4315352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief This diagnostic indicates that the code is ill-formed. 4325352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 4335352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor CXDiagnostic_Error = 3, 4345352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 4355352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor /** 4365352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief This diagnostic indicates that the code is ill-formed such 4375352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * that future parser recovery is unlikely to produce useful 4385352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * results. 4395352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 4405352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor CXDiagnostic_Fatal = 4 4415352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor}; 4425352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 4435352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/** 4445352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief A single diagnostic, containing the diagnostic's severity, 4455352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * location, text, source ranges, and fix-it hints. 4465352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 4475352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregortypedef void *CXDiagnostic; 4485352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 4495352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/** 450a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * \brief Determine the number of diagnostics produced for the given 451a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * translation unit. 452a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor */ 453a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas GregorCINDEX_LINKAGE unsigned clang_getNumDiagnostics(CXTranslationUnit Unit); 454a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor 455a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor/** 456a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * \brief Retrieve a diagnostic associated with the given translation unit. 4575352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 458a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * \param Unit the translation unit to query. 459a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * \param Index the zero-based diagnostic number to retrieve. 4605352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 461a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * \returns the requested diagnostic. This diagnostic must be freed 462a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * via a call to \c clang_disposeDiagnostic(). 4635352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 464a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas GregorCINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit, 465a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor unsigned Index); 466a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor 467a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor/** 468a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * \brief Destroy a diagnostic. 469a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor */ 470a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas GregorCINDEX_LINKAGE void clang_disposeDiagnostic(CXDiagnostic Diagnostic); 4715352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 4725352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/** 4730a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * \brief Options to control the display of diagnostics. 4740a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * 4750a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * The values in this enum are meant to be combined to customize the 4760a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * behavior of \c clang_displayDiagnostic(). 4770a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor */ 4780a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregorenum CXDiagnosticDisplayOptions { 4790a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor /** 4800a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * \brief Display the source-location information where the 4810a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * diagnostic was located. 4820a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * 4830a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * When set, diagnostics will be prefixed by the file, line, and 4840a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * (optionally) column to which the diagnostic refers. For example, 4850a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * 4860a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * \code 4870a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * test.c:28: warning: extra tokens at end of #endif directive 4880a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * \endcode 4890a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * 4900a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * This option corresponds to the clang flag \c -fshow-source-location. 4910a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor */ 4920a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor CXDiagnostic_DisplaySourceLocation = 0x01, 4930a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor 4940a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor /** 4950a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * \brief If displaying the source-location information of the 4960a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * diagnostic, also include the column number. 4970a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * 4980a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * This option corresponds to the clang flag \c -fshow-column. 4990a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor */ 5000a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor CXDiagnostic_DisplayColumn = 0x02, 5010a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor 5020a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor /** 5030a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * \brief If displaying the source-location information of the 5040a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * diagnostic, also include information about source ranges in a 5050a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * machine-parsable format. 5060a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * 507896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek * This option corresponds to the clang flag 5080a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * \c -fdiagnostics-print-source-range-info. 5090a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor */ 510aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor CXDiagnostic_DisplaySourceRanges = 0x04, 511aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor 512aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor /** 513aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor * \brief Display the option name associated with this diagnostic, if any. 514aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor * 515aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor * The option name displayed (e.g., -Wconversion) will be placed in brackets 516aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor * after the diagnostic text. This option corresponds to the clang flag 517aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor * \c -fdiagnostics-show-option. 518aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor */ 519aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor CXDiagnostic_DisplayOption = 0x08, 520aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor 521aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor /** 522aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor * \brief Display the category number associated with this diagnostic, if any. 523aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor * 524aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor * The category number is displayed within brackets after the diagnostic text. 525aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor * This option corresponds to the clang flag 526aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor * \c -fdiagnostics-show-category=id. 527aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor */ 528aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor CXDiagnostic_DisplayCategoryId = 0x10, 529aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor 530aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor /** 531aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor * \brief Display the category name associated with this diagnostic, if any. 532aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor * 533aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor * The category name is displayed within brackets after the diagnostic text. 534aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor * This option corresponds to the clang flag 535aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor * \c -fdiagnostics-show-category=name. 536aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor */ 537aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor CXDiagnostic_DisplayCategoryName = 0x20 5380a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor}; 5390a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor 5400a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor/** 541274f1906f12ebf8fcc179701deeda6d3271120c1Douglas Gregor * \brief Format the given diagnostic in a manner that is suitable for display. 5420a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * 543274f1906f12ebf8fcc179701deeda6d3271120c1Douglas Gregor * This routine will format the given diagnostic to a string, rendering 544896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek * the diagnostic according to the various options given. The 545896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek * \c clang_defaultDiagnosticDisplayOptions() function returns the set of 5460a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * options that most closely mimics the behavior of the clang compiler. 5470a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * 5480a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * \param Diagnostic The diagnostic to print. 5490a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * 550896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek * \param Options A set of options that control the diagnostic display, 5510a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * created by combining \c CXDiagnosticDisplayOptions values. 552274f1906f12ebf8fcc179701deeda6d3271120c1Douglas Gregor * 553274f1906f12ebf8fcc179701deeda6d3271120c1Douglas Gregor * \returns A new string containing for formatted diagnostic. 5540a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor */ 555274f1906f12ebf8fcc179701deeda6d3271120c1Douglas GregorCINDEX_LINKAGE CXString clang_formatDiagnostic(CXDiagnostic Diagnostic, 556274f1906f12ebf8fcc179701deeda6d3271120c1Douglas Gregor unsigned Options); 5570a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor 5580a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor/** 5590a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * \brief Retrieve the set of display options most similar to the 5600a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * default behavior of the clang compiler. 5610a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * 5620a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * \returns A set of display options suitable for use with \c 5630a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * clang_displayDiagnostic(). 5640a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor */ 5650a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas GregorCINDEX_LINKAGE unsigned clang_defaultDiagnosticDisplayOptions(void); 5660a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor 5670a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor/** 5685352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Determine the severity of the given diagnostic. 5695352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 570896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE enum CXDiagnosticSeverity 5715352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregorclang_getDiagnosticSeverity(CXDiagnostic); 5725352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 5735352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/** 5745352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Retrieve the source location of the given diagnostic. 5755352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 5765352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * This location is where Clang would print the caret ('^') when 5775352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * displaying the diagnostic on the command line. 5785352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 5795352ac06d8f6194825bb2a99ffa009b61bafb503Douglas GregorCINDEX_LINKAGE CXSourceLocation clang_getDiagnosticLocation(CXDiagnostic); 5805352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 5815352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/** 5825352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Retrieve the text of the given diagnostic. 5835352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 5845352ac06d8f6194825bb2a99ffa009b61bafb503Douglas GregorCINDEX_LINKAGE CXString clang_getDiagnosticSpelling(CXDiagnostic); 585a3890baf1256ff26081306c7fef70202f8223f41Douglas Gregor 586a3890baf1256ff26081306c7fef70202f8223f41Douglas Gregor/** 587aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor * \brief Retrieve the name of the command-line option that enabled this 588aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor * diagnostic. 589aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor * 590aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor * \param Diag The diagnostic to be queried. 591aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor * 592aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor * \param Disable If non-NULL, will be set to the option that disables this 593aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor * diagnostic (if any). 594aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor * 595aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor * \returns A string that contains the command-line option used to enable this 596aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor * warning, such as "-Wconversion" or "-pedantic". 597aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor */ 598aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas GregorCINDEX_LINKAGE CXString clang_getDiagnosticOption(CXDiagnostic Diag, 599aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor CXString *Disable); 600aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor 601aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor/** 602aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor * \brief Retrieve the category number for this diagnostic. 603aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor * 604aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor * Diagnostics can be categorized into groups along with other, related 605aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor * diagnostics (e.g., diagnostics under the same warning flag). This routine 606aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor * retrieves the category number for the given diagnostic. 607aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor * 608aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor * \returns The number of the category that contains this diagnostic, or zero 609aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor * if this diagnostic is uncategorized. 610aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor */ 611aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas GregorCINDEX_LINKAGE unsigned clang_getDiagnosticCategory(CXDiagnostic); 612aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor 613aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor/** 614aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor * \brief Retrieve the name of a particular diagnostic category. 615aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor * 616aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor * \param Category A diagnostic category number, as returned by 617aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor * \c clang_getDiagnosticCategory(). 618aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor * 619aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor * \returns The name of the given diagnostic category. 620aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor */ 621aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas GregorCINDEX_LINKAGE CXString clang_getDiagnosticCategoryName(unsigned Category); 622aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor 623aa5f135f8db82b5e5fb1640fd51f8078e0b2d82dDouglas Gregor/** 624a3890baf1256ff26081306c7fef70202f8223f41Douglas Gregor * \brief Determine the number of source ranges associated with the given 625a3890baf1256ff26081306c7fef70202f8223f41Douglas Gregor * diagnostic. 626a3890baf1256ff26081306c7fef70202f8223f41Douglas Gregor */ 627a3890baf1256ff26081306c7fef70202f8223f41Douglas GregorCINDEX_LINKAGE unsigned clang_getDiagnosticNumRanges(CXDiagnostic); 628896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek 6295352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/** 630a3890baf1256ff26081306c7fef70202f8223f41Douglas Gregor * \brief Retrieve a source range associated with the diagnostic. 6315352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 632a3890baf1256ff26081306c7fef70202f8223f41Douglas Gregor * A diagnostic's source ranges highlight important elements in the source 6335352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * code. On the command line, Clang displays source ranges by 634896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek * underlining them with '~' characters. 6355352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 636a3890baf1256ff26081306c7fef70202f8223f41Douglas Gregor * \param Diagnostic the diagnostic whose range is being extracted. 6375352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 638896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek * \param Range the zero-based index specifying which range to 6395352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 640a3890baf1256ff26081306c7fef70202f8223f41Douglas Gregor * \returns the requested source range. 6415352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 642896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE CXSourceRange clang_getDiagnosticRange(CXDiagnostic Diagnostic, 643a3890baf1256ff26081306c7fef70202f8223f41Douglas Gregor unsigned Range); 6445352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 6455352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/** 6465352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Determine the number of fix-it hints associated with the 6475352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * given diagnostic. 6485352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 6495352ac06d8f6194825bb2a99ffa009b61bafb503Douglas GregorCINDEX_LINKAGE unsigned clang_getDiagnosticNumFixIts(CXDiagnostic Diagnostic); 6505352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 6515352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/** 652473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * \brief Retrieve the replacement information for a given fix-it. 6535352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 654473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * Fix-its are described in terms of a source range whose contents 655473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * should be replaced by a string. This approach generalizes over 656473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * three kinds of operations: removal of source code (the range covers 657473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * the code to be removed and the replacement string is empty), 658473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * replacement of source code (the range covers the code to be 659473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * replaced and the replacement string provides the new code), and 660473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * insertion (both the start and end of the range point at the 661473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * insertion location, and the replacement string provides the text to 662473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * insert). 6635352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 664473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * \param Diagnostic The diagnostic whose fix-its are being queried. 6655352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 666473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * \param FixIt The zero-based index of the fix-it. 6675352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 668473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * \param ReplacementRange The source range whose contents will be 669473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * replaced with the returned replacement string. Note that source 670473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * ranges are half-open ranges [a, b), so the source code should be 671473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * replaced from a and up to (but not including) b. 6725352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 673473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * \returns A string containing text that should be replace the source 674473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * code indicated by the \c ReplacementRange. 6755352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 676896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE CXString clang_getDiagnosticFixIt(CXDiagnostic Diagnostic, 677473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor unsigned FixIt, 678473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor CXSourceRange *ReplacementRange); 6795352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 6805352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/** 6815352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * @} 6825352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 6835352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 6845352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/** 6855352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation 6865352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 6875352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * The routines in this group provide the ability to create and destroy 6885352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * translation units from files, either by parsing the contents of the files or 6895352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * by reading in a serialized representation of a translation unit. 6905352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 6915352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * @{ 6925352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 693896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek 6945352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/** 6955352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Get the original translation unit source file name. 6965352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 6975352ac06d8f6194825bb2a99ffa009b61bafb503Douglas GregorCINDEX_LINKAGE CXString 6985352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregorclang_getTranslationUnitSpelling(CXTranslationUnit CTUnit); 6995352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 7005352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/** 7015352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Return the CXTranslationUnit for a given source file and the provided 7025352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * command line arguments one would pass to the compiler. 7035352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 7045352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * Note: The 'source_filename' argument is optional. If the caller provides a 7055352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * NULL pointer, the name of the source file is expected to reside in the 7065352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * specified command line arguments. 7075352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 7085352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * Note: When encountered in 'clang_command_line_args', the following options 7095352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * are ignored: 7105352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 7115352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * '-c' 7125352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * '-emit-ast' 7135352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * '-fsyntax-only' 7145352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * '-o <output file>' (both '-o' and '<output file>' are ignored) 7155352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 7161ddb02cabd4374bcbe9afdff5123be0be8e32d12Ted Kremenek * \param CIdx The index object with which the translation unit will be 7171ddb02cabd4374bcbe9afdff5123be0be8e32d12Ted Kremenek * associated. 7185352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 7195352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \param source_filename - The name of the source file to load, or NULL if the 7201ddb02cabd4374bcbe9afdff5123be0be8e32d12Ted Kremenek * source file is included in \p clang_command_line_args. 7211ddb02cabd4374bcbe9afdff5123be0be8e32d12Ted Kremenek * 7221ddb02cabd4374bcbe9afdff5123be0be8e32d12Ted Kremenek * \param num_clang_command_line_args The number of command-line arguments in 7231ddb02cabd4374bcbe9afdff5123be0be8e32d12Ted Kremenek * \p clang_command_line_args. 7241ddb02cabd4374bcbe9afdff5123be0be8e32d12Ted Kremenek * 7251ddb02cabd4374bcbe9afdff5123be0be8e32d12Ted Kremenek * \param clang_command_line_args The command-line arguments that would be 7261ddb02cabd4374bcbe9afdff5123be0be8e32d12Ted Kremenek * passed to the \c clang executable if it were being invoked out-of-process. 7271ddb02cabd4374bcbe9afdff5123be0be8e32d12Ted Kremenek * These command-line options will be parsed and will affect how the translation 7281ddb02cabd4374bcbe9afdff5123be0be8e32d12Ted Kremenek * unit is parsed. Note that the following options are ignored: '-c', 7291ddb02cabd4374bcbe9afdff5123be0be8e32d12Ted Kremenek * '-emit-ast', '-fsyntex-only' (which is the default), and '-o <output file>'. 7305352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 7315352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \param num_unsaved_files the number of unsaved file entries in \p 7325352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * unsaved_files. 7335352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * 7345352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \param unsaved_files the files that have not yet been saved to disk 7355352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * but may be required for code completion, including the contents of 736c6f530defd937faa1c00998e60deea6368526961Ted Kremenek * those files. The contents and name of these files (as specified by 737c6f530defd937faa1c00998e60deea6368526961Ted Kremenek * CXUnsavedFile) are copied when necessary, so the client only needs to 738c6f530defd937faa1c00998e60deea6368526961Ted Kremenek * guarantee their validity until the call to this function returns. 7395352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 7405352ac06d8f6194825bb2a99ffa009b61bafb503Douglas GregorCINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnitFromSourceFile( 7415352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor CXIndex CIdx, 7425352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor const char *source_filename, 7435352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor int num_clang_command_line_args, 7442ef6944d529c94824f5bf96f65665f5bee30f5a2Douglas Gregor const char * const *clang_command_line_args, 7455352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor unsigned num_unsaved_files, 746a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor struct CXUnsavedFile *unsaved_files); 747896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek 7485352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/** 7495352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Create a translation unit from an AST file (-emit-ast). 7505352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 751896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnit(CXIndex, 752a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor const char *ast_filename); 7535352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor 75444c181aec37789f25f6c15543c164416f72e562aDouglas Gregor/** 75544c181aec37789f25f6c15543c164416f72e562aDouglas Gregor * \brief Flags that control the creation of translation units. 75644c181aec37789f25f6c15543c164416f72e562aDouglas Gregor * 75744c181aec37789f25f6c15543c164416f72e562aDouglas Gregor * The enumerators in this enumeration type are meant to be bitwise 75844c181aec37789f25f6c15543c164416f72e562aDouglas Gregor * ORed together to specify which options should be used when 75944c181aec37789f25f6c15543c164416f72e562aDouglas Gregor * constructing the translation unit. 76044c181aec37789f25f6c15543c164416f72e562aDouglas Gregor */ 7615a43021ac491bf091494167127772a20d9a9bb48Douglas Gregorenum CXTranslationUnit_Flags { 7625a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor /** 7635a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * \brief Used to indicate that no special translation-unit options are 7645a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * needed. 7655a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor */ 7665a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor CXTranslationUnit_None = 0x0, 7675a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor 7685a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor /** 7695a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * \brief Used to indicate that the parser should construct a "detailed" 7705a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * preprocessing record, including all macro definitions and instantiations. 7715a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * 7725a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * Constructing a detailed preprocessing record requires more memory 7735a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * and time to parse, since the information contained in the record 7745a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * is usually not retained. However, it can be useful for 7755a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * applications that require more detailed information about the 7765a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * behavior of the preprocessor. 7775a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor */ 77844c181aec37789f25f6c15543c164416f72e562aDouglas Gregor CXTranslationUnit_DetailedPreprocessingRecord = 0x01, 77944c181aec37789f25f6c15543c164416f72e562aDouglas Gregor 78044c181aec37789f25f6c15543c164416f72e562aDouglas Gregor /** 781b1c031be513705d924038f497279b9b599868ba1Douglas Gregor * \brief Used to indicate that the translation unit is incomplete. 78244c181aec37789f25f6c15543c164416f72e562aDouglas Gregor * 783b1c031be513705d924038f497279b9b599868ba1Douglas Gregor * When a translation unit is considered "incomplete", semantic 784b1c031be513705d924038f497279b9b599868ba1Douglas Gregor * analysis that is typically performed at the end of the 785b1c031be513705d924038f497279b9b599868ba1Douglas Gregor * translation unit will be suppressed. For example, this suppresses 786b1c031be513705d924038f497279b9b599868ba1Douglas Gregor * the completion of tentative declarations in C and of 787b1c031be513705d924038f497279b9b599868ba1Douglas Gregor * instantiation of implicitly-instantiation function templates in 788b1c031be513705d924038f497279b9b599868ba1Douglas Gregor * C++. This option is typically used when parsing a header with the 789b1c031be513705d924038f497279b9b599868ba1Douglas Gregor * intent of producing a precompiled header. 79044c181aec37789f25f6c15543c164416f72e562aDouglas Gregor */ 791b1c031be513705d924038f497279b9b599868ba1Douglas Gregor CXTranslationUnit_Incomplete = 0x02, 79244c181aec37789f25f6c15543c164416f72e562aDouglas Gregor 79344c181aec37789f25f6c15543c164416f72e562aDouglas Gregor /** 79444c181aec37789f25f6c15543c164416f72e562aDouglas Gregor * \brief Used to indicate that the translation unit should be built with an 79544c181aec37789f25f6c15543c164416f72e562aDouglas Gregor * implicit precompiled header for the preamble. 79644c181aec37789f25f6c15543c164416f72e562aDouglas Gregor * 79744c181aec37789f25f6c15543c164416f72e562aDouglas Gregor * An implicit precompiled header is used as an optimization when a 79844c181aec37789f25f6c15543c164416f72e562aDouglas Gregor * particular translation unit is likely to be reparsed many times 79944c181aec37789f25f6c15543c164416f72e562aDouglas Gregor * when the sources aren't changing that often. In this case, an 80044c181aec37789f25f6c15543c164416f72e562aDouglas Gregor * implicit precompiled header will be built containing all of the 80144c181aec37789f25f6c15543c164416f72e562aDouglas Gregor * initial includes at the top of the main file (what we refer to as 80244c181aec37789f25f6c15543c164416f72e562aDouglas Gregor * the "preamble" of the file). In subsequent parses, if the 80344c181aec37789f25f6c15543c164416f72e562aDouglas Gregor * preamble or the files in it have not changed, \c 80444c181aec37789f25f6c15543c164416f72e562aDouglas Gregor * clang_reparseTranslationUnit() will re-use the implicit 80544c181aec37789f25f6c15543c164416f72e562aDouglas Gregor * precompiled header to improve parsing performance. 80644c181aec37789f25f6c15543c164416f72e562aDouglas Gregor */ 807e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor CXTranslationUnit_PrecompiledPreamble = 0x04, 808e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor 809e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor /** 810e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * \brief Used to indicate that the translation unit should cache some 811e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * code-completion results with each reparse of the source file. 812e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * 813e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * Caching of code-completion results is a performance optimization that 814e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * introduces some overhead to reparsing but improves the performance of 815e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * code-completion operations. 816e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor */ 81799ba202f659e1885fa5ee114f97c97cf6a857491Douglas Gregor CXTranslationUnit_CacheCompletionResults = 0x08, 81899ba202f659e1885fa5ee114f97c97cf6a857491Douglas Gregor /** 81999ba202f659e1885fa5ee114f97c97cf6a857491Douglas Gregor * \brief Enable precompiled preambles in C++. 82099ba202f659e1885fa5ee114f97c97cf6a857491Douglas Gregor * 82199ba202f659e1885fa5ee114f97c97cf6a857491Douglas Gregor * Note: this is a *temporary* option that is available only while 82299ba202f659e1885fa5ee114f97c97cf6a857491Douglas Gregor * we are testing C++ precompiled preamble support. 82399ba202f659e1885fa5ee114f97c97cf6a857491Douglas Gregor */ 82499ba202f659e1885fa5ee114f97c97cf6a857491Douglas Gregor CXTranslationUnit_CXXPrecompiledPreamble = 0x10, 82599ba202f659e1885fa5ee114f97c97cf6a857491Douglas Gregor 82699ba202f659e1885fa5ee114f97c97cf6a857491Douglas Gregor /** 82799ba202f659e1885fa5ee114f97c97cf6a857491Douglas Gregor * \brief Enabled chained precompiled preambles in C++. 82899ba202f659e1885fa5ee114f97c97cf6a857491Douglas Gregor * 82999ba202f659e1885fa5ee114f97c97cf6a857491Douglas Gregor * Note: this is a *temporary* option that is available only while 83099ba202f659e1885fa5ee114f97c97cf6a857491Douglas Gregor * we are testing C++ precompiled preamble support. 83199ba202f659e1885fa5ee114f97c97cf6a857491Douglas Gregor */ 83299ba202f659e1885fa5ee114f97c97cf6a857491Douglas Gregor CXTranslationUnit_CXXChainedPCH = 0x20 8335a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor}; 8345a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor 8355a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor/** 836b1c031be513705d924038f497279b9b599868ba1Douglas Gregor * \brief Returns the set of flags that is suitable for parsing a translation 837b1c031be513705d924038f497279b9b599868ba1Douglas Gregor * unit that is being edited. 838b1c031be513705d924038f497279b9b599868ba1Douglas Gregor * 839b1c031be513705d924038f497279b9b599868ba1Douglas Gregor * The set of flags returned provide options for \c clang_parseTranslationUnit() 840b1c031be513705d924038f497279b9b599868ba1Douglas Gregor * to indicate that the translation unit is likely to be reparsed many times, 841b1c031be513705d924038f497279b9b599868ba1Douglas Gregor * either explicitly (via \c clang_reparseTranslationUnit()) or implicitly 842b1c031be513705d924038f497279b9b599868ba1Douglas Gregor * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag 843b1c031be513705d924038f497279b9b599868ba1Douglas Gregor * set contains an unspecified set of optimizations (e.g., the precompiled 844b1c031be513705d924038f497279b9b599868ba1Douglas Gregor * preamble) geared toward improving the performance of these routines. The 845b1c031be513705d924038f497279b9b599868ba1Douglas Gregor * set of optimizations enabled may change from one version to the next. 846b1c031be513705d924038f497279b9b599868ba1Douglas Gregor */ 847e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas GregorCINDEX_LINKAGE unsigned clang_defaultEditingTranslationUnitOptions(void); 848b1c031be513705d924038f497279b9b599868ba1Douglas Gregor 849b1c031be513705d924038f497279b9b599868ba1Douglas Gregor/** 8505a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * \brief Parse the given source file and the translation unit corresponding 8515a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * to that file. 8525a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * 8535a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * This routine is the main entry point for the Clang C API, providing the 8545a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * ability to parse a source file into a translation unit that can then be 8555a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * queried by other functions in the API. This routine accepts a set of 8565a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * command-line arguments so that the compilation can be configured in the same 8575a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * way that the compiler is configured on the command line. 8585a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * 8595a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * \param CIdx The index object with which the translation unit will be 8605a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * associated. 8615a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * 8625a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * \param source_filename The name of the source file to load, or NULL if the 8631ddb02cabd4374bcbe9afdff5123be0be8e32d12Ted Kremenek * source file is included in \p command_line_args. 8645a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * 8655a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * \param command_line_args The command-line arguments that would be 8665a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * passed to the \c clang executable if it were being invoked out-of-process. 8675a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * These command-line options will be parsed and will affect how the translation 8685a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * unit is parsed. Note that the following options are ignored: '-c', 8695a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * '-emit-ast', '-fsyntex-only' (which is the default), and '-o <output file>'. 8705a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * 8715a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * \param num_command_line_args The number of command-line arguments in 8725a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * \p command_line_args. 8735a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * 8745a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * \param unsaved_files the files that have not yet been saved to disk 8751abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * but may be required for parsing, including the contents of 8765a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * those files. The contents and name of these files (as specified by 8775a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * CXUnsavedFile) are copied when necessary, so the client only needs to 8785a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * guarantee their validity until the call to this function returns. 8795a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * 8805a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * \param num_unsaved_files the number of unsaved file entries in \p 8815a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * unsaved_files. 8825a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * 8835a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * \param options A bitmask of options that affects how the translation unit 8845a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * is managed but not its compilation. This should be a bitwise OR of the 8855a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * CXTranslationUnit_XXX flags. 8865a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * 8875a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * \returns A new translation unit describing the parsed code and containing 8885a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * any diagnostics produced by the compiler. If there is a failure from which 8895a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * the compiler cannot recover, returns NULL. 8905a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor */ 8915a43021ac491bf091494167127772a20d9a9bb48Douglas GregorCINDEX_LINKAGE CXTranslationUnit clang_parseTranslationUnit(CXIndex CIdx, 8925a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor const char *source_filename, 8932ef6944d529c94824f5bf96f65665f5bee30f5a2Douglas Gregor const char * const *command_line_args, 8945a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor int num_command_line_args, 8955a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor struct CXUnsavedFile *unsaved_files, 8965a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor unsigned num_unsaved_files, 8975a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor unsigned options); 8985a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor 8995352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/** 9001999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * \brief Flags that control how translation units are saved. 9011999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * 9021999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * The enumerators in this enumeration type are meant to be bitwise 9031999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * ORed together to specify which options should be used when 9041999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * saving the translation unit. 9051999844e7a18786e61e619e1dc6c789827541863Douglas Gregor */ 9061999844e7a18786e61e619e1dc6c789827541863Douglas Gregorenum CXSaveTranslationUnit_Flags { 9071999844e7a18786e61e619e1dc6c789827541863Douglas Gregor /** 9081999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * \brief Used to indicate that no special saving options are needed. 9091999844e7a18786e61e619e1dc6c789827541863Douglas Gregor */ 9101999844e7a18786e61e619e1dc6c789827541863Douglas Gregor CXSaveTranslationUnit_None = 0x0 9111999844e7a18786e61e619e1dc6c789827541863Douglas Gregor}; 9121999844e7a18786e61e619e1dc6c789827541863Douglas Gregor 9131999844e7a18786e61e619e1dc6c789827541863Douglas Gregor/** 9141999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * \brief Returns the set of flags that is suitable for saving a translation 9151999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * unit. 9161999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * 9171999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * The set of flags returned provide options for 9181999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * \c clang_saveTranslationUnit() by default. The returned flag 9191999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * set contains an unspecified set of options that save translation units with 9201999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * the most commonly-requested data. 9211999844e7a18786e61e619e1dc6c789827541863Douglas Gregor */ 9221999844e7a18786e61e619e1dc6c789827541863Douglas GregorCINDEX_LINKAGE unsigned clang_defaultSaveOptions(CXTranslationUnit TU); 9231999844e7a18786e61e619e1dc6c789827541863Douglas Gregor 9241999844e7a18786e61e619e1dc6c789827541863Douglas Gregor/** 9257ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor * \brief Saves a translation unit into a serialized representation of 9267ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor * that translation unit on disk. 9277ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor * 9287ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor * Any translation unit that was parsed without error can be saved 9297ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor * into a file. The translation unit can then be deserialized into a 9307ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor * new \c CXTranslationUnit with \c clang_createTranslationUnit() or, 9317ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor * if it is an incomplete translation unit that corresponds to a 9327ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor * header, used as a precompiled header when parsing other translation 9337ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor * units. 9347ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor * 9357ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor * \param TU The translation unit to save. 9361999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * 9377ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor * \param FileName The file to which the translation unit will be saved. 9387ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor * 9391999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * \param options A bitmask of options that affects how the translation unit 9401999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * is saved. This should be a bitwise OR of the 9411999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * CXSaveTranslationUnit_XXX flags. 9421999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * 9437ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor * \returns Zero if the translation unit was saved successfully, a 9447ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor * non-zero value otherwise. 9457ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor */ 9467ae2faafd30524ef5f863bb3b8701977888839bbDouglas GregorCINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU, 9471999844e7a18786e61e619e1dc6c789827541863Douglas Gregor const char *FileName, 9481999844e7a18786e61e619e1dc6c789827541863Douglas Gregor unsigned options); 9497ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor 9507ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor/** 9515352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Destroy the specified CXTranslationUnit object. 9525352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 9535352ac06d8f6194825bb2a99ffa009b61bafb503Douglas GregorCINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit); 954896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek 9555352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/** 956e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * \brief Flags that control the reparsing of translation units. 957e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * 958e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * The enumerators in this enumeration type are meant to be bitwise 959e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * ORed together to specify which options should be used when 960e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * reparsing the translation unit. 961e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor */ 962e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregorenum CXReparse_Flags { 963e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor /** 964e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * \brief Used to indicate that no special reparsing options are needed. 965e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor */ 966e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor CXReparse_None = 0x0 967e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor}; 968e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor 969e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor/** 970e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * \brief Returns the set of flags that is suitable for reparsing a translation 971e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * unit. 972e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * 973e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * The set of flags returned provide options for 974e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * \c clang_reparseTranslationUnit() by default. The returned flag 975e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * set contains an unspecified set of optimizations geared toward common uses 976e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * of reparsing. The set of optimizations enabled may change from one version 977e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * to the next. 978e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor */ 979e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas GregorCINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU); 980e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor 981e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor/** 982abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * \brief Reparse the source files that produced this translation unit. 983abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * 984abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * This routine can be used to re-parse the source files that originally 985abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * created the given translation unit, for example because those source files 986abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * have changed (either on disk or as passed via \p unsaved_files). The 987abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * source code will be reparsed with the same command-line options as it 988abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * was originally parsed. 989abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * 990abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * Reparsing a translation unit invalidates all cursors and source locations 991abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * that refer into that translation unit. This makes reparsing a translation 992abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * unit semantically equivalent to destroying the translation unit and then 993abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * creating a new translation unit with the same command-line arguments. 994abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * However, it may be more efficient to reparse a translation 995abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * unit using this routine. 996abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * 997abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * \param TU The translation unit whose contents will be re-parsed. The 998abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * translation unit must originally have been built with 999abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * \c clang_createTranslationUnitFromSourceFile(). 1000abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * 1001abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * \param num_unsaved_files The number of unsaved file entries in \p 1002abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * unsaved_files. 1003abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * 1004abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * \param unsaved_files The files that have not yet been saved to disk 1005abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * but may be required for parsing, including the contents of 1006abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * those files. The contents and name of these files (as specified by 1007abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * CXUnsavedFile) are copied when necessary, so the client only needs to 1008abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * guarantee their validity until the call to this function returns. 1009abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * 1010e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * \param options A bitset of options composed of the flags in CXReparse_Flags. 1011e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * The function \c clang_defaultReparseOptions() produces a default set of 1012e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * options recommended for most uses, based on the translation unit. 1013e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * 1014abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * \returns 0 if the sources could be reparsed. A non-zero value will be 1015abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * returned if reparsing was impossible, such that the translation unit is 1016abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * invalid. In such cases, the only valid call for \p TU is 1017abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * \c clang_disposeTranslationUnit(TU). 1018abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor */ 1019abc563f554951259bbe0315055cad92ee14d87e4Douglas GregorCINDEX_LINKAGE int clang_reparseTranslationUnit(CXTranslationUnit TU, 1020abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor unsigned num_unsaved_files, 1021e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor struct CXUnsavedFile *unsaved_files, 1022e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor unsigned options); 102359fc1e55da9c856d1703d3d3ac14a36320d26b30Ted Kremenek 102459fc1e55da9c856d1703d3d3ac14a36320d26b30Ted Kremenek/** 102559fc1e55da9c856d1703d3d3ac14a36320d26b30Ted Kremenek * \brief Categorizes how memory is being used by a translation unit. 102659fc1e55da9c856d1703d3d3ac14a36320d26b30Ted Kremenek */ 1027f787002478f09af1741fb0f82a562002e6799c49Ted Kremenekenum CXTUResourceUsageKind { 1028f787002478f09af1741fb0f82a562002e6799c49Ted Kremenek CXTUResourceUsage_AST = 1, 1029f787002478f09af1741fb0f82a562002e6799c49Ted Kremenek CXTUResourceUsage_Identifiers = 2, 1030f787002478f09af1741fb0f82a562002e6799c49Ted Kremenek CXTUResourceUsage_Selectors = 3, 1031f787002478f09af1741fb0f82a562002e6799c49Ted Kremenek CXTUResourceUsage_GlobalCompletionResults = 4, 1032457aaf0692dfb2d9638f383334b81027f637f20cTed Kremenek CXTUResourceUsage_SourceManagerContentCache = 5, 1033ba29bd25515fbd99e98ba0fedb9d93617b27609eTed Kremenek CXTUResourceUsage_AST_SideTables = 6, 1034f61b831d7f6a15676b07647f507de80324cb7056Ted Kremenek CXTUResourceUsage_SourceManager_Membuffer_Malloc = 7, 1035e9b5f3d4acfc2ad6e8b65a4072464e997dea9ed3Ted Kremenek CXTUResourceUsage_SourceManager_Membuffer_MMap = 8, 1036e9b5f3d4acfc2ad6e8b65a4072464e997dea9ed3Ted Kremenek CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc = 9, 1037e9b5f3d4acfc2ad6e8b65a4072464e997dea9ed3Ted Kremenek CXTUResourceUsage_ExternalASTSource_Membuffer_MMap = 10, 1038f787002478f09af1741fb0f82a562002e6799c49Ted Kremenek CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST, 1039f787002478f09af1741fb0f82a562002e6799c49Ted Kremenek CXTUResourceUsage_MEMORY_IN_BYTES_END = 1040e9b5f3d4acfc2ad6e8b65a4072464e997dea9ed3Ted Kremenek CXTUResourceUsage_ExternalASTSource_Membuffer_MMap, 1041f787002478f09af1741fb0f82a562002e6799c49Ted Kremenek 1042f787002478f09af1741fb0f82a562002e6799c49Ted Kremenek CXTUResourceUsage_First = CXTUResourceUsage_AST, 1043e9b5f3d4acfc2ad6e8b65a4072464e997dea9ed3Ted Kremenek CXTUResourceUsage_Last = CXTUResourceUsage_ExternalASTSource_Membuffer_MMap 104459fc1e55da9c856d1703d3d3ac14a36320d26b30Ted Kremenek}; 104559fc1e55da9c856d1703d3d3ac14a36320d26b30Ted Kremenek 104659fc1e55da9c856d1703d3d3ac14a36320d26b30Ted Kremenek/** 104759fc1e55da9c856d1703d3d3ac14a36320d26b30Ted Kremenek * \brief Returns the human-readable null-terminated C string that represents 1048f787002478f09af1741fb0f82a562002e6799c49Ted Kremenek * the name of the memory category. This string should never be freed. 104959fc1e55da9c856d1703d3d3ac14a36320d26b30Ted Kremenek */ 105059fc1e55da9c856d1703d3d3ac14a36320d26b30Ted KremenekCINDEX_LINKAGE 1051f787002478f09af1741fb0f82a562002e6799c49Ted Kremenekconst char *clang_getTUResourceUsageName(enum CXTUResourceUsageKind kind); 105259fc1e55da9c856d1703d3d3ac14a36320d26b30Ted Kremenek 1053f787002478f09af1741fb0f82a562002e6799c49Ted Kremenektypedef struct CXTUResourceUsageEntry { 105459fc1e55da9c856d1703d3d3ac14a36320d26b30Ted Kremenek /* \brief The memory usage category. */ 1055f787002478f09af1741fb0f82a562002e6799c49Ted Kremenek enum CXTUResourceUsageKind kind; 1056f787002478f09af1741fb0f82a562002e6799c49Ted Kremenek /* \brief Amount of resources used. 1057f787002478f09af1741fb0f82a562002e6799c49Ted Kremenek The units will depend on the resource kind. */ 105859fc1e55da9c856d1703d3d3ac14a36320d26b30Ted Kremenek unsigned long amount; 1059f787002478f09af1741fb0f82a562002e6799c49Ted Kremenek} CXTUResourceUsageEntry; 106059fc1e55da9c856d1703d3d3ac14a36320d26b30Ted Kremenek 106159fc1e55da9c856d1703d3d3ac14a36320d26b30Ted Kremenek/** 106259fc1e55da9c856d1703d3d3ac14a36320d26b30Ted Kremenek * \brief The memory usage of a CXTranslationUnit, broken into categories. 106359fc1e55da9c856d1703d3d3ac14a36320d26b30Ted Kremenek */ 1064f787002478f09af1741fb0f82a562002e6799c49Ted Kremenektypedef struct CXTUResourceUsage { 106559fc1e55da9c856d1703d3d3ac14a36320d26b30Ted Kremenek /* \brief Private data member, used for queries. */ 106659fc1e55da9c856d1703d3d3ac14a36320d26b30Ted Kremenek void *data; 106759fc1e55da9c856d1703d3d3ac14a36320d26b30Ted Kremenek 106859fc1e55da9c856d1703d3d3ac14a36320d26b30Ted Kremenek /* \brief The number of entries in the 'entries' array. */ 106959fc1e55da9c856d1703d3d3ac14a36320d26b30Ted Kremenek unsigned numEntries; 107059fc1e55da9c856d1703d3d3ac14a36320d26b30Ted Kremenek 107159fc1e55da9c856d1703d3d3ac14a36320d26b30Ted Kremenek /* \brief An array of key-value pairs, representing the breakdown of memory 107259fc1e55da9c856d1703d3d3ac14a36320d26b30Ted Kremenek usage. */ 1073f787002478f09af1741fb0f82a562002e6799c49Ted Kremenek CXTUResourceUsageEntry *entries; 107459fc1e55da9c856d1703d3d3ac14a36320d26b30Ted Kremenek 1075f787002478f09af1741fb0f82a562002e6799c49Ted Kremenek} CXTUResourceUsage; 107659fc1e55da9c856d1703d3d3ac14a36320d26b30Ted Kremenek 107759fc1e55da9c856d1703d3d3ac14a36320d26b30Ted Kremenek/** 107859fc1e55da9c856d1703d3d3ac14a36320d26b30Ted Kremenek * \brief Return the memory usage of a translation unit. This object 1079f787002478f09af1741fb0f82a562002e6799c49Ted Kremenek * should be released with clang_disposeCXTUResourceUsage(). 108059fc1e55da9c856d1703d3d3ac14a36320d26b30Ted Kremenek */ 1081f787002478f09af1741fb0f82a562002e6799c49Ted KremenekCINDEX_LINKAGE CXTUResourceUsage clang_getCXTUResourceUsage(CXTranslationUnit TU); 108259fc1e55da9c856d1703d3d3ac14a36320d26b30Ted Kremenek 1083f787002478f09af1741fb0f82a562002e6799c49Ted KremenekCINDEX_LINKAGE void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage); 108459fc1e55da9c856d1703d3d3ac14a36320d26b30Ted Kremenek 1085abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor/** 10865352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * @} 10875352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */ 1088896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek 10895352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/** 1090c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Describes the kind of entity that a cursor refers to. 1091c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 1092c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregorenum CXCursorKind { 1093c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /* Declarations */ 10941efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar /** 1095c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief A declaration whose specific kind is not exposed via this 10961efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * interface. 1097c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 1098c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * Unexposed declarations have the same operations as any other kind 1099c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * of declaration; one can extract their location information, 1100c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * spelling, find their definitions, etc. However, the specific kind 1101c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * of the declaration is not reported. 1102c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 1103c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_UnexposedDecl = 1, 1104c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** \brief A C or C++ struct. */ 11051efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar CXCursor_StructDecl = 2, 1106c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** \brief A C or C++ union. */ 1107c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_UnionDecl = 3, 1108c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** \brief A C++ class. */ 1109c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_ClassDecl = 4, 1110c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** \brief An enumeration. */ 1111c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_EnumDecl = 5, 11121efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar /** 1113c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief A field (in C) or non-static data member (in C++) in a 1114c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * struct, union, or C++ class. 1115c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 1116c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_FieldDecl = 6, 1117c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** \brief An enumerator constant. */ 1118c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_EnumConstantDecl = 7, 1119c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** \brief A function. */ 1120c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_FunctionDecl = 8, 1121c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** \brief A variable. */ 1122c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_VarDecl = 9, 1123c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** \brief A function or method parameter. */ 1124c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_ParmDecl = 10, 1125c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** \brief An Objective-C @interface. */ 1126c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_ObjCInterfaceDecl = 11, 1127c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** \brief An Objective-C @interface for a category. */ 1128c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_ObjCCategoryDecl = 12, 1129c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** \brief An Objective-C @protocol declaration. */ 1130c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_ObjCProtocolDecl = 13, 1131c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** \brief An Objective-C @property declaration. */ 1132c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_ObjCPropertyDecl = 14, 1133c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** \brief An Objective-C instance variable. */ 1134c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_ObjCIvarDecl = 15, 1135c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** \brief An Objective-C instance method. */ 1136c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_ObjCInstanceMethodDecl = 16, 1137c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** \brief An Objective-C class method. */ 1138c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_ObjCClassMethodDecl = 17, 1139c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** \brief An Objective-C @implementation. */ 1140c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_ObjCImplementationDecl = 18, 1141c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** \brief An Objective-C @implementation for a category. */ 1142c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_ObjCCategoryImplDecl = 19, 1143c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** \brief A typedef */ 1144c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_TypedefDecl = 20, 11458bd5a69999cfd06b6b5a58fdd04e4f802b2df5a4Ted Kremenek /** \brief A C++ class method. */ 11468bd5a69999cfd06b6b5a58fdd04e4f802b2df5a4Ted Kremenek CXCursor_CXXMethod = 21, 11478f06e0e9fec3ca501e5fb129f413adbfc88e82f8Ted Kremenek /** \brief A C++ namespace. */ 11488f06e0e9fec3ca501e5fb129f413adbfc88e82f8Ted Kremenek CXCursor_Namespace = 22, 1149a0536d8dd900bb48ea886bd68d777b03b061c068Ted Kremenek /** \brief A linkage specification, e.g. 'extern "C"'. */ 1150a0536d8dd900bb48ea886bd68d777b03b061c068Ted Kremenek CXCursor_LinkageSpec = 23, 115101829d3afafdfd355cbe93537bc408aeeed964c6Douglas Gregor /** \brief A C++ constructor. */ 115201829d3afafdfd355cbe93537bc408aeeed964c6Douglas Gregor CXCursor_Constructor = 24, 115301829d3afafdfd355cbe93537bc408aeeed964c6Douglas Gregor /** \brief A C++ destructor. */ 115401829d3afafdfd355cbe93537bc408aeeed964c6Douglas Gregor CXCursor_Destructor = 25, 115501829d3afafdfd355cbe93537bc408aeeed964c6Douglas Gregor /** \brief A C++ conversion function. */ 115601829d3afafdfd355cbe93537bc408aeeed964c6Douglas Gregor CXCursor_ConversionFunction = 26, 1157fe72e9ceeae6cc8669cd8bb722425300190638eaDouglas Gregor /** \brief A C++ template type parameter. */ 1158fe72e9ceeae6cc8669cd8bb722425300190638eaDouglas Gregor CXCursor_TemplateTypeParameter = 27, 1159fe72e9ceeae6cc8669cd8bb722425300190638eaDouglas Gregor /** \brief A C++ non-type template parameter. */ 1160fe72e9ceeae6cc8669cd8bb722425300190638eaDouglas Gregor CXCursor_NonTypeTemplateParameter = 28, 1161fe72e9ceeae6cc8669cd8bb722425300190638eaDouglas Gregor /** \brief A C++ template template parameter. */ 1162fe72e9ceeae6cc8669cd8bb722425300190638eaDouglas Gregor CXCursor_TemplateTemplateParameter = 29, 1163fe72e9ceeae6cc8669cd8bb722425300190638eaDouglas Gregor /** \brief A C++ function template. */ 1164fe72e9ceeae6cc8669cd8bb722425300190638eaDouglas Gregor CXCursor_FunctionTemplate = 30, 116539d6f07b056c31e1e6b5946165ed4b23e7887f22Douglas Gregor /** \brief A C++ class template. */ 116639d6f07b056c31e1e6b5946165ed4b23e7887f22Douglas Gregor CXCursor_ClassTemplate = 31, 116774dbe640021d96a8dbb85c592471c04449ade81cDouglas Gregor /** \brief A C++ class template partial specialization. */ 116874dbe640021d96a8dbb85c592471c04449ade81cDouglas Gregor CXCursor_ClassTemplatePartialSpecialization = 32, 11696931900f43cea558c6974075256c07728dbfecc6Douglas Gregor /** \brief A C++ namespace alias declaration. */ 11706931900f43cea558c6974075256c07728dbfecc6Douglas Gregor CXCursor_NamespaceAlias = 33, 11710a35bceb7768fc0be62cb644a4e31d8bfd9fb44aDouglas Gregor /** \brief A C++ using directive. */ 11720a35bceb7768fc0be62cb644a4e31d8bfd9fb44aDouglas Gregor CXCursor_UsingDirective = 34, 1173162e1c1b487352434552147967c3dd296ebee2f7Richard Smith /** \brief A C++ using declaration. */ 11747e24256c95afb64b4d5abf201a0f9f0527cb4cf3Douglas Gregor CXCursor_UsingDeclaration = 35, 1175162e1c1b487352434552147967c3dd296ebee2f7Richard Smith /** \brief A C++ alias declaration */ 1176162e1c1b487352434552147967c3dd296ebee2f7Richard Smith CXCursor_TypeAliasDecl = 36, 117750aa6acd0b8d40c8956372a69e0a73f0802a5494Ted Kremenek CXCursor_FirstDecl = CXCursor_UnexposedDecl, 1178162e1c1b487352434552147967c3dd296ebee2f7Richard Smith CXCursor_LastDecl = CXCursor_TypeAliasDecl, 11791efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 1180c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /* References */ 1181c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_FirstRef = 40, /* Decl references */ 11821efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar CXCursor_ObjCSuperClassRef = 40, 1183c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_ObjCProtocolRef = 41, 1184c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_ObjCClassRef = 42, 1185c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** 1186c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief A reference to a type declaration. 1187c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 1188c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * A type reference occurs anywhere where a type is named but not 1189c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * declared. For example, given: 1190c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 1191c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \code 1192c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * typedef unsigned size_type; 1193c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * size_type size; 1194c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \endcode 1195c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 1196c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * The typedef is a declaration of size_type (CXCursor_TypedefDecl), 1197c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * while the type of the variable "size" is referenced. The cursor 1198c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * referenced by the type of size is the typedef for size_type. 1199c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 1200c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_TypeRef = 43, 12013064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek CXCursor_CXXBaseSpecifier = 44, 12020b36e614aa19df72885d5e0de996f7fbb9874ec3Douglas Gregor /** 1203a67e03fdf1ae8a1f92463a307d0b6281f1161f40Douglas Gregor * \brief A reference to a class template, function template, template 1204a67e03fdf1ae8a1f92463a307d0b6281f1161f40Douglas Gregor * template parameter, or class template partial specialization. 12050b36e614aa19df72885d5e0de996f7fbb9874ec3Douglas Gregor */ 12060b36e614aa19df72885d5e0de996f7fbb9874ec3Douglas Gregor CXCursor_TemplateRef = 45, 12076931900f43cea558c6974075256c07728dbfecc6Douglas Gregor /** 12086931900f43cea558c6974075256c07728dbfecc6Douglas Gregor * \brief A reference to a namespace or namespace alias. 12096931900f43cea558c6974075256c07728dbfecc6Douglas Gregor */ 12106931900f43cea558c6974075256c07728dbfecc6Douglas Gregor CXCursor_NamespaceRef = 46, 1211a67e03fdf1ae8a1f92463a307d0b6281f1161f40Douglas Gregor /** 121236897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor * \brief A reference to a member of a struct, union, or class that occurs in 121336897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor * some non-expression context, e.g., a designated initializer. 1214a67e03fdf1ae8a1f92463a307d0b6281f1161f40Douglas Gregor */ 1215a67e03fdf1ae8a1f92463a307d0b6281f1161f40Douglas Gregor CXCursor_MemberRef = 47, 121636897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor /** 121736897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor * \brief A reference to a labeled statement. 121836897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor * 121936897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor * This cursor kind is used to describe the jump to "start_over" in the 122036897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor * goto statement in the following example: 122136897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor * 122236897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor * \code 122336897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor * start_over: 122436897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor * ++counter; 122536897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor * 122636897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor * goto start_over; 122736897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor * \endcode 122836897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor * 122936897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor * A label reference cursor refers to a label statement. 123036897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor */ 123136897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor CXCursor_LabelRef = 48, 123236897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor 12331f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor /** 12341f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * \brief A reference to a set of overloaded functions or function templates 12351f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * that has not yet been resolved to a specific function or function template. 12361f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * 12371f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * An overloaded declaration reference cursor occurs in C++ templates where 12381f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * a dependent name refers to a function. For example: 12391f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * 12401f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * \code 12411f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * template<typename T> void swap(T&, T&); 12421f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * 12431f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * struct X { ... }; 12441f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * void swap(X&, X&); 12451f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * 12461f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * template<typename T> 12471f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * void reverse(T* first, T* last) { 12481f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * while (first < last - 1) { 12491f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * swap(*first, *--last); 12501f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * ++first; 12511f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * } 12521f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * } 12531f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * 12541f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * struct Y { }; 12551f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * void swap(Y&, Y&); 12561f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * \endcode 12571f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * 12581f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * Here, the identifier "swap" is associated with an overloaded declaration 12591f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * reference. In the template definition, "swap" refers to either of the two 12601f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * "swap" functions declared above, so both results will be available. At 12611f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * instantiation time, "swap" may also refer to other functions found via 12621f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * argument-dependent lookup (e.g., the "swap" function at the end of the 12631f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * example). 12641f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * 12651f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * The functions \c clang_getNumOverloadedDecls() and 12661f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * \c clang_getOverloadedDecl() can be used to retrieve the definitions 12671f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * referenced by this cursor. 12681f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor */ 12691f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor CXCursor_OverloadedDeclRef = 49, 12701f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor 12711f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor CXCursor_LastRef = CXCursor_OverloadedDeclRef, 12721efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 1273c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /* Error conditions */ 1274c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_FirstInvalid = 70, 1275c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_InvalidFile = 70, 1276c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_NoDeclFound = 71, 1277c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_NotImplemented = 72, 1278ebfa339321f8a4df9d5011e591a615d5765107d5Ted Kremenek CXCursor_InvalidCode = 73, 1279ebfa339321f8a4df9d5011e591a615d5765107d5Ted Kremenek CXCursor_LastInvalid = CXCursor_InvalidCode, 12801efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 1281c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /* Expressions */ 1282c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_FirstExpr = 100, 12831efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 1284c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** 1285c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief An expression whose specific kind is not exposed via this 12861efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * interface. 1287c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 1288c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * Unexposed expressions have the same operations as any other kind 1289c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * of expression; one can extract their location information, 1290c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * spelling, children, etc. However, the specific kind of the 1291c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * expression is not reported. 1292c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 1293c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_UnexposedExpr = 100, 12941efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 1295c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** 1296c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief An expression that refers to some value declaration, such 1297c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * as a function, varible, or enumerator. 1298c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 1299c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_DeclRefExpr = 101, 13001efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 1301c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** 1302c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief An expression that refers to a member of a struct, union, 1303c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * class, Objective-C class, etc. 1304c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 1305c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_MemberRefExpr = 102, 13061efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 1307c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** \brief An expression that calls a function. */ 1308c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_CallExpr = 103, 13091efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 1310c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** \brief An expression that sends a message to an Objective-C 1311c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor object or class. */ 1312c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_ObjCMessageExpr = 104, 13131ee6cad59f017601ea54fbb4f62a6e8d69897e3eTed Kremenek 13141ee6cad59f017601ea54fbb4f62a6e8d69897e3eTed Kremenek /** \brief An expression that represents a block literal. */ 13151ee6cad59f017601ea54fbb4f62a6e8d69897e3eTed Kremenek CXCursor_BlockExpr = 105, 13161ee6cad59f017601ea54fbb4f62a6e8d69897e3eTed Kremenek 13171ee6cad59f017601ea54fbb4f62a6e8d69897e3eTed Kremenek CXCursor_LastExpr = 105, 13181efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 1319c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /* Statements */ 1320c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_FirstStmt = 200, 1321c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** 1322c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief A statement whose specific kind is not exposed via this 1323c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * interface. 1324c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 1325c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * Unexposed statements have the same operations as any other kind of 1326c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * statement; one can extract their location information, spelling, 1327c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * children, etc. However, the specific kind of the statement is not 1328c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * reported. 1329c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 1330c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursor_UnexposedStmt = 200, 133136897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor 133236897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor /** \brief A labelled statement in a function. 133336897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor * 133436897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor * This cursor kind is used to describe the "start_over:" label statement in 133536897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor * the following example: 133636897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor * 133736897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor * \code 133836897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor * start_over: 133936897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor * ++counter; 134036897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor * \endcode 134136897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor * 134236897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor */ 134336897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor CXCursor_LabelStmt = 201, 134436897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor 134536897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor CXCursor_LastStmt = CXCursor_LabelStmt, 13461efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 1347c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** 1348c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Cursor that represents the translation unit itself. 1349c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 1350c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * The translation unit cursor exists primarily to act as the root 1351c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * cursor for traversing the contents of a translation unit. 1352c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 1353e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek CXCursor_TranslationUnit = 300, 1354e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek 1355e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek /* Attributes */ 1356e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek CXCursor_FirstAttr = 400, 1357e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek /** 1358e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek * \brief An attribute whose specific kind is not exposed via this 1359e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek * interface. 1360e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek */ 1361e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek CXCursor_UnexposedAttr = 400, 1362e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek 1363e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek CXCursor_IBActionAttr = 401, 1364e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek CXCursor_IBOutletAttr = 402, 1365857e918a8a40deb128840308a318bf623d68295fTed Kremenek CXCursor_IBOutletCollectionAttr = 403, 1366857e918a8a40deb128840308a318bf623d68295fTed Kremenek CXCursor_LastAttr = CXCursor_IBOutletCollectionAttr, 13679f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor 13689f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor /* Preprocessing */ 13699f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor CXCursor_PreprocessingDirective = 500, 1370572feb2a190b5e8b04fb06c4ac50ee0f61e93ff0Douglas Gregor CXCursor_MacroDefinition = 501, 1371572feb2a190b5e8b04fb06c4ac50ee0f61e93ff0Douglas Gregor CXCursor_MacroInstantiation = 502, 1372ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor CXCursor_InclusionDirective = 503, 13739f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor CXCursor_FirstPreprocessing = CXCursor_PreprocessingDirective, 1374ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor CXCursor_LastPreprocessing = CXCursor_InclusionDirective 1375c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor}; 1376c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor 1377c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 1378c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief A cursor representing some element in the abstract syntax tree for 1379c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * a translation unit. 1380c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 13811efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * The cursor abstraction unifies the different kinds of entities in a 1382c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * program--declaration, statements, expressions, references to declarations, 1383c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * etc.--under a single "cursor" abstraction with a common set of operations. 1384c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * Common operation for a cursor include: getting the physical location in 1385c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * a source file where the cursor points, getting the name associated with a 1386c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * cursor, and retrieving cursors for any child nodes of a particular cursor. 1387c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 1388c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * Cursors can be produced in two specific ways. 1389c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * clang_getTranslationUnitCursor() produces a cursor for a translation unit, 1390c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * from which one can use clang_visitChildren() to explore the rest of the 1391c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * translation unit. clang_getCursor() maps from a physical source location 1392c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * to the entity that resides at that location, allowing one to map from the 1393c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * source code into the AST. 1394c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 1395c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregortypedef struct { 1396c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor enum CXCursorKind kind; 1397c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor void *data[3]; 13981efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar} CXCursor; 1399c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor 1400c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 1401c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations 1402c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 1403c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @{ 1404c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 14051efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 1406c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 1407c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Retrieve the NULL cursor, which represents no entity. 1408c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 1409c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE CXCursor clang_getNullCursor(void); 14101efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 1411c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 1412c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Retrieve the cursor that represents the given translation unit. 1413c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 1414c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * The translation unit cursor can be used to start traversing the 1415c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * various declarations within the given translation unit. 1416c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 1417c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE CXCursor clang_getTranslationUnitCursor(CXTranslationUnit); 1418c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor 1419c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 1420c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Determine whether two cursors are equivalent. 1421c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 1422c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE unsigned clang_equalCursors(CXCursor, CXCursor); 14231efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 1424c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 14259ce5584553054d0cb934940586aca0186e87fa57Douglas Gregor * \brief Compute a hash value for the given cursor. 14269ce5584553054d0cb934940586aca0186e87fa57Douglas Gregor */ 14279ce5584553054d0cb934940586aca0186e87fa57Douglas GregorCINDEX_LINKAGE unsigned clang_hashCursor(CXCursor); 14289ce5584553054d0cb934940586aca0186e87fa57Douglas Gregor 14299ce5584553054d0cb934940586aca0186e87fa57Douglas Gregor/** 1430c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Retrieve the kind of the given cursor. 1431c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 1432c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor); 1433c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor 1434c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 1435c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Determine whether the given cursor kind represents a declaration. 1436c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 1437c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind); 1438c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor 1439c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 1440c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Determine whether the given cursor kind represents a simple 1441c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * reference. 1442c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 1443c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * Note that other kinds of cursors (such as expressions) can also refer to 1444c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * other cursors. Use clang_getCursorReferenced() to determine whether a 1445c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * particular cursor refers to another entity. 1446c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 1447c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE unsigned clang_isReference(enum CXCursorKind); 1448c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor 1449c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 1450c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Determine whether the given cursor kind represents an expression. 1451c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 1452c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE unsigned clang_isExpression(enum CXCursorKind); 1453c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor 1454c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 1455c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Determine whether the given cursor kind represents a statement. 1456c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 1457c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE unsigned clang_isStatement(enum CXCursorKind); 1458c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor 1459c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 14601efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \brief Determine whether the given cursor kind represents an invalid 1461c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * cursor. 14621efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar */ 1463c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE unsigned clang_isInvalid(enum CXCursorKind); 1464c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor 1465c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 14661efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \brief Determine whether the given cursor kind represents a translation 14671efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * unit. 1468c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 1469c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE unsigned clang_isTranslationUnit(enum CXCursorKind); 14701efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 1471ad6eff611a4391f89fd6c458db16993f76e7f5d0Ted Kremenek/*** 14729f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor * \brief Determine whether the given cursor represents a preprocessing 14739f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor * element, such as a preprocessor directive or macro instantiation. 14749f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor */ 14759f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas GregorCINDEX_LINKAGE unsigned clang_isPreprocessing(enum CXCursorKind); 14769f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor 14779f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor/*** 1478ad6eff611a4391f89fd6c458db16993f76e7f5d0Ted Kremenek * \brief Determine whether the given cursor represents a currently 1479ad6eff611a4391f89fd6c458db16993f76e7f5d0Ted Kremenek * unexposed piece of the AST (e.g., CXCursor_UnexposedStmt). 1480ad6eff611a4391f89fd6c458db16993f76e7f5d0Ted Kremenek */ 1481ad6eff611a4391f89fd6c458db16993f76e7f5d0Ted KremenekCINDEX_LINKAGE unsigned clang_isUnexposed(enum CXCursorKind); 1482ad6eff611a4391f89fd6c458db16993f76e7f5d0Ted Kremenek 1483c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 148416b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek * \brief Describe the linkage of the entity referred to by a cursor. 148516b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek */ 148616b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenekenum CXLinkageKind { 148716b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek /** \brief This value indicates that no linkage information is available 148816b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek * for a provided CXCursor. */ 148916b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek CXLinkage_Invalid, 149016b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek /** 149116b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek * \brief This is the linkage for variables, parameters, and so on that 149216b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek * have automatic storage. This covers normal (non-extern) local variables. 149316b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek */ 149416b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek CXLinkage_NoLinkage, 149516b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek /** \brief This is the linkage for static variables and static functions. */ 149616b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek CXLinkage_Internal, 149716b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek /** \brief This is the linkage for entities with external linkage that live 149816b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek * in C++ anonymous namespaces.*/ 149916b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek CXLinkage_UniqueExternal, 150016b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek /** \brief This is the linkage for entities with true, external linkage. */ 150116b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek CXLinkage_External 150216b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek}; 150316b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek 150416b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek/** 150545e1dae500bba7a9ef5b8206263a5609c07c6f03Ted Kremenek * \brief Determine the linkage of the entity referred to by a given cursor. 150616b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek */ 150716b4259aecaa22b642d35d36fd89965ed700c1e0Ted KremenekCINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor); 150816b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek 150916b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek/** 151058ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor * \brief Determine the availability of the entity that this cursor refers to. 151158ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor * 151258ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor * \param cursor The cursor to query. 151358ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor * 151458ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor * \returns The availability of the cursor. 151558ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor */ 151658ddb60f409125eda5436c4a1f070f7fa4744295Douglas GregorCINDEX_LINKAGE enum CXAvailabilityKind 151758ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregorclang_getCursorAvailability(CXCursor cursor); 151858ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor 151958ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor/** 152045e1dae500bba7a9ef5b8206263a5609c07c6f03Ted Kremenek * \brief Describe the "language" of the entity referred to by a cursor. 152145e1dae500bba7a9ef5b8206263a5609c07c6f03Ted Kremenek */ 152245e1dae500bba7a9ef5b8206263a5609c07c6f03Ted KremenekCINDEX_LINKAGE enum CXLanguageKind { 15236cd1e7cb04d1da66e8b5675062152ff60bbc354fTed Kremenek CXLanguage_Invalid = 0, 152445e1dae500bba7a9ef5b8206263a5609c07c6f03Ted Kremenek CXLanguage_C, 152545e1dae500bba7a9ef5b8206263a5609c07c6f03Ted Kremenek CXLanguage_ObjC, 15266cd1e7cb04d1da66e8b5675062152ff60bbc354fTed Kremenek CXLanguage_CPlusPlus 152745e1dae500bba7a9ef5b8206263a5609c07c6f03Ted Kremenek}; 152845e1dae500bba7a9ef5b8206263a5609c07c6f03Ted Kremenek 152945e1dae500bba7a9ef5b8206263a5609c07c6f03Ted Kremenek/** 153045e1dae500bba7a9ef5b8206263a5609c07c6f03Ted Kremenek * \brief Determine the "language" of the entity referred to by a given cursor. 153145e1dae500bba7a9ef5b8206263a5609c07c6f03Ted Kremenek */ 153245e1dae500bba7a9ef5b8206263a5609c07c6f03Ted KremenekCINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor); 153345e1dae500bba7a9ef5b8206263a5609c07c6f03Ted Kremenek 1534eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek 1535eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek/** 1536eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek * \brief A fast container representing a set of CXCursors. 1537eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek */ 1538eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenektypedef struct CXCursorSetImpl *CXCursorSet; 1539eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek 1540eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek/** 1541eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek * \brief Creates an empty CXCursorSet. 1542eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek */ 1543eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted KremenekCINDEX_LINKAGE CXCursorSet clang_createCXCursorSet(); 1544eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek 1545eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek/** 1546eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek * \brief Disposes a CXCursorSet and releases its associated memory. 1547eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek */ 1548eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted KremenekCINDEX_LINKAGE void clang_disposeCXCursorSet(CXCursorSet cset); 1549eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek 1550eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek/** 1551eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek * \brief Queries a CXCursorSet to see if it contains a specific CXCursor. 1552eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek * 1553eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek * \returns non-zero if the set contains the specified cursor. 1554eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek*/ 1555eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted KremenekCINDEX_LINKAGE unsigned clang_CXCursorSet_contains(CXCursorSet cset, 1556eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek CXCursor cursor); 1557eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek 1558eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek/** 1559eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek * \brief Inserts a CXCursor into a CXCursorSet. 1560eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek * 1561eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek * \returns zero if the CXCursor was already in the set, and non-zero otherwise. 1562eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek*/ 1563eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted KremenekCINDEX_LINKAGE unsigned clang_CXCursorSet_insert(CXCursorSet cset, 1564eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek CXCursor cursor); 1565eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek 15662be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor/** 15672be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * \brief Determine the semantic parent of the given cursor. 15682be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * 15692be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * The semantic parent of a cursor is the cursor that semantically contains 15702be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * the given \p cursor. For many declarations, the lexical and semantic parents 15712be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * are equivalent (the lexical parent is returned by 15722be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * \c clang_getCursorLexicalParent()). They diverge when declarations or 15732be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * definitions are provided out-of-line. For example: 15742be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * 15752be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * \code 15762be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * class C { 15772be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * void f(); 15782be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * }; 15792be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * 15802be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * void C::f() { } 15812be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * \endcode 15822be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * 15832be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * In the out-of-line definition of \c C::f, the semantic parent is the 15842be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * the class \c C, of which this function is a member. The lexical parent is 15852be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * the place where the declaration actually occurs in the source code; in this 15862be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * case, the definition occurs in the translation unit. In general, the 15872be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * lexical parent for a given entity can change without affecting the semantics 15882be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * of the program, and the lexical parent of different declarations of the 15892be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * same entity may be different. Changing the semantic parent of a declaration, 15902be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * on the other hand, can have a major impact on semantics, and redeclarations 15912be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * of a particular entity should all have the same semantic context. 15922be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * 15932be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * In the example above, both declarations of \c C::f have \c C as their 15942be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * semantic context, while the lexical context of the first \c C::f is \c C 15952be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * and the lexical context of the second \c C::f is the translation unit. 15963910cfd17fcd99ac80158e625fc63e4784d26435Douglas Gregor * 15973910cfd17fcd99ac80158e625fc63e4784d26435Douglas Gregor * For global declarations, the semantic parent is the translation unit. 15982be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor */ 15992be5bc9ad3981347a000742f81b91ab3080f1214Douglas GregorCINDEX_LINKAGE CXCursor clang_getCursorSemanticParent(CXCursor cursor); 16002be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor 16012be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor/** 16022be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * \brief Determine the lexical parent of the given cursor. 16032be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * 16042be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * The lexical parent of a cursor is the cursor in which the given \p cursor 16052be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * was actually written. For many declarations, the lexical and semantic parents 16062be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * are equivalent (the semantic parent is returned by 16072be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * \c clang_getCursorSemanticParent()). They diverge when declarations or 16082be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * definitions are provided out-of-line. For example: 16092be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * 16102be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * \code 16112be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * class C { 16122be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * void f(); 16132be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * }; 16142be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * 16152be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * void C::f() { } 16162be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * \endcode 16172be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * 16182be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * In the out-of-line definition of \c C::f, the semantic parent is the 16192be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * the class \c C, of which this function is a member. The lexical parent is 16202be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * the place where the declaration actually occurs in the source code; in this 16212be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * case, the definition occurs in the translation unit. In general, the 16222be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * lexical parent for a given entity can change without affecting the semantics 16232be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * of the program, and the lexical parent of different declarations of the 16242be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * same entity may be different. Changing the semantic parent of a declaration, 16252be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * on the other hand, can have a major impact on semantics, and redeclarations 16262be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * of a particular entity should all have the same semantic context. 16272be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * 16282be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * In the example above, both declarations of \c C::f have \c C as their 16292be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * semantic context, while the lexical context of the first \c C::f is \c C 16302be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * and the lexical context of the second \c C::f is the translation unit. 16313910cfd17fcd99ac80158e625fc63e4784d26435Douglas Gregor * 16323910cfd17fcd99ac80158e625fc63e4784d26435Douglas Gregor * For declarations written in the global scope, the lexical parent is 16333910cfd17fcd99ac80158e625fc63e4784d26435Douglas Gregor * the translation unit. 16342be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor */ 16352be5bc9ad3981347a000742f81b91ab3080f1214Douglas GregorCINDEX_LINKAGE CXCursor clang_getCursorLexicalParent(CXCursor cursor); 16369f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor 16379f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor/** 16389f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * \brief Determine the set of methods that are overridden by the given 16399f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * method. 16409f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * 16419f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * In both Objective-C and C++, a method (aka virtual member function, 16429f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * in C++) can override a virtual method in a base class. For 16439f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * Objective-C, a method is said to override any method in the class's 16449f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * interface (if we're coming from an implementation), its protocols, 16459f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * or its categories, that has the same selector and is of the same 16469f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * kind (class or instance). If no such method exists, the search 16479f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * continues to the class's superclass, its protocols, and its 16489f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * categories, and so on. 16499f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * 16509f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * For C++, a virtual member function overrides any virtual member 16519f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * function with the same signature that occurs in its base 16529f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * classes. With multiple inheritance, a virtual member function can 16539f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * override several virtual member functions coming from different 16549f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * base classes. 16559f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * 16569f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * In all cases, this function determines the immediate overridden 16579f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * method, rather than all of the overridden methods. For example, if 16589f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * a method is originally declared in a class A, then overridden in B 16599f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * (which in inherits from A) and also in C (which inherited from B), 16609f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * then the only overridden method returned from this function when 16619f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * invoked on C's method will be B's method. The client may then 16629f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * invoke this function again, given the previously-found overridden 16639f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * methods, to map out the complete method-override set. 16649f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * 16659f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * \param cursor A cursor representing an Objective-C or C++ 16669f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * method. This routine will compute the set of methods that this 16679f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * method overrides. 16689f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * 16699f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * \param overridden A pointer whose pointee will be replaced with a 16709f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * pointer to an array of cursors, representing the set of overridden 16719f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * methods. If there are no overridden methods, the pointee will be 16729f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * set to NULL. The pointee must be freed via a call to 16739f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * \c clang_disposeOverriddenCursors(). 16749f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * 16759f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * \param num_overridden A pointer to the number of overridden 16769f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * functions, will be set to the number of overridden functions in the 16779f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * array pointed to by \p overridden. 16789f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor */ 16799f59234a91d057cee7c5e3cee91da8696858c692Douglas GregorCINDEX_LINKAGE void clang_getOverriddenCursors(CXCursor cursor, 16809f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor CXCursor **overridden, 16819f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor unsigned *num_overridden); 16829f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor 16839f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor/** 16849f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * \brief Free the set of overridden cursors returned by \c 16859f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * clang_getOverriddenCursors(). 16869f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor */ 16879f59234a91d057cee7c5e3cee91da8696858c692Douglas GregorCINDEX_LINKAGE void clang_disposeOverriddenCursors(CXCursor *overridden); 16889f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor 168945e1dae500bba7a9ef5b8206263a5609c07c6f03Ted Kremenek/** 1690ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor * \brief Retrieve the file that is included by the given inclusion directive 1691ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor * cursor. 1692ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor */ 1693ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas GregorCINDEX_LINKAGE CXFile clang_getIncludedFile(CXCursor cursor); 1694ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor 1695ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor/** 1696c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @} 1697c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 16981efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 1699c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 1700c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code 1701c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 1702c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * Cursors represent a location within the Abstract Syntax Tree (AST). These 1703c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * routines help map between cursors and the physical locations where the 1704c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * described entities occur in the source code. The mapping is provided in 1705c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * both directions, so one can map from source code to the AST and back. 1706c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 1707c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @{ 170850398199fb10e196a8d92fbf7a062dbe42ed88fdSteve Naroff */ 17091efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 17106a6de8b4fc944ca1bfa4e47c516d049a0d627b0eSteve Naroff/** 1711b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * \brief Map a source location to the cursor that describes the entity at that 1712b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * location in the source code. 1713b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * 1714b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * clang_getCursor() maps an arbitrary source location within a translation 1715b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * unit down to the most specific cursor that describes the entity at that 17161efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * location. For example, given an expression \c x + y, invoking 1717b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * clang_getCursor() with a source location pointing to "x" will return the 17181efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * cursor for "x"; similarly for "y". If the cursor points anywhere between 1719b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor() 1720b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * will return a cursor referring to the "+" expression. 1721b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * 1722b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * \returns a cursor representing the entity at the given source location, or 1723b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * a NULL cursor if no such entity can be found. 17246a6de8b4fc944ca1bfa4e47c516d049a0d627b0eSteve Naroff */ 1725b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas GregorCINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, CXSourceLocation); 17261efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 172798258afae66bab39b0c57a3efb6b20d4fbb5746cDouglas Gregor/** 172898258afae66bab39b0c57a3efb6b20d4fbb5746cDouglas Gregor * \brief Retrieve the physical location of the source constructor referenced 172998258afae66bab39b0c57a3efb6b20d4fbb5746cDouglas Gregor * by the given cursor. 173098258afae66bab39b0c57a3efb6b20d4fbb5746cDouglas Gregor * 173198258afae66bab39b0c57a3efb6b20d4fbb5746cDouglas Gregor * The location of a declaration is typically the location of the name of that 17321efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * declaration, where the name of that declaration would occur if it is 17331efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * unnamed, or some keyword that introduces that particular declaration. 17341efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * The location of a reference is where that reference occurs within the 173598258afae66bab39b0c57a3efb6b20d4fbb5746cDouglas Gregor * source code. 173698258afae66bab39b0c57a3efb6b20d4fbb5746cDouglas Gregor */ 173798258afae66bab39b0c57a3efb6b20d4fbb5746cDouglas GregorCINDEX_LINKAGE CXSourceLocation clang_getCursorLocation(CXCursor); 1738c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor 1739b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor/** 1740b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * \brief Retrieve the physical extent of the source construct referenced by 1741a7bde20f8c6334ccc3a7ef4dd77243d0921a8497Douglas Gregor * the given cursor. 1742a7bde20f8c6334ccc3a7ef4dd77243d0921a8497Douglas Gregor * 1743a7bde20f8c6334ccc3a7ef4dd77243d0921a8497Douglas Gregor * The extent of a cursor starts with the file/line/column pointing at the 1744a7bde20f8c6334ccc3a7ef4dd77243d0921a8497Douglas Gregor * first character within the source construct that the cursor refers to and 17451efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * ends with the last character withinin that source construct. For a 1746a7bde20f8c6334ccc3a7ef4dd77243d0921a8497Douglas Gregor * declaration, the extent covers the declaration itself. For a reference, 1747a7bde20f8c6334ccc3a7ef4dd77243d0921a8497Douglas Gregor * the extent covers the location of the reference (e.g., where the referenced 1748a7bde20f8c6334ccc3a7ef4dd77243d0921a8497Douglas Gregor * entity was actually used). 1749a7bde20f8c6334ccc3a7ef4dd77243d0921a8497Douglas Gregor */ 1750a7bde20f8c6334ccc3a7ef4dd77243d0921a8497Douglas GregorCINDEX_LINKAGE CXSourceRange clang_getCursorExtent(CXCursor); 1751c5d1e9375d71e66d22456e7cc52cc7c0a5c65c3fDouglas Gregor 1752c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 1753c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @} 1754c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 175595f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek 1756c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 17578e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * \defgroup CINDEX_TYPES Type information for CXCursors 17588e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * 17598e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * @{ 17608e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek */ 17618e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek 17628e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek/** 17638e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * \brief Describes the kind of type 17648e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek */ 17658e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenekenum CXTypeKind { 17668e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek /** 17678e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * \brief Reprents an invalid type (e.g., where no type is available). 17688e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek */ 17698e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek CXType_Invalid = 0, 17708e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek 17718e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek /** 17728e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * \brief A type whose specific kind is not exposed via this 17738e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * interface. 17748e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek */ 17758e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek CXType_Unexposed = 1, 17768e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek 17778e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek /* Builtin types */ 17788e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek CXType_Void = 2, 17798e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek CXType_Bool = 3, 17808e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek CXType_Char_U = 4, 17818e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek CXType_UChar = 5, 17828e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek CXType_Char16 = 6, 17838e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek CXType_Char32 = 7, 17848e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek CXType_UShort = 8, 17858e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek CXType_UInt = 9, 17868e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek CXType_ULong = 10, 17878e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek CXType_ULongLong = 11, 17888e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek CXType_UInt128 = 12, 17898e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek CXType_Char_S = 13, 17908e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek CXType_SChar = 14, 17918e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek CXType_WChar = 15, 17928e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek CXType_Short = 16, 17938e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek CXType_Int = 17, 17948e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek CXType_Long = 18, 17958e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek CXType_LongLong = 19, 17968e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek CXType_Int128 = 20, 17978e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek CXType_Float = 21, 17988e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek CXType_Double = 22, 17998e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek CXType_LongDouble = 23, 18008e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek CXType_NullPtr = 24, 18018e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek CXType_Overload = 25, 18028e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek CXType_Dependent = 26, 18038e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek CXType_ObjCId = 27, 18048e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek CXType_ObjCClass = 28, 18058e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek CXType_ObjCSel = 29, 18068e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek CXType_FirstBuiltin = CXType_Void, 18078e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek CXType_LastBuiltin = CXType_ObjCSel, 18088e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek 18098e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek CXType_Complex = 100, 18108e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek CXType_Pointer = 101, 18118e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek CXType_BlockPointer = 102, 18128e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek CXType_LValueReference = 103, 18138e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek CXType_RValueReference = 104, 18148e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek CXType_Record = 105, 18158e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek CXType_Enum = 106, 18168e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek CXType_Typedef = 107, 18178e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek CXType_ObjCInterface = 108, 181804c3cf35a80c09ab78e519f2e71ecccd5c5d8da0Ted Kremenek CXType_ObjCObjectPointer = 109, 181904c3cf35a80c09ab78e519f2e71ecccd5c5d8da0Ted Kremenek CXType_FunctionNoProto = 110, 182004c3cf35a80c09ab78e519f2e71ecccd5c5d8da0Ted Kremenek CXType_FunctionProto = 111 18218e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek}; 18228e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek 18238e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek/** 18248e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * \brief The type of an element in the abstract syntax tree. 18258e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * 18268e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek */ 18278e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenektypedef struct { 18288e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek enum CXTypeKind kind; 18298e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek void *data[2]; 18308e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek} CXType; 18318e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek 18328e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek/** 18338e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * \brief Retrieve the type of a CXCursor (if any). 18348e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek */ 18358e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted KremenekCINDEX_LINKAGE CXType clang_getCursorType(CXCursor C); 18368e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek 18378e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek/** 18388e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * \determine Determine whether two CXTypes represent the same type. 18398e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * 18408e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * \returns non-zero if the CXTypes represent the same type and 18418e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek zero otherwise. 18428e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek */ 18438e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted KremenekCINDEX_LINKAGE unsigned clang_equalTypes(CXType A, CXType B); 18448e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek 18458e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek/** 18468e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * \brief Return the canonical type for a CXType. 18478e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * 18488e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * Clang's type system explicitly models typedefs and all the ways 18498e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * a specific type can be represented. The canonical type is the underlying 18508e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * type with all the "sugar" removed. For example, if 'T' is a typedef 18518e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * for 'int', the canonical type for 'T' would be 'int'. 18528e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek */ 18538e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted KremenekCINDEX_LINKAGE CXType clang_getCanonicalType(CXType T); 18548e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek 18558e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek/** 1856e72fb6f40231a1e8372c7576b69f06f0a1eb28a7Douglas Gregor * \determine Determine whether a CXType has the "const" qualifier set, 1857e72fb6f40231a1e8372c7576b69f06f0a1eb28a7Douglas Gregor * without looking through typedefs that may have added "const" at a different level. 1858e72fb6f40231a1e8372c7576b69f06f0a1eb28a7Douglas Gregor */ 1859e72fb6f40231a1e8372c7576b69f06f0a1eb28a7Douglas GregorCINDEX_LINKAGE unsigned clang_isConstQualifiedType(CXType T); 1860e72fb6f40231a1e8372c7576b69f06f0a1eb28a7Douglas Gregor 1861e72fb6f40231a1e8372c7576b69f06f0a1eb28a7Douglas Gregor/** 1862e72fb6f40231a1e8372c7576b69f06f0a1eb28a7Douglas Gregor * \determine Determine whether a CXType has the "volatile" qualifier set, 1863e72fb6f40231a1e8372c7576b69f06f0a1eb28a7Douglas Gregor * without looking through typedefs that may have added "volatile" at a different level. 1864e72fb6f40231a1e8372c7576b69f06f0a1eb28a7Douglas Gregor */ 1865e72fb6f40231a1e8372c7576b69f06f0a1eb28a7Douglas GregorCINDEX_LINKAGE unsigned clang_isVolatileQualifiedType(CXType T); 1866e72fb6f40231a1e8372c7576b69f06f0a1eb28a7Douglas Gregor 1867e72fb6f40231a1e8372c7576b69f06f0a1eb28a7Douglas Gregor/** 1868e72fb6f40231a1e8372c7576b69f06f0a1eb28a7Douglas Gregor * \determine Determine whether a CXType has the "restrict" qualifier set, 1869e72fb6f40231a1e8372c7576b69f06f0a1eb28a7Douglas Gregor * without looking through typedefs that may have added "restrict" at a different level. 1870e72fb6f40231a1e8372c7576b69f06f0a1eb28a7Douglas Gregor */ 1871e72fb6f40231a1e8372c7576b69f06f0a1eb28a7Douglas GregorCINDEX_LINKAGE unsigned clang_isRestrictQualifiedType(CXType T); 1872e72fb6f40231a1e8372c7576b69f06f0a1eb28a7Douglas Gregor 1873e72fb6f40231a1e8372c7576b69f06f0a1eb28a7Douglas Gregor/** 18748e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * \brief For pointer types, returns the type of the pointee. 18758e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * 18768e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek */ 18778e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted KremenekCINDEX_LINKAGE CXType clang_getPointeeType(CXType T); 18788e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek 18798e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek/** 18808e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * \brief Return the cursor for the declaration of the given type. 18818e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek */ 18828e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted KremenekCINDEX_LINKAGE CXCursor clang_getTypeDeclaration(CXType T); 18838e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek 18845389f48b24937ad7b4093307128b3cbf25235654David Chisnall/** 18855389f48b24937ad7b4093307128b3cbf25235654David Chisnall * Returns the Objective-C type encoding for the specified declaration. 18865389f48b24937ad7b4093307128b3cbf25235654David Chisnall */ 18875389f48b24937ad7b4093307128b3cbf25235654David ChisnallCINDEX_LINKAGE CXString clang_getDeclObjCTypeEncoding(CXCursor C); 18888e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek 18898e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek/** 18908e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * \brief Retrieve the spelling of a given CXTypeKind. 18918e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek */ 18928e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted KremenekCINDEX_LINKAGE CXString clang_getTypeKindSpelling(enum CXTypeKind K); 18938e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek 18948e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek/** 18959a140845438c2fc31e7d48a6dedbc695f4c83c68Ted Kremenek * \brief Retrieve the result type associated with a function type. 189604c3cf35a80c09ab78e519f2e71ecccd5c5d8da0Ted Kremenek */ 189704c3cf35a80c09ab78e519f2e71ecccd5c5d8da0Ted KremenekCINDEX_LINKAGE CXType clang_getResultType(CXType T); 189804c3cf35a80c09ab78e519f2e71ecccd5c5d8da0Ted Kremenek 189904c3cf35a80c09ab78e519f2e71ecccd5c5d8da0Ted Kremenek/** 19009a140845438c2fc31e7d48a6dedbc695f4c83c68Ted Kremenek * \brief Retrieve the result type associated with a given cursor. This only 19019a140845438c2fc31e7d48a6dedbc695f4c83c68Ted Kremenek * returns a valid type of the cursor refers to a function or method. 19029a140845438c2fc31e7d48a6dedbc695f4c83c68Ted Kremenek */ 19039a140845438c2fc31e7d48a6dedbc695f4c83c68Ted KremenekCINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C); 19049a140845438c2fc31e7d48a6dedbc695f4c83c68Ted Kremenek 19059a140845438c2fc31e7d48a6dedbc695f4c83c68Ted Kremenek/** 19063ce9e7d270e7df86c09c8126b4412d55be7c123bTed Kremenek * \brief Return 1 if the CXType is a POD (plain old data) type, and 0 19073ce9e7d270e7df86c09c8126b4412d55be7c123bTed Kremenek * otherwise. 19083ce9e7d270e7df86c09c8126b4412d55be7c123bTed Kremenek */ 19093ce9e7d270e7df86c09c8126b4412d55be7c123bTed KremenekCINDEX_LINKAGE unsigned clang_isPODType(CXType T); 19103ce9e7d270e7df86c09c8126b4412d55be7c123bTed Kremenek 19113ce9e7d270e7df86c09c8126b4412d55be7c123bTed Kremenek/** 19123064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek * \brief Returns 1 if the base class specified by the cursor with kind 19133064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek * CX_CXXBaseSpecifier is virtual. 19143064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek */ 19153064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed KremenekCINDEX_LINKAGE unsigned clang_isVirtualBase(CXCursor); 19163064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek 19173064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek/** 19183064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek * \brief Represents the C++ access control level to a base class for a 19193064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek * cursor with kind CX_CXXBaseSpecifier. 19203064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek */ 19213064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenekenum CX_CXXAccessSpecifier { 19223064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek CX_CXXInvalidAccessSpecifier, 19233064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek CX_CXXPublic, 19243064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek CX_CXXProtected, 19253064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek CX_CXXPrivate 19263064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek}; 19273064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek 19283064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek/** 19293064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek * \brief Returns the access control level for the C++ base specifier 19303064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek * represented by a cursor with kind CX_CXXBaseSpecifier. 19313064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek */ 19323064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed KremenekCINDEX_LINKAGE enum CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor); 19333064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek 19343064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek/** 19351f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * \brief Determine the number of overloaded declarations referenced by a 19361f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * \c CXCursor_OverloadedDeclRef cursor. 19371f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * 19381f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * \param cursor The cursor whose overloaded declarations are being queried. 19391f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * 19401f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * \returns The number of overloaded declarations referenced by \c cursor. If it 19411f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * is not a \c CXCursor_OverloadedDeclRef cursor, returns 0. 19421f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor */ 19431f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas GregorCINDEX_LINKAGE unsigned clang_getNumOverloadedDecls(CXCursor cursor); 19441f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor 19451f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor/** 19461f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * \brief Retrieve a cursor for one of the overloaded declarations referenced 19471f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * by a \c CXCursor_OverloadedDeclRef cursor. 19481f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * 19491f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * \param cursor The cursor whose overloaded declarations are being queried. 19501f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * 19511f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * \param index The zero-based index into the set of overloaded declarations in 19521f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * the cursor. 19531f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * 19541f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * \returns A cursor representing the declaration referenced by the given 19551f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * \c cursor at the specified \c index. If the cursor does not have an 19561f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * associated set of overloaded declarations, or if the index is out of bounds, 19571f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * returns \c clang_getNullCursor(); 19581f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor */ 19591f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas GregorCINDEX_LINKAGE CXCursor clang_getOverloadedDecl(CXCursor cursor, 19601f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor unsigned index); 19611f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor 19621f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor/** 19638e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * @} 19648e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek */ 196595f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek 196695f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek/** 1967ad72f4dad4cf0fd2b71eb8f4704d2fe7ac58fb44Ted Kremenek * \defgroup CINDEX_ATTRIBUTES Information for attributes 196895f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek * 196995f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek * @{ 197095f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek */ 197195f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek 197295f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek 197395f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek/** 197495f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek * \brief For cursors representing an iboutletcollection attribute, 197595f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek * this function returns the collection element type. 197695f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek * 197795f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek */ 197895f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted KremenekCINDEX_LINKAGE CXType clang_getIBOutletCollectionType(CXCursor); 197995f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek 198095f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek/** 198195f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek * @} 198295f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek */ 19838e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek 19848e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek/** 1985c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors 1986c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 1987c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * These routines provide the ability to traverse the abstract syntax tree 1988c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * using cursors. 1989c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 1990c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @{ 1991c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 19921efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 1993c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 1994c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Describes how the traversal of the children of a particular 1995c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * cursor should proceed after visiting a particular child cursor. 1996c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 1997c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * A value of this enumeration type should be returned by each 1998c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \c CXCursorVisitor to indicate how clang_visitChildren() proceed. 1999c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 2000c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregorenum CXChildVisitResult { 2001c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** 20021efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \brief Terminates the cursor traversal. 2003c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 2004c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXChildVisit_Break, 20051efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar /** 2006c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Continues the cursor traversal with the next sibling of 2007c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * the cursor just visited, without visiting its children. 2008c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 2009c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXChildVisit_Continue, 2010c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor /** 2011c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Recursively traverse the children of this cursor, using 2012c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * the same visitor and client data. 2013c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 2014c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXChildVisit_Recurse 2015c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor}; 2016c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor 2017c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 2018c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Visitor invoked for each cursor found by a traversal. 2019c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 2020c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * This visitor function will be invoked for each cursor found by 2021c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * clang_visitCursorChildren(). Its first argument is the cursor being 2022c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * visited, its second argument is the parent visitor for that cursor, 2023c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * and its third argument is the client data provided to 2024c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * clang_visitCursorChildren(). 2025c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 2026c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * The visitor should return one of the \c CXChildVisitResult values 2027c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * to direct clang_visitCursorChildren(). 2028c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 20291efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbartypedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor, 20301efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar CXCursor parent, 2031c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXClientData client_data); 2032c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor 2033c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 2034c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Visit the children of a particular cursor. 2035c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 2036c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * This function visits all the direct children of the given cursor, 2037c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * invoking the given \p visitor function with the cursors of each 2038c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * visited child. The traversal may be recursive, if the visitor returns 2039c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if 2040c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * the visitor returns \c CXChildVisit_Break. 2041c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 2042c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \param parent the cursor whose child may be visited. All kinds of 2043a57259e9d7b30bcce93f0a62eee0488738026172Daniel Dunbar * cursors can be visited, including invalid cursors (which, by 2044c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * definition, have no children). 2045c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 2046c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \param visitor the visitor function that will be invoked for each 2047c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * child of \p parent. 2048c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 2049c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \param client_data pointer data supplied by the client, which will 2050c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * be passed to the visitor each time it is invoked. 2051c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 2052c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \returns a non-zero value if the traversal was terminated 2053c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * prematurely by the visitor returning \c CXChildVisit_Break. 2054c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 20551efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel DunbarCINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent, 2056c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXCursorVisitor visitor, 2057c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor CXClientData client_data); 20583387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall#ifdef __has_feature 20593387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall# if __has_feature(blocks) 20603387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall/** 20613387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall * \brief Visitor invoked for each cursor found by a traversal. 20623387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall * 20633387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall * This visitor block will be invoked for each cursor found by 20643387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall * clang_visitChildrenWithBlock(). Its first argument is the cursor being 20653387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall * visited, its second argument is the parent visitor for that cursor. 20663387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall * 20673387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall * The visitor should return one of the \c CXChildVisitResult values 20683387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall * to direct clang_visitChildrenWithBlock(). 20693387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall */ 20703387c65a094a02b2a94c05111d035a97d3d5c794David Chisnalltypedef enum CXChildVisitResult 20713387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall (^CXCursorVisitorBlock)(CXCursor cursor, CXCursor parent); 20723387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall 20733387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall/** 20743387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall * Visits the children of a cursor using the specified block. Behaves 20753387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall * identically to clang_visitChildren() in all other respects. 20763387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall */ 20773387c65a094a02b2a94c05111d035a97d3d5c794David Chisnallunsigned clang_visitChildrenWithBlock(CXCursor parent, 20783387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall CXCursorVisitorBlock block); 20793387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall# endif 20803387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall#endif 20811efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 2082c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 2083c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @} 2084c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 20851efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 2086c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 2087c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST 2088c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 20891efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * These routines provide the ability to determine references within and 2090c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * across translation units, by providing the names of the entities referenced 2091c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * by cursors, follow reference cursors to the declarations they reference, 2092c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * and associate declarations with their definitions. 2093c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 2094c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @{ 2095c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 20961efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 2097c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 2098c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Retrieve a Unified Symbol Resolution (USR) for the entity referenced 2099c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * by the given cursor. 2100c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 2101c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * A Unified Symbol Resolution (USR) is a string that identifies a particular 2102c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * entity (function, class, variable, etc.) within a program. USRs can be 2103c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * compared across translation units to determine, e.g., when references in 2104c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * one translation refer to an entity defined in another translation unit. 2105c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 2106c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE CXString clang_getCursorUSR(CXCursor); 2107c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor 2108c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 2109896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek * \brief Construct a USR for a specified Objective-C class. 2110896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek */ 2111896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name); 2112896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek 2113896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek/** 2114896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek * \brief Construct a USR for a specified Objective-C category. 2115896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek */ 2116896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE CXString 211766ccaec73706f3623d2e7d191fe2c944feedcc2bTed Kremenek clang_constructUSR_ObjCCategory(const char *class_name, 2118896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek const char *category_name); 2119896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek 2120896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek/** 2121896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek * \brief Construct a USR for a specified Objective-C protocol. 2122896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek */ 2123896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE CXString 2124896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek clang_constructUSR_ObjCProtocol(const char *protocol_name); 2125896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek 2126896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek 2127896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek/** 2128896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek * \brief Construct a USR for a specified Objective-C instance variable and 2129896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek * the USR for its containing class. 2130896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek */ 2131896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE CXString clang_constructUSR_ObjCIvar(const char *name, 2132896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek CXString classUSR); 2133896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek 2134896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek/** 2135896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek * \brief Construct a USR for a specified Objective-C method and 2136896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek * the USR for its containing class. 2137896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek */ 2138896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE CXString clang_constructUSR_ObjCMethod(const char *name, 2139896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek unsigned isInstanceMethod, 2140896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek CXString classUSR); 2141896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek 2142896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek/** 2143896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek * \brief Construct a USR for a specified Objective-C property and the USR 2144896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek * for its containing class. 2145896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek */ 2146896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE CXString clang_constructUSR_ObjCProperty(const char *property, 2147896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek CXString classUSR); 2148896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek 2149896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek/** 2150c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Retrieve a name for the entity referenced by this cursor. 2151c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 2152c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE CXString clang_getCursorSpelling(CXCursor); 2153c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor 2154358559d8d7b458c5f64941842383a16e61f0828dDouglas Gregor/** 2155358559d8d7b458c5f64941842383a16e61f0828dDouglas Gregor * \brief Retrieve the display name for the entity referenced by this cursor. 2156358559d8d7b458c5f64941842383a16e61f0828dDouglas Gregor * 2157358559d8d7b458c5f64941842383a16e61f0828dDouglas Gregor * The display name contains extra information that helps identify the cursor, 2158358559d8d7b458c5f64941842383a16e61f0828dDouglas Gregor * such as the parameters of a function or template or the arguments of a 2159358559d8d7b458c5f64941842383a16e61f0828dDouglas Gregor * class template specialization. 2160358559d8d7b458c5f64941842383a16e61f0828dDouglas Gregor */ 2161358559d8d7b458c5f64941842383a16e61f0828dDouglas GregorCINDEX_LINKAGE CXString clang_getCursorDisplayName(CXCursor); 2162358559d8d7b458c5f64941842383a16e61f0828dDouglas Gregor 2163c5d1e9375d71e66d22456e7cc52cc7c0a5c65c3fDouglas Gregor/** \brief For a cursor that is a reference, retrieve a cursor representing the 2164c5d1e9375d71e66d22456e7cc52cc7c0a5c65c3fDouglas Gregor * entity that it references. 2165c5d1e9375d71e66d22456e7cc52cc7c0a5c65c3fDouglas Gregor * 2166c5d1e9375d71e66d22456e7cc52cc7c0a5c65c3fDouglas Gregor * Reference cursors refer to other entities in the AST. For example, an 2167c5d1e9375d71e66d22456e7cc52cc7c0a5c65c3fDouglas Gregor * Objective-C superclass reference cursor refers to an Objective-C class. 21681efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * This function produces the cursor for the Objective-C class from the 2169c5d1e9375d71e66d22456e7cc52cc7c0a5c65c3fDouglas Gregor * cursor for the superclass reference. If the input cursor is a declaration or 2170c5d1e9375d71e66d22456e7cc52cc7c0a5c65c3fDouglas Gregor * definition, it returns that declaration or definition unchanged. 21711efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * Otherwise, returns the NULL cursor. 2172c5d1e9375d71e66d22456e7cc52cc7c0a5c65c3fDouglas Gregor */ 2173c5d1e9375d71e66d22456e7cc52cc7c0a5c65c3fDouglas GregorCINDEX_LINKAGE CXCursor clang_getCursorReferenced(CXCursor); 2174b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor 21751efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar/** 2176b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * \brief For a cursor that is either a reference to or a declaration 2177b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * of some entity, retrieve a cursor that describes the definition of 2178b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * that entity. 2179b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * 2180b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * Some entities can be declared multiple times within a translation 2181b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * unit, but only one of those declarations can also be a 2182b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * definition. For example, given: 2183b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * 2184b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * \code 2185b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * int f(int, int); 2186b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * int g(int x, int y) { return f(x, y); } 2187b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * int f(int a, int b) { return a + b; } 2188b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * int f(int, int); 2189b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * \endcode 2190b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * 2191b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * there are three declarations of the function "f", but only the 2192b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * second one is a definition. The clang_getCursorDefinition() 2193b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * function will take any cursor pointing to a declaration of "f" 2194b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * (the first or fourth lines of the example) or a cursor referenced 2195b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * that uses "f" (the call to "f' inside "g") and will return a 2196b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * declaration cursor pointing to the definition (the second "f" 2197b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * declaration). 2198b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * 2199b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * If given a cursor for which there is no corresponding definition, 2200b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * e.g., because there is no definition of that entity within this 2201b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * translation unit, returns a NULL cursor. 2202b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor */ 2203b699866820102a69d83d6ac6941985c5ef4e8c40Douglas GregorCINDEX_LINKAGE CXCursor clang_getCursorDefinition(CXCursor); 2204b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor 22051efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar/** 2206b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * \brief Determine whether the declaration pointed to by this cursor 2207b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * is also a definition of that entity. 2208b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor */ 2209b699866820102a69d83d6ac6941985c5ef4e8c40Douglas GregorCINDEX_LINKAGE unsigned clang_isCursorDefinition(CXCursor); 2210b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor 2211c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 22121a9d0503b67a499797141af0fd6d315d5045f0eaDouglas Gregor * \brief Retrieve the canonical cursor corresponding to the given cursor. 22131a9d0503b67a499797141af0fd6d315d5045f0eaDouglas Gregor * 22141a9d0503b67a499797141af0fd6d315d5045f0eaDouglas Gregor * In the C family of languages, many kinds of entities can be declared several 22151a9d0503b67a499797141af0fd6d315d5045f0eaDouglas Gregor * times within a single translation unit. For example, a structure type can 22161a9d0503b67a499797141af0fd6d315d5045f0eaDouglas Gregor * be forward-declared (possibly multiple times) and later defined: 22171a9d0503b67a499797141af0fd6d315d5045f0eaDouglas Gregor * 22181a9d0503b67a499797141af0fd6d315d5045f0eaDouglas Gregor * \code 22191a9d0503b67a499797141af0fd6d315d5045f0eaDouglas Gregor * struct X; 22201a9d0503b67a499797141af0fd6d315d5045f0eaDouglas Gregor * struct X; 22211a9d0503b67a499797141af0fd6d315d5045f0eaDouglas Gregor * struct X { 22221a9d0503b67a499797141af0fd6d315d5045f0eaDouglas Gregor * int member; 22231a9d0503b67a499797141af0fd6d315d5045f0eaDouglas Gregor * }; 22241a9d0503b67a499797141af0fd6d315d5045f0eaDouglas Gregor * \endcode 22251a9d0503b67a499797141af0fd6d315d5045f0eaDouglas Gregor * 22261a9d0503b67a499797141af0fd6d315d5045f0eaDouglas Gregor * The declarations and the definition of \c X are represented by three 22271a9d0503b67a499797141af0fd6d315d5045f0eaDouglas Gregor * different cursors, all of which are declarations of the same underlying 22281a9d0503b67a499797141af0fd6d315d5045f0eaDouglas Gregor * entity. One of these cursor is considered the "canonical" cursor, which 22291a9d0503b67a499797141af0fd6d315d5045f0eaDouglas Gregor * is effectively the representative for the underlying entity. One can 22301a9d0503b67a499797141af0fd6d315d5045f0eaDouglas Gregor * determine if two cursors are declarations of the same underlying entity by 22311a9d0503b67a499797141af0fd6d315d5045f0eaDouglas Gregor * comparing their canonical cursors. 22321a9d0503b67a499797141af0fd6d315d5045f0eaDouglas Gregor * 22331a9d0503b67a499797141af0fd6d315d5045f0eaDouglas Gregor * \returns The canonical cursor for the entity referred to by the given cursor. 22341a9d0503b67a499797141af0fd6d315d5045f0eaDouglas Gregor */ 22351a9d0503b67a499797141af0fd6d315d5045f0eaDouglas GregorCINDEX_LINKAGE CXCursor clang_getCanonicalCursor(CXCursor); 22361a9d0503b67a499797141af0fd6d315d5045f0eaDouglas Gregor 22371a9d0503b67a499797141af0fd6d315d5045f0eaDouglas Gregor/** 2238c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @} 2239c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 22401efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 2241c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 22429ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek * \defgroup CINDEX_CPP C++ AST introspection 22439ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek * 22449ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek * The routines in this group provide access information in the ASTs specific 22459ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek * to C++ language features. 22469ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek * 22479ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek * @{ 22489ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek */ 22499ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek 22509ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek/** 225149f6f5489483beaffc7ce48dfc000af4e65b9216Douglas Gregor * \brief Determine if a C++ member function or member function template is 225249f6f5489483beaffc7ce48dfc000af4e65b9216Douglas Gregor * declared 'static'. 22539ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek */ 22549ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed KremenekCINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C); 22559ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek 22569ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek/** 225749f6f5489483beaffc7ce48dfc000af4e65b9216Douglas Gregor * \brief Given a cursor that represents a template, determine 225849f6f5489483beaffc7ce48dfc000af4e65b9216Douglas Gregor * the cursor kind of the specializations would be generated by instantiating 225949f6f5489483beaffc7ce48dfc000af4e65b9216Douglas Gregor * the template. 226049f6f5489483beaffc7ce48dfc000af4e65b9216Douglas Gregor * 226149f6f5489483beaffc7ce48dfc000af4e65b9216Douglas Gregor * This routine can be used to determine what flavor of function template, 226249f6f5489483beaffc7ce48dfc000af4e65b9216Douglas Gregor * class template, or class template partial specialization is stored in the 226349f6f5489483beaffc7ce48dfc000af4e65b9216Douglas Gregor * cursor. For example, it can describe whether a class template cursor is 226449f6f5489483beaffc7ce48dfc000af4e65b9216Douglas Gregor * declared with "struct", "class" or "union". 226549f6f5489483beaffc7ce48dfc000af4e65b9216Douglas Gregor * 226649f6f5489483beaffc7ce48dfc000af4e65b9216Douglas Gregor * \param C The cursor to query. This cursor should represent a template 226749f6f5489483beaffc7ce48dfc000af4e65b9216Douglas Gregor * declaration. 226849f6f5489483beaffc7ce48dfc000af4e65b9216Douglas Gregor * 226949f6f5489483beaffc7ce48dfc000af4e65b9216Douglas Gregor * \returns The cursor kind of the specializations that would be generated 227049f6f5489483beaffc7ce48dfc000af4e65b9216Douglas Gregor * by instantiating the template \p C. If \p C is not a template, returns 227149f6f5489483beaffc7ce48dfc000af4e65b9216Douglas Gregor * \c CXCursor_NoDeclFound. 227249f6f5489483beaffc7ce48dfc000af4e65b9216Douglas Gregor */ 227349f6f5489483beaffc7ce48dfc000af4e65b9216Douglas GregorCINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind(CXCursor C); 227449f6f5489483beaffc7ce48dfc000af4e65b9216Douglas Gregor 227549f6f5489483beaffc7ce48dfc000af4e65b9216Douglas Gregor/** 2276e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * \brief Given a cursor that may represent a specialization or instantiation 2277e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * of a template, retrieve the cursor that represents the template that it 2278e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * specializes or from which it was instantiated. 2279e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * 2280e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * This routine determines the template involved both for explicit 2281e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * specializations of templates and for implicit instantiations of the template, 2282e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * both of which are referred to as "specializations". For a class template 2283e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * specialization (e.g., \c std::vector<bool>), this routine will return 2284e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * either the primary template (\c std::vector) or, if the specialization was 2285e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * instantiated from a class template partial specialization, the class template 2286e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * partial specialization. For a class template partial specialization and a 2287e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * function template specialization (including instantiations), this 2288e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * this routine will return the specialized template. 2289e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * 2290e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * For members of a class template (e.g., member functions, member classes, or 2291e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * static data members), returns the specialized or instantiated member. 2292e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * Although not strictly "templates" in the C++ language, members of class 2293e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * templates have the same notions of specializations and instantiations that 2294e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * templates do, so this routine treats them similarly. 2295e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * 2296e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * \param C A cursor that may be a specialization of a template or a member 2297e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * of a template. 2298e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * 2299e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * \returns If the given cursor is a specialization or instantiation of a 2300e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * template or a member thereof, the template or member that it specializes or 2301e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * from which it was instantiated. Otherwise, returns a NULL cursor. 2302e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor */ 2303e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas GregorCINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate(CXCursor C); 2304e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor 2305e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor/** 23069ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek * @} 23079ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek */ 23089ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek 23099ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek/** 23100045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * \defgroup CINDEX_LEX Token extraction and manipulation 23110045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * 23120045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * The routines in this group provide access to the tokens within a 23130045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * translation unit, along with a semantic mapping of those tokens to 23140045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * their corresponding cursors. 2315fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * 2316fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * @{ 2317fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */ 2318fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor 2319fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/** 2320fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief Describes a kind of token. 2321fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */ 2322fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregortypedef enum CXTokenKind { 2323fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor /** 2324fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief A token that contains some kind of punctuation. 2325fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */ 2326fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor CXToken_Punctuation, 2327896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek 2328fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor /** 23290045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * \brief A language keyword. 2330fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */ 2331fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor CXToken_Keyword, 2332896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek 2333fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor /** 2334fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief An identifier (that is not a keyword). 2335fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */ 2336fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor CXToken_Identifier, 2337896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek 2338fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor /** 2339fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief A numeric, string, or character literal. 2340fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */ 2341fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor CXToken_Literal, 2342896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek 2343fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor /** 2344fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief A comment. 2345fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */ 2346fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor CXToken_Comment 2347fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor} CXTokenKind; 2348fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor 2349fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/** 2350fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief Describes a single preprocessing token. 2351fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */ 2352fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregortypedef struct { 2353fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor unsigned int_data[4]; 2354fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor void *ptr_data; 2355fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor} CXToken; 2356fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor 2357fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/** 2358fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief Determine the kind of the given token. 2359fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */ 2360fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas GregorCINDEX_LINKAGE CXTokenKind clang_getTokenKind(CXToken); 2361896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek 2362fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/** 2363fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief Determine the spelling of the given token. 2364fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * 2365fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * The spelling of a token is the textual representation of that token, e.g., 2366fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * the text of an identifier or keyword. 2367fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */ 2368fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas GregorCINDEX_LINKAGE CXString clang_getTokenSpelling(CXTranslationUnit, CXToken); 2369896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek 2370fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/** 2371fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief Retrieve the source location of the given token. 2372fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */ 2373896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE CXSourceLocation clang_getTokenLocation(CXTranslationUnit, 2374fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor CXToken); 2375896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek 2376fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/** 2377fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief Retrieve a source range that covers the given token. 2378fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */ 2379fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas GregorCINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken); 2380fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor 2381fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/** 2382fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief Tokenize the source code described by the given range into raw 2383fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * lexical tokens. 2384fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * 2385fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \param TU the translation unit whose text is being tokenized. 2386fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * 2387fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \param Range the source range in which text should be tokenized. All of the 2388fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * tokens produced by tokenization will fall within this source range, 2389fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * 2390fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \param Tokens this pointer will be set to point to the array of tokens 2391fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * that occur within the given source range. The returned pointer must be 2392fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * freed with clang_disposeTokens() before the translation unit is destroyed. 2393fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * 2394fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \param NumTokens will be set to the number of tokens in the \c *Tokens 2395fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * array. 2396fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * 2397fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */ 2398fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas GregorCINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range, 2399fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor CXToken **Tokens, unsigned *NumTokens); 2400896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek 2401fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/** 2402fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief Annotate the given set of tokens by providing cursors for each token 2403fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * that can be mapped to a specific entity within the abstract syntax tree. 2404fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * 24050045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * This token-annotation routine is equivalent to invoking 24060045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * clang_getCursor() for the source locations of each of the 24070045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * tokens. The cursors provided are filtered, so that only those 24080045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * cursors that have a direct correspondence to the token are 24090045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * accepted. For example, given a function call \c f(x), 24100045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * clang_getCursor() would provide the following cursors: 24110045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * 24120045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'. 24130045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'. 24140045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'. 24150045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * 24160045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * Only the first and last of these cursors will occur within the 24170045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * annotate, since the tokens "f" and "x' directly refer to a function 24180045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * and a variable, respectively, but the parentheses are just a small 24190045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * part of the full syntax of the function call expression, which is 24200045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * not provided as an annotation. 2421fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * 2422fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \param TU the translation unit that owns the given tokens. 2423fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * 2424fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \param Tokens the set of tokens to annotate. 2425fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * 2426fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \param NumTokens the number of tokens in \p Tokens. 2427fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * 2428fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \param Cursors an array of \p NumTokens cursors, whose contents will be 2429fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * replaced with the cursors corresponding to each token. 2430fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */ 2431fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas GregorCINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU, 2432fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor CXToken *Tokens, unsigned NumTokens, 2433fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor CXCursor *Cursors); 2434896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek 2435fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/** 2436fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief Free the given set of tokens. 2437fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */ 2438896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU, 2439fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor CXToken *Tokens, unsigned NumTokens); 2440896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek 2441fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/** 2442fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * @} 2443fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */ 2444896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek 2445fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/** 2446c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \defgroup CINDEX_DEBUG Debugging facilities 2447c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 2448c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * These routines are used for testing and debugging, only, and should not 2449c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * be relied upon. 2450c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 2451c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @{ 2452c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 24531efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 24544ade6d6eae934f796ca43c81a5aa185e456dde9bSteve Naroff/* for debug/testing */ 2455e68fff6fc083c6270d835216a3de0b82c6ef0310Ted KremenekCINDEX_LINKAGE CXString clang_getCursorKindSpelling(enum CXCursorKind Kind); 24561efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel DunbarCINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(CXCursor, 24571efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar const char **startBuf, 24584ade6d6eae934f796ca43c81a5aa185e456dde9bSteve Naroff const char **endBuf, 24594ade6d6eae934f796ca43c81a5aa185e456dde9bSteve Naroff unsigned *startLine, 24604ade6d6eae934f796ca43c81a5aa185e456dde9bSteve Naroff unsigned *startColumn, 24614ade6d6eae934f796ca43c81a5aa185e456dde9bSteve Naroff unsigned *endLine, 24624ade6d6eae934f796ca43c81a5aa185e456dde9bSteve Naroff unsigned *endColumn); 24630a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas GregorCINDEX_LINKAGE void clang_enableStackTraces(void); 2464995aaf9c8f0131bef0215a9a0bc794b83a49e0b7Daniel DunbarCINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void*), void *user_data, 2465995aaf9c8f0131bef0215a9a0bc794b83a49e0b7Daniel Dunbar unsigned stack_size); 2466995aaf9c8f0131bef0215a9a0bc794b83a49e0b7Daniel Dunbar 24670c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor/** 2468c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @} 2469c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 24701efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 2471c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 2472c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \defgroup CINDEX_CODE_COMPLET Code completion 2473c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 2474c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * Code completion involves taking an (incomplete) source file, along with 2475c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * knowledge of where the user is actively editing that file, and suggesting 2476c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * syntactically- and semantically-valid constructs that the user might want to 2477c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * use at that particular point in the source code. These data structures and 2478c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * routines provide support for code completion. 2479c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * 2480c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @{ 2481c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 24821efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 2483c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 24840c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief A semantic string that describes a code-completion result. 24850c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 24860c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * A semantic string that describes the formatting of a code-completion 24870c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * result as a single "template" of text that should be inserted into the 24880c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * source buffer when a particular code-completion result is selected. 24890c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * Each semantic string is made up of some number of "chunks", each of which 24900c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * contains some text along with a description of what that text means, e.g., 24910c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * the name of the entity being referenced, whether the text chunk is part of 24920c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * the template, or whether it is a "placeholder" that the user should replace 24930c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * with actual code,of a specific kind. See \c CXCompletionChunkKind for a 24941efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * description of the different kinds of chunks. 24950c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 24960c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregortypedef void *CXCompletionString; 24971efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 24980c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor/** 24990c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief A single result of code completion. 25000c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 25010c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregortypedef struct { 25020c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 25031efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \brief The kind of entity that this completion refers to. 25040c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 25051efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * The cursor kind will be a macro, keyword, or a declaration (one of the 25060c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * *Decl cursor kinds), describing the entity that the completion is 25070c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * referring to. 25080c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 25090c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \todo In the future, we would like to provide a full cursor, to allow 25100c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * the client to extract additional information from declaration. 25110c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 25120c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor enum CXCursorKind CursorKind; 25131efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 25141efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar /** 25150c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief The code-completion string that describes how to insert this 25160c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * code-completion result into the editing buffer. 25170c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 25180c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionString CompletionString; 25190c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor} CXCompletionResult; 25200c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor 25210c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor/** 25220c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief Describes a single piece of text within a code-completion string. 25230c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 25241efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * Each "chunk" within a code-completion string (\c CXCompletionString) is 25251efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * either a piece of text with a specific "kind" that describes how that text 25260c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * should be interpreted by the client or is another completion string. 25270c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 25280c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregorenum CXCompletionChunkKind { 25290c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 25300c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief A code-completion string that describes "optional" text that 25310c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * could be a part of the template (but is not required). 25320c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 25330c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * The Optional chunk is the only kind of chunk that has a code-completion 25341efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * string for its representation, which is accessible via 25350c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \c clang_getCompletionChunkCompletionString(). The code-completion string 25360c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * describes an additional part of the template that is completely optional. 25370c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * For example, optional chunks can be used to describe the placeholders for 25380c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * arguments that match up with defaulted function parameters, e.g. given: 25390c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 25400c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \code 25410c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * void f(int x, float y = 3.14, double z = 2.71828); 25420c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \endcode 25430c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 25440c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * The code-completion string for this function would contain: 25450c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * - a TypedText chunk for "f". 25460c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * - a LeftParen chunk for "(". 25470c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * - a Placeholder chunk for "int x" 25480c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * - an Optional chunk containing the remaining defaulted arguments, e.g., 25490c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * - a Comma chunk for "," 255071570182471d502a97f7f175aa527152544c75f2Daniel Dunbar * - a Placeholder chunk for "float y" 25510c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * - an Optional chunk containing the last defaulted argument: 25520c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * - a Comma chunk for "," 25530c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * - a Placeholder chunk for "double z" 25540c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * - a RightParen chunk for ")" 25550c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 255671570182471d502a97f7f175aa527152544c75f2Daniel Dunbar * There are many ways to handle Optional chunks. Two simple approaches are: 25570c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * - Completely ignore optional chunks, in which case the template for the 25580c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * function "f" would only include the first parameter ("int x"). 25590c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * - Fully expand all optional chunks, in which case the template for the 25600c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * function "f" would have all of the parameters. 25610c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 25620c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_Optional, 25630c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 25640c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief Text that a user would be expected to type to get this 25651efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * code-completion result. 25660c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 25671efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * There will be exactly one "typed text" chunk in a semantic string, which 25681efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * will typically provide the spelling of a keyword or the name of a 25690c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * declaration that could be used at the current code point. Clients are 25700c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * expected to filter the code-completion results based on the text in this 25710c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * chunk. 25720c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 25730c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_TypedText, 25740c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 25750c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief Text that should be inserted as part of a code-completion result. 25760c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 25770c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * A "text" chunk represents text that is part of the template to be 25780c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * inserted into user code should this particular code-completion result 25790c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * be selected. 25800c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 25810c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_Text, 25820c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 25830c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief Placeholder text that should be replaced by the user. 25840c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 25850c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * A "placeholder" chunk marks a place where the user should insert text 25860c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * into the code-completion template. For example, placeholders might mark 25870c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * the function parameters for a function declaration, to indicate that the 25880c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * user should provide arguments for each of those parameters. The actual 25890c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * text in a placeholder is a suggestion for the text to display before 25900c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * the user replaces the placeholder with real code. 25910c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 25920c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_Placeholder, 25930c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 25940c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief Informative text that should be displayed but never inserted as 25950c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * part of the template. 25961efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * 25970c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * An "informative" chunk contains annotations that can be displayed to 25980c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * help the user decide whether a particular code-completion result is the 25990c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * right option, but which is not part of the actual template to be inserted 26000c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * by code completion. 26010c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 26020c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_Informative, 26030c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 26040c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief Text that describes the current parameter when code-completion is 26050c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * referring to function call, message send, or template specialization. 26060c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 26070c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * A "current parameter" chunk occurs when code-completion is providing 26080c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * information about a parameter corresponding to the argument at the 26090c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * code-completion point. For example, given a function 26100c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 26110c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \code 26120c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * int add(int x, int y); 26130c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \endcode 26140c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 26150c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * and the source code \c add(, where the code-completion point is after the 26160c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * "(", the code-completion string will contain a "current parameter" chunk 26170c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * for "int x", indicating that the current argument will initialize that 26180c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * parameter. After typing further, to \c add(17, (where the code-completion 26191efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * point is after the ","), the code-completion string will contain a 26200c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * "current paremeter" chunk to "int y". 26210c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 26220c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_CurrentParameter, 26230c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 26240c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief A left parenthesis ('('), used to initiate a function call or 26250c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * signal the beginning of a function parameter list. 26260c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 26270c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_LeftParen, 26280c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 26290c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief A right parenthesis (')'), used to finish a function call or 26300c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * signal the end of a function parameter list. 26310c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 26320c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_RightParen, 26330c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 26340c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief A left bracket ('['). 26350c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 26360c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_LeftBracket, 26370c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 26380c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief A right bracket (']'). 26390c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 26400c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_RightBracket, 26410c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 26420c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief A left brace ('{'). 26430c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 26440c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_LeftBrace, 26450c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 26460c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief A right brace ('}'). 26470c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 26480c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_RightBrace, 26490c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 26500c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief A left angle bracket ('<'). 26510c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 26520c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_LeftAngle, 26530c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 26540c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief A right angle bracket ('>'). 26550c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 26560c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor CXCompletionChunk_RightAngle, 26570c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor /** 26580c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief A comma separator (','). 26590c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 2660ff5ce6eefc7c253ef6edf4d4bfc996fdd82d09aaDouglas Gregor CXCompletionChunk_Comma, 2661ff5ce6eefc7c253ef6edf4d4bfc996fdd82d09aaDouglas Gregor /** 26621efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \brief Text that specifies the result type of a given result. 2663ff5ce6eefc7c253ef6edf4d4bfc996fdd82d09aaDouglas Gregor * 2664ff5ce6eefc7c253ef6edf4d4bfc996fdd82d09aaDouglas Gregor * This special kind of informative chunk is not meant to be inserted into 26651efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * the text buffer. Rather, it is meant to illustrate the type that an 2666ff5ce6eefc7c253ef6edf4d4bfc996fdd82d09aaDouglas Gregor * expression using the given completion string would have. 2667ff5ce6eefc7c253ef6edf4d4bfc996fdd82d09aaDouglas Gregor */ 266801dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor CXCompletionChunk_ResultType, 266901dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor /** 267001dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor * \brief A colon (':'). 267101dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor */ 267201dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor CXCompletionChunk_Colon, 267301dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor /** 267401dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor * \brief A semicolon (';'). 267501dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor */ 267601dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor CXCompletionChunk_SemiColon, 267701dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor /** 267801dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor * \brief An '=' sign. 267901dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor */ 268001dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor CXCompletionChunk_Equal, 268101dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor /** 268201dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor * Horizontal space (' '). 268301dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor */ 268401dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor CXCompletionChunk_HorizontalSpace, 268501dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor /** 268601dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor * Vertical space ('\n'), after which it is generally a good idea to 268701dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor * perform indentation. 268801dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor */ 268901dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor CXCompletionChunk_VerticalSpace 26900c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor}; 26911efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 26920c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor/** 26930c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief Determine the kind of a particular chunk within a completion string. 26940c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 26950c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param completion_string the completion string to query. 26960c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 26970c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param chunk_number the 0-based index of the chunk in the completion string. 26980c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 26990c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \returns the kind of the chunk at the index \c chunk_number. 27000c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 27011efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel DunbarCINDEX_LINKAGE enum CXCompletionChunkKind 27020c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregorclang_getCompletionChunkKind(CXCompletionString completion_string, 27030c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor unsigned chunk_number); 27041efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 27050c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor/** 27061efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \brief Retrieve the text associated with a particular chunk within a 27070c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * completion string. 27080c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 27090c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param completion_string the completion string to query. 27100c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 27110c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param chunk_number the 0-based index of the chunk in the completion string. 27120c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 27130c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \returns the text associated with the chunk at index \c chunk_number. 27140c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 27152ef6f8f5a35a60870594c5b04e0aa2bf22c6886fTed KremenekCINDEX_LINKAGE CXString 27160c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregorclang_getCompletionChunkText(CXCompletionString completion_string, 27170c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor unsigned chunk_number); 27180c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor 27190c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor/** 27201efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \brief Retrieve the completion string associated with a particular chunk 27210c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * within a completion string. 27220c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 27230c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param completion_string the completion string to query. 27240c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 27250c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param chunk_number the 0-based index of the chunk in the completion string. 27260c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * 27270c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \returns the completion string associated with the chunk at index 27280c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \c chunk_number, or NULL if that chunk is not represented by a completion 27290c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * string. 27300c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 27310c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas GregorCINDEX_LINKAGE CXCompletionString 27320c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregorclang_getCompletionChunkCompletionString(CXCompletionString completion_string, 27330c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor unsigned chunk_number); 27341efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 27350c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor/** 27360c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief Retrieve the number of chunks in the given code-completion string. 27370c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 27380c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas GregorCINDEX_LINKAGE unsigned 27390c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregorclang_getNumCompletionChunks(CXCompletionString completion_string); 27400c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor 27410c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor/** 274212e131385e892e3723483a1081a89bcad29c8a84Douglas Gregor * \brief Determine the priority of this code completion. 274312e131385e892e3723483a1081a89bcad29c8a84Douglas Gregor * 274412e131385e892e3723483a1081a89bcad29c8a84Douglas Gregor * The priority of a code completion indicates how likely it is that this 274512e131385e892e3723483a1081a89bcad29c8a84Douglas Gregor * particular completion is the completion that the user will select. The 274612e131385e892e3723483a1081a89bcad29c8a84Douglas Gregor * priority is selected by various internal heuristics. 274712e131385e892e3723483a1081a89bcad29c8a84Douglas Gregor * 274812e131385e892e3723483a1081a89bcad29c8a84Douglas Gregor * \param completion_string The completion string to query. 274912e131385e892e3723483a1081a89bcad29c8a84Douglas Gregor * 275012e131385e892e3723483a1081a89bcad29c8a84Douglas Gregor * \returns The priority of this completion string. Smaller values indicate 275112e131385e892e3723483a1081a89bcad29c8a84Douglas Gregor * higher-priority (more likely) completions. 275212e131385e892e3723483a1081a89bcad29c8a84Douglas Gregor */ 275312e131385e892e3723483a1081a89bcad29c8a84Douglas GregorCINDEX_LINKAGE unsigned 275412e131385e892e3723483a1081a89bcad29c8a84Douglas Gregorclang_getCompletionPriority(CXCompletionString completion_string); 275512e131385e892e3723483a1081a89bcad29c8a84Douglas Gregor 275612e131385e892e3723483a1081a89bcad29c8a84Douglas Gregor/** 275758ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor * \brief Determine the availability of the entity that this code-completion 275858ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor * string refers to. 275958ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor * 276058ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor * \param completion_string The completion string to query. 276158ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor * 276258ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor * \returns The availability of the completion string. 276358ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor */ 276458ddb60f409125eda5436c4a1f070f7fa4744295Douglas GregorCINDEX_LINKAGE enum CXAvailabilityKind 276558ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregorclang_getCompletionAvailability(CXCompletionString completion_string); 276658ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor 276758ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor/** 2768ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor * \brief Contains the results of code-completion. 2769ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor * 2770ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor * This data structure contains the results of code completion, as 2771e0cc52ef8afc8d1cba9c534191b5f0ddaff1d694Douglas Gregor * produced by \c clang_codeCompleteAt(). Its contents must be freed by 2772ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor * \c clang_disposeCodeCompleteResults. 2773ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor */ 2774ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregortypedef struct { 2775ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor /** 2776ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor * \brief The code-completion results. 2777ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor */ 2778ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor CXCompletionResult *Results; 2779ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor 2780ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor /** 2781ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor * \brief The number of code-completion results stored in the 2782ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor * \c Results array. 2783ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor */ 2784ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor unsigned NumResults; 2785ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor} CXCodeCompleteResults; 2786ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor 2787ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor/** 2788cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor * \brief Flags that can be passed to \c clang_codeCompleteAt() to 2789cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor * modify its behavior. 2790cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor * 2791cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor * The enumerators in this enumeration can be bitwise-OR'd together to 2792cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor * provide multiple options to \c clang_codeCompleteAt(). 2793cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor */ 2794cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregorenum CXCodeComplete_Flags { 2795cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor /** 2796cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor * \brief Whether to include macros within the set of code 2797cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor * completions returned. 2798cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor */ 2799cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor CXCodeComplete_IncludeMacros = 0x01, 2800cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor 2801cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor /** 2802cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor * \brief Whether to include code patterns for language constructs 2803cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor * within the set of code completions, e.g., for loops. 2804cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor */ 2805cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor CXCodeComplete_IncludeCodePatterns = 0x02 2806cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor}; 2807cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor 2808cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor/** 2809cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor * \brief Returns a default set of code-completion options that can be 2810cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor * passed to\c clang_codeCompleteAt(). 2811cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor */ 2812cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas GregorCINDEX_LINKAGE unsigned clang_defaultCodeCompleteOptions(void); 2813cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor 2814cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor/** 28151abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * \brief Perform code completion at a given location in a translation unit. 28161abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * 28171abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * This function performs code completion at a particular file, line, and 28181abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * column within source code, providing results that suggest potential 28191abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * code snippets based on the context of the completion. The basic model 28201abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * for code completion is that Clang will parse a complete source file, 28211abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * performing syntax checking up to the location where code-completion has 28221abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * been requested. At that point, a special code-completion token is passed 28231abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * to the parser, which recognizes this token and determines, based on the 28241abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * current location in the C/Objective-C/C++ grammar and the state of 28251abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * semantic analysis, what completions to provide. These completions are 28261abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * returned via a new \c CXCodeCompleteResults structure. 28271abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * 28281abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * Code completion itself is meant to be triggered by the client when the 28291abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * user types punctuation characters or whitespace, at which point the 28301abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * code-completion location will coincide with the cursor. For example, if \c p 28311abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * is a pointer, code-completion might be triggered after the "-" and then 28321abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * after the ">" in \c p->. When the code-completion location is afer the ">", 28331abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * the completion results will provide, e.g., the members of the struct that 28341abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * "p" points to. The client is responsible for placing the cursor at the 28351abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * beginning of the token currently being typed, then filtering the results 28361abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * based on the contents of the token. For example, when code-completing for 28371abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * the expression \c p->get, the client should provide the location just after 28381abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the 28391abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * client can filter the results based on the current token text ("get"), only 28401abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * showing those results that start with "get". The intent of this interface 28411abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * is to separate the relatively high-latency acquisition of code-completion 28421abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * results from the filtering of results on a per-character basis, which must 28431abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * have a lower latency. 28441abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * 28451abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * \param TU The translation unit in which code-completion should 28461abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * occur. The source files for this translation unit need not be 28471abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * completely up-to-date (and the contents of those source files may 28481abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * be overridden via \p unsaved_files). Cursors referring into the 28491abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * translation unit may be invalidated by this invocation. 28501abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * 28511abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * \param complete_filename The name of the source file where code 28521abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * completion should be performed. This filename may be any file 28531abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * included in the translation unit. 28541abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * 28551abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * \param complete_line The line at which code-completion should occur. 28561abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * 28571abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * \param complete_column The column at which code-completion should occur. 28581abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * Note that the column should point just after the syntactic construct that 28591abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * initiated code completion, and not in the middle of a lexical token. 28601abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * 28611abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * \param unsaved_files the Tiles that have not yet been saved to disk 28621abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * but may be required for parsing or code completion, including the 28631abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * contents of those files. The contents and name of these files (as 28641abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * specified by CXUnsavedFile) are copied when necessary, so the 28651abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * client only needs to guarantee their validity until the call to 28661abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * this function returns. 28671abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * 28681abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * \param num_unsaved_files The number of unsaved file entries in \p 28691abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * unsaved_files. 28701abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * 2871cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor * \param options Extra options that control the behavior of code 2872cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor * completion, expressed as a bitwise OR of the enumerators of the 2873cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor * CXCodeComplete_Flags enumeration. The 2874cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor * \c clang_defaultCodeCompleteOptions() function returns a default set 2875cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor * of code-completion options. 2876cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor * 28771abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * \returns If successful, a new \c CXCodeCompleteResults structure 28781abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * containing code-completion results, which should eventually be 28791abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * freed with \c clang_disposeCodeCompleteResults(). If code 28801abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * completion fails, returns NULL. 28811abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor */ 28821abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas GregorCINDEX_LINKAGE 28831abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas GregorCXCodeCompleteResults *clang_codeCompleteAt(CXTranslationUnit TU, 28841abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor const char *complete_filename, 28851abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor unsigned complete_line, 28861abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor unsigned complete_column, 28871abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor struct CXUnsavedFile *unsaved_files, 2888cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor unsigned num_unsaved_files, 2889cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor unsigned options); 28901abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor 28911abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor/** 28921e5e6684b0f27701e6f7c65f8c6a32a10cbcc3edDouglas Gregor * \brief Sort the code-completion results in case-insensitive alphabetical 28931e5e6684b0f27701e6f7c65f8c6a32a10cbcc3edDouglas Gregor * order. 28941e5e6684b0f27701e6f7c65f8c6a32a10cbcc3edDouglas Gregor * 28951e5e6684b0f27701e6f7c65f8c6a32a10cbcc3edDouglas Gregor * \param Results The set of results to sort. 28961e5e6684b0f27701e6f7c65f8c6a32a10cbcc3edDouglas Gregor * \param NumResults The number of results in \p Results. 28971e5e6684b0f27701e6f7c65f8c6a32a10cbcc3edDouglas Gregor */ 28981e5e6684b0f27701e6f7c65f8c6a32a10cbcc3edDouglas GregorCINDEX_LINKAGE 28991e5e6684b0f27701e6f7c65f8c6a32a10cbcc3edDouglas Gregorvoid clang_sortCodeCompletionResults(CXCompletionResult *Results, 29001e5e6684b0f27701e6f7c65f8c6a32a10cbcc3edDouglas Gregor unsigned NumResults); 29011e5e6684b0f27701e6f7c65f8c6a32a10cbcc3edDouglas Gregor 29021e5e6684b0f27701e6f7c65f8c6a32a10cbcc3edDouglas Gregor/** 2903ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor * \brief Free the given set of code-completion results. 29040c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */ 29051efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel DunbarCINDEX_LINKAGE 2906ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregorvoid clang_disposeCodeCompleteResults(CXCodeCompleteResults *Results); 290758ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor 290820d416c36b46dd19ee0b1ea2d0266ae43be86e51Douglas Gregor/** 2909a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * \brief Determine the number of diagnostics produced prior to the 2910a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * location where code completion was performed. 2911a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor */ 2912896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE 2913a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregorunsigned clang_codeCompleteGetNumDiagnostics(CXCodeCompleteResults *Results); 2914a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor 2915a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor/** 2916a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * \brief Retrieve a diagnostic associated with the given code completion. 2917a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * 2918a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * \param Result the code completion results to query. 2919a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * \param Index the zero-based diagnostic number to retrieve. 2920a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * 2921a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * \returns the requested diagnostic. This diagnostic must be freed 2922a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * via a call to \c clang_disposeDiagnostic(). 2923a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor */ 2924896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE 2925a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas GregorCXDiagnostic clang_codeCompleteGetDiagnostic(CXCodeCompleteResults *Results, 2926a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor unsigned Index); 2927a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor 2928a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor/** 292920d416c36b46dd19ee0b1ea2d0266ae43be86e51Douglas Gregor * @} 293020d416c36b46dd19ee0b1ea2d0266ae43be86e51Douglas Gregor */ 29311efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 29321efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 293304bb716aea8fd2372ac10b0c640cabc5e5caa615Ted Kremenek/** 293404bb716aea8fd2372ac10b0c640cabc5e5caa615Ted Kremenek * \defgroup CINDEX_MISC Miscellaneous utility functions 293504bb716aea8fd2372ac10b0c640cabc5e5caa615Ted Kremenek * 293604bb716aea8fd2372ac10b0c640cabc5e5caa615Ted Kremenek * @{ 293704bb716aea8fd2372ac10b0c640cabc5e5caa615Ted Kremenek */ 293823e1ad09bb68f929212e0ff51206258d06e7f6cfTed Kremenek 293923e1ad09bb68f929212e0ff51206258d06e7f6cfTed Kremenek/** 294023e1ad09bb68f929212e0ff51206258d06e7f6cfTed Kremenek * \brief Return a version string, suitable for showing to a user, but not 294123e1ad09bb68f929212e0ff51206258d06e7f6cfTed Kremenek * intended to be parsed (the format is not guaranteed to be stable). 294223e1ad09bb68f929212e0ff51206258d06e7f6cfTed Kremenek */ 2943a2a9d6e4e5b6001b86b7dfc5db1ea296ce29a3d3Ted KremenekCINDEX_LINKAGE CXString clang_getClangVersion(); 294404bb716aea8fd2372ac10b0c640cabc5e5caa615Ted Kremenek 2945d2427ddf00aacdc288c386f3882e0821ca9bd27bTed Kremenek 2946d2427ddf00aacdc288c386f3882e0821ca9bd27bTed Kremenek/** 2947d2427ddf00aacdc288c386f3882e0821ca9bd27bTed Kremenek * \brief Enable/disable crash recovery. 2948d2427ddf00aacdc288c386f3882e0821ca9bd27bTed Kremenek * 2949d2427ddf00aacdc288c386f3882e0821ca9bd27bTed Kremenek * \param Flag to indicate if crash recovery is enabled. A non-zero value 2950d2427ddf00aacdc288c386f3882e0821ca9bd27bTed Kremenek * enables crash recovery, while 0 disables it. 2951d2427ddf00aacdc288c386f3882e0821ca9bd27bTed Kremenek */ 2952d2427ddf00aacdc288c386f3882e0821ca9bd27bTed KremenekCINDEX_LINKAGE void clang_toggleCrashRecovery(unsigned isEnabled); 2953d2427ddf00aacdc288c386f3882e0821ca9bd27bTed Kremenek 295416b55a71695a33c094383295cc7b7a2080e098daTed Kremenek /** 2955896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek * \brief Visitor invoked for each file in a translation unit 295616b55a71695a33c094383295cc7b7a2080e098daTed Kremenek * (used with clang_getInclusions()). 295716b55a71695a33c094383295cc7b7a2080e098daTed Kremenek * 295816b55a71695a33c094383295cc7b7a2080e098daTed Kremenek * This visitor function will be invoked by clang_getInclusions() for each 295916b55a71695a33c094383295cc7b7a2080e098daTed Kremenek * file included (either at the top-level or by #include directives) within 296016b55a71695a33c094383295cc7b7a2080e098daTed Kremenek * a translation unit. The first argument is the file being included, and 296116b55a71695a33c094383295cc7b7a2080e098daTed Kremenek * the second and third arguments provide the inclusion stack. The 296216b55a71695a33c094383295cc7b7a2080e098daTed Kremenek * array is sorted in order of immediate inclusion. For example, 296316b55a71695a33c094383295cc7b7a2080e098daTed Kremenek * the first element refers to the location that included 'included_file'. 296416b55a71695a33c094383295cc7b7a2080e098daTed Kremenek */ 296516b55a71695a33c094383295cc7b7a2080e098daTed Kremenektypedef void (*CXInclusionVisitor)(CXFile included_file, 296616b55a71695a33c094383295cc7b7a2080e098daTed Kremenek CXSourceLocation* inclusion_stack, 296716b55a71695a33c094383295cc7b7a2080e098daTed Kremenek unsigned include_len, 296816b55a71695a33c094383295cc7b7a2080e098daTed Kremenek CXClientData client_data); 296916b55a71695a33c094383295cc7b7a2080e098daTed Kremenek 297016b55a71695a33c094383295cc7b7a2080e098daTed Kremenek/** 297116b55a71695a33c094383295cc7b7a2080e098daTed Kremenek * \brief Visit the set of preprocessor inclusions in a translation unit. 297216b55a71695a33c094383295cc7b7a2080e098daTed Kremenek * The visitor function is called with the provided data for every included 297316b55a71695a33c094383295cc7b7a2080e098daTed Kremenek * file. This does not include headers included by the PCH file (unless one 297416b55a71695a33c094383295cc7b7a2080e098daTed Kremenek * is inspecting the inclusions in the PCH file itself). 297516b55a71695a33c094383295cc7b7a2080e098daTed Kremenek */ 297616b55a71695a33c094383295cc7b7a2080e098daTed KremenekCINDEX_LINKAGE void clang_getInclusions(CXTranslationUnit tu, 297716b55a71695a33c094383295cc7b7a2080e098daTed Kremenek CXInclusionVisitor visitor, 297816b55a71695a33c094383295cc7b7a2080e098daTed Kremenek CXClientData client_data); 297916b55a71695a33c094383295cc7b7a2080e098daTed Kremenek 298016b55a71695a33c094383295cc7b7a2080e098daTed Kremenek/** 298104bb716aea8fd2372ac10b0c640cabc5e5caa615Ted Kremenek * @} 298204bb716aea8fd2372ac10b0c640cabc5e5caa615Ted Kremenek */ 29831efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 2984c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/** 2985c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @} 2986c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */ 29871efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar 2988d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek#ifdef __cplusplus 2989d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek} 2990d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek#endif 2991d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek#endif 2992d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek 2993