Ted Kremenek | d2fa566 | 2009-08-26 22:36:44 +0000 | [diff] [blame] | 1 | /*===-- clang-c/Index.h - Indexing Public C Interface -------------*- C -*-===*\ |
| 2 | |* *| |
| 3 | |* The LLVM Compiler Infrastructure *| |
| 4 | |* *| |
| 5 | |* This file is distributed under the University of Illinois Open Source *| |
| 6 | |* License. See LICENSE.TXT for details. *| |
| 7 | |* *| |
| 8 | |*===----------------------------------------------------------------------===*| |
| 9 | |* *| |
| 10 | |* This header provides a public inferface to a Clang library for extracting *| |
| 11 | |* high-level symbol information from source files without exposing the full *| |
| 12 | |* Clang C++ API. *| |
| 13 | |* *| |
| 14 | \*===----------------------------------------------------------------------===*/ |
| 15 | |
| 16 | #ifndef CLANG_C_INDEX_H |
| 17 | #define CLANG_C_INDEX_H |
| 18 | |
Steve Naroff | 8814503 | 2009-10-27 14:35:18 +0000 | [diff] [blame] | 19 | #include <sys/stat.h> |
Chandler Carruth | 3d31560 | 2009-12-17 09:27:29 +0000 | [diff] [blame] | 20 | #include <time.h> |
Douglas Gregor | 0a812cf | 2010-02-18 23:07:20 +0000 | [diff] [blame] | 21 | #include <stdio.h> |
Steve Naroff | 8814503 | 2009-10-27 14:35:18 +0000 | [diff] [blame] | 22 | |
Ted Kremenek | d2fa566 | 2009-08-26 22:36:44 +0000 | [diff] [blame] | 23 | #ifdef __cplusplus |
| 24 | extern "C" { |
| 25 | #endif |
| 26 | |
Steve Naroff | 8814503 | 2009-10-27 14:35:18 +0000 | [diff] [blame] | 27 | /* MSVC DLL import/export. */ |
John Thompson | 2e06fc8 | 2009-10-27 13:42:56 +0000 | [diff] [blame] | 28 | #ifdef _MSC_VER |
| 29 | #ifdef _CINDEX_LIB_ |
| 30 | #define CINDEX_LINKAGE __declspec(dllexport) |
| 31 | #else |
| 32 | #define CINDEX_LINKAGE __declspec(dllimport) |
| 33 | #endif |
| 34 | #else |
| 35 | #define CINDEX_LINKAGE |
| 36 | #endif |
| 37 | |
Ted Kremenek | 78d5d3b | 2012-04-12 00:03:31 +0000 | [diff] [blame] | 38 | #ifdef __GNUC__ |
| 39 | #define CINDEX_DEPRECATED __attribute__((deprecated)) |
| 40 | #else |
| 41 | #ifdef _MSC_VER |
| 42 | #define CINDEX_DEPRECATED __declspec(deprecated) |
| 43 | #else |
| 44 | #define CINDEX_DEPRECATED |
| 45 | #endif |
| 46 | #endif |
| 47 | |
Douglas Gregor | 87fb940 | 2011-02-23 17:45:25 +0000 | [diff] [blame] | 48 | /** \defgroup CINDEX libclang: C Interface to Clang |
Douglas Gregor | 20d416c | 2010-01-20 01:10:47 +0000 | [diff] [blame] | 49 | * |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 50 | * The C Interface to Clang provides a relatively small API that exposes |
Douglas Gregor | f552544 | 2010-01-20 22:45:41 +0000 | [diff] [blame] | 51 | * facilities for parsing source code into an abstract syntax tree (AST), |
| 52 | * loading already-parsed ASTs, traversing the AST, associating |
| 53 | * physical source locations with elements within the AST, and other |
| 54 | * facilities that support Clang-based development tools. |
Douglas Gregor | 20d416c | 2010-01-20 01:10:47 +0000 | [diff] [blame] | 55 | * |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 56 | * This C interface to Clang will never provide all of the information |
Douglas Gregor | f552544 | 2010-01-20 22:45:41 +0000 | [diff] [blame] | 57 | * representation stored in Clang's C++ AST, nor should it: the intent is to |
| 58 | * maintain an API that is relatively stable from one release to the next, |
| 59 | * providing only the basic functionality needed to support development tools. |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 60 | * |
| 61 | * To avoid namespace pollution, data types are prefixed with "CX" and |
Douglas Gregor | f552544 | 2010-01-20 22:45:41 +0000 | [diff] [blame] | 62 | * functions are prefixed with "clang_". |
Douglas Gregor | 20d416c | 2010-01-20 01:10:47 +0000 | [diff] [blame] | 63 | * |
| 64 | * @{ |
| 65 | */ |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 66 | |
Douglas Gregor | 7f17376 | 2010-01-20 22:28:27 +0000 | [diff] [blame] | 67 | /** |
| 68 | * \brief An "index" that consists of a set of translation units that would |
| 69 | * typically be linked together into an executable or library. |
| 70 | */ |
| 71 | typedef void *CXIndex; |
Steve Naroff | 600866c | 2009-08-27 19:51:58 +0000 | [diff] [blame] | 72 | |
Douglas Gregor | 7f17376 | 2010-01-20 22:28:27 +0000 | [diff] [blame] | 73 | /** |
| 74 | * \brief A single translation unit, which resides in an index. |
| 75 | */ |
Ted Kremenek | 0a90d32 | 2010-11-17 23:24:11 +0000 | [diff] [blame] | 76 | typedef struct CXTranslationUnitImpl *CXTranslationUnit; |
Steve Naroff | 600866c | 2009-08-27 19:51:58 +0000 | [diff] [blame] | 77 | |
Douglas Gregor | 7f17376 | 2010-01-20 22:28:27 +0000 | [diff] [blame] | 78 | /** |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 79 | * \brief Opaque pointer representing client data that will be passed through |
| 80 | * to various callbacks and visitors. |
Douglas Gregor | 7f17376 | 2010-01-20 22:28:27 +0000 | [diff] [blame] | 81 | */ |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 82 | typedef void *CXClientData; |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 83 | |
Douglas Gregor | 735df88 | 2009-12-02 09:21:34 +0000 | [diff] [blame] | 84 | /** |
| 85 | * \brief Provides the contents of a file that has not yet been saved to disk. |
| 86 | * |
| 87 | * Each CXUnsavedFile instance provides the name of a file on the |
| 88 | * system along with the current contents of that file that have not |
| 89 | * yet been saved to disk. |
| 90 | */ |
| 91 | struct CXUnsavedFile { |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 92 | /** |
| 93 | * \brief The file whose contents have not yet been saved. |
Douglas Gregor | 735df88 | 2009-12-02 09:21:34 +0000 | [diff] [blame] | 94 | * |
| 95 | * This file must already exist in the file system. |
| 96 | */ |
| 97 | const char *Filename; |
| 98 | |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 99 | /** |
Douglas Gregor | c8dfe5e | 2010-02-27 01:32:48 +0000 | [diff] [blame] | 100 | * \brief A buffer containing the unsaved contents of this file. |
Douglas Gregor | 735df88 | 2009-12-02 09:21:34 +0000 | [diff] [blame] | 101 | */ |
| 102 | const char *Contents; |
| 103 | |
| 104 | /** |
Douglas Gregor | c8dfe5e | 2010-02-27 01:32:48 +0000 | [diff] [blame] | 105 | * \brief The length of the unsaved contents of this buffer. |
Douglas Gregor | 735df88 | 2009-12-02 09:21:34 +0000 | [diff] [blame] | 106 | */ |
| 107 | unsigned long Length; |
| 108 | }; |
| 109 | |
Peter Collingbourne | 076c22a | 2010-08-24 00:31:37 +0000 | [diff] [blame] | 110 | /** |
| 111 | * \brief Describes the availability of a particular entity, which indicates |
| 112 | * whether the use of this entity will result in a warning or error due to |
| 113 | * it being deprecated or unavailable. |
| 114 | */ |
Douglas Gregor | 58ddb60 | 2010-08-23 23:00:57 +0000 | [diff] [blame] | 115 | enum CXAvailabilityKind { |
Peter Collingbourne | 076c22a | 2010-08-24 00:31:37 +0000 | [diff] [blame] | 116 | /** |
| 117 | * \brief The entity is available. |
| 118 | */ |
Douglas Gregor | 58ddb60 | 2010-08-23 23:00:57 +0000 | [diff] [blame] | 119 | CXAvailability_Available, |
Peter Collingbourne | 076c22a | 2010-08-24 00:31:37 +0000 | [diff] [blame] | 120 | /** |
| 121 | * \brief The entity is available, but has been deprecated (and its use is |
| 122 | * not recommended). |
| 123 | */ |
Douglas Gregor | 58ddb60 | 2010-08-23 23:00:57 +0000 | [diff] [blame] | 124 | CXAvailability_Deprecated, |
Peter Collingbourne | 076c22a | 2010-08-24 00:31:37 +0000 | [diff] [blame] | 125 | /** |
| 126 | * \brief The entity is not available; any use of it will be an error. |
| 127 | */ |
Erik Verbruggen | d120596 | 2011-10-06 07:27:49 +0000 | [diff] [blame] | 128 | CXAvailability_NotAvailable, |
| 129 | /** |
| 130 | * \brief The entity is available, but not accessible; any use of it will be |
| 131 | * an error. |
| 132 | */ |
| 133 | CXAvailability_NotAccessible |
Douglas Gregor | 58ddb60 | 2010-08-23 23:00:57 +0000 | [diff] [blame] | 134 | }; |
Douglas Gregor | cc88966 | 2012-05-08 00:14:45 +0000 | [diff] [blame] | 135 | |
| 136 | /** |
| 137 | * \brief Describes a version number of the form major.minor.subminor. |
| 138 | */ |
| 139 | typedef struct CXVersion { |
| 140 | /** |
| 141 | * \brief The major version number, e.g., the '10' in '10.7.3'. A negative |
| 142 | * value indicates that there is no version number at all. |
| 143 | */ |
| 144 | int Major; |
| 145 | /** |
| 146 | * \brief The minor version number, e.g., the '7' in '10.7.3'. This value |
| 147 | * will be negative if no minor version number was provided, e.g., for |
| 148 | * version '10'. |
| 149 | */ |
| 150 | int Minor; |
| 151 | /** |
| 152 | * \brief The subminor version number, e.g., the '3' in '10.7.3'. This value |
| 153 | * will be negative if no minor or subminor version number was provided, |
| 154 | * e.g., in version '10' or '10.7'. |
| 155 | */ |
| 156 | int Subminor; |
| 157 | } CXVersion; |
Douglas Gregor | 58ddb60 | 2010-08-23 23:00:57 +0000 | [diff] [blame] | 158 | |
Douglas Gregor | 7f17376 | 2010-01-20 22:28:27 +0000 | [diff] [blame] | 159 | /** |
Douglas Gregor | 7f17376 | 2010-01-20 22:28:27 +0000 | [diff] [blame] | 160 | * \defgroup CINDEX_STRING String manipulation routines |
| 161 | * |
| 162 | * @{ |
| 163 | */ |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 164 | |
Douglas Gregor | 7f17376 | 2010-01-20 22:28:27 +0000 | [diff] [blame] | 165 | /** |
| 166 | * \brief A character string. |
| 167 | * |
| 168 | * The \c CXString type is used to return strings from the interface when |
| 169 | * the ownership of that string might different from one call to the next. |
| 170 | * Use \c clang_getCString() to retrieve the string data and, once finished |
| 171 | * with the string data, call \c clang_disposeString() to free the string. |
Steve Naroff | ef0cef6 | 2009-11-09 17:45:52 +0000 | [diff] [blame] | 172 | */ |
| 173 | typedef struct { |
Ted Kremenek | a60ed47 | 2010-11-16 08:15:36 +0000 | [diff] [blame] | 174 | void *data; |
Ted Kremenek | ed12273 | 2010-11-16 01:56:27 +0000 | [diff] [blame] | 175 | unsigned private_flags; |
Steve Naroff | ef0cef6 | 2009-11-09 17:45:52 +0000 | [diff] [blame] | 176 | } CXString; |
| 177 | |
Douglas Gregor | 7f17376 | 2010-01-20 22:28:27 +0000 | [diff] [blame] | 178 | /** |
| 179 | * \brief Retrieve the character data associated with the given string. |
| 180 | */ |
Steve Naroff | ef0cef6 | 2009-11-09 17:45:52 +0000 | [diff] [blame] | 181 | CINDEX_LINKAGE const char *clang_getCString(CXString string); |
| 182 | |
Douglas Gregor | 7f17376 | 2010-01-20 22:28:27 +0000 | [diff] [blame] | 183 | /** |
| 184 | * \brief Free the given string, |
| 185 | */ |
Steve Naroff | ef0cef6 | 2009-11-09 17:45:52 +0000 | [diff] [blame] | 186 | CINDEX_LINKAGE void clang_disposeString(CXString string); |
| 187 | |
Douglas Gregor | 7f17376 | 2010-01-20 22:28:27 +0000 | [diff] [blame] | 188 | /** |
| 189 | * @} |
| 190 | */ |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 191 | |
| 192 | /** |
Steve Naroff | e56b4ba | 2009-10-20 14:46:24 +0000 | [diff] [blame] | 193 | * \brief clang_createIndex() provides a shared context for creating |
| 194 | * translation units. It provides two options: |
| 195 | * |
| 196 | * - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local" |
| 197 | * declarations (when loading any new translation units). A "local" declaration |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 198 | * is one that belongs in the translation unit itself and not in a precompiled |
Steve Naroff | e56b4ba | 2009-10-20 14:46:24 +0000 | [diff] [blame] | 199 | * header that was used by the translation unit. If zero, all declarations |
| 200 | * will be enumerated. |
| 201 | * |
Steve Naroff | b4ece63 | 2009-10-20 16:36:34 +0000 | [diff] [blame] | 202 | * Here is an example: |
| 203 | * |
Douglas Gregor | 0a812cf | 2010-02-18 23:07:20 +0000 | [diff] [blame] | 204 | * // excludeDeclsFromPCH = 1, displayDiagnostics=1 |
| 205 | * Idx = clang_createIndex(1, 1); |
Steve Naroff | b4ece63 | 2009-10-20 16:36:34 +0000 | [diff] [blame] | 206 | * |
| 207 | * // IndexTest.pch was produced with the following command: |
| 208 | * // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch" |
| 209 | * TU = clang_createTranslationUnit(Idx, "IndexTest.pch"); |
| 210 | * |
| 211 | * // This will load all the symbols from 'IndexTest.pch' |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 212 | * clang_visitChildren(clang_getTranslationUnitCursor(TU), |
Douglas Gregor | 002a528 | 2010-01-20 21:37:00 +0000 | [diff] [blame] | 213 | * TranslationUnitVisitor, 0); |
Steve Naroff | b4ece63 | 2009-10-20 16:36:34 +0000 | [diff] [blame] | 214 | * clang_disposeTranslationUnit(TU); |
| 215 | * |
| 216 | * // This will load all the symbols from 'IndexTest.c', excluding symbols |
| 217 | * // from 'IndexTest.pch'. |
Daniel Dunbar | fd9f234 | 2010-01-25 00:43:14 +0000 | [diff] [blame] | 218 | * char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" }; |
| 219 | * TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args, |
| 220 | * 0, 0); |
Douglas Gregor | b2cd487 | 2010-01-20 23:57:43 +0000 | [diff] [blame] | 221 | * clang_visitChildren(clang_getTranslationUnitCursor(TU), |
| 222 | * TranslationUnitVisitor, 0); |
Steve Naroff | b4ece63 | 2009-10-20 16:36:34 +0000 | [diff] [blame] | 223 | * clang_disposeTranslationUnit(TU); |
| 224 | * |
| 225 | * This process of creating the 'pch', loading it separately, and using it (via |
| 226 | * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks |
| 227 | * (which gives the indexer the same performance benefit as the compiler). |
Steve Naroff | e56b4ba | 2009-10-20 14:46:24 +0000 | [diff] [blame] | 228 | */ |
Douglas Gregor | 0a812cf | 2010-02-18 23:07:20 +0000 | [diff] [blame] | 229 | CINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH, |
| 230 | int displayDiagnostics); |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 231 | |
Douglas Gregor | 0087e1a | 2010-02-08 23:03:06 +0000 | [diff] [blame] | 232 | /** |
| 233 | * \brief Destroy the given index. |
| 234 | * |
| 235 | * The index must not be destroyed until all of the translation units created |
| 236 | * within that index have been destroyed. |
| 237 | */ |
Daniel Dunbar | 8506dde | 2009-12-03 01:54:28 +0000 | [diff] [blame] | 238 | CINDEX_LINKAGE void clang_disposeIndex(CXIndex index); |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 239 | |
Argyrios Kyrtzidis | fdc1795 | 2012-03-28 02:18:05 +0000 | [diff] [blame] | 240 | typedef enum { |
| 241 | /** |
| 242 | * \brief Used to indicate that no special CXIndex options are needed. |
| 243 | */ |
| 244 | CXGlobalOpt_None = 0x0, |
| 245 | |
| 246 | /** |
| 247 | * \brief Used to indicate that threads that libclang creates for indexing |
| 248 | * purposes should use background priority. |
| 249 | * Affects \see clang_indexSourceFile, \see clang_indexTranslationUnit, |
| 250 | * \see clang_parseTranslationUnit, \see clang_saveTranslationUnit. |
| 251 | */ |
| 252 | CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1, |
| 253 | |
| 254 | /** |
| 255 | * \brief Used to indicate that threads that libclang creates for editing |
| 256 | * purposes should use background priority. |
| 257 | * Affects \see clang_reparseTranslationUnit, \see clang_codeCompleteAt, |
| 258 | * \see clang_annotateTokens |
| 259 | */ |
| 260 | CXGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2, |
| 261 | |
| 262 | /** |
| 263 | * \brief Used to indicate that all threads that libclang creates should use |
| 264 | * background priority. |
| 265 | */ |
| 266 | CXGlobalOpt_ThreadBackgroundPriorityForAll = |
| 267 | CXGlobalOpt_ThreadBackgroundPriorityForIndexing | |
| 268 | CXGlobalOpt_ThreadBackgroundPriorityForEditing |
| 269 | |
| 270 | } CXGlobalOptFlags; |
| 271 | |
| 272 | /** |
| 273 | * \brief Sets general options associated with a CXIndex. |
| 274 | * |
| 275 | * For example: |
| 276 | * \code |
| 277 | * CXIndex idx = ...; |
| 278 | * clang_CXIndex_setGlobalOptions(idx, |
| 279 | * clang_CXIndex_getGlobalOptions(idx) | |
| 280 | * CXGlobalOpt_ThreadBackgroundPriorityForIndexing); |
| 281 | * \endcode |
| 282 | * |
| 283 | * \param options A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags. |
| 284 | */ |
| 285 | CINDEX_LINKAGE void clang_CXIndex_setGlobalOptions(CXIndex, unsigned options); |
| 286 | |
| 287 | /** |
| 288 | * \brief Gets the general options associated with a CXIndex. |
| 289 | * |
| 290 | * \returns A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags that |
| 291 | * are associated with the given CXIndex object. |
| 292 | */ |
| 293 | CINDEX_LINKAGE unsigned clang_CXIndex_getGlobalOptions(CXIndex); |
| 294 | |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 295 | /** |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 296 | * \defgroup CINDEX_FILES File manipulation routines |
Douglas Gregor | f552544 | 2010-01-20 22:45:41 +0000 | [diff] [blame] | 297 | * |
| 298 | * @{ |
| 299 | */ |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 300 | |
Douglas Gregor | f552544 | 2010-01-20 22:45:41 +0000 | [diff] [blame] | 301 | /** |
| 302 | * \brief A particular source file that is part of a translation unit. |
| 303 | */ |
| 304 | typedef void *CXFile; |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 305 | |
Douglas Gregor | f552544 | 2010-01-20 22:45:41 +0000 | [diff] [blame] | 306 | |
| 307 | /** |
| 308 | * \brief Retrieve the complete file and path name of the given file. |
Steve Naroff | 8814503 | 2009-10-27 14:35:18 +0000 | [diff] [blame] | 309 | */ |
Ted Kremenek | 7484407 | 2010-02-17 00:41:20 +0000 | [diff] [blame] | 310 | CINDEX_LINKAGE CXString clang_getFileName(CXFile SFile); |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 311 | |
Douglas Gregor | f552544 | 2010-01-20 22:45:41 +0000 | [diff] [blame] | 312 | /** |
| 313 | * \brief Retrieve the last modification time of the given file. |
| 314 | */ |
Douglas Gregor | 08b0e8d | 2009-10-31 15:48:08 +0000 | [diff] [blame] | 315 | CINDEX_LINKAGE time_t clang_getFileTime(CXFile SFile); |
Steve Naroff | 8814503 | 2009-10-27 14:35:18 +0000 | [diff] [blame] | 316 | |
Douglas Gregor | 3c7313d | 2010-01-18 22:13:09 +0000 | [diff] [blame] | 317 | /** |
Douglas Gregor | dd3e554 | 2011-05-04 00:14:37 +0000 | [diff] [blame] | 318 | * \brief Determine whether the given header is guarded against |
| 319 | * multiple inclusions, either with the conventional |
| 320 | * #ifndef/#define/#endif macro guards or with #pragma once. |
| 321 | */ |
| 322 | CINDEX_LINKAGE unsigned |
| 323 | clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu, CXFile file); |
| 324 | |
| 325 | /** |
Douglas Gregor | b979034 | 2010-01-22 21:44:22 +0000 | [diff] [blame] | 326 | * \brief Retrieve a file handle within the given translation unit. |
| 327 | * |
| 328 | * \param tu the translation unit |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 329 | * |
Douglas Gregor | b979034 | 2010-01-22 21:44:22 +0000 | [diff] [blame] | 330 | * \param file_name the name of the file. |
| 331 | * |
| 332 | * \returns the file handle for the named file in the translation unit \p tu, |
| 333 | * or a NULL file handle if the file was not a part of this translation unit. |
| 334 | */ |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 335 | CINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu, |
Douglas Gregor | b979034 | 2010-01-22 21:44:22 +0000 | [diff] [blame] | 336 | const char *file_name); |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 337 | |
Douglas Gregor | b979034 | 2010-01-22 21:44:22 +0000 | [diff] [blame] | 338 | /** |
Douglas Gregor | f552544 | 2010-01-20 22:45:41 +0000 | [diff] [blame] | 339 | * @} |
| 340 | */ |
| 341 | |
| 342 | /** |
| 343 | * \defgroup CINDEX_LOCATIONS Physical source locations |
| 344 | * |
| 345 | * Clang represents physical source locations in its abstract syntax tree in |
| 346 | * great detail, with file, line, and column information for the majority of |
| 347 | * the tokens parsed in the source code. These data types and functions are |
| 348 | * used to represent source location information, either for a particular |
| 349 | * point in the program or for a range of points in the program, and extract |
| 350 | * specific location information from those data types. |
| 351 | * |
| 352 | * @{ |
| 353 | */ |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 354 | |
Douglas Gregor | f552544 | 2010-01-20 22:45:41 +0000 | [diff] [blame] | 355 | /** |
Douglas Gregor | 1db19de | 2010-01-19 21:36:55 +0000 | [diff] [blame] | 356 | * \brief Identifies a specific source location within a translation |
| 357 | * unit. |
| 358 | * |
Chandler Carruth | 2017422 | 2011-08-31 16:53:37 +0000 | [diff] [blame] | 359 | * Use clang_getExpansionLocation() or clang_getSpellingLocation() |
Douglas Gregor | a9b06d4 | 2010-11-09 06:24:54 +0000 | [diff] [blame] | 360 | * to map a source location to a particular file, line, and column. |
Douglas Gregor | 3c7313d | 2010-01-18 22:13:09 +0000 | [diff] [blame] | 361 | */ |
| 362 | typedef struct { |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 363 | void *ptr_data[2]; |
Douglas Gregor | 1db19de | 2010-01-19 21:36:55 +0000 | [diff] [blame] | 364 | unsigned int_data; |
Douglas Gregor | 3c7313d | 2010-01-18 22:13:09 +0000 | [diff] [blame] | 365 | } CXSourceLocation; |
Ted Kremenek | fe6fd3d | 2010-01-05 23:18:49 +0000 | [diff] [blame] | 366 | |
Douglas Gregor | 3c7313d | 2010-01-18 22:13:09 +0000 | [diff] [blame] | 367 | /** |
Daniel Dunbar | d52864b | 2010-02-14 10:02:57 +0000 | [diff] [blame] | 368 | * \brief Identifies a half-open character range in the source code. |
Douglas Gregor | 3c7313d | 2010-01-18 22:13:09 +0000 | [diff] [blame] | 369 | * |
Douglas Gregor | 1db19de | 2010-01-19 21:36:55 +0000 | [diff] [blame] | 370 | * Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the |
| 371 | * starting and end locations from a source range, respectively. |
Douglas Gregor | 3c7313d | 2010-01-18 22:13:09 +0000 | [diff] [blame] | 372 | */ |
| 373 | typedef struct { |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 374 | void *ptr_data[2]; |
Douglas Gregor | 1db19de | 2010-01-19 21:36:55 +0000 | [diff] [blame] | 375 | unsigned begin_int_data; |
| 376 | unsigned end_int_data; |
Douglas Gregor | 3c7313d | 2010-01-18 22:13:09 +0000 | [diff] [blame] | 377 | } CXSourceRange; |
Ted Kremenek | fe6fd3d | 2010-01-05 23:18:49 +0000 | [diff] [blame] | 378 | |
Douglas Gregor | 1db19de | 2010-01-19 21:36:55 +0000 | [diff] [blame] | 379 | /** |
Douglas Gregor | b979034 | 2010-01-22 21:44:22 +0000 | [diff] [blame] | 380 | * \brief Retrieve a NULL (invalid) source location. |
| 381 | */ |
| 382 | CINDEX_LINKAGE CXSourceLocation clang_getNullLocation(); |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 383 | |
Douglas Gregor | b979034 | 2010-01-22 21:44:22 +0000 | [diff] [blame] | 384 | /** |
| 385 | * \determine Determine whether two source locations, which must refer into |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 386 | * the same translation unit, refer to exactly the same point in the source |
Douglas Gregor | b979034 | 2010-01-22 21:44:22 +0000 | [diff] [blame] | 387 | * code. |
| 388 | * |
| 389 | * \returns non-zero if the source locations refer to the same location, zero |
| 390 | * if they refer to different locations. |
| 391 | */ |
| 392 | CINDEX_LINKAGE unsigned clang_equalLocations(CXSourceLocation loc1, |
| 393 | CXSourceLocation loc2); |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 394 | |
Douglas Gregor | b979034 | 2010-01-22 21:44:22 +0000 | [diff] [blame] | 395 | /** |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 396 | * \brief Retrieves the source location associated with a given file/line/column |
| 397 | * in a particular translation unit. |
Douglas Gregor | b979034 | 2010-01-22 21:44:22 +0000 | [diff] [blame] | 398 | */ |
| 399 | CINDEX_LINKAGE CXSourceLocation clang_getLocation(CXTranslationUnit tu, |
| 400 | CXFile file, |
| 401 | unsigned line, |
| 402 | unsigned column); |
David Chisnall | 83889a7 | 2010-10-15 17:07:39 +0000 | [diff] [blame] | 403 | /** |
| 404 | * \brief Retrieves the source location associated with a given character offset |
| 405 | * in a particular translation unit. |
| 406 | */ |
| 407 | CINDEX_LINKAGE CXSourceLocation clang_getLocationForOffset(CXTranslationUnit tu, |
| 408 | CXFile file, |
| 409 | unsigned offset); |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 410 | |
Douglas Gregor | b979034 | 2010-01-22 21:44:22 +0000 | [diff] [blame] | 411 | /** |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 412 | * \brief Retrieve a NULL (invalid) source range. |
| 413 | */ |
| 414 | CINDEX_LINKAGE CXSourceRange clang_getNullRange(); |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 415 | |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 416 | /** |
Douglas Gregor | b979034 | 2010-01-22 21:44:22 +0000 | [diff] [blame] | 417 | * \brief Retrieve a source range given the beginning and ending source |
| 418 | * locations. |
| 419 | */ |
| 420 | CINDEX_LINKAGE CXSourceRange clang_getRange(CXSourceLocation begin, |
| 421 | CXSourceLocation end); |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 422 | |
Douglas Gregor | b979034 | 2010-01-22 21:44:22 +0000 | [diff] [blame] | 423 | /** |
Douglas Gregor | ab4e83b | 2011-07-23 19:35:14 +0000 | [diff] [blame] | 424 | * \brief Determine whether two ranges are equivalent. |
| 425 | * |
| 426 | * \returns non-zero if the ranges are the same, zero if they differ. |
| 427 | */ |
| 428 | CINDEX_LINKAGE unsigned clang_equalRanges(CXSourceRange range1, |
| 429 | CXSourceRange range2); |
| 430 | |
| 431 | /** |
Argyrios Kyrtzidis | de5db64 | 2011-09-28 18:14:21 +0000 | [diff] [blame] | 432 | * \brief Returns non-zero if \arg range is null. |
| 433 | */ |
Erik Verbruggen | 733dbc8 | 2011-10-06 12:11:57 +0000 | [diff] [blame] | 434 | CINDEX_LINKAGE int clang_Range_isNull(CXSourceRange range); |
Argyrios Kyrtzidis | de5db64 | 2011-09-28 18:14:21 +0000 | [diff] [blame] | 435 | |
| 436 | /** |
Douglas Gregor | 46766dc | 2010-01-26 19:19:08 +0000 | [diff] [blame] | 437 | * \brief Retrieve the file, line, column, and offset represented by |
| 438 | * the given source location. |
Douglas Gregor | 1db19de | 2010-01-19 21:36:55 +0000 | [diff] [blame] | 439 | * |
Chandler Carruth | 2017422 | 2011-08-31 16:53:37 +0000 | [diff] [blame] | 440 | * If the location refers into a macro expansion, retrieves the |
| 441 | * location of the macro expansion. |
Douglas Gregor | a9b06d4 | 2010-11-09 06:24:54 +0000 | [diff] [blame] | 442 | * |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 443 | * \param location the location within a source file that will be decomposed |
| 444 | * into its parts. |
Douglas Gregor | 1db19de | 2010-01-19 21:36:55 +0000 | [diff] [blame] | 445 | * |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 446 | * \param file [out] if non-NULL, will be set to the file to which the given |
Douglas Gregor | 1db19de | 2010-01-19 21:36:55 +0000 | [diff] [blame] | 447 | * source location points. |
| 448 | * |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 449 | * \param line [out] if non-NULL, will be set to the line to which the given |
Douglas Gregor | 1db19de | 2010-01-19 21:36:55 +0000 | [diff] [blame] | 450 | * source location points. |
| 451 | * |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 452 | * \param column [out] if non-NULL, will be set to the column to which the given |
| 453 | * source location points. |
Douglas Gregor | 46766dc | 2010-01-26 19:19:08 +0000 | [diff] [blame] | 454 | * |
| 455 | * \param offset [out] if non-NULL, will be set to the offset into the |
| 456 | * buffer to which the given source location points. |
Douglas Gregor | 1db19de | 2010-01-19 21:36:55 +0000 | [diff] [blame] | 457 | */ |
Chandler Carruth | 2017422 | 2011-08-31 16:53:37 +0000 | [diff] [blame] | 458 | CINDEX_LINKAGE void clang_getExpansionLocation(CXSourceLocation location, |
| 459 | CXFile *file, |
| 460 | unsigned *line, |
| 461 | unsigned *column, |
| 462 | unsigned *offset); |
| 463 | |
| 464 | /** |
Argyrios Kyrtzidis | e6be34d | 2011-09-13 21:49:08 +0000 | [diff] [blame] | 465 | * \brief Retrieve the file, line, column, and offset represented by |
| 466 | * the given source location, as specified in a # line directive. |
| 467 | * |
| 468 | * Example: given the following source code in a file somefile.c |
| 469 | * |
| 470 | * #123 "dummy.c" 1 |
| 471 | * |
| 472 | * static int func(void) |
| 473 | * { |
| 474 | * return 0; |
| 475 | * } |
| 476 | * |
| 477 | * the location information returned by this function would be |
| 478 | * |
| 479 | * File: dummy.c Line: 124 Column: 12 |
| 480 | * |
| 481 | * whereas clang_getExpansionLocation would have returned |
| 482 | * |
| 483 | * File: somefile.c Line: 3 Column: 12 |
| 484 | * |
| 485 | * \param location the location within a source file that will be decomposed |
| 486 | * into its parts. |
| 487 | * |
| 488 | * \param filename [out] if non-NULL, will be set to the filename of the |
| 489 | * source location. Note that filenames returned will be for "virtual" files, |
| 490 | * which don't necessarily exist on the machine running clang - e.g. when |
| 491 | * parsing preprocessed output obtained from a different environment. If |
| 492 | * a non-NULL value is passed in, remember to dispose of the returned value |
| 493 | * using \c clang_disposeString() once you've finished with it. For an invalid |
| 494 | * source location, an empty string is returned. |
| 495 | * |
| 496 | * \param line [out] if non-NULL, will be set to the line number of the |
| 497 | * source location. For an invalid source location, zero is returned. |
| 498 | * |
| 499 | * \param column [out] if non-NULL, will be set to the column number of the |
| 500 | * source location. For an invalid source location, zero is returned. |
| 501 | */ |
| 502 | CINDEX_LINKAGE void clang_getPresumedLocation(CXSourceLocation location, |
| 503 | CXString *filename, |
| 504 | unsigned *line, |
| 505 | unsigned *column); |
| 506 | |
| 507 | /** |
Chandler Carruth | 2017422 | 2011-08-31 16:53:37 +0000 | [diff] [blame] | 508 | * \brief Legacy API to retrieve the file, line, column, and offset represented |
| 509 | * by the given source location. |
| 510 | * |
| 511 | * This interface has been replaced by the newer interface |
| 512 | * \see clang_getExpansionLocation(). See that interface's documentation for |
| 513 | * details. |
| 514 | */ |
Douglas Gregor | 1db19de | 2010-01-19 21:36:55 +0000 | [diff] [blame] | 515 | CINDEX_LINKAGE void clang_getInstantiationLocation(CXSourceLocation location, |
| 516 | CXFile *file, |
| 517 | unsigned *line, |
Douglas Gregor | 46766dc | 2010-01-26 19:19:08 +0000 | [diff] [blame] | 518 | unsigned *column, |
| 519 | unsigned *offset); |
Douglas Gregor | e69517c | 2010-01-26 03:07:15 +0000 | [diff] [blame] | 520 | |
| 521 | /** |
Douglas Gregor | a9b06d4 | 2010-11-09 06:24:54 +0000 | [diff] [blame] | 522 | * \brief Retrieve the file, line, column, and offset represented by |
| 523 | * the given source location. |
| 524 | * |
| 525 | * If the location refers into a macro instantiation, return where the |
| 526 | * location was originally spelled in the source file. |
| 527 | * |
| 528 | * \param location the location within a source file that will be decomposed |
| 529 | * into its parts. |
| 530 | * |
| 531 | * \param file [out] if non-NULL, will be set to the file to which the given |
| 532 | * source location points. |
| 533 | * |
| 534 | * \param line [out] if non-NULL, will be set to the line to which the given |
| 535 | * source location points. |
| 536 | * |
| 537 | * \param column [out] if non-NULL, will be set to the column to which the given |
| 538 | * source location points. |
| 539 | * |
| 540 | * \param offset [out] if non-NULL, will be set to the offset into the |
| 541 | * buffer to which the given source location points. |
| 542 | */ |
| 543 | CINDEX_LINKAGE void clang_getSpellingLocation(CXSourceLocation location, |
| 544 | CXFile *file, |
| 545 | unsigned *line, |
| 546 | unsigned *column, |
| 547 | unsigned *offset); |
| 548 | |
| 549 | /** |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 550 | * \brief Retrieve a source location representing the first character within a |
| 551 | * source range. |
Douglas Gregor | 1db19de | 2010-01-19 21:36:55 +0000 | [diff] [blame] | 552 | */ |
| 553 | CINDEX_LINKAGE CXSourceLocation clang_getRangeStart(CXSourceRange range); |
| 554 | |
| 555 | /** |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 556 | * \brief Retrieve a source location representing the last character within a |
| 557 | * source range. |
Douglas Gregor | 1db19de | 2010-01-19 21:36:55 +0000 | [diff] [blame] | 558 | */ |
| 559 | CINDEX_LINKAGE CXSourceLocation clang_getRangeEnd(CXSourceRange range); |
| 560 | |
Douglas Gregor | f552544 | 2010-01-20 22:45:41 +0000 | [diff] [blame] | 561 | /** |
| 562 | * @} |
| 563 | */ |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 564 | |
| 565 | /** |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 566 | * \defgroup CINDEX_DIAG Diagnostic reporting |
| 567 | * |
| 568 | * @{ |
| 569 | */ |
| 570 | |
| 571 | /** |
| 572 | * \brief Describes the severity of a particular diagnostic. |
| 573 | */ |
| 574 | enum CXDiagnosticSeverity { |
| 575 | /** |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 576 | * \brief A diagnostic that has been suppressed, e.g., by a command-line |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 577 | * option. |
| 578 | */ |
| 579 | CXDiagnostic_Ignored = 0, |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 580 | |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 581 | /** |
| 582 | * \brief This diagnostic is a note that should be attached to the |
| 583 | * previous (non-note) diagnostic. |
| 584 | */ |
| 585 | CXDiagnostic_Note = 1, |
| 586 | |
| 587 | /** |
| 588 | * \brief This diagnostic indicates suspicious code that may not be |
| 589 | * wrong. |
| 590 | */ |
| 591 | CXDiagnostic_Warning = 2, |
| 592 | |
| 593 | /** |
| 594 | * \brief This diagnostic indicates that the code is ill-formed. |
| 595 | */ |
| 596 | CXDiagnostic_Error = 3, |
| 597 | |
| 598 | /** |
| 599 | * \brief This diagnostic indicates that the code is ill-formed such |
| 600 | * that future parser recovery is unlikely to produce useful |
| 601 | * results. |
| 602 | */ |
| 603 | CXDiagnostic_Fatal = 4 |
| 604 | }; |
| 605 | |
| 606 | /** |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 607 | * \brief A single diagnostic, containing the diagnostic's severity, |
| 608 | * location, text, source ranges, and fix-it hints. |
| 609 | */ |
| 610 | typedef void *CXDiagnostic; |
| 611 | |
| 612 | /** |
Ted Kremenek | 1532217 | 2011-11-10 08:43:12 +0000 | [diff] [blame] | 613 | * \brief A group of CXDiagnostics. |
| 614 | */ |
| 615 | typedef void *CXDiagnosticSet; |
| 616 | |
| 617 | /** |
| 618 | * \brief Determine the number of diagnostics in a CXDiagnosticSet. |
| 619 | */ |
| 620 | CINDEX_LINKAGE unsigned clang_getNumDiagnosticsInSet(CXDiagnosticSet Diags); |
| 621 | |
| 622 | /** |
| 623 | * \brief Retrieve a diagnostic associated with the given CXDiagnosticSet. |
| 624 | * |
| 625 | * \param Unit the CXDiagnosticSet to query. |
| 626 | * \param Index the zero-based diagnostic number to retrieve. |
| 627 | * |
| 628 | * \returns the requested diagnostic. This diagnostic must be freed |
| 629 | * via a call to \c clang_disposeDiagnostic(). |
| 630 | */ |
| 631 | CINDEX_LINKAGE CXDiagnostic clang_getDiagnosticInSet(CXDiagnosticSet Diags, |
| 632 | unsigned Index); |
| 633 | |
| 634 | |
| 635 | /** |
| 636 | * \brief Describes the kind of error that occurred (if any) in a call to |
| 637 | * \c clang_loadDiagnostics. |
| 638 | */ |
| 639 | enum CXLoadDiag_Error { |
| 640 | /** |
| 641 | * \brief Indicates that no error occurred. |
| 642 | */ |
| 643 | CXLoadDiag_None = 0, |
| 644 | |
| 645 | /** |
| 646 | * \brief Indicates that an unknown error occurred while attempting to |
| 647 | * deserialize diagnostics. |
| 648 | */ |
| 649 | CXLoadDiag_Unknown = 1, |
| 650 | |
| 651 | /** |
| 652 | * \brief Indicates that the file containing the serialized diagnostics |
| 653 | * could not be opened. |
| 654 | */ |
| 655 | CXLoadDiag_CannotLoad = 2, |
| 656 | |
| 657 | /** |
| 658 | * \brief Indicates that the serialized diagnostics file is invalid or |
| 659 | * corrupt. |
| 660 | */ |
| 661 | CXLoadDiag_InvalidFile = 3 |
| 662 | }; |
| 663 | |
| 664 | /** |
| 665 | * \brief Deserialize a set of diagnostics from a Clang diagnostics bitcode |
| 666 | * file. |
| 667 | * |
| 668 | * \param The name of the file to deserialize. |
| 669 | * \param A pointer to a enum value recording if there was a problem |
| 670 | * deserializing the diagnostics. |
| 671 | * \param A pointer to a CXString for recording the error string |
| 672 | * if the file was not successfully loaded. |
| 673 | * |
| 674 | * \returns A loaded CXDiagnosticSet if successful, and NULL otherwise. These |
| 675 | * diagnostics should be released using clang_disposeDiagnosticSet(). |
| 676 | */ |
| 677 | CINDEX_LINKAGE CXDiagnosticSet clang_loadDiagnostics(const char *file, |
| 678 | enum CXLoadDiag_Error *error, |
| 679 | CXString *errorString); |
| 680 | |
| 681 | /** |
| 682 | * \brief Release a CXDiagnosticSet and all of its contained diagnostics. |
| 683 | */ |
| 684 | CINDEX_LINKAGE void clang_disposeDiagnosticSet(CXDiagnosticSet Diags); |
| 685 | |
| 686 | /** |
| 687 | * \brief Retrieve the child diagnostics of a CXDiagnostic. This |
| 688 | * CXDiagnosticSet does not need to be released by clang_diposeDiagnosticSet. |
| 689 | */ |
| 690 | CINDEX_LINKAGE CXDiagnosticSet clang_getChildDiagnostics(CXDiagnostic D); |
| 691 | |
| 692 | /** |
Douglas Gregor | a88084b | 2010-02-18 18:08:43 +0000 | [diff] [blame] | 693 | * \brief Determine the number of diagnostics produced for the given |
| 694 | * translation unit. |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 695 | */ |
Douglas Gregor | a88084b | 2010-02-18 18:08:43 +0000 | [diff] [blame] | 696 | CINDEX_LINKAGE unsigned clang_getNumDiagnostics(CXTranslationUnit Unit); |
| 697 | |
| 698 | /** |
| 699 | * \brief Retrieve a diagnostic associated with the given translation unit. |
| 700 | * |
| 701 | * \param Unit the translation unit to query. |
| 702 | * \param Index the zero-based diagnostic number to retrieve. |
| 703 | * |
| 704 | * \returns the requested diagnostic. This diagnostic must be freed |
| 705 | * via a call to \c clang_disposeDiagnostic(). |
| 706 | */ |
| 707 | CINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit, |
| 708 | unsigned Index); |
| 709 | |
| 710 | /** |
Ted Kremenek | 0373fcc | 2011-12-09 22:28:32 +0000 | [diff] [blame] | 711 | * \brief Retrieve the complete set of diagnostics associated with a |
| 712 | * translation unit. |
| 713 | * |
| 714 | * \param Unit the translation unit to query. |
| 715 | */ |
| 716 | CINDEX_LINKAGE CXDiagnosticSet |
| 717 | clang_getDiagnosticSetFromTU(CXTranslationUnit Unit); |
| 718 | |
| 719 | /** |
Douglas Gregor | a88084b | 2010-02-18 18:08:43 +0000 | [diff] [blame] | 720 | * \brief Destroy a diagnostic. |
| 721 | */ |
| 722 | CINDEX_LINKAGE void clang_disposeDiagnostic(CXDiagnostic Diagnostic); |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 723 | |
| 724 | /** |
Douglas Gregor | 0a812cf | 2010-02-18 23:07:20 +0000 | [diff] [blame] | 725 | * \brief Options to control the display of diagnostics. |
| 726 | * |
| 727 | * The values in this enum are meant to be combined to customize the |
| 728 | * behavior of \c clang_displayDiagnostic(). |
| 729 | */ |
| 730 | enum CXDiagnosticDisplayOptions { |
| 731 | /** |
| 732 | * \brief Display the source-location information where the |
| 733 | * diagnostic was located. |
| 734 | * |
| 735 | * When set, diagnostics will be prefixed by the file, line, and |
| 736 | * (optionally) column to which the diagnostic refers. For example, |
| 737 | * |
| 738 | * \code |
| 739 | * test.c:28: warning: extra tokens at end of #endif directive |
| 740 | * \endcode |
| 741 | * |
| 742 | * This option corresponds to the clang flag \c -fshow-source-location. |
| 743 | */ |
| 744 | CXDiagnostic_DisplaySourceLocation = 0x01, |
| 745 | |
| 746 | /** |
| 747 | * \brief If displaying the source-location information of the |
| 748 | * diagnostic, also include the column number. |
| 749 | * |
| 750 | * This option corresponds to the clang flag \c -fshow-column. |
| 751 | */ |
| 752 | CXDiagnostic_DisplayColumn = 0x02, |
| 753 | |
| 754 | /** |
| 755 | * \brief If displaying the source-location information of the |
| 756 | * diagnostic, also include information about source ranges in a |
| 757 | * machine-parsable format. |
| 758 | * |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 759 | * This option corresponds to the clang flag |
Douglas Gregor | 0a812cf | 2010-02-18 23:07:20 +0000 | [diff] [blame] | 760 | * \c -fdiagnostics-print-source-range-info. |
| 761 | */ |
Douglas Gregor | aa5f135 | 2010-11-19 16:18:16 +0000 | [diff] [blame] | 762 | CXDiagnostic_DisplaySourceRanges = 0x04, |
| 763 | |
| 764 | /** |
| 765 | * \brief Display the option name associated with this diagnostic, if any. |
| 766 | * |
| 767 | * The option name displayed (e.g., -Wconversion) will be placed in brackets |
| 768 | * after the diagnostic text. This option corresponds to the clang flag |
| 769 | * \c -fdiagnostics-show-option. |
| 770 | */ |
| 771 | CXDiagnostic_DisplayOption = 0x08, |
| 772 | |
| 773 | /** |
| 774 | * \brief Display the category number associated with this diagnostic, if any. |
| 775 | * |
| 776 | * The category number is displayed within brackets after the diagnostic text. |
| 777 | * This option corresponds to the clang flag |
| 778 | * \c -fdiagnostics-show-category=id. |
| 779 | */ |
| 780 | CXDiagnostic_DisplayCategoryId = 0x10, |
| 781 | |
| 782 | /** |
| 783 | * \brief Display the category name associated with this diagnostic, if any. |
| 784 | * |
| 785 | * The category name is displayed within brackets after the diagnostic text. |
| 786 | * This option corresponds to the clang flag |
| 787 | * \c -fdiagnostics-show-category=name. |
| 788 | */ |
| 789 | CXDiagnostic_DisplayCategoryName = 0x20 |
Douglas Gregor | 0a812cf | 2010-02-18 23:07:20 +0000 | [diff] [blame] | 790 | }; |
| 791 | |
| 792 | /** |
Douglas Gregor | 274f190 | 2010-02-22 23:17:23 +0000 | [diff] [blame] | 793 | * \brief Format the given diagnostic in a manner that is suitable for display. |
Douglas Gregor | 0a812cf | 2010-02-18 23:07:20 +0000 | [diff] [blame] | 794 | * |
Douglas Gregor | 274f190 | 2010-02-22 23:17:23 +0000 | [diff] [blame] | 795 | * This routine will format the given diagnostic to a string, rendering |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 796 | * the diagnostic according to the various options given. The |
| 797 | * \c clang_defaultDiagnosticDisplayOptions() function returns the set of |
Douglas Gregor | 0a812cf | 2010-02-18 23:07:20 +0000 | [diff] [blame] | 798 | * options that most closely mimics the behavior of the clang compiler. |
| 799 | * |
| 800 | * \param Diagnostic The diagnostic to print. |
| 801 | * |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 802 | * \param Options A set of options that control the diagnostic display, |
Douglas Gregor | 0a812cf | 2010-02-18 23:07:20 +0000 | [diff] [blame] | 803 | * created by combining \c CXDiagnosticDisplayOptions values. |
Douglas Gregor | 274f190 | 2010-02-22 23:17:23 +0000 | [diff] [blame] | 804 | * |
| 805 | * \returns A new string containing for formatted diagnostic. |
Douglas Gregor | 0a812cf | 2010-02-18 23:07:20 +0000 | [diff] [blame] | 806 | */ |
Douglas Gregor | 274f190 | 2010-02-22 23:17:23 +0000 | [diff] [blame] | 807 | CINDEX_LINKAGE CXString clang_formatDiagnostic(CXDiagnostic Diagnostic, |
| 808 | unsigned Options); |
Douglas Gregor | 0a812cf | 2010-02-18 23:07:20 +0000 | [diff] [blame] | 809 | |
| 810 | /** |
| 811 | * \brief Retrieve the set of display options most similar to the |
| 812 | * default behavior of the clang compiler. |
| 813 | * |
| 814 | * \returns A set of display options suitable for use with \c |
| 815 | * clang_displayDiagnostic(). |
| 816 | */ |
| 817 | CINDEX_LINKAGE unsigned clang_defaultDiagnosticDisplayOptions(void); |
| 818 | |
| 819 | /** |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 820 | * \brief Determine the severity of the given diagnostic. |
| 821 | */ |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 822 | CINDEX_LINKAGE enum CXDiagnosticSeverity |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 823 | clang_getDiagnosticSeverity(CXDiagnostic); |
| 824 | |
| 825 | /** |
| 826 | * \brief Retrieve the source location of the given diagnostic. |
| 827 | * |
| 828 | * This location is where Clang would print the caret ('^') when |
| 829 | * displaying the diagnostic on the command line. |
| 830 | */ |
| 831 | CINDEX_LINKAGE CXSourceLocation clang_getDiagnosticLocation(CXDiagnostic); |
| 832 | |
| 833 | /** |
| 834 | * \brief Retrieve the text of the given diagnostic. |
| 835 | */ |
| 836 | CINDEX_LINKAGE CXString clang_getDiagnosticSpelling(CXDiagnostic); |
Douglas Gregor | a3890ba | 2010-02-08 23:11:56 +0000 | [diff] [blame] | 837 | |
| 838 | /** |
Douglas Gregor | aa5f135 | 2010-11-19 16:18:16 +0000 | [diff] [blame] | 839 | * \brief Retrieve the name of the command-line option that enabled this |
| 840 | * diagnostic. |
| 841 | * |
| 842 | * \param Diag The diagnostic to be queried. |
| 843 | * |
| 844 | * \param Disable If non-NULL, will be set to the option that disables this |
| 845 | * diagnostic (if any). |
| 846 | * |
| 847 | * \returns A string that contains the command-line option used to enable this |
| 848 | * warning, such as "-Wconversion" or "-pedantic". |
| 849 | */ |
| 850 | CINDEX_LINKAGE CXString clang_getDiagnosticOption(CXDiagnostic Diag, |
| 851 | CXString *Disable); |
| 852 | |
| 853 | /** |
| 854 | * \brief Retrieve the category number for this diagnostic. |
| 855 | * |
| 856 | * Diagnostics can be categorized into groups along with other, related |
| 857 | * diagnostics (e.g., diagnostics under the same warning flag). This routine |
| 858 | * retrieves the category number for the given diagnostic. |
| 859 | * |
| 860 | * \returns The number of the category that contains this diagnostic, or zero |
| 861 | * if this diagnostic is uncategorized. |
| 862 | */ |
| 863 | CINDEX_LINKAGE unsigned clang_getDiagnosticCategory(CXDiagnostic); |
| 864 | |
| 865 | /** |
Ted Kremenek | 78d5d3b | 2012-04-12 00:03:31 +0000 | [diff] [blame] | 866 | * \brief Retrieve the name of a particular diagnostic category. This |
| 867 | * is now deprecated. Use clang_getDiagnosticCategoryText() |
| 868 | * instead. |
Douglas Gregor | aa5f135 | 2010-11-19 16:18:16 +0000 | [diff] [blame] | 869 | * |
| 870 | * \param Category A diagnostic category number, as returned by |
| 871 | * \c clang_getDiagnosticCategory(). |
| 872 | * |
| 873 | * \returns The name of the given diagnostic category. |
| 874 | */ |
Ted Kremenek | 78d5d3b | 2012-04-12 00:03:31 +0000 | [diff] [blame] | 875 | CINDEX_DEPRECATED CINDEX_LINKAGE |
| 876 | CXString clang_getDiagnosticCategoryName(unsigned Category); |
| 877 | |
| 878 | /** |
| 879 | * \brief Retrieve the diagnostic category text for a given diagnostic. |
| 880 | * |
| 881 | * |
| 882 | * \returns The text of the given diagnostic category. |
| 883 | */ |
| 884 | CINDEX_LINKAGE CXString clang_getDiagnosticCategoryText(CXDiagnostic); |
Douglas Gregor | aa5f135 | 2010-11-19 16:18:16 +0000 | [diff] [blame] | 885 | |
| 886 | /** |
Douglas Gregor | a3890ba | 2010-02-08 23:11:56 +0000 | [diff] [blame] | 887 | * \brief Determine the number of source ranges associated with the given |
| 888 | * diagnostic. |
| 889 | */ |
| 890 | CINDEX_LINKAGE unsigned clang_getDiagnosticNumRanges(CXDiagnostic); |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 891 | |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 892 | /** |
Douglas Gregor | a3890ba | 2010-02-08 23:11:56 +0000 | [diff] [blame] | 893 | * \brief Retrieve a source range associated with the diagnostic. |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 894 | * |
Douglas Gregor | a3890ba | 2010-02-08 23:11:56 +0000 | [diff] [blame] | 895 | * A diagnostic's source ranges highlight important elements in the source |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 896 | * code. On the command line, Clang displays source ranges by |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 897 | * underlining them with '~' characters. |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 898 | * |
Douglas Gregor | a3890ba | 2010-02-08 23:11:56 +0000 | [diff] [blame] | 899 | * \param Diagnostic the diagnostic whose range is being extracted. |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 900 | * |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 901 | * \param Range the zero-based index specifying which range to |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 902 | * |
Douglas Gregor | a3890ba | 2010-02-08 23:11:56 +0000 | [diff] [blame] | 903 | * \returns the requested source range. |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 904 | */ |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 905 | CINDEX_LINKAGE CXSourceRange clang_getDiagnosticRange(CXDiagnostic Diagnostic, |
Douglas Gregor | a3890ba | 2010-02-08 23:11:56 +0000 | [diff] [blame] | 906 | unsigned Range); |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 907 | |
| 908 | /** |
| 909 | * \brief Determine the number of fix-it hints associated with the |
| 910 | * given diagnostic. |
| 911 | */ |
| 912 | CINDEX_LINKAGE unsigned clang_getDiagnosticNumFixIts(CXDiagnostic Diagnostic); |
| 913 | |
| 914 | /** |
Douglas Gregor | 473d701 | 2010-02-19 18:16:06 +0000 | [diff] [blame] | 915 | * \brief Retrieve the replacement information for a given fix-it. |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 916 | * |
Douglas Gregor | 473d701 | 2010-02-19 18:16:06 +0000 | [diff] [blame] | 917 | * Fix-its are described in terms of a source range whose contents |
| 918 | * should be replaced by a string. This approach generalizes over |
| 919 | * three kinds of operations: removal of source code (the range covers |
| 920 | * the code to be removed and the replacement string is empty), |
| 921 | * replacement of source code (the range covers the code to be |
| 922 | * replaced and the replacement string provides the new code), and |
| 923 | * insertion (both the start and end of the range point at the |
| 924 | * insertion location, and the replacement string provides the text to |
| 925 | * insert). |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 926 | * |
Douglas Gregor | 473d701 | 2010-02-19 18:16:06 +0000 | [diff] [blame] | 927 | * \param Diagnostic The diagnostic whose fix-its are being queried. |
| 928 | * |
| 929 | * \param FixIt The zero-based index of the fix-it. |
| 930 | * |
| 931 | * \param ReplacementRange The source range whose contents will be |
| 932 | * replaced with the returned replacement string. Note that source |
| 933 | * ranges are half-open ranges [a, b), so the source code should be |
| 934 | * replaced from a and up to (but not including) b. |
| 935 | * |
| 936 | * \returns A string containing text that should be replace the source |
| 937 | * code indicated by the \c ReplacementRange. |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 938 | */ |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 939 | CINDEX_LINKAGE CXString clang_getDiagnosticFixIt(CXDiagnostic Diagnostic, |
Douglas Gregor | 473d701 | 2010-02-19 18:16:06 +0000 | [diff] [blame] | 940 | unsigned FixIt, |
| 941 | CXSourceRange *ReplacementRange); |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 942 | |
| 943 | /** |
| 944 | * @} |
| 945 | */ |
| 946 | |
| 947 | /** |
| 948 | * \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation |
| 949 | * |
| 950 | * The routines in this group provide the ability to create and destroy |
| 951 | * translation units from files, either by parsing the contents of the files or |
| 952 | * by reading in a serialized representation of a translation unit. |
| 953 | * |
| 954 | * @{ |
| 955 | */ |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 956 | |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 957 | /** |
| 958 | * \brief Get the original translation unit source file name. |
| 959 | */ |
| 960 | CINDEX_LINKAGE CXString |
| 961 | clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit); |
| 962 | |
| 963 | /** |
| 964 | * \brief Return the CXTranslationUnit for a given source file and the provided |
| 965 | * command line arguments one would pass to the compiler. |
| 966 | * |
| 967 | * Note: The 'source_filename' argument is optional. If the caller provides a |
| 968 | * NULL pointer, the name of the source file is expected to reside in the |
| 969 | * specified command line arguments. |
| 970 | * |
| 971 | * Note: When encountered in 'clang_command_line_args', the following options |
| 972 | * are ignored: |
| 973 | * |
| 974 | * '-c' |
| 975 | * '-emit-ast' |
| 976 | * '-fsyntax-only' |
| 977 | * '-o <output file>' (both '-o' and '<output file>' are ignored) |
| 978 | * |
Ted Kremenek | 1ddb02c | 2010-11-08 04:28:51 +0000 | [diff] [blame] | 979 | * \param CIdx The index object with which the translation unit will be |
| 980 | * associated. |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 981 | * |
| 982 | * \param source_filename - The name of the source file to load, or NULL if the |
Ted Kremenek | 1ddb02c | 2010-11-08 04:28:51 +0000 | [diff] [blame] | 983 | * source file is included in \p clang_command_line_args. |
| 984 | * |
| 985 | * \param num_clang_command_line_args The number of command-line arguments in |
| 986 | * \p clang_command_line_args. |
| 987 | * |
| 988 | * \param clang_command_line_args The command-line arguments that would be |
| 989 | * passed to the \c clang executable if it were being invoked out-of-process. |
| 990 | * These command-line options will be parsed and will affect how the translation |
| 991 | * unit is parsed. Note that the following options are ignored: '-c', |
Aaron Ballman | d0f709e | 2012-05-06 16:07:45 +0000 | [diff] [blame] | 992 | * '-emit-ast', '-fsyntax-only' (which is the default), and '-o <output file>'. |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 993 | * |
| 994 | * \param num_unsaved_files the number of unsaved file entries in \p |
| 995 | * unsaved_files. |
| 996 | * |
| 997 | * \param unsaved_files the files that have not yet been saved to disk |
| 998 | * but may be required for code completion, including the contents of |
Ted Kremenek | c6f530d | 2010-04-12 18:47:26 +0000 | [diff] [blame] | 999 | * those files. The contents and name of these files (as specified by |
| 1000 | * CXUnsavedFile) are copied when necessary, so the client only needs to |
| 1001 | * guarantee their validity until the call to this function returns. |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 1002 | */ |
| 1003 | CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnitFromSourceFile( |
| 1004 | CXIndex CIdx, |
| 1005 | const char *source_filename, |
| 1006 | int num_clang_command_line_args, |
Douglas Gregor | 2ef6944 | 2010-09-01 16:43:19 +0000 | [diff] [blame] | 1007 | const char * const *clang_command_line_args, |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 1008 | unsigned num_unsaved_files, |
Douglas Gregor | a88084b | 2010-02-18 18:08:43 +0000 | [diff] [blame] | 1009 | struct CXUnsavedFile *unsaved_files); |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 1010 | |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 1011 | /** |
| 1012 | * \brief Create a translation unit from an AST file (-emit-ast). |
| 1013 | */ |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 1014 | CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnit(CXIndex, |
Douglas Gregor | a88084b | 2010-02-18 18:08:43 +0000 | [diff] [blame] | 1015 | const char *ast_filename); |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 1016 | |
Douglas Gregor | 44c181a | 2010-07-23 00:33:23 +0000 | [diff] [blame] | 1017 | /** |
| 1018 | * \brief Flags that control the creation of translation units. |
| 1019 | * |
| 1020 | * The enumerators in this enumeration type are meant to be bitwise |
| 1021 | * ORed together to specify which options should be used when |
| 1022 | * constructing the translation unit. |
| 1023 | */ |
Douglas Gregor | 5a43021 | 2010-07-21 18:52:53 +0000 | [diff] [blame] | 1024 | enum CXTranslationUnit_Flags { |
| 1025 | /** |
| 1026 | * \brief Used to indicate that no special translation-unit options are |
| 1027 | * needed. |
| 1028 | */ |
| 1029 | CXTranslationUnit_None = 0x0, |
| 1030 | |
| 1031 | /** |
| 1032 | * \brief Used to indicate that the parser should construct a "detailed" |
| 1033 | * preprocessing record, including all macro definitions and instantiations. |
| 1034 | * |
| 1035 | * Constructing a detailed preprocessing record requires more memory |
| 1036 | * and time to parse, since the information contained in the record |
| 1037 | * is usually not retained. However, it can be useful for |
| 1038 | * applications that require more detailed information about the |
| 1039 | * behavior of the preprocessor. |
| 1040 | */ |
Douglas Gregor | 44c181a | 2010-07-23 00:33:23 +0000 | [diff] [blame] | 1041 | CXTranslationUnit_DetailedPreprocessingRecord = 0x01, |
| 1042 | |
| 1043 | /** |
Douglas Gregor | b1c031b | 2010-08-09 22:28:58 +0000 | [diff] [blame] | 1044 | * \brief Used to indicate that the translation unit is incomplete. |
Douglas Gregor | 44c181a | 2010-07-23 00:33:23 +0000 | [diff] [blame] | 1045 | * |
Douglas Gregor | b1c031b | 2010-08-09 22:28:58 +0000 | [diff] [blame] | 1046 | * When a translation unit is considered "incomplete", semantic |
| 1047 | * analysis that is typically performed at the end of the |
| 1048 | * translation unit will be suppressed. For example, this suppresses |
| 1049 | * the completion of tentative declarations in C and of |
| 1050 | * instantiation of implicitly-instantiation function templates in |
| 1051 | * C++. This option is typically used when parsing a header with the |
| 1052 | * intent of producing a precompiled header. |
Douglas Gregor | 44c181a | 2010-07-23 00:33:23 +0000 | [diff] [blame] | 1053 | */ |
Douglas Gregor | b1c031b | 2010-08-09 22:28:58 +0000 | [diff] [blame] | 1054 | CXTranslationUnit_Incomplete = 0x02, |
Douglas Gregor | 44c181a | 2010-07-23 00:33:23 +0000 | [diff] [blame] | 1055 | |
| 1056 | /** |
| 1057 | * \brief Used to indicate that the translation unit should be built with an |
| 1058 | * implicit precompiled header for the preamble. |
| 1059 | * |
| 1060 | * An implicit precompiled header is used as an optimization when a |
| 1061 | * particular translation unit is likely to be reparsed many times |
| 1062 | * when the sources aren't changing that often. In this case, an |
| 1063 | * implicit precompiled header will be built containing all of the |
| 1064 | * initial includes at the top of the main file (what we refer to as |
| 1065 | * the "preamble" of the file). In subsequent parses, if the |
| 1066 | * preamble or the files in it have not changed, \c |
| 1067 | * clang_reparseTranslationUnit() will re-use the implicit |
| 1068 | * precompiled header to improve parsing performance. |
| 1069 | */ |
Douglas Gregor | e1e13bf | 2010-08-11 15:58:42 +0000 | [diff] [blame] | 1070 | CXTranslationUnit_PrecompiledPreamble = 0x04, |
| 1071 | |
| 1072 | /** |
| 1073 | * \brief Used to indicate that the translation unit should cache some |
| 1074 | * code-completion results with each reparse of the source file. |
| 1075 | * |
| 1076 | * Caching of code-completion results is a performance optimization that |
| 1077 | * introduces some overhead to reparsing but improves the performance of |
| 1078 | * code-completion operations. |
| 1079 | */ |
Douglas Gregor | 99ba202 | 2010-10-27 17:24:53 +0000 | [diff] [blame] | 1080 | CXTranslationUnit_CacheCompletionResults = 0x08, |
| 1081 | /** |
Douglas Gregor | b5af843 | 2011-08-25 22:54:01 +0000 | [diff] [blame] | 1082 | * \brief DEPRECATED: Enable precompiled preambles in C++. |
Douglas Gregor | 99ba202 | 2010-10-27 17:24:53 +0000 | [diff] [blame] | 1083 | * |
| 1084 | * Note: this is a *temporary* option that is available only while |
Douglas Gregor | b5af843 | 2011-08-25 22:54:01 +0000 | [diff] [blame] | 1085 | * we are testing C++ precompiled preamble support. It is deprecated. |
Douglas Gregor | 99ba202 | 2010-10-27 17:24:53 +0000 | [diff] [blame] | 1086 | */ |
| 1087 | CXTranslationUnit_CXXPrecompiledPreamble = 0x10, |
| 1088 | |
| 1089 | /** |
Douglas Gregor | b5af843 | 2011-08-25 22:54:01 +0000 | [diff] [blame] | 1090 | * \brief DEPRECATED: Enabled chained precompiled preambles in C++. |
Douglas Gregor | 99ba202 | 2010-10-27 17:24:53 +0000 | [diff] [blame] | 1091 | * |
| 1092 | * Note: this is a *temporary* option that is available only while |
Douglas Gregor | b5af843 | 2011-08-25 22:54:01 +0000 | [diff] [blame] | 1093 | * we are testing C++ precompiled preamble support. It is deprecated. |
Douglas Gregor | 99ba202 | 2010-10-27 17:24:53 +0000 | [diff] [blame] | 1094 | */ |
Erik Verbruggen | 6a91d38 | 2012-04-12 10:11:59 +0000 | [diff] [blame] | 1095 | CXTranslationUnit_CXXChainedPCH = 0x20, |
| 1096 | |
| 1097 | /** |
| 1098 | * \brief Used to indicate that function/method bodies should be skipped while |
| 1099 | * parsing. |
| 1100 | * |
| 1101 | * This option can be used to search for declarations/definitions while |
| 1102 | * ignoring the usages. |
| 1103 | */ |
| 1104 | CXTranslationUnit_SkipFunctionBodies = 0x40 |
Douglas Gregor | 5a43021 | 2010-07-21 18:52:53 +0000 | [diff] [blame] | 1105 | }; |
| 1106 | |
| 1107 | /** |
Douglas Gregor | b1c031b | 2010-08-09 22:28:58 +0000 | [diff] [blame] | 1108 | * \brief Returns the set of flags that is suitable for parsing a translation |
| 1109 | * unit that is being edited. |
| 1110 | * |
| 1111 | * The set of flags returned provide options for \c clang_parseTranslationUnit() |
| 1112 | * to indicate that the translation unit is likely to be reparsed many times, |
| 1113 | * either explicitly (via \c clang_reparseTranslationUnit()) or implicitly |
| 1114 | * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag |
| 1115 | * set contains an unspecified set of optimizations (e.g., the precompiled |
| 1116 | * preamble) geared toward improving the performance of these routines. The |
| 1117 | * set of optimizations enabled may change from one version to the next. |
| 1118 | */ |
Douglas Gregor | e1e13bf | 2010-08-11 15:58:42 +0000 | [diff] [blame] | 1119 | CINDEX_LINKAGE unsigned clang_defaultEditingTranslationUnitOptions(void); |
Douglas Gregor | b1c031b | 2010-08-09 22:28:58 +0000 | [diff] [blame] | 1120 | |
| 1121 | /** |
Douglas Gregor | 5a43021 | 2010-07-21 18:52:53 +0000 | [diff] [blame] | 1122 | * \brief Parse the given source file and the translation unit corresponding |
| 1123 | * to that file. |
| 1124 | * |
| 1125 | * This routine is the main entry point for the Clang C API, providing the |
| 1126 | * ability to parse a source file into a translation unit that can then be |
| 1127 | * queried by other functions in the API. This routine accepts a set of |
| 1128 | * command-line arguments so that the compilation can be configured in the same |
| 1129 | * way that the compiler is configured on the command line. |
| 1130 | * |
| 1131 | * \param CIdx The index object with which the translation unit will be |
| 1132 | * associated. |
| 1133 | * |
| 1134 | * \param source_filename The name of the source file to load, or NULL if the |
Ted Kremenek | 1ddb02c | 2010-11-08 04:28:51 +0000 | [diff] [blame] | 1135 | * source file is included in \p command_line_args. |
Douglas Gregor | 5a43021 | 2010-07-21 18:52:53 +0000 | [diff] [blame] | 1136 | * |
| 1137 | * \param command_line_args The command-line arguments that would be |
| 1138 | * passed to the \c clang executable if it were being invoked out-of-process. |
| 1139 | * These command-line options will be parsed and will affect how the translation |
| 1140 | * unit is parsed. Note that the following options are ignored: '-c', |
Aaron Ballman | d0f709e | 2012-05-06 16:07:45 +0000 | [diff] [blame] | 1141 | * '-emit-ast', '-fsyntax-only' (which is the default), and '-o <output file>'. |
Douglas Gregor | 5a43021 | 2010-07-21 18:52:53 +0000 | [diff] [blame] | 1142 | * |
| 1143 | * \param num_command_line_args The number of command-line arguments in |
| 1144 | * \p command_line_args. |
| 1145 | * |
| 1146 | * \param unsaved_files the files that have not yet been saved to disk |
Douglas Gregor | 1abc6bc | 2010-08-04 16:47:14 +0000 | [diff] [blame] | 1147 | * but may be required for parsing, including the contents of |
Douglas Gregor | 5a43021 | 2010-07-21 18:52:53 +0000 | [diff] [blame] | 1148 | * those files. The contents and name of these files (as specified by |
| 1149 | * CXUnsavedFile) are copied when necessary, so the client only needs to |
| 1150 | * guarantee their validity until the call to this function returns. |
| 1151 | * |
| 1152 | * \param num_unsaved_files the number of unsaved file entries in \p |
| 1153 | * unsaved_files. |
| 1154 | * |
| 1155 | * \param options A bitmask of options that affects how the translation unit |
| 1156 | * is managed but not its compilation. This should be a bitwise OR of the |
| 1157 | * CXTranslationUnit_XXX flags. |
| 1158 | * |
| 1159 | * \returns A new translation unit describing the parsed code and containing |
| 1160 | * any diagnostics produced by the compiler. If there is a failure from which |
| 1161 | * the compiler cannot recover, returns NULL. |
| 1162 | */ |
| 1163 | CINDEX_LINKAGE CXTranslationUnit clang_parseTranslationUnit(CXIndex CIdx, |
| 1164 | const char *source_filename, |
Douglas Gregor | 2ef6944 | 2010-09-01 16:43:19 +0000 | [diff] [blame] | 1165 | const char * const *command_line_args, |
Douglas Gregor | 5a43021 | 2010-07-21 18:52:53 +0000 | [diff] [blame] | 1166 | int num_command_line_args, |
| 1167 | struct CXUnsavedFile *unsaved_files, |
| 1168 | unsigned num_unsaved_files, |
| 1169 | unsigned options); |
| 1170 | |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 1171 | /** |
Douglas Gregor | 1999844 | 2010-08-13 15:35:05 +0000 | [diff] [blame] | 1172 | * \brief Flags that control how translation units are saved. |
| 1173 | * |
| 1174 | * The enumerators in this enumeration type are meant to be bitwise |
| 1175 | * ORed together to specify which options should be used when |
| 1176 | * saving the translation unit. |
| 1177 | */ |
| 1178 | enum CXSaveTranslationUnit_Flags { |
| 1179 | /** |
| 1180 | * \brief Used to indicate that no special saving options are needed. |
| 1181 | */ |
| 1182 | CXSaveTranslationUnit_None = 0x0 |
| 1183 | }; |
| 1184 | |
| 1185 | /** |
| 1186 | * \brief Returns the set of flags that is suitable for saving a translation |
| 1187 | * unit. |
| 1188 | * |
| 1189 | * The set of flags returned provide options for |
| 1190 | * \c clang_saveTranslationUnit() by default. The returned flag |
| 1191 | * set contains an unspecified set of options that save translation units with |
| 1192 | * the most commonly-requested data. |
| 1193 | */ |
| 1194 | CINDEX_LINKAGE unsigned clang_defaultSaveOptions(CXTranslationUnit TU); |
| 1195 | |
| 1196 | /** |
Douglas Gregor | 39c411f | 2011-07-06 16:43:36 +0000 | [diff] [blame] | 1197 | * \brief Describes the kind of error that occurred (if any) in a call to |
| 1198 | * \c clang_saveTranslationUnit(). |
| 1199 | */ |
| 1200 | enum CXSaveError { |
| 1201 | /** |
| 1202 | * \brief Indicates that no error occurred while saving a translation unit. |
| 1203 | */ |
| 1204 | CXSaveError_None = 0, |
| 1205 | |
| 1206 | /** |
| 1207 | * \brief Indicates that an unknown error occurred while attempting to save |
| 1208 | * the file. |
| 1209 | * |
| 1210 | * This error typically indicates that file I/O failed when attempting to |
| 1211 | * write the file. |
| 1212 | */ |
| 1213 | CXSaveError_Unknown = 1, |
| 1214 | |
| 1215 | /** |
| 1216 | * \brief Indicates that errors during translation prevented this attempt |
| 1217 | * to save the translation unit. |
| 1218 | * |
| 1219 | * Errors that prevent the translation unit from being saved can be |
| 1220 | * extracted using \c clang_getNumDiagnostics() and \c clang_getDiagnostic(). |
| 1221 | */ |
| 1222 | CXSaveError_TranslationErrors = 2, |
| 1223 | |
| 1224 | /** |
| 1225 | * \brief Indicates that the translation unit to be saved was somehow |
| 1226 | * invalid (e.g., NULL). |
| 1227 | */ |
| 1228 | CXSaveError_InvalidTU = 3 |
| 1229 | }; |
| 1230 | |
| 1231 | /** |
Douglas Gregor | 7ae2faa | 2010-08-13 05:36:37 +0000 | [diff] [blame] | 1232 | * \brief Saves a translation unit into a serialized representation of |
| 1233 | * that translation unit on disk. |
| 1234 | * |
| 1235 | * Any translation unit that was parsed without error can be saved |
| 1236 | * into a file. The translation unit can then be deserialized into a |
| 1237 | * new \c CXTranslationUnit with \c clang_createTranslationUnit() or, |
| 1238 | * if it is an incomplete translation unit that corresponds to a |
| 1239 | * header, used as a precompiled header when parsing other translation |
| 1240 | * units. |
| 1241 | * |
| 1242 | * \param TU The translation unit to save. |
Douglas Gregor | 1999844 | 2010-08-13 15:35:05 +0000 | [diff] [blame] | 1243 | * |
Douglas Gregor | 7ae2faa | 2010-08-13 05:36:37 +0000 | [diff] [blame] | 1244 | * \param FileName The file to which the translation unit will be saved. |
| 1245 | * |
Douglas Gregor | 1999844 | 2010-08-13 15:35:05 +0000 | [diff] [blame] | 1246 | * \param options A bitmask of options that affects how the translation unit |
| 1247 | * is saved. This should be a bitwise OR of the |
| 1248 | * CXSaveTranslationUnit_XXX flags. |
| 1249 | * |
Douglas Gregor | 39c411f | 2011-07-06 16:43:36 +0000 | [diff] [blame] | 1250 | * \returns A value that will match one of the enumerators of the CXSaveError |
| 1251 | * enumeration. Zero (CXSaveError_None) indicates that the translation unit was |
| 1252 | * saved successfully, while a non-zero value indicates that a problem occurred. |
Douglas Gregor | 7ae2faa | 2010-08-13 05:36:37 +0000 | [diff] [blame] | 1253 | */ |
| 1254 | CINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU, |
Douglas Gregor | 1999844 | 2010-08-13 15:35:05 +0000 | [diff] [blame] | 1255 | const char *FileName, |
| 1256 | unsigned options); |
Douglas Gregor | 7ae2faa | 2010-08-13 05:36:37 +0000 | [diff] [blame] | 1257 | |
| 1258 | /** |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 1259 | * \brief Destroy the specified CXTranslationUnit object. |
| 1260 | */ |
| 1261 | CINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit); |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 1262 | |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 1263 | /** |
Douglas Gregor | e1e13bf | 2010-08-11 15:58:42 +0000 | [diff] [blame] | 1264 | * \brief Flags that control the reparsing of translation units. |
| 1265 | * |
| 1266 | * The enumerators in this enumeration type are meant to be bitwise |
| 1267 | * ORed together to specify which options should be used when |
| 1268 | * reparsing the translation unit. |
| 1269 | */ |
| 1270 | enum CXReparse_Flags { |
| 1271 | /** |
| 1272 | * \brief Used to indicate that no special reparsing options are needed. |
| 1273 | */ |
| 1274 | CXReparse_None = 0x0 |
| 1275 | }; |
| 1276 | |
| 1277 | /** |
| 1278 | * \brief Returns the set of flags that is suitable for reparsing a translation |
| 1279 | * unit. |
| 1280 | * |
| 1281 | * The set of flags returned provide options for |
| 1282 | * \c clang_reparseTranslationUnit() by default. The returned flag |
| 1283 | * set contains an unspecified set of optimizations geared toward common uses |
| 1284 | * of reparsing. The set of optimizations enabled may change from one version |
| 1285 | * to the next. |
| 1286 | */ |
| 1287 | CINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU); |
| 1288 | |
| 1289 | /** |
Douglas Gregor | abc563f | 2010-07-19 21:46:24 +0000 | [diff] [blame] | 1290 | * \brief Reparse the source files that produced this translation unit. |
| 1291 | * |
| 1292 | * This routine can be used to re-parse the source files that originally |
| 1293 | * created the given translation unit, for example because those source files |
| 1294 | * have changed (either on disk or as passed via \p unsaved_files). The |
| 1295 | * source code will be reparsed with the same command-line options as it |
| 1296 | * was originally parsed. |
| 1297 | * |
| 1298 | * Reparsing a translation unit invalidates all cursors and source locations |
| 1299 | * that refer into that translation unit. This makes reparsing a translation |
| 1300 | * unit semantically equivalent to destroying the translation unit and then |
| 1301 | * creating a new translation unit with the same command-line arguments. |
| 1302 | * However, it may be more efficient to reparse a translation |
| 1303 | * unit using this routine. |
| 1304 | * |
| 1305 | * \param TU The translation unit whose contents will be re-parsed. The |
| 1306 | * translation unit must originally have been built with |
| 1307 | * \c clang_createTranslationUnitFromSourceFile(). |
| 1308 | * |
| 1309 | * \param num_unsaved_files The number of unsaved file entries in \p |
| 1310 | * unsaved_files. |
| 1311 | * |
| 1312 | * \param unsaved_files The files that have not yet been saved to disk |
| 1313 | * but may be required for parsing, including the contents of |
| 1314 | * those files. The contents and name of these files (as specified by |
| 1315 | * CXUnsavedFile) are copied when necessary, so the client only needs to |
| 1316 | * guarantee their validity until the call to this function returns. |
| 1317 | * |
Douglas Gregor | e1e13bf | 2010-08-11 15:58:42 +0000 | [diff] [blame] | 1318 | * \param options A bitset of options composed of the flags in CXReparse_Flags. |
| 1319 | * The function \c clang_defaultReparseOptions() produces a default set of |
| 1320 | * options recommended for most uses, based on the translation unit. |
| 1321 | * |
Douglas Gregor | abc563f | 2010-07-19 21:46:24 +0000 | [diff] [blame] | 1322 | * \returns 0 if the sources could be reparsed. A non-zero value will be |
| 1323 | * returned if reparsing was impossible, such that the translation unit is |
| 1324 | * invalid. In such cases, the only valid call for \p TU is |
| 1325 | * \c clang_disposeTranslationUnit(TU). |
| 1326 | */ |
| 1327 | CINDEX_LINKAGE int clang_reparseTranslationUnit(CXTranslationUnit TU, |
| 1328 | unsigned num_unsaved_files, |
Douglas Gregor | e1e13bf | 2010-08-11 15:58:42 +0000 | [diff] [blame] | 1329 | struct CXUnsavedFile *unsaved_files, |
| 1330 | unsigned options); |
Ted Kremenek | 59fc1e5 | 2011-04-18 22:47:10 +0000 | [diff] [blame] | 1331 | |
| 1332 | /** |
| 1333 | * \brief Categorizes how memory is being used by a translation unit. |
| 1334 | */ |
Ted Kremenek | f787002 | 2011-04-20 16:41:07 +0000 | [diff] [blame] | 1335 | enum CXTUResourceUsageKind { |
| 1336 | CXTUResourceUsage_AST = 1, |
| 1337 | CXTUResourceUsage_Identifiers = 2, |
| 1338 | CXTUResourceUsage_Selectors = 3, |
| 1339 | CXTUResourceUsage_GlobalCompletionResults = 4, |
Ted Kremenek | 457aaf0 | 2011-04-28 04:10:31 +0000 | [diff] [blame] | 1340 | CXTUResourceUsage_SourceManagerContentCache = 5, |
Ted Kremenek | ba29bd2 | 2011-04-28 04:53:38 +0000 | [diff] [blame] | 1341 | CXTUResourceUsage_AST_SideTables = 6, |
Ted Kremenek | f61b831 | 2011-04-28 20:36:42 +0000 | [diff] [blame] | 1342 | CXTUResourceUsage_SourceManager_Membuffer_Malloc = 7, |
Ted Kremenek | e9b5f3d | 2011-04-28 23:46:20 +0000 | [diff] [blame] | 1343 | CXTUResourceUsage_SourceManager_Membuffer_MMap = 8, |
| 1344 | CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc = 9, |
| 1345 | CXTUResourceUsage_ExternalASTSource_Membuffer_MMap = 10, |
Ted Kremenek | 5e1db6a | 2011-05-04 01:38:46 +0000 | [diff] [blame] | 1346 | CXTUResourceUsage_Preprocessor = 11, |
| 1347 | CXTUResourceUsage_PreprocessingRecord = 12, |
Ted Kremenek | ca7dc2b | 2011-07-26 23:46:06 +0000 | [diff] [blame] | 1348 | CXTUResourceUsage_SourceManager_DataStructures = 13, |
Ted Kremenek | d1194fb | 2011-07-26 23:46:11 +0000 | [diff] [blame] | 1349 | CXTUResourceUsage_Preprocessor_HeaderSearch = 14, |
Ted Kremenek | f787002 | 2011-04-20 16:41:07 +0000 | [diff] [blame] | 1350 | CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST, |
| 1351 | CXTUResourceUsage_MEMORY_IN_BYTES_END = |
Ted Kremenek | d1194fb | 2011-07-26 23:46:11 +0000 | [diff] [blame] | 1352 | CXTUResourceUsage_Preprocessor_HeaderSearch, |
Ted Kremenek | f787002 | 2011-04-20 16:41:07 +0000 | [diff] [blame] | 1353 | |
| 1354 | CXTUResourceUsage_First = CXTUResourceUsage_AST, |
Ted Kremenek | d1194fb | 2011-07-26 23:46:11 +0000 | [diff] [blame] | 1355 | CXTUResourceUsage_Last = CXTUResourceUsage_Preprocessor_HeaderSearch |
Ted Kremenek | 59fc1e5 | 2011-04-18 22:47:10 +0000 | [diff] [blame] | 1356 | }; |
| 1357 | |
| 1358 | /** |
| 1359 | * \brief Returns the human-readable null-terminated C string that represents |
Ted Kremenek | f787002 | 2011-04-20 16:41:07 +0000 | [diff] [blame] | 1360 | * the name of the memory category. This string should never be freed. |
Ted Kremenek | 59fc1e5 | 2011-04-18 22:47:10 +0000 | [diff] [blame] | 1361 | */ |
| 1362 | CINDEX_LINKAGE |
Ted Kremenek | f787002 | 2011-04-20 16:41:07 +0000 | [diff] [blame] | 1363 | const char *clang_getTUResourceUsageName(enum CXTUResourceUsageKind kind); |
Ted Kremenek | 59fc1e5 | 2011-04-18 22:47:10 +0000 | [diff] [blame] | 1364 | |
Ted Kremenek | f787002 | 2011-04-20 16:41:07 +0000 | [diff] [blame] | 1365 | typedef struct CXTUResourceUsageEntry { |
Ted Kremenek | 59fc1e5 | 2011-04-18 22:47:10 +0000 | [diff] [blame] | 1366 | /* \brief The memory usage category. */ |
Ted Kremenek | f787002 | 2011-04-20 16:41:07 +0000 | [diff] [blame] | 1367 | enum CXTUResourceUsageKind kind; |
| 1368 | /* \brief Amount of resources used. |
| 1369 | The units will depend on the resource kind. */ |
Ted Kremenek | 59fc1e5 | 2011-04-18 22:47:10 +0000 | [diff] [blame] | 1370 | unsigned long amount; |
Ted Kremenek | f787002 | 2011-04-20 16:41:07 +0000 | [diff] [blame] | 1371 | } CXTUResourceUsageEntry; |
Ted Kremenek | 59fc1e5 | 2011-04-18 22:47:10 +0000 | [diff] [blame] | 1372 | |
| 1373 | /** |
| 1374 | * \brief The memory usage of a CXTranslationUnit, broken into categories. |
| 1375 | */ |
Ted Kremenek | f787002 | 2011-04-20 16:41:07 +0000 | [diff] [blame] | 1376 | typedef struct CXTUResourceUsage { |
Ted Kremenek | 59fc1e5 | 2011-04-18 22:47:10 +0000 | [diff] [blame] | 1377 | /* \brief Private data member, used for queries. */ |
| 1378 | void *data; |
| 1379 | |
| 1380 | /* \brief The number of entries in the 'entries' array. */ |
| 1381 | unsigned numEntries; |
| 1382 | |
| 1383 | /* \brief An array of key-value pairs, representing the breakdown of memory |
| 1384 | usage. */ |
Ted Kremenek | f787002 | 2011-04-20 16:41:07 +0000 | [diff] [blame] | 1385 | CXTUResourceUsageEntry *entries; |
Ted Kremenek | 59fc1e5 | 2011-04-18 22:47:10 +0000 | [diff] [blame] | 1386 | |
Ted Kremenek | f787002 | 2011-04-20 16:41:07 +0000 | [diff] [blame] | 1387 | } CXTUResourceUsage; |
Ted Kremenek | 59fc1e5 | 2011-04-18 22:47:10 +0000 | [diff] [blame] | 1388 | |
| 1389 | /** |
| 1390 | * \brief Return the memory usage of a translation unit. This object |
Ted Kremenek | f787002 | 2011-04-20 16:41:07 +0000 | [diff] [blame] | 1391 | * should be released with clang_disposeCXTUResourceUsage(). |
Ted Kremenek | 59fc1e5 | 2011-04-18 22:47:10 +0000 | [diff] [blame] | 1392 | */ |
Ted Kremenek | f787002 | 2011-04-20 16:41:07 +0000 | [diff] [blame] | 1393 | CINDEX_LINKAGE CXTUResourceUsage clang_getCXTUResourceUsage(CXTranslationUnit TU); |
Ted Kremenek | 59fc1e5 | 2011-04-18 22:47:10 +0000 | [diff] [blame] | 1394 | |
Ted Kremenek | f787002 | 2011-04-20 16:41:07 +0000 | [diff] [blame] | 1395 | CINDEX_LINKAGE void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage); |
Ted Kremenek | 59fc1e5 | 2011-04-18 22:47:10 +0000 | [diff] [blame] | 1396 | |
Douglas Gregor | abc563f | 2010-07-19 21:46:24 +0000 | [diff] [blame] | 1397 | /** |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 1398 | * @} |
| 1399 | */ |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 1400 | |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 1401 | /** |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1402 | * \brief Describes the kind of entity that a cursor refers to. |
| 1403 | */ |
| 1404 | enum CXCursorKind { |
| 1405 | /* Declarations */ |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1406 | /** |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1407 | * \brief A declaration whose specific kind is not exposed via this |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1408 | * interface. |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1409 | * |
| 1410 | * Unexposed declarations have the same operations as any other kind |
| 1411 | * of declaration; one can extract their location information, |
| 1412 | * spelling, find their definitions, etc. However, the specific kind |
| 1413 | * of the declaration is not reported. |
| 1414 | */ |
| 1415 | CXCursor_UnexposedDecl = 1, |
| 1416 | /** \brief A C or C++ struct. */ |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1417 | CXCursor_StructDecl = 2, |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1418 | /** \brief A C or C++ union. */ |
| 1419 | CXCursor_UnionDecl = 3, |
| 1420 | /** \brief A C++ class. */ |
| 1421 | CXCursor_ClassDecl = 4, |
| 1422 | /** \brief An enumeration. */ |
| 1423 | CXCursor_EnumDecl = 5, |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1424 | /** |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1425 | * \brief A field (in C) or non-static data member (in C++) in a |
| 1426 | * struct, union, or C++ class. |
| 1427 | */ |
| 1428 | CXCursor_FieldDecl = 6, |
| 1429 | /** \brief An enumerator constant. */ |
| 1430 | CXCursor_EnumConstantDecl = 7, |
| 1431 | /** \brief A function. */ |
| 1432 | CXCursor_FunctionDecl = 8, |
| 1433 | /** \brief A variable. */ |
| 1434 | CXCursor_VarDecl = 9, |
| 1435 | /** \brief A function or method parameter. */ |
| 1436 | CXCursor_ParmDecl = 10, |
James Dennett | 17d26a6 | 2012-06-11 06:19:40 +0000 | [diff] [blame] | 1437 | /** \brief An Objective-C \@interface. */ |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1438 | CXCursor_ObjCInterfaceDecl = 11, |
James Dennett | 17d26a6 | 2012-06-11 06:19:40 +0000 | [diff] [blame] | 1439 | /** \brief An Objective-C \@interface for a category. */ |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1440 | CXCursor_ObjCCategoryDecl = 12, |
James Dennett | 17d26a6 | 2012-06-11 06:19:40 +0000 | [diff] [blame] | 1441 | /** \brief An Objective-C \@protocol declaration. */ |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1442 | CXCursor_ObjCProtocolDecl = 13, |
James Dennett | 17d26a6 | 2012-06-11 06:19:40 +0000 | [diff] [blame] | 1443 | /** \brief An Objective-C \@property declaration. */ |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1444 | CXCursor_ObjCPropertyDecl = 14, |
| 1445 | /** \brief An Objective-C instance variable. */ |
| 1446 | CXCursor_ObjCIvarDecl = 15, |
| 1447 | /** \brief An Objective-C instance method. */ |
| 1448 | CXCursor_ObjCInstanceMethodDecl = 16, |
| 1449 | /** \brief An Objective-C class method. */ |
| 1450 | CXCursor_ObjCClassMethodDecl = 17, |
James Dennett | 17d26a6 | 2012-06-11 06:19:40 +0000 | [diff] [blame] | 1451 | /** \brief An Objective-C \@implementation. */ |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1452 | CXCursor_ObjCImplementationDecl = 18, |
James Dennett | 17d26a6 | 2012-06-11 06:19:40 +0000 | [diff] [blame] | 1453 | /** \brief An Objective-C \@implementation for a category. */ |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1454 | CXCursor_ObjCCategoryImplDecl = 19, |
| 1455 | /** \brief A typedef */ |
| 1456 | CXCursor_TypedefDecl = 20, |
Ted Kremenek | 8bd5a69 | 2010-04-13 23:39:06 +0000 | [diff] [blame] | 1457 | /** \brief A C++ class method. */ |
| 1458 | CXCursor_CXXMethod = 21, |
Ted Kremenek | 8f06e0e | 2010-05-06 23:38:21 +0000 | [diff] [blame] | 1459 | /** \brief A C++ namespace. */ |
| 1460 | CXCursor_Namespace = 22, |
Ted Kremenek | a0536d8 | 2010-05-07 01:04:29 +0000 | [diff] [blame] | 1461 | /** \brief A linkage specification, e.g. 'extern "C"'. */ |
| 1462 | CXCursor_LinkageSpec = 23, |
Douglas Gregor | 01829d3 | 2010-08-31 14:41:23 +0000 | [diff] [blame] | 1463 | /** \brief A C++ constructor. */ |
| 1464 | CXCursor_Constructor = 24, |
| 1465 | /** \brief A C++ destructor. */ |
| 1466 | CXCursor_Destructor = 25, |
| 1467 | /** \brief A C++ conversion function. */ |
| 1468 | CXCursor_ConversionFunction = 26, |
Douglas Gregor | fe72e9c | 2010-08-31 17:01:39 +0000 | [diff] [blame] | 1469 | /** \brief A C++ template type parameter. */ |
| 1470 | CXCursor_TemplateTypeParameter = 27, |
| 1471 | /** \brief A C++ non-type template parameter. */ |
| 1472 | CXCursor_NonTypeTemplateParameter = 28, |
| 1473 | /** \brief A C++ template template parameter. */ |
| 1474 | CXCursor_TemplateTemplateParameter = 29, |
| 1475 | /** \brief A C++ function template. */ |
| 1476 | CXCursor_FunctionTemplate = 30, |
Douglas Gregor | 39d6f07 | 2010-08-31 19:02:00 +0000 | [diff] [blame] | 1477 | /** \brief A C++ class template. */ |
| 1478 | CXCursor_ClassTemplate = 31, |
Douglas Gregor | 74dbe64 | 2010-08-31 19:31:58 +0000 | [diff] [blame] | 1479 | /** \brief A C++ class template partial specialization. */ |
| 1480 | CXCursor_ClassTemplatePartialSpecialization = 32, |
Douglas Gregor | 6931900 | 2010-08-31 23:48:11 +0000 | [diff] [blame] | 1481 | /** \brief A C++ namespace alias declaration. */ |
| 1482 | CXCursor_NamespaceAlias = 33, |
Douglas Gregor | 0a35bce | 2010-09-01 03:07:18 +0000 | [diff] [blame] | 1483 | /** \brief A C++ using directive. */ |
| 1484 | CXCursor_UsingDirective = 34, |
Richard Smith | 162e1c1 | 2011-04-15 14:24:37 +0000 | [diff] [blame] | 1485 | /** \brief A C++ using declaration. */ |
Douglas Gregor | 7e24256 | 2010-09-01 19:52:22 +0000 | [diff] [blame] | 1486 | CXCursor_UsingDeclaration = 35, |
Richard Smith | 162e1c1 | 2011-04-15 14:24:37 +0000 | [diff] [blame] | 1487 | /** \brief A C++ alias declaration */ |
| 1488 | CXCursor_TypeAliasDecl = 36, |
Douglas Gregor | 352697a | 2011-06-03 23:08:58 +0000 | [diff] [blame] | 1489 | /** \brief An Objective-C @synthesize definition. */ |
| 1490 | CXCursor_ObjCSynthesizeDecl = 37, |
| 1491 | /** \brief An Objective-C @dynamic definition. */ |
| 1492 | CXCursor_ObjCDynamicDecl = 38, |
Argyrios Kyrtzidis | 2dfdb94 | 2011-09-30 17:58:23 +0000 | [diff] [blame] | 1493 | /** \brief An access specifier. */ |
| 1494 | CXCursor_CXXAccessSpecifier = 39, |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 1495 | |
Ted Kremenek | 50aa6ac | 2010-05-19 21:51:10 +0000 | [diff] [blame] | 1496 | CXCursor_FirstDecl = CXCursor_UnexposedDecl, |
Argyrios Kyrtzidis | 2dfdb94 | 2011-09-30 17:58:23 +0000 | [diff] [blame] | 1497 | CXCursor_LastDecl = CXCursor_CXXAccessSpecifier, |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1498 | |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1499 | /* References */ |
| 1500 | CXCursor_FirstRef = 40, /* Decl references */ |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1501 | CXCursor_ObjCSuperClassRef = 40, |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1502 | CXCursor_ObjCProtocolRef = 41, |
| 1503 | CXCursor_ObjCClassRef = 42, |
| 1504 | /** |
| 1505 | * \brief A reference to a type declaration. |
| 1506 | * |
| 1507 | * A type reference occurs anywhere where a type is named but not |
| 1508 | * declared. For example, given: |
| 1509 | * |
| 1510 | * \code |
| 1511 | * typedef unsigned size_type; |
| 1512 | * size_type size; |
| 1513 | * \endcode |
| 1514 | * |
| 1515 | * The typedef is a declaration of size_type (CXCursor_TypedefDecl), |
| 1516 | * while the type of the variable "size" is referenced. The cursor |
| 1517 | * referenced by the type of size is the typedef for size_type. |
| 1518 | */ |
| 1519 | CXCursor_TypeRef = 43, |
Ted Kremenek | 3064ef9 | 2010-08-27 21:34:58 +0000 | [diff] [blame] | 1520 | CXCursor_CXXBaseSpecifier = 44, |
Douglas Gregor | 0b36e61 | 2010-08-31 20:37:03 +0000 | [diff] [blame] | 1521 | /** |
Douglas Gregor | a67e03f | 2010-09-09 21:42:20 +0000 | [diff] [blame] | 1522 | * \brief A reference to a class template, function template, template |
| 1523 | * template parameter, or class template partial specialization. |
Douglas Gregor | 0b36e61 | 2010-08-31 20:37:03 +0000 | [diff] [blame] | 1524 | */ |
| 1525 | CXCursor_TemplateRef = 45, |
Douglas Gregor | 6931900 | 2010-08-31 23:48:11 +0000 | [diff] [blame] | 1526 | /** |
| 1527 | * \brief A reference to a namespace or namespace alias. |
| 1528 | */ |
| 1529 | CXCursor_NamespaceRef = 46, |
Douglas Gregor | a67e03f | 2010-09-09 21:42:20 +0000 | [diff] [blame] | 1530 | /** |
Douglas Gregor | 36897b0 | 2010-09-10 00:22:18 +0000 | [diff] [blame] | 1531 | * \brief A reference to a member of a struct, union, or class that occurs in |
| 1532 | * some non-expression context, e.g., a designated initializer. |
Douglas Gregor | a67e03f | 2010-09-09 21:42:20 +0000 | [diff] [blame] | 1533 | */ |
| 1534 | CXCursor_MemberRef = 47, |
Douglas Gregor | 36897b0 | 2010-09-10 00:22:18 +0000 | [diff] [blame] | 1535 | /** |
| 1536 | * \brief A reference to a labeled statement. |
| 1537 | * |
| 1538 | * This cursor kind is used to describe the jump to "start_over" in the |
| 1539 | * goto statement in the following example: |
| 1540 | * |
| 1541 | * \code |
| 1542 | * start_over: |
| 1543 | * ++counter; |
| 1544 | * |
| 1545 | * goto start_over; |
| 1546 | * \endcode |
| 1547 | * |
| 1548 | * A label reference cursor refers to a label statement. |
| 1549 | */ |
| 1550 | CXCursor_LabelRef = 48, |
| 1551 | |
Douglas Gregor | 1f60d9e | 2010-09-13 22:52:57 +0000 | [diff] [blame] | 1552 | /** |
| 1553 | * \brief A reference to a set of overloaded functions or function templates |
| 1554 | * that has not yet been resolved to a specific function or function template. |
| 1555 | * |
| 1556 | * An overloaded declaration reference cursor occurs in C++ templates where |
| 1557 | * a dependent name refers to a function. For example: |
| 1558 | * |
| 1559 | * \code |
| 1560 | * template<typename T> void swap(T&, T&); |
| 1561 | * |
| 1562 | * struct X { ... }; |
| 1563 | * void swap(X&, X&); |
| 1564 | * |
| 1565 | * template<typename T> |
| 1566 | * void reverse(T* first, T* last) { |
| 1567 | * while (first < last - 1) { |
| 1568 | * swap(*first, *--last); |
| 1569 | * ++first; |
| 1570 | * } |
| 1571 | * } |
| 1572 | * |
| 1573 | * struct Y { }; |
| 1574 | * void swap(Y&, Y&); |
| 1575 | * \endcode |
| 1576 | * |
| 1577 | * Here, the identifier "swap" is associated with an overloaded declaration |
| 1578 | * reference. In the template definition, "swap" refers to either of the two |
| 1579 | * "swap" functions declared above, so both results will be available. At |
| 1580 | * instantiation time, "swap" may also refer to other functions found via |
| 1581 | * argument-dependent lookup (e.g., the "swap" function at the end of the |
| 1582 | * example). |
| 1583 | * |
| 1584 | * The functions \c clang_getNumOverloadedDecls() and |
| 1585 | * \c clang_getOverloadedDecl() can be used to retrieve the definitions |
| 1586 | * referenced by this cursor. |
| 1587 | */ |
| 1588 | CXCursor_OverloadedDeclRef = 49, |
| 1589 | |
Douglas Gregor | 011d8b9 | 2012-02-15 00:54:55 +0000 | [diff] [blame] | 1590 | /** |
| 1591 | * \brief A reference to a variable that occurs in some non-expression |
| 1592 | * context, e.g., a C++ lambda capture list. |
| 1593 | */ |
| 1594 | CXCursor_VariableRef = 50, |
| 1595 | |
| 1596 | CXCursor_LastRef = CXCursor_VariableRef, |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1597 | |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1598 | /* Error conditions */ |
| 1599 | CXCursor_FirstInvalid = 70, |
| 1600 | CXCursor_InvalidFile = 70, |
| 1601 | CXCursor_NoDeclFound = 71, |
| 1602 | CXCursor_NotImplemented = 72, |
Ted Kremenek | ebfa339 | 2010-03-19 20:39:03 +0000 | [diff] [blame] | 1603 | CXCursor_InvalidCode = 73, |
| 1604 | CXCursor_LastInvalid = CXCursor_InvalidCode, |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1605 | |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1606 | /* Expressions */ |
| 1607 | CXCursor_FirstExpr = 100, |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1608 | |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1609 | /** |
| 1610 | * \brief An expression whose specific kind is not exposed via this |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1611 | * interface. |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1612 | * |
| 1613 | * Unexposed expressions have the same operations as any other kind |
| 1614 | * of expression; one can extract their location information, |
| 1615 | * spelling, children, etc. However, the specific kind of the |
| 1616 | * expression is not reported. |
| 1617 | */ |
| 1618 | CXCursor_UnexposedExpr = 100, |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1619 | |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1620 | /** |
| 1621 | * \brief An expression that refers to some value declaration, such |
| 1622 | * as a function, varible, or enumerator. |
| 1623 | */ |
| 1624 | CXCursor_DeclRefExpr = 101, |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1625 | |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1626 | /** |
| 1627 | * \brief An expression that refers to a member of a struct, union, |
| 1628 | * class, Objective-C class, etc. |
| 1629 | */ |
| 1630 | CXCursor_MemberRefExpr = 102, |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1631 | |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1632 | /** \brief An expression that calls a function. */ |
| 1633 | CXCursor_CallExpr = 103, |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1634 | |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1635 | /** \brief An expression that sends a message to an Objective-C |
| 1636 | object or class. */ |
| 1637 | CXCursor_ObjCMessageExpr = 104, |
Ted Kremenek | 1ee6cad | 2010-04-11 21:47:37 +0000 | [diff] [blame] | 1638 | |
| 1639 | /** \brief An expression that represents a block literal. */ |
| 1640 | CXCursor_BlockExpr = 105, |
| 1641 | |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 1642 | /** \brief An integer literal. |
| 1643 | */ |
| 1644 | CXCursor_IntegerLiteral = 106, |
| 1645 | |
| 1646 | /** \brief A floating point number literal. |
| 1647 | */ |
| 1648 | CXCursor_FloatingLiteral = 107, |
| 1649 | |
| 1650 | /** \brief An imaginary number literal. |
| 1651 | */ |
| 1652 | CXCursor_ImaginaryLiteral = 108, |
| 1653 | |
| 1654 | /** \brief A string literal. |
| 1655 | */ |
| 1656 | CXCursor_StringLiteral = 109, |
| 1657 | |
| 1658 | /** \brief A character literal. |
| 1659 | */ |
| 1660 | CXCursor_CharacterLiteral = 110, |
| 1661 | |
| 1662 | /** \brief A parenthesized expression, e.g. "(1)". |
| 1663 | * |
| 1664 | * This AST node is only formed if full location information is requested. |
| 1665 | */ |
| 1666 | CXCursor_ParenExpr = 111, |
| 1667 | |
| 1668 | /** \brief This represents the unary-expression's (except sizeof and |
| 1669 | * alignof). |
| 1670 | */ |
| 1671 | CXCursor_UnaryOperator = 112, |
| 1672 | |
| 1673 | /** \brief [C99 6.5.2.1] Array Subscripting. |
| 1674 | */ |
| 1675 | CXCursor_ArraySubscriptExpr = 113, |
| 1676 | |
| 1677 | /** \brief A builtin binary operation expression such as "x + y" or |
| 1678 | * "x <= y". |
| 1679 | */ |
| 1680 | CXCursor_BinaryOperator = 114, |
| 1681 | |
| 1682 | /** \brief Compound assignment such as "+=". |
| 1683 | */ |
| 1684 | CXCursor_CompoundAssignOperator = 115, |
| 1685 | |
| 1686 | /** \brief The ?: ternary operator. |
| 1687 | */ |
| 1688 | CXCursor_ConditionalOperator = 116, |
| 1689 | |
| 1690 | /** \brief An explicit cast in C (C99 6.5.4) or a C-style cast in C++ |
| 1691 | * (C++ [expr.cast]), which uses the syntax (Type)expr. |
| 1692 | * |
| 1693 | * For example: (int)f. |
| 1694 | */ |
| 1695 | CXCursor_CStyleCastExpr = 117, |
| 1696 | |
| 1697 | /** \brief [C99 6.5.2.5] |
| 1698 | */ |
| 1699 | CXCursor_CompoundLiteralExpr = 118, |
| 1700 | |
| 1701 | /** \brief Describes an C or C++ initializer list. |
| 1702 | */ |
| 1703 | CXCursor_InitListExpr = 119, |
| 1704 | |
| 1705 | /** \brief The GNU address of label extension, representing &&label. |
| 1706 | */ |
| 1707 | CXCursor_AddrLabelExpr = 120, |
| 1708 | |
| 1709 | /** \brief This is the GNU Statement Expression extension: ({int X=4; X;}) |
| 1710 | */ |
| 1711 | CXCursor_StmtExpr = 121, |
| 1712 | |
Benjamin Kramer | ffbe9b9 | 2011-12-23 17:00:35 +0000 | [diff] [blame] | 1713 | /** \brief Represents a C11 generic selection. |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 1714 | */ |
| 1715 | CXCursor_GenericSelectionExpr = 122, |
| 1716 | |
| 1717 | /** \brief Implements the GNU __null extension, which is a name for a null |
| 1718 | * pointer constant that has integral type (e.g., int or long) and is the same |
| 1719 | * size and alignment as a pointer. |
| 1720 | * |
| 1721 | * The __null extension is typically only used by system headers, which define |
| 1722 | * NULL as __null in C++ rather than using 0 (which is an integer that may not |
| 1723 | * match the size of a pointer). |
| 1724 | */ |
| 1725 | CXCursor_GNUNullExpr = 123, |
| 1726 | |
| 1727 | /** \brief C++'s static_cast<> expression. |
| 1728 | */ |
| 1729 | CXCursor_CXXStaticCastExpr = 124, |
| 1730 | |
| 1731 | /** \brief C++'s dynamic_cast<> expression. |
| 1732 | */ |
| 1733 | CXCursor_CXXDynamicCastExpr = 125, |
| 1734 | |
| 1735 | /** \brief C++'s reinterpret_cast<> expression. |
| 1736 | */ |
| 1737 | CXCursor_CXXReinterpretCastExpr = 126, |
| 1738 | |
| 1739 | /** \brief C++'s const_cast<> expression. |
| 1740 | */ |
| 1741 | CXCursor_CXXConstCastExpr = 127, |
| 1742 | |
| 1743 | /** \brief Represents an explicit C++ type conversion that uses "functional" |
| 1744 | * notion (C++ [expr.type.conv]). |
| 1745 | * |
| 1746 | * Example: |
| 1747 | * \code |
| 1748 | * x = int(0.5); |
| 1749 | * \endcode |
| 1750 | */ |
| 1751 | CXCursor_CXXFunctionalCastExpr = 128, |
| 1752 | |
| 1753 | /** \brief A C++ typeid expression (C++ [expr.typeid]). |
| 1754 | */ |
| 1755 | CXCursor_CXXTypeidExpr = 129, |
| 1756 | |
| 1757 | /** \brief [C++ 2.13.5] C++ Boolean Literal. |
| 1758 | */ |
| 1759 | CXCursor_CXXBoolLiteralExpr = 130, |
| 1760 | |
| 1761 | /** \brief [C++0x 2.14.7] C++ Pointer Literal. |
| 1762 | */ |
| 1763 | CXCursor_CXXNullPtrLiteralExpr = 131, |
| 1764 | |
| 1765 | /** \brief Represents the "this" expression in C++ |
| 1766 | */ |
| 1767 | CXCursor_CXXThisExpr = 132, |
| 1768 | |
| 1769 | /** \brief [C++ 15] C++ Throw Expression. |
| 1770 | * |
| 1771 | * This handles 'throw' and 'throw' assignment-expression. When |
| 1772 | * assignment-expression isn't present, Op will be null. |
| 1773 | */ |
| 1774 | CXCursor_CXXThrowExpr = 133, |
| 1775 | |
| 1776 | /** \brief A new expression for memory allocation and constructor calls, e.g: |
| 1777 | * "new CXXNewExpr(foo)". |
| 1778 | */ |
| 1779 | CXCursor_CXXNewExpr = 134, |
| 1780 | |
| 1781 | /** \brief A delete expression for memory deallocation and destructor calls, |
| 1782 | * e.g. "delete[] pArray". |
| 1783 | */ |
| 1784 | CXCursor_CXXDeleteExpr = 135, |
| 1785 | |
| 1786 | /** \brief A unary expression. |
| 1787 | */ |
| 1788 | CXCursor_UnaryExpr = 136, |
| 1789 | |
Douglas Gregor | 9793e8f | 2011-11-11 22:35:18 +0000 | [diff] [blame] | 1790 | /** \brief An Objective-C string literal i.e. @"foo". |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 1791 | */ |
| 1792 | CXCursor_ObjCStringLiteral = 137, |
| 1793 | |
Douglas Gregor | 9793e8f | 2011-11-11 22:35:18 +0000 | [diff] [blame] | 1794 | /** \brief An Objective-C @encode expression. |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 1795 | */ |
| 1796 | CXCursor_ObjCEncodeExpr = 138, |
| 1797 | |
Douglas Gregor | 9793e8f | 2011-11-11 22:35:18 +0000 | [diff] [blame] | 1798 | /** \brief An Objective-C @selector expression. |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 1799 | */ |
| 1800 | CXCursor_ObjCSelectorExpr = 139, |
| 1801 | |
James Dennett | 17d26a6 | 2012-06-11 06:19:40 +0000 | [diff] [blame] | 1802 | /** \brief An Objective-C \@protocol expression. |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 1803 | */ |
| 1804 | CXCursor_ObjCProtocolExpr = 140, |
| 1805 | |
| 1806 | /** \brief An Objective-C "bridged" cast expression, which casts between |
| 1807 | * Objective-C pointers and C pointers, transferring ownership in the process. |
| 1808 | * |
| 1809 | * \code |
| 1810 | * NSString *str = (__bridge_transfer NSString *)CFCreateString(); |
| 1811 | * \endcode |
| 1812 | */ |
| 1813 | CXCursor_ObjCBridgedCastExpr = 141, |
| 1814 | |
| 1815 | /** \brief Represents a C++0x pack expansion that produces a sequence of |
| 1816 | * expressions. |
| 1817 | * |
| 1818 | * A pack expansion expression contains a pattern (which itself is an |
| 1819 | * expression) followed by an ellipsis. For example: |
| 1820 | * |
| 1821 | * \code |
| 1822 | * template<typename F, typename ...Types> |
| 1823 | * void forward(F f, Types &&...args) { |
| 1824 | * f(static_cast<Types&&>(args)...); |
| 1825 | * } |
| 1826 | * \endcode |
| 1827 | */ |
| 1828 | CXCursor_PackExpansionExpr = 142, |
| 1829 | |
| 1830 | /** \brief Represents an expression that computes the length of a parameter |
| 1831 | * pack. |
| 1832 | * |
| 1833 | * \code |
| 1834 | * template<typename ...Types> |
| 1835 | * struct count { |
| 1836 | * static const unsigned value = sizeof...(Types); |
| 1837 | * }; |
| 1838 | * \endcode |
| 1839 | */ |
| 1840 | CXCursor_SizeOfPackExpr = 143, |
| 1841 | |
Douglas Gregor | 011d8b9 | 2012-02-15 00:54:55 +0000 | [diff] [blame] | 1842 | /* \brief Represents a C++ lambda expression that produces a local function |
| 1843 | * object. |
| 1844 | * |
| 1845 | * \code |
| 1846 | * void abssort(float *x, unsigned N) { |
| 1847 | * std::sort(x, x + N, |
| 1848 | * [](float a, float b) { |
| 1849 | * return std::abs(a) < std::abs(b); |
| 1850 | * }); |
| 1851 | * } |
| 1852 | * \endcode |
| 1853 | */ |
| 1854 | CXCursor_LambdaExpr = 144, |
| 1855 | |
Ted Kremenek | b3f7542 | 2012-03-06 20:06:06 +0000 | [diff] [blame] | 1856 | /** \brief Objective-c Boolean Literal. |
| 1857 | */ |
| 1858 | CXCursor_ObjCBoolLiteralExpr = 145, |
| 1859 | |
| 1860 | CXCursor_LastExpr = CXCursor_ObjCBoolLiteralExpr, |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1861 | |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1862 | /* Statements */ |
| 1863 | CXCursor_FirstStmt = 200, |
| 1864 | /** |
| 1865 | * \brief A statement whose specific kind is not exposed via this |
| 1866 | * interface. |
| 1867 | * |
| 1868 | * Unexposed statements have the same operations as any other kind of |
| 1869 | * statement; one can extract their location information, spelling, |
| 1870 | * children, etc. However, the specific kind of the statement is not |
| 1871 | * reported. |
| 1872 | */ |
| 1873 | CXCursor_UnexposedStmt = 200, |
Douglas Gregor | 36897b0 | 2010-09-10 00:22:18 +0000 | [diff] [blame] | 1874 | |
| 1875 | /** \brief A labelled statement in a function. |
| 1876 | * |
| 1877 | * This cursor kind is used to describe the "start_over:" label statement in |
| 1878 | * the following example: |
| 1879 | * |
| 1880 | * \code |
| 1881 | * start_over: |
| 1882 | * ++counter; |
| 1883 | * \endcode |
| 1884 | * |
| 1885 | */ |
| 1886 | CXCursor_LabelStmt = 201, |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 1887 | |
| 1888 | /** \brief A group of statements like { stmt stmt }. |
| 1889 | * |
| 1890 | * This cursor kind is used to describe compound statements, e.g. function |
| 1891 | * bodies. |
| 1892 | */ |
| 1893 | CXCursor_CompoundStmt = 202, |
| 1894 | |
| 1895 | /** \brief A case statment. |
| 1896 | */ |
| 1897 | CXCursor_CaseStmt = 203, |
| 1898 | |
| 1899 | /** \brief A default statement. |
| 1900 | */ |
| 1901 | CXCursor_DefaultStmt = 204, |
| 1902 | |
| 1903 | /** \brief An if statement |
| 1904 | */ |
| 1905 | CXCursor_IfStmt = 205, |
| 1906 | |
| 1907 | /** \brief A switch statement. |
| 1908 | */ |
| 1909 | CXCursor_SwitchStmt = 206, |
| 1910 | |
| 1911 | /** \brief A while statement. |
| 1912 | */ |
| 1913 | CXCursor_WhileStmt = 207, |
| 1914 | |
| 1915 | /** \brief A do statement. |
| 1916 | */ |
| 1917 | CXCursor_DoStmt = 208, |
| 1918 | |
| 1919 | /** \brief A for statement. |
| 1920 | */ |
| 1921 | CXCursor_ForStmt = 209, |
| 1922 | |
| 1923 | /** \brief A goto statement. |
| 1924 | */ |
| 1925 | CXCursor_GotoStmt = 210, |
| 1926 | |
| 1927 | /** \brief An indirect goto statement. |
| 1928 | */ |
| 1929 | CXCursor_IndirectGotoStmt = 211, |
| 1930 | |
| 1931 | /** \brief A continue statement. |
| 1932 | */ |
| 1933 | CXCursor_ContinueStmt = 212, |
| 1934 | |
| 1935 | /** \brief A break statement. |
| 1936 | */ |
| 1937 | CXCursor_BreakStmt = 213, |
| 1938 | |
| 1939 | /** \brief A return statement. |
| 1940 | */ |
| 1941 | CXCursor_ReturnStmt = 214, |
| 1942 | |
| 1943 | /** \brief A GNU inline assembly statement extension. |
| 1944 | */ |
| 1945 | CXCursor_AsmStmt = 215, |
| 1946 | |
Douglas Gregor | 3f54d48 | 2011-11-08 21:07:04 +0000 | [diff] [blame] | 1947 | /** \brief Objective-C's overall @try-@catch-@finally statement. |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 1948 | */ |
| 1949 | CXCursor_ObjCAtTryStmt = 216, |
| 1950 | |
| 1951 | /** \brief Objective-C's @catch statement. |
| 1952 | */ |
| 1953 | CXCursor_ObjCAtCatchStmt = 217, |
| 1954 | |
| 1955 | /** \brief Objective-C's @finally statement. |
| 1956 | */ |
| 1957 | CXCursor_ObjCAtFinallyStmt = 218, |
| 1958 | |
| 1959 | /** \brief Objective-C's @throw statement. |
| 1960 | */ |
| 1961 | CXCursor_ObjCAtThrowStmt = 219, |
| 1962 | |
| 1963 | /** \brief Objective-C's @synchronized statement. |
| 1964 | */ |
| 1965 | CXCursor_ObjCAtSynchronizedStmt = 220, |
| 1966 | |
| 1967 | /** \brief Objective-C's autorelease pool statement. |
| 1968 | */ |
| 1969 | CXCursor_ObjCAutoreleasePoolStmt = 221, |
| 1970 | |
| 1971 | /** \brief Objective-C's collection statement. |
| 1972 | */ |
| 1973 | CXCursor_ObjCForCollectionStmt = 222, |
| 1974 | |
| 1975 | /** \brief C++'s catch statement. |
| 1976 | */ |
| 1977 | CXCursor_CXXCatchStmt = 223, |
| 1978 | |
| 1979 | /** \brief C++'s try statement. |
| 1980 | */ |
| 1981 | CXCursor_CXXTryStmt = 224, |
| 1982 | |
| 1983 | /** \brief C++'s for (* : *) statement. |
| 1984 | */ |
| 1985 | CXCursor_CXXForRangeStmt = 225, |
| 1986 | |
| 1987 | /** \brief Windows Structured Exception Handling's try statement. |
| 1988 | */ |
| 1989 | CXCursor_SEHTryStmt = 226, |
| 1990 | |
| 1991 | /** \brief Windows Structured Exception Handling's except statement. |
| 1992 | */ |
| 1993 | CXCursor_SEHExceptStmt = 227, |
| 1994 | |
| 1995 | /** \brief Windows Structured Exception Handling's finally statement. |
| 1996 | */ |
| 1997 | CXCursor_SEHFinallyStmt = 228, |
| 1998 | |
Chad Rosier | 8cd64b4 | 2012-06-11 20:47:18 +0000 | [diff] [blame^] | 1999 | /** \brief A MS inline assembly statement extension. |
| 2000 | */ |
| 2001 | CXCursor_MSAsmStmt = 229, |
| 2002 | |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 2003 | /** \brief The null satement ";": C99 6.8.3p3. |
| 2004 | * |
| 2005 | * This cursor kind is used to describe the null statement. |
| 2006 | */ |
| 2007 | CXCursor_NullStmt = 230, |
| 2008 | |
| 2009 | /** \brief Adaptor class for mixing declarations with statements and |
| 2010 | * expressions. |
| 2011 | */ |
| 2012 | CXCursor_DeclStmt = 231, |
| 2013 | |
| 2014 | CXCursor_LastStmt = CXCursor_DeclStmt, |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2015 | |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2016 | /** |
| 2017 | * \brief Cursor that represents the translation unit itself. |
| 2018 | * |
| 2019 | * The translation unit cursor exists primarily to act as the root |
| 2020 | * cursor for traversing the contents of a translation unit. |
| 2021 | */ |
Ted Kremenek | e77f443 | 2010-02-18 03:09:07 +0000 | [diff] [blame] | 2022 | CXCursor_TranslationUnit = 300, |
| 2023 | |
| 2024 | /* Attributes */ |
| 2025 | CXCursor_FirstAttr = 400, |
| 2026 | /** |
| 2027 | * \brief An attribute whose specific kind is not exposed via this |
| 2028 | * interface. |
| 2029 | */ |
| 2030 | CXCursor_UnexposedAttr = 400, |
| 2031 | |
| 2032 | CXCursor_IBActionAttr = 401, |
| 2033 | CXCursor_IBOutletAttr = 402, |
Ted Kremenek | 857e918 | 2010-05-19 17:38:06 +0000 | [diff] [blame] | 2034 | CXCursor_IBOutletCollectionAttr = 403, |
Argyrios Kyrtzidis | 6639e92 | 2011-09-13 17:39:31 +0000 | [diff] [blame] | 2035 | CXCursor_CXXFinalAttr = 404, |
| 2036 | CXCursor_CXXOverrideAttr = 405, |
Erik Verbruggen | 5f1c822 | 2011-10-13 09:41:32 +0000 | [diff] [blame] | 2037 | CXCursor_AnnotateAttr = 406, |
Argyrios Kyrtzidis | 84b7964 | 2011-12-06 22:05:01 +0000 | [diff] [blame] | 2038 | CXCursor_AsmLabelAttr = 407, |
| 2039 | CXCursor_LastAttr = CXCursor_AsmLabelAttr, |
Douglas Gregor | 9f1e3ff | 2010-03-18 00:42:48 +0000 | [diff] [blame] | 2040 | |
| 2041 | /* Preprocessing */ |
| 2042 | CXCursor_PreprocessingDirective = 500, |
Douglas Gregor | 572feb2 | 2010-03-18 18:04:21 +0000 | [diff] [blame] | 2043 | CXCursor_MacroDefinition = 501, |
Chandler Carruth | 9b2a0ac | 2011-07-14 08:41:15 +0000 | [diff] [blame] | 2044 | CXCursor_MacroExpansion = 502, |
| 2045 | CXCursor_MacroInstantiation = CXCursor_MacroExpansion, |
Douglas Gregor | ecdcb88 | 2010-10-20 22:00:55 +0000 | [diff] [blame] | 2046 | CXCursor_InclusionDirective = 503, |
Douglas Gregor | 9f1e3ff | 2010-03-18 00:42:48 +0000 | [diff] [blame] | 2047 | CXCursor_FirstPreprocessing = CXCursor_PreprocessingDirective, |
Douglas Gregor | ecdcb88 | 2010-10-20 22:00:55 +0000 | [diff] [blame] | 2048 | CXCursor_LastPreprocessing = CXCursor_InclusionDirective |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2049 | }; |
| 2050 | |
| 2051 | /** |
| 2052 | * \brief A cursor representing some element in the abstract syntax tree for |
| 2053 | * a translation unit. |
| 2054 | * |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2055 | * The cursor abstraction unifies the different kinds of entities in a |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2056 | * program--declaration, statements, expressions, references to declarations, |
| 2057 | * etc.--under a single "cursor" abstraction with a common set of operations. |
| 2058 | * Common operation for a cursor include: getting the physical location in |
| 2059 | * a source file where the cursor points, getting the name associated with a |
| 2060 | * cursor, and retrieving cursors for any child nodes of a particular cursor. |
| 2061 | * |
| 2062 | * Cursors can be produced in two specific ways. |
| 2063 | * clang_getTranslationUnitCursor() produces a cursor for a translation unit, |
| 2064 | * from which one can use clang_visitChildren() to explore the rest of the |
| 2065 | * translation unit. clang_getCursor() maps from a physical source location |
| 2066 | * to the entity that resides at that location, allowing one to map from the |
| 2067 | * source code into the AST. |
| 2068 | */ |
| 2069 | typedef struct { |
| 2070 | enum CXCursorKind kind; |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 2071 | int xdata; |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2072 | void *data[3]; |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2073 | } CXCursor; |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2074 | |
| 2075 | /** |
| 2076 | * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations |
| 2077 | * |
| 2078 | * @{ |
| 2079 | */ |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2080 | |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2081 | /** |
| 2082 | * \brief Retrieve the NULL cursor, which represents no entity. |
| 2083 | */ |
| 2084 | CINDEX_LINKAGE CXCursor clang_getNullCursor(void); |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2085 | |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2086 | /** |
| 2087 | * \brief Retrieve the cursor that represents the given translation unit. |
| 2088 | * |
| 2089 | * The translation unit cursor can be used to start traversing the |
| 2090 | * various declarations within the given translation unit. |
| 2091 | */ |
| 2092 | CINDEX_LINKAGE CXCursor clang_getTranslationUnitCursor(CXTranslationUnit); |
| 2093 | |
| 2094 | /** |
| 2095 | * \brief Determine whether two cursors are equivalent. |
| 2096 | */ |
| 2097 | CINDEX_LINKAGE unsigned clang_equalCursors(CXCursor, CXCursor); |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2098 | |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2099 | /** |
Argyrios Kyrtzidis | b0d6eaa | 2011-09-27 00:30:30 +0000 | [diff] [blame] | 2100 | * \brief Returns non-zero if \arg cursor is null. |
| 2101 | */ |
Benjamin Kramer | 5b41936 | 2012-02-01 20:37:28 +0000 | [diff] [blame] | 2102 | CINDEX_LINKAGE int clang_Cursor_isNull(CXCursor); |
Argyrios Kyrtzidis | b0d6eaa | 2011-09-27 00:30:30 +0000 | [diff] [blame] | 2103 | |
| 2104 | /** |
Douglas Gregor | 9ce5584 | 2010-11-20 00:09:34 +0000 | [diff] [blame] | 2105 | * \brief Compute a hash value for the given cursor. |
| 2106 | */ |
| 2107 | CINDEX_LINKAGE unsigned clang_hashCursor(CXCursor); |
| 2108 | |
| 2109 | /** |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2110 | * \brief Retrieve the kind of the given cursor. |
| 2111 | */ |
| 2112 | CINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor); |
| 2113 | |
| 2114 | /** |
| 2115 | * \brief Determine whether the given cursor kind represents a declaration. |
| 2116 | */ |
| 2117 | CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind); |
| 2118 | |
| 2119 | /** |
| 2120 | * \brief Determine whether the given cursor kind represents a simple |
| 2121 | * reference. |
| 2122 | * |
| 2123 | * Note that other kinds of cursors (such as expressions) can also refer to |
| 2124 | * other cursors. Use clang_getCursorReferenced() to determine whether a |
| 2125 | * particular cursor refers to another entity. |
| 2126 | */ |
| 2127 | CINDEX_LINKAGE unsigned clang_isReference(enum CXCursorKind); |
| 2128 | |
| 2129 | /** |
| 2130 | * \brief Determine whether the given cursor kind represents an expression. |
| 2131 | */ |
| 2132 | CINDEX_LINKAGE unsigned clang_isExpression(enum CXCursorKind); |
| 2133 | |
| 2134 | /** |
| 2135 | * \brief Determine whether the given cursor kind represents a statement. |
| 2136 | */ |
| 2137 | CINDEX_LINKAGE unsigned clang_isStatement(enum CXCursorKind); |
| 2138 | |
| 2139 | /** |
Douglas Gregor | 8be80e1 | 2011-07-06 03:00:34 +0000 | [diff] [blame] | 2140 | * \brief Determine whether the given cursor kind represents an attribute. |
| 2141 | */ |
| 2142 | CINDEX_LINKAGE unsigned clang_isAttribute(enum CXCursorKind); |
| 2143 | |
| 2144 | /** |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2145 | * \brief Determine whether the given cursor kind represents an invalid |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2146 | * cursor. |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2147 | */ |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2148 | CINDEX_LINKAGE unsigned clang_isInvalid(enum CXCursorKind); |
| 2149 | |
| 2150 | /** |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2151 | * \brief Determine whether the given cursor kind represents a translation |
| 2152 | * unit. |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2153 | */ |
| 2154 | CINDEX_LINKAGE unsigned clang_isTranslationUnit(enum CXCursorKind); |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2155 | |
Ted Kremenek | ad6eff6 | 2010-03-08 21:17:29 +0000 | [diff] [blame] | 2156 | /*** |
Douglas Gregor | 9f1e3ff | 2010-03-18 00:42:48 +0000 | [diff] [blame] | 2157 | * \brief Determine whether the given cursor represents a preprocessing |
| 2158 | * element, such as a preprocessor directive or macro instantiation. |
| 2159 | */ |
| 2160 | CINDEX_LINKAGE unsigned clang_isPreprocessing(enum CXCursorKind); |
| 2161 | |
| 2162 | /*** |
Ted Kremenek | ad6eff6 | 2010-03-08 21:17:29 +0000 | [diff] [blame] | 2163 | * \brief Determine whether the given cursor represents a currently |
| 2164 | * unexposed piece of the AST (e.g., CXCursor_UnexposedStmt). |
| 2165 | */ |
| 2166 | CINDEX_LINKAGE unsigned clang_isUnexposed(enum CXCursorKind); |
| 2167 | |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2168 | /** |
Ted Kremenek | 16b4259 | 2010-03-03 06:36:57 +0000 | [diff] [blame] | 2169 | * \brief Describe the linkage of the entity referred to by a cursor. |
| 2170 | */ |
| 2171 | enum CXLinkageKind { |
| 2172 | /** \brief This value indicates that no linkage information is available |
| 2173 | * for a provided CXCursor. */ |
| 2174 | CXLinkage_Invalid, |
| 2175 | /** |
| 2176 | * \brief This is the linkage for variables, parameters, and so on that |
| 2177 | * have automatic storage. This covers normal (non-extern) local variables. |
| 2178 | */ |
| 2179 | CXLinkage_NoLinkage, |
| 2180 | /** \brief This is the linkage for static variables and static functions. */ |
| 2181 | CXLinkage_Internal, |
| 2182 | /** \brief This is the linkage for entities with external linkage that live |
| 2183 | * in C++ anonymous namespaces.*/ |
| 2184 | CXLinkage_UniqueExternal, |
| 2185 | /** \brief This is the linkage for entities with true, external linkage. */ |
| 2186 | CXLinkage_External |
| 2187 | }; |
| 2188 | |
| 2189 | /** |
Ted Kremenek | 45e1dae | 2010-04-12 21:22:16 +0000 | [diff] [blame] | 2190 | * \brief Determine the linkage of the entity referred to by a given cursor. |
Ted Kremenek | 16b4259 | 2010-03-03 06:36:57 +0000 | [diff] [blame] | 2191 | */ |
| 2192 | CINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor); |
| 2193 | |
| 2194 | /** |
Douglas Gregor | cc88966 | 2012-05-08 00:14:45 +0000 | [diff] [blame] | 2195 | * \brief Determine the availability of the entity that this cursor refers to, |
| 2196 | * taking the current target platform into account. |
Douglas Gregor | 58ddb60 | 2010-08-23 23:00:57 +0000 | [diff] [blame] | 2197 | * |
| 2198 | * \param cursor The cursor to query. |
| 2199 | * |
| 2200 | * \returns The availability of the cursor. |
| 2201 | */ |
| 2202 | CINDEX_LINKAGE enum CXAvailabilityKind |
| 2203 | clang_getCursorAvailability(CXCursor cursor); |
| 2204 | |
| 2205 | /** |
Douglas Gregor | cc88966 | 2012-05-08 00:14:45 +0000 | [diff] [blame] | 2206 | * Describes the availability of a given entity on a particular platform, e.g., |
| 2207 | * a particular class might only be available on Mac OS 10.7 or newer. |
| 2208 | */ |
| 2209 | typedef struct CXPlatformAvailability { |
| 2210 | /** |
| 2211 | * \brief A string that describes the platform for which this structure |
| 2212 | * provides availability information. |
| 2213 | * |
| 2214 | * Possible values are "ios" or "macosx". |
| 2215 | */ |
| 2216 | CXString Platform; |
| 2217 | /** |
| 2218 | * \brief The version number in which this entity was introduced. |
| 2219 | */ |
| 2220 | CXVersion Introduced; |
| 2221 | /** |
| 2222 | * \brief The version number in which this entity was deprecated (but is |
| 2223 | * still available). |
| 2224 | */ |
| 2225 | CXVersion Deprecated; |
| 2226 | /** |
| 2227 | * \brief The version number in which this entity was obsoleted, and therefore |
| 2228 | * is no longer available. |
| 2229 | */ |
| 2230 | CXVersion Obsoleted; |
| 2231 | /** |
| 2232 | * \brief Whether the entity is unconditionally unavailable on this platform. |
| 2233 | */ |
| 2234 | int Unavailable; |
| 2235 | /** |
| 2236 | * \brief An optional message to provide to a user of this API, e.g., to |
| 2237 | * suggest replacement APIs. |
| 2238 | */ |
| 2239 | CXString Message; |
| 2240 | } CXPlatformAvailability; |
| 2241 | |
| 2242 | /** |
| 2243 | * \brief Determine the availability of the entity that this cursor refers to |
| 2244 | * on any platforms for which availability information is known. |
| 2245 | * |
| 2246 | * \param cursor The cursor to query. |
| 2247 | * |
| 2248 | * \param always_deprecated If non-NULL, will be set to indicate whether the |
| 2249 | * entity is deprecated on all platforms. |
| 2250 | * |
| 2251 | * \param deprecated_message If non-NULL, will be set to the message text |
| 2252 | * provided along with the unconditional deprecation of this entity. The client |
| 2253 | * is responsible for deallocating this string. |
| 2254 | * |
| 2255 | * \param always_unavailabile If non-NULL, will be set to indicate whether the |
| 2256 | * entity is unavailable on all platforms. |
| 2257 | * |
| 2258 | * \param unavailable_message If non-NULL, will be set to the message text |
| 2259 | * provided along with the unconditional unavailability of this entity. The |
| 2260 | * client is responsible for deallocating this string. |
| 2261 | * |
| 2262 | * \param availability If non-NULL, an array of CXPlatformAvailability instances |
| 2263 | * that will be populated with platform availability information, up to either |
| 2264 | * the number of platforms for which availability information is available (as |
| 2265 | * returned by this function) or \c availability_size, whichever is smaller. |
| 2266 | * |
| 2267 | * \param availability_size The number of elements available in the |
| 2268 | * \c availability array. |
| 2269 | * |
| 2270 | * \returns The number of platforms (N) for which availability information is |
| 2271 | * available (which is unrelated to \c availability_size). |
| 2272 | * |
| 2273 | * Note that the client is responsible for calling |
| 2274 | * \c clang_disposeCXPlatformAvailability to free each of the |
| 2275 | * platform-availability structures returned. There are |
| 2276 | * \c min(N, availability_size) such structures. |
| 2277 | */ |
| 2278 | CINDEX_LINKAGE int |
| 2279 | clang_getCursorPlatformAvailability(CXCursor cursor, |
| 2280 | int *always_deprecated, |
| 2281 | CXString *deprecated_message, |
| 2282 | int *always_unavailable, |
| 2283 | CXString *unavailable_message, |
| 2284 | CXPlatformAvailability *availability, |
| 2285 | int availability_size); |
| 2286 | |
| 2287 | /** |
| 2288 | * \brief Free the memory associated with a \c CXPlatformAvailability structure. |
| 2289 | */ |
| 2290 | CINDEX_LINKAGE void |
| 2291 | clang_disposeCXPlatformAvailability(CXPlatformAvailability *availability); |
| 2292 | |
| 2293 | /** |
Ted Kremenek | 45e1dae | 2010-04-12 21:22:16 +0000 | [diff] [blame] | 2294 | * \brief Describe the "language" of the entity referred to by a cursor. |
| 2295 | */ |
| 2296 | CINDEX_LINKAGE enum CXLanguageKind { |
Ted Kremenek | 6cd1e7c | 2010-04-14 20:58:32 +0000 | [diff] [blame] | 2297 | CXLanguage_Invalid = 0, |
Ted Kremenek | 45e1dae | 2010-04-12 21:22:16 +0000 | [diff] [blame] | 2298 | CXLanguage_C, |
| 2299 | CXLanguage_ObjC, |
Ted Kremenek | 6cd1e7c | 2010-04-14 20:58:32 +0000 | [diff] [blame] | 2300 | CXLanguage_CPlusPlus |
Ted Kremenek | 45e1dae | 2010-04-12 21:22:16 +0000 | [diff] [blame] | 2301 | }; |
| 2302 | |
| 2303 | /** |
| 2304 | * \brief Determine the "language" of the entity referred to by a given cursor. |
| 2305 | */ |
| 2306 | CINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor); |
| 2307 | |
Argyrios Kyrtzidis | b0d6eaa | 2011-09-27 00:30:30 +0000 | [diff] [blame] | 2308 | /** |
| 2309 | * \brief Returns the translation unit that a cursor originated from. |
| 2310 | */ |
| 2311 | CINDEX_LINKAGE CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor); |
| 2312 | |
Ted Kremenek | eca099b | 2010-12-08 23:43:14 +0000 | [diff] [blame] | 2313 | |
| 2314 | /** |
| 2315 | * \brief A fast container representing a set of CXCursors. |
| 2316 | */ |
| 2317 | typedef struct CXCursorSetImpl *CXCursorSet; |
| 2318 | |
| 2319 | /** |
| 2320 | * \brief Creates an empty CXCursorSet. |
| 2321 | */ |
| 2322 | CINDEX_LINKAGE CXCursorSet clang_createCXCursorSet(); |
| 2323 | |
| 2324 | /** |
| 2325 | * \brief Disposes a CXCursorSet and releases its associated memory. |
| 2326 | */ |
| 2327 | CINDEX_LINKAGE void clang_disposeCXCursorSet(CXCursorSet cset); |
| 2328 | |
| 2329 | /** |
| 2330 | * \brief Queries a CXCursorSet to see if it contains a specific CXCursor. |
| 2331 | * |
| 2332 | * \returns non-zero if the set contains the specified cursor. |
| 2333 | */ |
| 2334 | CINDEX_LINKAGE unsigned clang_CXCursorSet_contains(CXCursorSet cset, |
| 2335 | CXCursor cursor); |
| 2336 | |
| 2337 | /** |
| 2338 | * \brief Inserts a CXCursor into a CXCursorSet. |
| 2339 | * |
| 2340 | * \returns zero if the CXCursor was already in the set, and non-zero otherwise. |
| 2341 | */ |
| 2342 | CINDEX_LINKAGE unsigned clang_CXCursorSet_insert(CXCursorSet cset, |
| 2343 | CXCursor cursor); |
| 2344 | |
Douglas Gregor | 2be5bc9 | 2010-09-22 21:22:29 +0000 | [diff] [blame] | 2345 | /** |
| 2346 | * \brief Determine the semantic parent of the given cursor. |
| 2347 | * |
| 2348 | * The semantic parent of a cursor is the cursor that semantically contains |
| 2349 | * the given \p cursor. For many declarations, the lexical and semantic parents |
| 2350 | * are equivalent (the lexical parent is returned by |
| 2351 | * \c clang_getCursorLexicalParent()). They diverge when declarations or |
| 2352 | * definitions are provided out-of-line. For example: |
| 2353 | * |
| 2354 | * \code |
| 2355 | * class C { |
| 2356 | * void f(); |
| 2357 | * }; |
| 2358 | * |
| 2359 | * void C::f() { } |
| 2360 | * \endcode |
| 2361 | * |
| 2362 | * In the out-of-line definition of \c C::f, the semantic parent is the |
| 2363 | * the class \c C, of which this function is a member. The lexical parent is |
| 2364 | * the place where the declaration actually occurs in the source code; in this |
| 2365 | * case, the definition occurs in the translation unit. In general, the |
| 2366 | * lexical parent for a given entity can change without affecting the semantics |
| 2367 | * of the program, and the lexical parent of different declarations of the |
| 2368 | * same entity may be different. Changing the semantic parent of a declaration, |
| 2369 | * on the other hand, can have a major impact on semantics, and redeclarations |
| 2370 | * of a particular entity should all have the same semantic context. |
| 2371 | * |
| 2372 | * In the example above, both declarations of \c C::f have \c C as their |
| 2373 | * semantic context, while the lexical context of the first \c C::f is \c C |
| 2374 | * and the lexical context of the second \c C::f is the translation unit. |
Douglas Gregor | 3910cfd | 2010-12-21 07:55:45 +0000 | [diff] [blame] | 2375 | * |
| 2376 | * For global declarations, the semantic parent is the translation unit. |
Douglas Gregor | 2be5bc9 | 2010-09-22 21:22:29 +0000 | [diff] [blame] | 2377 | */ |
| 2378 | CINDEX_LINKAGE CXCursor clang_getCursorSemanticParent(CXCursor cursor); |
| 2379 | |
| 2380 | /** |
| 2381 | * \brief Determine the lexical parent of the given cursor. |
| 2382 | * |
| 2383 | * The lexical parent of a cursor is the cursor in which the given \p cursor |
| 2384 | * was actually written. For many declarations, the lexical and semantic parents |
| 2385 | * are equivalent (the semantic parent is returned by |
| 2386 | * \c clang_getCursorSemanticParent()). They diverge when declarations or |
| 2387 | * definitions are provided out-of-line. For example: |
| 2388 | * |
| 2389 | * \code |
| 2390 | * class C { |
| 2391 | * void f(); |
| 2392 | * }; |
| 2393 | * |
| 2394 | * void C::f() { } |
| 2395 | * \endcode |
| 2396 | * |
| 2397 | * In the out-of-line definition of \c C::f, the semantic parent is the |
| 2398 | * the class \c C, of which this function is a member. The lexical parent is |
| 2399 | * the place where the declaration actually occurs in the source code; in this |
| 2400 | * case, the definition occurs in the translation unit. In general, the |
| 2401 | * lexical parent for a given entity can change without affecting the semantics |
| 2402 | * of the program, and the lexical parent of different declarations of the |
| 2403 | * same entity may be different. Changing the semantic parent of a declaration, |
| 2404 | * on the other hand, can have a major impact on semantics, and redeclarations |
| 2405 | * of a particular entity should all have the same semantic context. |
| 2406 | * |
| 2407 | * In the example above, both declarations of \c C::f have \c C as their |
| 2408 | * semantic context, while the lexical context of the first \c C::f is \c C |
| 2409 | * and the lexical context of the second \c C::f is the translation unit. |
Douglas Gregor | 3910cfd | 2010-12-21 07:55:45 +0000 | [diff] [blame] | 2410 | * |
| 2411 | * For declarations written in the global scope, the lexical parent is |
| 2412 | * the translation unit. |
Douglas Gregor | 2be5bc9 | 2010-09-22 21:22:29 +0000 | [diff] [blame] | 2413 | */ |
| 2414 | CINDEX_LINKAGE CXCursor clang_getCursorLexicalParent(CXCursor cursor); |
Douglas Gregor | 9f59234 | 2010-10-01 20:25:15 +0000 | [diff] [blame] | 2415 | |
| 2416 | /** |
| 2417 | * \brief Determine the set of methods that are overridden by the given |
| 2418 | * method. |
| 2419 | * |
| 2420 | * In both Objective-C and C++, a method (aka virtual member function, |
| 2421 | * in C++) can override a virtual method in a base class. For |
| 2422 | * Objective-C, a method is said to override any method in the class's |
Argyrios Kyrtzidis | 044e645 | 2012-03-08 00:20:03 +0000 | [diff] [blame] | 2423 | * base class, its protocols, or its categories' protocols, that has the same |
| 2424 | * selector and is of the same kind (class or instance). |
| 2425 | * If no such method exists, the search continues to the class's superclass, |
| 2426 | * its protocols, and its categories, and so on. A method from an Objective-C |
| 2427 | * implementation is considered to override the same methods as its |
| 2428 | * corresponding method in the interface. |
Douglas Gregor | 9f59234 | 2010-10-01 20:25:15 +0000 | [diff] [blame] | 2429 | * |
| 2430 | * For C++, a virtual member function overrides any virtual member |
| 2431 | * function with the same signature that occurs in its base |
| 2432 | * classes. With multiple inheritance, a virtual member function can |
| 2433 | * override several virtual member functions coming from different |
| 2434 | * base classes. |
| 2435 | * |
| 2436 | * In all cases, this function determines the immediate overridden |
| 2437 | * method, rather than all of the overridden methods. For example, if |
| 2438 | * a method is originally declared in a class A, then overridden in B |
| 2439 | * (which in inherits from A) and also in C (which inherited from B), |
| 2440 | * then the only overridden method returned from this function when |
| 2441 | * invoked on C's method will be B's method. The client may then |
| 2442 | * invoke this function again, given the previously-found overridden |
| 2443 | * methods, to map out the complete method-override set. |
| 2444 | * |
| 2445 | * \param cursor A cursor representing an Objective-C or C++ |
| 2446 | * method. This routine will compute the set of methods that this |
| 2447 | * method overrides. |
| 2448 | * |
| 2449 | * \param overridden A pointer whose pointee will be replaced with a |
| 2450 | * pointer to an array of cursors, representing the set of overridden |
| 2451 | * methods. If there are no overridden methods, the pointee will be |
| 2452 | * set to NULL. The pointee must be freed via a call to |
| 2453 | * \c clang_disposeOverriddenCursors(). |
| 2454 | * |
| 2455 | * \param num_overridden A pointer to the number of overridden |
| 2456 | * functions, will be set to the number of overridden functions in the |
| 2457 | * array pointed to by \p overridden. |
| 2458 | */ |
| 2459 | CINDEX_LINKAGE void clang_getOverriddenCursors(CXCursor cursor, |
| 2460 | CXCursor **overridden, |
| 2461 | unsigned *num_overridden); |
| 2462 | |
| 2463 | /** |
| 2464 | * \brief Free the set of overridden cursors returned by \c |
| 2465 | * clang_getOverriddenCursors(). |
| 2466 | */ |
| 2467 | CINDEX_LINKAGE void clang_disposeOverriddenCursors(CXCursor *overridden); |
| 2468 | |
Ted Kremenek | 45e1dae | 2010-04-12 21:22:16 +0000 | [diff] [blame] | 2469 | /** |
Douglas Gregor | ecdcb88 | 2010-10-20 22:00:55 +0000 | [diff] [blame] | 2470 | * \brief Retrieve the file that is included by the given inclusion directive |
| 2471 | * cursor. |
| 2472 | */ |
| 2473 | CINDEX_LINKAGE CXFile clang_getIncludedFile(CXCursor cursor); |
| 2474 | |
| 2475 | /** |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2476 | * @} |
| 2477 | */ |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2478 | |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2479 | /** |
| 2480 | * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code |
| 2481 | * |
| 2482 | * Cursors represent a location within the Abstract Syntax Tree (AST). These |
| 2483 | * routines help map between cursors and the physical locations where the |
| 2484 | * described entities occur in the source code. The mapping is provided in |
| 2485 | * both directions, so one can map from source code to the AST and back. |
| 2486 | * |
| 2487 | * @{ |
Steve Naroff | 5039819 | 2009-08-28 15:28:48 +0000 | [diff] [blame] | 2488 | */ |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2489 | |
Steve Naroff | 6a6de8b | 2009-10-21 13:56:23 +0000 | [diff] [blame] | 2490 | /** |
Douglas Gregor | b979034 | 2010-01-22 21:44:22 +0000 | [diff] [blame] | 2491 | * \brief Map a source location to the cursor that describes the entity at that |
| 2492 | * location in the source code. |
| 2493 | * |
| 2494 | * clang_getCursor() maps an arbitrary source location within a translation |
| 2495 | * unit down to the most specific cursor that describes the entity at that |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2496 | * location. For example, given an expression \c x + y, invoking |
Douglas Gregor | b979034 | 2010-01-22 21:44:22 +0000 | [diff] [blame] | 2497 | * clang_getCursor() with a source location pointing to "x" will return the |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2498 | * cursor for "x"; similarly for "y". If the cursor points anywhere between |
Douglas Gregor | b979034 | 2010-01-22 21:44:22 +0000 | [diff] [blame] | 2499 | * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor() |
| 2500 | * will return a cursor referring to the "+" expression. |
| 2501 | * |
| 2502 | * \returns a cursor representing the entity at the given source location, or |
| 2503 | * a NULL cursor if no such entity can be found. |
Steve Naroff | 6a6de8b | 2009-10-21 13:56:23 +0000 | [diff] [blame] | 2504 | */ |
Douglas Gregor | b979034 | 2010-01-22 21:44:22 +0000 | [diff] [blame] | 2505 | CINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, CXSourceLocation); |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2506 | |
Douglas Gregor | 98258af | 2010-01-18 22:46:11 +0000 | [diff] [blame] | 2507 | /** |
| 2508 | * \brief Retrieve the physical location of the source constructor referenced |
| 2509 | * by the given cursor. |
| 2510 | * |
| 2511 | * The location of a declaration is typically the location of the name of that |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2512 | * declaration, where the name of that declaration would occur if it is |
| 2513 | * unnamed, or some keyword that introduces that particular declaration. |
| 2514 | * The location of a reference is where that reference occurs within the |
Douglas Gregor | 98258af | 2010-01-18 22:46:11 +0000 | [diff] [blame] | 2515 | * source code. |
| 2516 | */ |
| 2517 | CINDEX_LINKAGE CXSourceLocation clang_getCursorLocation(CXCursor); |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2518 | |
Douglas Gregor | b699866 | 2010-01-19 19:34:47 +0000 | [diff] [blame] | 2519 | /** |
| 2520 | * \brief Retrieve the physical extent of the source construct referenced by |
Douglas Gregor | a7bde20 | 2010-01-19 00:34:46 +0000 | [diff] [blame] | 2521 | * the given cursor. |
| 2522 | * |
| 2523 | * The extent of a cursor starts with the file/line/column pointing at the |
| 2524 | * first character within the source construct that the cursor refers to and |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2525 | * ends with the last character withinin that source construct. For a |
Douglas Gregor | a7bde20 | 2010-01-19 00:34:46 +0000 | [diff] [blame] | 2526 | * declaration, the extent covers the declaration itself. For a reference, |
| 2527 | * the extent covers the location of the reference (e.g., where the referenced |
| 2528 | * entity was actually used). |
| 2529 | */ |
| 2530 | CINDEX_LINKAGE CXSourceRange clang_getCursorExtent(CXCursor); |
Douglas Gregor | c5d1e93 | 2010-01-19 01:20:04 +0000 | [diff] [blame] | 2531 | |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2532 | /** |
| 2533 | * @} |
| 2534 | */ |
Ted Kremenek | 95f3355 | 2010-08-26 01:42:22 +0000 | [diff] [blame] | 2535 | |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2536 | /** |
Ted Kremenek | 8e0ac17 | 2010-05-14 21:29:26 +0000 | [diff] [blame] | 2537 | * \defgroup CINDEX_TYPES Type information for CXCursors |
| 2538 | * |
| 2539 | * @{ |
| 2540 | */ |
| 2541 | |
| 2542 | /** |
| 2543 | * \brief Describes the kind of type |
| 2544 | */ |
| 2545 | enum CXTypeKind { |
| 2546 | /** |
| 2547 | * \brief Reprents an invalid type (e.g., where no type is available). |
| 2548 | */ |
| 2549 | CXType_Invalid = 0, |
| 2550 | |
| 2551 | /** |
| 2552 | * \brief A type whose specific kind is not exposed via this |
| 2553 | * interface. |
| 2554 | */ |
| 2555 | CXType_Unexposed = 1, |
| 2556 | |
| 2557 | /* Builtin types */ |
| 2558 | CXType_Void = 2, |
| 2559 | CXType_Bool = 3, |
| 2560 | CXType_Char_U = 4, |
| 2561 | CXType_UChar = 5, |
| 2562 | CXType_Char16 = 6, |
| 2563 | CXType_Char32 = 7, |
| 2564 | CXType_UShort = 8, |
| 2565 | CXType_UInt = 9, |
| 2566 | CXType_ULong = 10, |
| 2567 | CXType_ULongLong = 11, |
| 2568 | CXType_UInt128 = 12, |
| 2569 | CXType_Char_S = 13, |
| 2570 | CXType_SChar = 14, |
| 2571 | CXType_WChar = 15, |
| 2572 | CXType_Short = 16, |
| 2573 | CXType_Int = 17, |
| 2574 | CXType_Long = 18, |
| 2575 | CXType_LongLong = 19, |
| 2576 | CXType_Int128 = 20, |
| 2577 | CXType_Float = 21, |
| 2578 | CXType_Double = 22, |
| 2579 | CXType_LongDouble = 23, |
| 2580 | CXType_NullPtr = 24, |
| 2581 | CXType_Overload = 25, |
| 2582 | CXType_Dependent = 26, |
| 2583 | CXType_ObjCId = 27, |
| 2584 | CXType_ObjCClass = 28, |
| 2585 | CXType_ObjCSel = 29, |
| 2586 | CXType_FirstBuiltin = CXType_Void, |
| 2587 | CXType_LastBuiltin = CXType_ObjCSel, |
| 2588 | |
| 2589 | CXType_Complex = 100, |
| 2590 | CXType_Pointer = 101, |
| 2591 | CXType_BlockPointer = 102, |
| 2592 | CXType_LValueReference = 103, |
| 2593 | CXType_RValueReference = 104, |
| 2594 | CXType_Record = 105, |
| 2595 | CXType_Enum = 106, |
| 2596 | CXType_Typedef = 107, |
| 2597 | CXType_ObjCInterface = 108, |
Ted Kremenek | 04c3cf3 | 2010-06-21 20:15:39 +0000 | [diff] [blame] | 2598 | CXType_ObjCObjectPointer = 109, |
| 2599 | CXType_FunctionNoProto = 110, |
Argyrios Kyrtzidis | 5f0bfc5 | 2011-09-27 17:44:34 +0000 | [diff] [blame] | 2600 | CXType_FunctionProto = 111, |
Argyrios Kyrtzidis | 84b7964 | 2011-12-06 22:05:01 +0000 | [diff] [blame] | 2601 | CXType_ConstantArray = 112, |
| 2602 | CXType_Vector = 113 |
Ted Kremenek | 8e0ac17 | 2010-05-14 21:29:26 +0000 | [diff] [blame] | 2603 | }; |
| 2604 | |
| 2605 | /** |
Argyrios Kyrtzidis | 84b7964 | 2011-12-06 22:05:01 +0000 | [diff] [blame] | 2606 | * \brief Describes the calling convention of a function type |
| 2607 | */ |
| 2608 | enum CXCallingConv { |
| 2609 | CXCallingConv_Default = 0, |
| 2610 | CXCallingConv_C = 1, |
| 2611 | CXCallingConv_X86StdCall = 2, |
| 2612 | CXCallingConv_X86FastCall = 3, |
| 2613 | CXCallingConv_X86ThisCall = 4, |
| 2614 | CXCallingConv_X86Pascal = 5, |
| 2615 | CXCallingConv_AAPCS = 6, |
| 2616 | CXCallingConv_AAPCS_VFP = 7, |
| 2617 | |
| 2618 | CXCallingConv_Invalid = 100, |
| 2619 | CXCallingConv_Unexposed = 200 |
| 2620 | }; |
| 2621 | |
| 2622 | |
| 2623 | /** |
Ted Kremenek | 8e0ac17 | 2010-05-14 21:29:26 +0000 | [diff] [blame] | 2624 | * \brief The type of an element in the abstract syntax tree. |
| 2625 | * |
| 2626 | */ |
| 2627 | typedef struct { |
| 2628 | enum CXTypeKind kind; |
| 2629 | void *data[2]; |
| 2630 | } CXType; |
| 2631 | |
| 2632 | /** |
| 2633 | * \brief Retrieve the type of a CXCursor (if any). |
| 2634 | */ |
| 2635 | CINDEX_LINKAGE CXType clang_getCursorType(CXCursor C); |
| 2636 | |
| 2637 | /** |
Argyrios Kyrtzidis | 84b7964 | 2011-12-06 22:05:01 +0000 | [diff] [blame] | 2638 | * \brief Retrieve the underlying type of a typedef declaration. |
| 2639 | * |
| 2640 | * If the cursor does not reference a typedef declaration, an invalid type is |
| 2641 | * returned. |
| 2642 | */ |
| 2643 | CINDEX_LINKAGE CXType clang_getTypedefDeclUnderlyingType(CXCursor C); |
| 2644 | |
| 2645 | /** |
| 2646 | * \brief Retrieve the integer type of an enum declaration. |
| 2647 | * |
| 2648 | * If the cursor does not reference an enum declaration, an invalid type is |
| 2649 | * returned. |
| 2650 | */ |
| 2651 | CINDEX_LINKAGE CXType clang_getEnumDeclIntegerType(CXCursor C); |
| 2652 | |
| 2653 | /** |
| 2654 | * \brief Retrieve the integer value of an enum constant declaration as a signed |
| 2655 | * long long. |
| 2656 | * |
| 2657 | * If the cursor does not reference an enum constant declaration, LLONG_MIN is returned. |
| 2658 | * Since this is also potentially a valid constant value, the kind of the cursor |
| 2659 | * must be verified before calling this function. |
| 2660 | */ |
| 2661 | CINDEX_LINKAGE long long clang_getEnumConstantDeclValue(CXCursor C); |
| 2662 | |
| 2663 | /** |
| 2664 | * \brief Retrieve the integer value of an enum constant declaration as an unsigned |
| 2665 | * long long. |
| 2666 | * |
| 2667 | * If the cursor does not reference an enum constant declaration, ULLONG_MAX is returned. |
| 2668 | * Since this is also potentially a valid constant value, the kind of the cursor |
| 2669 | * must be verified before calling this function. |
| 2670 | */ |
| 2671 | CINDEX_LINKAGE unsigned long long clang_getEnumConstantDeclUnsignedValue(CXCursor C); |
| 2672 | |
| 2673 | /** |
Argyrios Kyrtzidis | d98ef9a | 2012-04-11 19:32:19 +0000 | [diff] [blame] | 2674 | * \brief Retrieve the number of non-variadic arguments associated with a given |
| 2675 | * cursor. |
| 2676 | * |
| 2677 | * If a cursor that is not a function or method is passed in, -1 is returned. |
| 2678 | */ |
| 2679 | CINDEX_LINKAGE int clang_Cursor_getNumArguments(CXCursor C); |
| 2680 | |
| 2681 | /** |
| 2682 | * \brief Retrieve the argument cursor of a function or method. |
| 2683 | * |
| 2684 | * If a cursor that is not a function or method is passed in or the index |
| 2685 | * exceeds the number of arguments, an invalid cursor is returned. |
| 2686 | */ |
| 2687 | CINDEX_LINKAGE CXCursor clang_Cursor_getArgument(CXCursor C, unsigned i); |
| 2688 | |
| 2689 | /** |
Ted Kremenek | 8e0ac17 | 2010-05-14 21:29:26 +0000 | [diff] [blame] | 2690 | * \determine Determine whether two CXTypes represent the same type. |
| 2691 | * |
| 2692 | * \returns non-zero if the CXTypes represent the same type and |
| 2693 | zero otherwise. |
| 2694 | */ |
| 2695 | CINDEX_LINKAGE unsigned clang_equalTypes(CXType A, CXType B); |
| 2696 | |
| 2697 | /** |
| 2698 | * \brief Return the canonical type for a CXType. |
| 2699 | * |
| 2700 | * Clang's type system explicitly models typedefs and all the ways |
| 2701 | * a specific type can be represented. The canonical type is the underlying |
| 2702 | * type with all the "sugar" removed. For example, if 'T' is a typedef |
| 2703 | * for 'int', the canonical type for 'T' would be 'int'. |
| 2704 | */ |
| 2705 | CINDEX_LINKAGE CXType clang_getCanonicalType(CXType T); |
| 2706 | |
| 2707 | /** |
Douglas Gregor | e72fb6f | 2011-01-27 16:27:11 +0000 | [diff] [blame] | 2708 | * \determine Determine whether a CXType has the "const" qualifier set, |
| 2709 | * without looking through typedefs that may have added "const" at a different level. |
| 2710 | */ |
| 2711 | CINDEX_LINKAGE unsigned clang_isConstQualifiedType(CXType T); |
| 2712 | |
| 2713 | /** |
| 2714 | * \determine Determine whether a CXType has the "volatile" qualifier set, |
| 2715 | * without looking through typedefs that may have added "volatile" at a different level. |
| 2716 | */ |
| 2717 | CINDEX_LINKAGE unsigned clang_isVolatileQualifiedType(CXType T); |
| 2718 | |
| 2719 | /** |
| 2720 | * \determine Determine whether a CXType has the "restrict" qualifier set, |
| 2721 | * without looking through typedefs that may have added "restrict" at a different level. |
| 2722 | */ |
| 2723 | CINDEX_LINKAGE unsigned clang_isRestrictQualifiedType(CXType T); |
| 2724 | |
| 2725 | /** |
Ted Kremenek | 8e0ac17 | 2010-05-14 21:29:26 +0000 | [diff] [blame] | 2726 | * \brief For pointer types, returns the type of the pointee. |
| 2727 | * |
| 2728 | */ |
| 2729 | CINDEX_LINKAGE CXType clang_getPointeeType(CXType T); |
| 2730 | |
| 2731 | /** |
| 2732 | * \brief Return the cursor for the declaration of the given type. |
| 2733 | */ |
| 2734 | CINDEX_LINKAGE CXCursor clang_getTypeDeclaration(CXType T); |
| 2735 | |
David Chisnall | 5389f48 | 2010-12-30 14:05:53 +0000 | [diff] [blame] | 2736 | /** |
| 2737 | * Returns the Objective-C type encoding for the specified declaration. |
| 2738 | */ |
| 2739 | CINDEX_LINKAGE CXString clang_getDeclObjCTypeEncoding(CXCursor C); |
Ted Kremenek | 8e0ac17 | 2010-05-14 21:29:26 +0000 | [diff] [blame] | 2740 | |
| 2741 | /** |
| 2742 | * \brief Retrieve the spelling of a given CXTypeKind. |
| 2743 | */ |
| 2744 | CINDEX_LINKAGE CXString clang_getTypeKindSpelling(enum CXTypeKind K); |
| 2745 | |
| 2746 | /** |
Argyrios Kyrtzidis | 84b7964 | 2011-12-06 22:05:01 +0000 | [diff] [blame] | 2747 | * \brief Retrieve the calling convention associated with a function type. |
| 2748 | * |
| 2749 | * If a non-function type is passed in, CXCallingConv_Invalid is returned. |
| 2750 | */ |
| 2751 | CINDEX_LINKAGE enum CXCallingConv clang_getFunctionTypeCallingConv(CXType T); |
| 2752 | |
| 2753 | /** |
Ted Kremenek | 9a14084 | 2010-06-21 20:48:56 +0000 | [diff] [blame] | 2754 | * \brief Retrieve the result type associated with a function type. |
Argyrios Kyrtzidis | 84b7964 | 2011-12-06 22:05:01 +0000 | [diff] [blame] | 2755 | * |
| 2756 | * If a non-function type is passed in, an invalid type is returned. |
Ted Kremenek | 04c3cf3 | 2010-06-21 20:15:39 +0000 | [diff] [blame] | 2757 | */ |
| 2758 | CINDEX_LINKAGE CXType clang_getResultType(CXType T); |
| 2759 | |
| 2760 | /** |
Argyrios Kyrtzidis | 84b7964 | 2011-12-06 22:05:01 +0000 | [diff] [blame] | 2761 | * \brief Retrieve the number of non-variadic arguments associated with a function type. |
| 2762 | * |
Argyrios Kyrtzidis | d98ef9a | 2012-04-11 19:32:19 +0000 | [diff] [blame] | 2763 | * If a non-function type is passed in, -1 is returned. |
Argyrios Kyrtzidis | 84b7964 | 2011-12-06 22:05:01 +0000 | [diff] [blame] | 2764 | */ |
Argyrios Kyrtzidis | d98ef9a | 2012-04-11 19:32:19 +0000 | [diff] [blame] | 2765 | CINDEX_LINKAGE int clang_getNumArgTypes(CXType T); |
Argyrios Kyrtzidis | 84b7964 | 2011-12-06 22:05:01 +0000 | [diff] [blame] | 2766 | |
| 2767 | /** |
| 2768 | * \brief Retrieve the type of an argument of a function type. |
| 2769 | * |
| 2770 | * If a non-function type is passed in or the function does not have enough parameters, |
| 2771 | * an invalid type is returned. |
| 2772 | */ |
| 2773 | CINDEX_LINKAGE CXType clang_getArgType(CXType T, unsigned i); |
| 2774 | |
| 2775 | /** |
| 2776 | * \brief Return 1 if the CXType is a variadic function type, and 0 otherwise. |
| 2777 | * |
| 2778 | */ |
| 2779 | CINDEX_LINKAGE unsigned clang_isFunctionTypeVariadic(CXType T); |
| 2780 | |
| 2781 | /** |
| 2782 | * \brief Retrieve the result type associated with a given cursor. |
| 2783 | * |
| 2784 | * This only returns a valid type if the cursor refers to a function or method. |
Ted Kremenek | 9a14084 | 2010-06-21 20:48:56 +0000 | [diff] [blame] | 2785 | */ |
| 2786 | CINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C); |
| 2787 | |
| 2788 | /** |
Ted Kremenek | 3ce9e7d | 2010-07-30 00:14:11 +0000 | [diff] [blame] | 2789 | * \brief Return 1 if the CXType is a POD (plain old data) type, and 0 |
| 2790 | * otherwise. |
| 2791 | */ |
| 2792 | CINDEX_LINKAGE unsigned clang_isPODType(CXType T); |
| 2793 | |
| 2794 | /** |
Argyrios Kyrtzidis | 84b7964 | 2011-12-06 22:05:01 +0000 | [diff] [blame] | 2795 | * \brief Return the element type of an array, complex, or vector type. |
| 2796 | * |
| 2797 | * If a type is passed in that is not an array, complex, or vector type, |
| 2798 | * an invalid type is returned. |
| 2799 | */ |
| 2800 | CINDEX_LINKAGE CXType clang_getElementType(CXType T); |
| 2801 | |
| 2802 | /** |
| 2803 | * \brief Return the number of elements of an array or vector type. |
| 2804 | * |
| 2805 | * If a type is passed in that is not an array or vector type, |
| 2806 | * -1 is returned. |
| 2807 | */ |
| 2808 | CINDEX_LINKAGE long long clang_getNumElements(CXType T); |
| 2809 | |
| 2810 | /** |
Argyrios Kyrtzidis | 5f0bfc5 | 2011-09-27 17:44:34 +0000 | [diff] [blame] | 2811 | * \brief Return the element type of an array type. |
| 2812 | * |
| 2813 | * If a non-array type is passed in, an invalid type is returned. |
| 2814 | */ |
| 2815 | CINDEX_LINKAGE CXType clang_getArrayElementType(CXType T); |
| 2816 | |
| 2817 | /** |
| 2818 | * \brief Return the the array size of a constant array. |
| 2819 | * |
| 2820 | * If a non-array type is passed in, -1 is returned. |
| 2821 | */ |
| 2822 | CINDEX_LINKAGE long long clang_getArraySize(CXType T); |
| 2823 | |
| 2824 | /** |
Ted Kremenek | 3064ef9 | 2010-08-27 21:34:58 +0000 | [diff] [blame] | 2825 | * \brief Returns 1 if the base class specified by the cursor with kind |
| 2826 | * CX_CXXBaseSpecifier is virtual. |
| 2827 | */ |
| 2828 | CINDEX_LINKAGE unsigned clang_isVirtualBase(CXCursor); |
| 2829 | |
| 2830 | /** |
| 2831 | * \brief Represents the C++ access control level to a base class for a |
| 2832 | * cursor with kind CX_CXXBaseSpecifier. |
| 2833 | */ |
| 2834 | enum CX_CXXAccessSpecifier { |
| 2835 | CX_CXXInvalidAccessSpecifier, |
| 2836 | CX_CXXPublic, |
| 2837 | CX_CXXProtected, |
| 2838 | CX_CXXPrivate |
| 2839 | }; |
| 2840 | |
| 2841 | /** |
| 2842 | * \brief Returns the access control level for the C++ base specifier |
Argyrios Kyrtzidis | 2dfdb94 | 2011-09-30 17:58:23 +0000 | [diff] [blame] | 2843 | * represented by a cursor with kind CXCursor_CXXBaseSpecifier or |
| 2844 | * CXCursor_AccessSpecifier. |
Ted Kremenek | 3064ef9 | 2010-08-27 21:34:58 +0000 | [diff] [blame] | 2845 | */ |
| 2846 | CINDEX_LINKAGE enum CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor); |
| 2847 | |
| 2848 | /** |
Douglas Gregor | 1f60d9e | 2010-09-13 22:52:57 +0000 | [diff] [blame] | 2849 | * \brief Determine the number of overloaded declarations referenced by a |
| 2850 | * \c CXCursor_OverloadedDeclRef cursor. |
| 2851 | * |
| 2852 | * \param cursor The cursor whose overloaded declarations are being queried. |
| 2853 | * |
| 2854 | * \returns The number of overloaded declarations referenced by \c cursor. If it |
| 2855 | * is not a \c CXCursor_OverloadedDeclRef cursor, returns 0. |
| 2856 | */ |
| 2857 | CINDEX_LINKAGE unsigned clang_getNumOverloadedDecls(CXCursor cursor); |
| 2858 | |
| 2859 | /** |
| 2860 | * \brief Retrieve a cursor for one of the overloaded declarations referenced |
| 2861 | * by a \c CXCursor_OverloadedDeclRef cursor. |
| 2862 | * |
| 2863 | * \param cursor The cursor whose overloaded declarations are being queried. |
| 2864 | * |
| 2865 | * \param index The zero-based index into the set of overloaded declarations in |
| 2866 | * the cursor. |
| 2867 | * |
| 2868 | * \returns A cursor representing the declaration referenced by the given |
| 2869 | * \c cursor at the specified \c index. If the cursor does not have an |
| 2870 | * associated set of overloaded declarations, or if the index is out of bounds, |
| 2871 | * returns \c clang_getNullCursor(); |
| 2872 | */ |
| 2873 | CINDEX_LINKAGE CXCursor clang_getOverloadedDecl(CXCursor cursor, |
| 2874 | unsigned index); |
| 2875 | |
| 2876 | /** |
Ted Kremenek | 8e0ac17 | 2010-05-14 21:29:26 +0000 | [diff] [blame] | 2877 | * @} |
| 2878 | */ |
Ted Kremenek | 95f3355 | 2010-08-26 01:42:22 +0000 | [diff] [blame] | 2879 | |
| 2880 | /** |
Ted Kremenek | ad72f4d | 2010-08-27 21:34:51 +0000 | [diff] [blame] | 2881 | * \defgroup CINDEX_ATTRIBUTES Information for attributes |
Ted Kremenek | 95f3355 | 2010-08-26 01:42:22 +0000 | [diff] [blame] | 2882 | * |
| 2883 | * @{ |
| 2884 | */ |
| 2885 | |
| 2886 | |
| 2887 | /** |
| 2888 | * \brief For cursors representing an iboutletcollection attribute, |
| 2889 | * this function returns the collection element type. |
| 2890 | * |
| 2891 | */ |
| 2892 | CINDEX_LINKAGE CXType clang_getIBOutletCollectionType(CXCursor); |
| 2893 | |
| 2894 | /** |
| 2895 | * @} |
| 2896 | */ |
Ted Kremenek | 8e0ac17 | 2010-05-14 21:29:26 +0000 | [diff] [blame] | 2897 | |
| 2898 | /** |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2899 | * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors |
| 2900 | * |
| 2901 | * These routines provide the ability to traverse the abstract syntax tree |
| 2902 | * using cursors. |
| 2903 | * |
| 2904 | * @{ |
| 2905 | */ |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2906 | |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2907 | /** |
| 2908 | * \brief Describes how the traversal of the children of a particular |
| 2909 | * cursor should proceed after visiting a particular child cursor. |
| 2910 | * |
| 2911 | * A value of this enumeration type should be returned by each |
| 2912 | * \c CXCursorVisitor to indicate how clang_visitChildren() proceed. |
| 2913 | */ |
| 2914 | enum CXChildVisitResult { |
| 2915 | /** |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2916 | * \brief Terminates the cursor traversal. |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2917 | */ |
| 2918 | CXChildVisit_Break, |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2919 | /** |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2920 | * \brief Continues the cursor traversal with the next sibling of |
| 2921 | * the cursor just visited, without visiting its children. |
| 2922 | */ |
| 2923 | CXChildVisit_Continue, |
| 2924 | /** |
| 2925 | * \brief Recursively traverse the children of this cursor, using |
| 2926 | * the same visitor and client data. |
| 2927 | */ |
| 2928 | CXChildVisit_Recurse |
| 2929 | }; |
| 2930 | |
| 2931 | /** |
| 2932 | * \brief Visitor invoked for each cursor found by a traversal. |
| 2933 | * |
| 2934 | * This visitor function will be invoked for each cursor found by |
| 2935 | * clang_visitCursorChildren(). Its first argument is the cursor being |
| 2936 | * visited, its second argument is the parent visitor for that cursor, |
| 2937 | * and its third argument is the client data provided to |
| 2938 | * clang_visitCursorChildren(). |
| 2939 | * |
| 2940 | * The visitor should return one of the \c CXChildVisitResult values |
| 2941 | * to direct clang_visitCursorChildren(). |
| 2942 | */ |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2943 | typedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor, |
| 2944 | CXCursor parent, |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2945 | CXClientData client_data); |
| 2946 | |
| 2947 | /** |
| 2948 | * \brief Visit the children of a particular cursor. |
| 2949 | * |
| 2950 | * This function visits all the direct children of the given cursor, |
| 2951 | * invoking the given \p visitor function with the cursors of each |
| 2952 | * visited child. The traversal may be recursive, if the visitor returns |
| 2953 | * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if |
| 2954 | * the visitor returns \c CXChildVisit_Break. |
| 2955 | * |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2956 | * \param parent the cursor whose child may be visited. All kinds of |
Daniel Dunbar | a57259e | 2010-01-24 04:10:31 +0000 | [diff] [blame] | 2957 | * cursors can be visited, including invalid cursors (which, by |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2958 | * definition, have no children). |
| 2959 | * |
| 2960 | * \param visitor the visitor function that will be invoked for each |
| 2961 | * child of \p parent. |
| 2962 | * |
| 2963 | * \param client_data pointer data supplied by the client, which will |
| 2964 | * be passed to the visitor each time it is invoked. |
| 2965 | * |
| 2966 | * \returns a non-zero value if the traversal was terminated |
| 2967 | * prematurely by the visitor returning \c CXChildVisit_Break. |
| 2968 | */ |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2969 | CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent, |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2970 | CXCursorVisitor visitor, |
| 2971 | CXClientData client_data); |
David Chisnall | 3387c65 | 2010-11-03 14:12:26 +0000 | [diff] [blame] | 2972 | #ifdef __has_feature |
| 2973 | # if __has_feature(blocks) |
| 2974 | /** |
| 2975 | * \brief Visitor invoked for each cursor found by a traversal. |
| 2976 | * |
| 2977 | * This visitor block will be invoked for each cursor found by |
| 2978 | * clang_visitChildrenWithBlock(). Its first argument is the cursor being |
| 2979 | * visited, its second argument is the parent visitor for that cursor. |
| 2980 | * |
| 2981 | * The visitor should return one of the \c CXChildVisitResult values |
| 2982 | * to direct clang_visitChildrenWithBlock(). |
| 2983 | */ |
| 2984 | typedef enum CXChildVisitResult |
| 2985 | (^CXCursorVisitorBlock)(CXCursor cursor, CXCursor parent); |
| 2986 | |
| 2987 | /** |
| 2988 | * Visits the children of a cursor using the specified block. Behaves |
| 2989 | * identically to clang_visitChildren() in all other respects. |
| 2990 | */ |
| 2991 | unsigned clang_visitChildrenWithBlock(CXCursor parent, |
| 2992 | CXCursorVisitorBlock block); |
| 2993 | # endif |
| 2994 | #endif |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2995 | |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2996 | /** |
| 2997 | * @} |
| 2998 | */ |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2999 | |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 3000 | /** |
| 3001 | * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST |
| 3002 | * |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 3003 | * These routines provide the ability to determine references within and |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 3004 | * across translation units, by providing the names of the entities referenced |
| 3005 | * by cursors, follow reference cursors to the declarations they reference, |
| 3006 | * and associate declarations with their definitions. |
| 3007 | * |
| 3008 | * @{ |
| 3009 | */ |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 3010 | |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 3011 | /** |
| 3012 | * \brief Retrieve a Unified Symbol Resolution (USR) for the entity referenced |
| 3013 | * by the given cursor. |
| 3014 | * |
| 3015 | * A Unified Symbol Resolution (USR) is a string that identifies a particular |
| 3016 | * entity (function, class, variable, etc.) within a program. USRs can be |
| 3017 | * compared across translation units to determine, e.g., when references in |
| 3018 | * one translation refer to an entity defined in another translation unit. |
| 3019 | */ |
| 3020 | CINDEX_LINKAGE CXString clang_getCursorUSR(CXCursor); |
| 3021 | |
| 3022 | /** |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 3023 | * \brief Construct a USR for a specified Objective-C class. |
| 3024 | */ |
| 3025 | CINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name); |
| 3026 | |
| 3027 | /** |
| 3028 | * \brief Construct a USR for a specified Objective-C category. |
| 3029 | */ |
| 3030 | CINDEX_LINKAGE CXString |
Ted Kremenek | 66ccaec | 2010-03-15 17:38:58 +0000 | [diff] [blame] | 3031 | clang_constructUSR_ObjCCategory(const char *class_name, |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 3032 | const char *category_name); |
| 3033 | |
| 3034 | /** |
| 3035 | * \brief Construct a USR for a specified Objective-C protocol. |
| 3036 | */ |
| 3037 | CINDEX_LINKAGE CXString |
| 3038 | clang_constructUSR_ObjCProtocol(const char *protocol_name); |
| 3039 | |
| 3040 | |
| 3041 | /** |
| 3042 | * \brief Construct a USR for a specified Objective-C instance variable and |
| 3043 | * the USR for its containing class. |
| 3044 | */ |
| 3045 | CINDEX_LINKAGE CXString clang_constructUSR_ObjCIvar(const char *name, |
| 3046 | CXString classUSR); |
| 3047 | |
| 3048 | /** |
| 3049 | * \brief Construct a USR for a specified Objective-C method and |
| 3050 | * the USR for its containing class. |
| 3051 | */ |
| 3052 | CINDEX_LINKAGE CXString clang_constructUSR_ObjCMethod(const char *name, |
| 3053 | unsigned isInstanceMethod, |
| 3054 | CXString classUSR); |
| 3055 | |
| 3056 | /** |
| 3057 | * \brief Construct a USR for a specified Objective-C property and the USR |
| 3058 | * for its containing class. |
| 3059 | */ |
| 3060 | CINDEX_LINKAGE CXString clang_constructUSR_ObjCProperty(const char *property, |
| 3061 | CXString classUSR); |
| 3062 | |
| 3063 | /** |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 3064 | * \brief Retrieve a name for the entity referenced by this cursor. |
| 3065 | */ |
| 3066 | CINDEX_LINKAGE CXString clang_getCursorSpelling(CXCursor); |
| 3067 | |
Douglas Gregor | 358559d | 2010-10-02 22:49:11 +0000 | [diff] [blame] | 3068 | /** |
Argyrios Kyrtzidis | ba1da14 | 2012-03-30 20:58:35 +0000 | [diff] [blame] | 3069 | * \brief Retrieve a range for a piece that forms the cursors spelling name. |
| 3070 | * Most of the times there is only one range for the complete spelling but for |
| 3071 | * objc methods and objc message expressions, there are multiple pieces for each |
| 3072 | * selector identifier. |
| 3073 | * |
| 3074 | * \param pieceIndex the index of the spelling name piece. If this is greater |
| 3075 | * than the actual number of pieces, it will return a NULL (invalid) range. |
| 3076 | * |
| 3077 | * \param options Reserved. |
| 3078 | */ |
| 3079 | CINDEX_LINKAGE CXSourceRange clang_Cursor_getSpellingNameRange(CXCursor, |
| 3080 | unsigned pieceIndex, |
| 3081 | unsigned options); |
| 3082 | |
| 3083 | /** |
Douglas Gregor | 358559d | 2010-10-02 22:49:11 +0000 | [diff] [blame] | 3084 | * \brief Retrieve the display name for the entity referenced by this cursor. |
| 3085 | * |
| 3086 | * The display name contains extra information that helps identify the cursor, |
| 3087 | * such as the parameters of a function or template or the arguments of a |
| 3088 | * class template specialization. |
| 3089 | */ |
| 3090 | CINDEX_LINKAGE CXString clang_getCursorDisplayName(CXCursor); |
| 3091 | |
Douglas Gregor | c5d1e93 | 2010-01-19 01:20:04 +0000 | [diff] [blame] | 3092 | /** \brief For a cursor that is a reference, retrieve a cursor representing the |
| 3093 | * entity that it references. |
| 3094 | * |
| 3095 | * Reference cursors refer to other entities in the AST. For example, an |
| 3096 | * Objective-C superclass reference cursor refers to an Objective-C class. |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 3097 | * This function produces the cursor for the Objective-C class from the |
Douglas Gregor | c5d1e93 | 2010-01-19 01:20:04 +0000 | [diff] [blame] | 3098 | * cursor for the superclass reference. If the input cursor is a declaration or |
| 3099 | * definition, it returns that declaration or definition unchanged. |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 3100 | * Otherwise, returns the NULL cursor. |
Douglas Gregor | c5d1e93 | 2010-01-19 01:20:04 +0000 | [diff] [blame] | 3101 | */ |
| 3102 | CINDEX_LINKAGE CXCursor clang_getCursorReferenced(CXCursor); |
Douglas Gregor | b699866 | 2010-01-19 19:34:47 +0000 | [diff] [blame] | 3103 | |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 3104 | /** |
Douglas Gregor | b699866 | 2010-01-19 19:34:47 +0000 | [diff] [blame] | 3105 | * \brief For a cursor that is either a reference to or a declaration |
| 3106 | * of some entity, retrieve a cursor that describes the definition of |
| 3107 | * that entity. |
| 3108 | * |
| 3109 | * Some entities can be declared multiple times within a translation |
| 3110 | * unit, but only one of those declarations can also be a |
| 3111 | * definition. For example, given: |
| 3112 | * |
| 3113 | * \code |
| 3114 | * int f(int, int); |
| 3115 | * int g(int x, int y) { return f(x, y); } |
| 3116 | * int f(int a, int b) { return a + b; } |
| 3117 | * int f(int, int); |
| 3118 | * \endcode |
| 3119 | * |
| 3120 | * there are three declarations of the function "f", but only the |
| 3121 | * second one is a definition. The clang_getCursorDefinition() |
| 3122 | * function will take any cursor pointing to a declaration of "f" |
| 3123 | * (the first or fourth lines of the example) or a cursor referenced |
| 3124 | * that uses "f" (the call to "f' inside "g") and will return a |
| 3125 | * declaration cursor pointing to the definition (the second "f" |
| 3126 | * declaration). |
| 3127 | * |
| 3128 | * If given a cursor for which there is no corresponding definition, |
| 3129 | * e.g., because there is no definition of that entity within this |
| 3130 | * translation unit, returns a NULL cursor. |
| 3131 | */ |
| 3132 | CINDEX_LINKAGE CXCursor clang_getCursorDefinition(CXCursor); |
| 3133 | |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 3134 | /** |
Douglas Gregor | b699866 | 2010-01-19 19:34:47 +0000 | [diff] [blame] | 3135 | * \brief Determine whether the declaration pointed to by this cursor |
| 3136 | * is also a definition of that entity. |
| 3137 | */ |
| 3138 | CINDEX_LINKAGE unsigned clang_isCursorDefinition(CXCursor); |
| 3139 | |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 3140 | /** |
Douglas Gregor | 1a9d050 | 2010-11-19 23:44:15 +0000 | [diff] [blame] | 3141 | * \brief Retrieve the canonical cursor corresponding to the given cursor. |
| 3142 | * |
| 3143 | * In the C family of languages, many kinds of entities can be declared several |
| 3144 | * times within a single translation unit. For example, a structure type can |
| 3145 | * be forward-declared (possibly multiple times) and later defined: |
| 3146 | * |
| 3147 | * \code |
| 3148 | * struct X; |
| 3149 | * struct X; |
| 3150 | * struct X { |
| 3151 | * int member; |
| 3152 | * }; |
| 3153 | * \endcode |
| 3154 | * |
| 3155 | * The declarations and the definition of \c X are represented by three |
| 3156 | * different cursors, all of which are declarations of the same underlying |
| 3157 | * entity. One of these cursor is considered the "canonical" cursor, which |
| 3158 | * is effectively the representative for the underlying entity. One can |
| 3159 | * determine if two cursors are declarations of the same underlying entity by |
| 3160 | * comparing their canonical cursors. |
| 3161 | * |
| 3162 | * \returns The canonical cursor for the entity referred to by the given cursor. |
| 3163 | */ |
| 3164 | CINDEX_LINKAGE CXCursor clang_getCanonicalCursor(CXCursor); |
| 3165 | |
Argyrios Kyrtzidis | 34ebe1e | 2012-03-30 22:15:48 +0000 | [diff] [blame] | 3166 | |
| 3167 | /** |
| 3168 | * \brief If the cursor points to a selector identifier in a objc method or |
| 3169 | * message expression, this returns the selector index. |
| 3170 | * |
| 3171 | * After getting a cursor with \see clang_getCursor, this can be called to |
| 3172 | * determine if the location points to a selector identifier. |
| 3173 | * |
| 3174 | * \returns The selector index if the cursor is an objc method or message |
| 3175 | * expression and the cursor is pointing to a selector identifier, or -1 |
| 3176 | * otherwise. |
| 3177 | */ |
| 3178 | CINDEX_LINKAGE int clang_Cursor_getObjCSelectorIndex(CXCursor); |
| 3179 | |
Douglas Gregor | 1a9d050 | 2010-11-19 23:44:15 +0000 | [diff] [blame] | 3180 | /** |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 3181 | * @} |
| 3182 | */ |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 3183 | |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 3184 | /** |
Ted Kremenek | 9ada39a | 2010-05-17 20:06:56 +0000 | [diff] [blame] | 3185 | * \defgroup CINDEX_CPP C++ AST introspection |
| 3186 | * |
| 3187 | * The routines in this group provide access information in the ASTs specific |
| 3188 | * to C++ language features. |
| 3189 | * |
| 3190 | * @{ |
| 3191 | */ |
| 3192 | |
| 3193 | /** |
Douglas Gregor | 49f6f54 | 2010-08-31 22:12:17 +0000 | [diff] [blame] | 3194 | * \brief Determine if a C++ member function or member function template is |
| 3195 | * declared 'static'. |
Ted Kremenek | 9ada39a | 2010-05-17 20:06:56 +0000 | [diff] [blame] | 3196 | */ |
| 3197 | CINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C); |
| 3198 | |
| 3199 | /** |
Douglas Gregor | 211924b | 2011-05-12 15:17:24 +0000 | [diff] [blame] | 3200 | * \brief Determine if a C++ member function or member function template is |
| 3201 | * explicitly declared 'virtual' or if it overrides a virtual method from |
| 3202 | * one of the base classes. |
| 3203 | */ |
| 3204 | CINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual(CXCursor C); |
| 3205 | |
| 3206 | /** |
Douglas Gregor | 49f6f54 | 2010-08-31 22:12:17 +0000 | [diff] [blame] | 3207 | * \brief Given a cursor that represents a template, determine |
| 3208 | * the cursor kind of the specializations would be generated by instantiating |
| 3209 | * the template. |
| 3210 | * |
| 3211 | * This routine can be used to determine what flavor of function template, |
| 3212 | * class template, or class template partial specialization is stored in the |
| 3213 | * cursor. For example, it can describe whether a class template cursor is |
| 3214 | * declared with "struct", "class" or "union". |
| 3215 | * |
| 3216 | * \param C The cursor to query. This cursor should represent a template |
| 3217 | * declaration. |
| 3218 | * |
| 3219 | * \returns The cursor kind of the specializations that would be generated |
| 3220 | * by instantiating the template \p C. If \p C is not a template, returns |
| 3221 | * \c CXCursor_NoDeclFound. |
| 3222 | */ |
| 3223 | CINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind(CXCursor C); |
| 3224 | |
| 3225 | /** |
Douglas Gregor | e0329ac | 2010-09-02 00:07:54 +0000 | [diff] [blame] | 3226 | * \brief Given a cursor that may represent a specialization or instantiation |
| 3227 | * of a template, retrieve the cursor that represents the template that it |
| 3228 | * specializes or from which it was instantiated. |
| 3229 | * |
| 3230 | * This routine determines the template involved both for explicit |
| 3231 | * specializations of templates and for implicit instantiations of the template, |
| 3232 | * both of which are referred to as "specializations". For a class template |
| 3233 | * specialization (e.g., \c std::vector<bool>), this routine will return |
| 3234 | * either the primary template (\c std::vector) or, if the specialization was |
| 3235 | * instantiated from a class template partial specialization, the class template |
| 3236 | * partial specialization. For a class template partial specialization and a |
| 3237 | * function template specialization (including instantiations), this |
| 3238 | * this routine will return the specialized template. |
| 3239 | * |
| 3240 | * For members of a class template (e.g., member functions, member classes, or |
| 3241 | * static data members), returns the specialized or instantiated member. |
| 3242 | * Although not strictly "templates" in the C++ language, members of class |
| 3243 | * templates have the same notions of specializations and instantiations that |
| 3244 | * templates do, so this routine treats them similarly. |
| 3245 | * |
| 3246 | * \param C A cursor that may be a specialization of a template or a member |
| 3247 | * of a template. |
| 3248 | * |
| 3249 | * \returns If the given cursor is a specialization or instantiation of a |
| 3250 | * template or a member thereof, the template or member that it specializes or |
| 3251 | * from which it was instantiated. Otherwise, returns a NULL cursor. |
| 3252 | */ |
| 3253 | CINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate(CXCursor C); |
Douglas Gregor | 430d7a1 | 2011-07-25 17:48:11 +0000 | [diff] [blame] | 3254 | |
| 3255 | /** |
| 3256 | * \brief Given a cursor that references something else, return the source range |
| 3257 | * covering that reference. |
| 3258 | * |
| 3259 | * \param C A cursor pointing to a member reference, a declaration reference, or |
| 3260 | * an operator call. |
| 3261 | * \param NameFlags A bitset with three independent flags: |
| 3262 | * CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and |
| 3263 | * CXNameRange_WantSinglePiece. |
| 3264 | * \param PieceIndex For contiguous names or when passing the flag |
| 3265 | * CXNameRange_WantSinglePiece, only one piece with index 0 is |
| 3266 | * available. When the CXNameRange_WantSinglePiece flag is not passed for a |
Benjamin Kramer | 48d798c | 2012-06-02 10:20:41 +0000 | [diff] [blame] | 3267 | * non-contiguous names, this index can be used to retrieve the individual |
Douglas Gregor | 430d7a1 | 2011-07-25 17:48:11 +0000 | [diff] [blame] | 3268 | * pieces of the name. See also CXNameRange_WantSinglePiece. |
| 3269 | * |
| 3270 | * \returns The piece of the name pointed to by the given cursor. If there is no |
| 3271 | * name, or if the PieceIndex is out-of-range, a null-cursor will be returned. |
| 3272 | */ |
Francois Pichet | 48a8d14 | 2011-07-25 22:00:44 +0000 | [diff] [blame] | 3273 | CINDEX_LINKAGE CXSourceRange clang_getCursorReferenceNameRange(CXCursor C, |
| 3274 | unsigned NameFlags, |
Douglas Gregor | 430d7a1 | 2011-07-25 17:48:11 +0000 | [diff] [blame] | 3275 | unsigned PieceIndex); |
| 3276 | |
| 3277 | enum CXNameRefFlags { |
| 3278 | /** |
| 3279 | * \brief Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the |
| 3280 | * range. |
| 3281 | */ |
| 3282 | CXNameRange_WantQualifier = 0x1, |
| 3283 | |
| 3284 | /** |
| 3285 | * \brief Include the explicit template arguments, e.g. <int> in x.f<int>, in |
| 3286 | * the range. |
| 3287 | */ |
| 3288 | CXNameRange_WantTemplateArgs = 0x2, |
| 3289 | |
| 3290 | /** |
| 3291 | * \brief If the name is non-contiguous, return the full spanning range. |
| 3292 | * |
| 3293 | * Non-contiguous names occur in Objective-C when a selector with two or more |
| 3294 | * parameters is used, or in C++ when using an operator: |
| 3295 | * \code |
| 3296 | * [object doSomething:here withValue:there]; // ObjC |
| 3297 | * return some_vector[1]; // C++ |
| 3298 | * \endcode |
| 3299 | */ |
| 3300 | CXNameRange_WantSinglePiece = 0x4 |
| 3301 | }; |
Douglas Gregor | e0329ac | 2010-09-02 00:07:54 +0000 | [diff] [blame] | 3302 | |
| 3303 | /** |
Ted Kremenek | 9ada39a | 2010-05-17 20:06:56 +0000 | [diff] [blame] | 3304 | * @} |
| 3305 | */ |
| 3306 | |
| 3307 | /** |
Douglas Gregor | 0045e9f | 2010-01-26 18:31:56 +0000 | [diff] [blame] | 3308 | * \defgroup CINDEX_LEX Token extraction and manipulation |
| 3309 | * |
| 3310 | * The routines in this group provide access to the tokens within a |
| 3311 | * translation unit, along with a semantic mapping of those tokens to |
| 3312 | * their corresponding cursors. |
Douglas Gregor | fc8ea23 | 2010-01-26 17:06:03 +0000 | [diff] [blame] | 3313 | * |
| 3314 | * @{ |
| 3315 | */ |
| 3316 | |
| 3317 | /** |
| 3318 | * \brief Describes a kind of token. |
| 3319 | */ |
| 3320 | typedef enum CXTokenKind { |
| 3321 | /** |
| 3322 | * \brief A token that contains some kind of punctuation. |
| 3323 | */ |
| 3324 | CXToken_Punctuation, |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 3325 | |
Douglas Gregor | fc8ea23 | 2010-01-26 17:06:03 +0000 | [diff] [blame] | 3326 | /** |
Douglas Gregor | 0045e9f | 2010-01-26 18:31:56 +0000 | [diff] [blame] | 3327 | * \brief A language keyword. |
Douglas Gregor | fc8ea23 | 2010-01-26 17:06:03 +0000 | [diff] [blame] | 3328 | */ |
| 3329 | CXToken_Keyword, |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 3330 | |
Douglas Gregor | fc8ea23 | 2010-01-26 17:06:03 +0000 | [diff] [blame] | 3331 | /** |
| 3332 | * \brief An identifier (that is not a keyword). |
| 3333 | */ |
| 3334 | CXToken_Identifier, |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 3335 | |
Douglas Gregor | fc8ea23 | 2010-01-26 17:06:03 +0000 | [diff] [blame] | 3336 | /** |
| 3337 | * \brief A numeric, string, or character literal. |
| 3338 | */ |
| 3339 | CXToken_Literal, |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 3340 | |
Douglas Gregor | fc8ea23 | 2010-01-26 17:06:03 +0000 | [diff] [blame] | 3341 | /** |
| 3342 | * \brief A comment. |
| 3343 | */ |
| 3344 | CXToken_Comment |
| 3345 | } CXTokenKind; |
| 3346 | |
| 3347 | /** |
| 3348 | * \brief Describes a single preprocessing token. |
| 3349 | */ |
| 3350 | typedef struct { |
| 3351 | unsigned int_data[4]; |
| 3352 | void *ptr_data; |
| 3353 | } CXToken; |
| 3354 | |
| 3355 | /** |
| 3356 | * \brief Determine the kind of the given token. |
| 3357 | */ |
| 3358 | CINDEX_LINKAGE CXTokenKind clang_getTokenKind(CXToken); |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 3359 | |
Douglas Gregor | fc8ea23 | 2010-01-26 17:06:03 +0000 | [diff] [blame] | 3360 | /** |
| 3361 | * \brief Determine the spelling of the given token. |
| 3362 | * |
| 3363 | * The spelling of a token is the textual representation of that token, e.g., |
| 3364 | * the text of an identifier or keyword. |
| 3365 | */ |
| 3366 | CINDEX_LINKAGE CXString clang_getTokenSpelling(CXTranslationUnit, CXToken); |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 3367 | |
Douglas Gregor | fc8ea23 | 2010-01-26 17:06:03 +0000 | [diff] [blame] | 3368 | /** |
| 3369 | * \brief Retrieve the source location of the given token. |
| 3370 | */ |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 3371 | CINDEX_LINKAGE CXSourceLocation clang_getTokenLocation(CXTranslationUnit, |
Douglas Gregor | fc8ea23 | 2010-01-26 17:06:03 +0000 | [diff] [blame] | 3372 | CXToken); |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 3373 | |
Douglas Gregor | fc8ea23 | 2010-01-26 17:06:03 +0000 | [diff] [blame] | 3374 | /** |
| 3375 | * \brief Retrieve a source range that covers the given token. |
| 3376 | */ |
| 3377 | CINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken); |
| 3378 | |
| 3379 | /** |
| 3380 | * \brief Tokenize the source code described by the given range into raw |
| 3381 | * lexical tokens. |
| 3382 | * |
| 3383 | * \param TU the translation unit whose text is being tokenized. |
| 3384 | * |
| 3385 | * \param Range the source range in which text should be tokenized. All of the |
| 3386 | * tokens produced by tokenization will fall within this source range, |
| 3387 | * |
| 3388 | * \param Tokens this pointer will be set to point to the array of tokens |
| 3389 | * that occur within the given source range. The returned pointer must be |
| 3390 | * freed with clang_disposeTokens() before the translation unit is destroyed. |
| 3391 | * |
| 3392 | * \param NumTokens will be set to the number of tokens in the \c *Tokens |
| 3393 | * array. |
| 3394 | * |
| 3395 | */ |
| 3396 | CINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range, |
| 3397 | CXToken **Tokens, unsigned *NumTokens); |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 3398 | |
Douglas Gregor | fc8ea23 | 2010-01-26 17:06:03 +0000 | [diff] [blame] | 3399 | /** |
| 3400 | * \brief Annotate the given set of tokens by providing cursors for each token |
| 3401 | * that can be mapped to a specific entity within the abstract syntax tree. |
| 3402 | * |
Douglas Gregor | 0045e9f | 2010-01-26 18:31:56 +0000 | [diff] [blame] | 3403 | * This token-annotation routine is equivalent to invoking |
| 3404 | * clang_getCursor() for the source locations of each of the |
| 3405 | * tokens. The cursors provided are filtered, so that only those |
| 3406 | * cursors that have a direct correspondence to the token are |
| 3407 | * accepted. For example, given a function call \c f(x), |
| 3408 | * clang_getCursor() would provide the following cursors: |
| 3409 | * |
| 3410 | * * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'. |
| 3411 | * * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'. |
| 3412 | * * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'. |
| 3413 | * |
| 3414 | * Only the first and last of these cursors will occur within the |
| 3415 | * annotate, since the tokens "f" and "x' directly refer to a function |
| 3416 | * and a variable, respectively, but the parentheses are just a small |
| 3417 | * part of the full syntax of the function call expression, which is |
| 3418 | * not provided as an annotation. |
Douglas Gregor | fc8ea23 | 2010-01-26 17:06:03 +0000 | [diff] [blame] | 3419 | * |
| 3420 | * \param TU the translation unit that owns the given tokens. |
| 3421 | * |
| 3422 | * \param Tokens the set of tokens to annotate. |
| 3423 | * |
| 3424 | * \param NumTokens the number of tokens in \p Tokens. |
| 3425 | * |
| 3426 | * \param Cursors an array of \p NumTokens cursors, whose contents will be |
| 3427 | * replaced with the cursors corresponding to each token. |
| 3428 | */ |
| 3429 | CINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU, |
| 3430 | CXToken *Tokens, unsigned NumTokens, |
| 3431 | CXCursor *Cursors); |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 3432 | |
Douglas Gregor | fc8ea23 | 2010-01-26 17:06:03 +0000 | [diff] [blame] | 3433 | /** |
| 3434 | * \brief Free the given set of tokens. |
| 3435 | */ |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 3436 | CINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU, |
Douglas Gregor | fc8ea23 | 2010-01-26 17:06:03 +0000 | [diff] [blame] | 3437 | CXToken *Tokens, unsigned NumTokens); |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 3438 | |
Douglas Gregor | fc8ea23 | 2010-01-26 17:06:03 +0000 | [diff] [blame] | 3439 | /** |
| 3440 | * @} |
| 3441 | */ |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 3442 | |
Douglas Gregor | fc8ea23 | 2010-01-26 17:06:03 +0000 | [diff] [blame] | 3443 | /** |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 3444 | * \defgroup CINDEX_DEBUG Debugging facilities |
| 3445 | * |
| 3446 | * These routines are used for testing and debugging, only, and should not |
| 3447 | * be relied upon. |
| 3448 | * |
| 3449 | * @{ |
| 3450 | */ |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 3451 | |
Steve Naroff | 4ade6d6 | 2009-09-23 17:52:52 +0000 | [diff] [blame] | 3452 | /* for debug/testing */ |
Ted Kremenek | e68fff6 | 2010-02-17 00:41:32 +0000 | [diff] [blame] | 3453 | CINDEX_LINKAGE CXString clang_getCursorKindSpelling(enum CXCursorKind Kind); |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 3454 | CINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(CXCursor, |
| 3455 | const char **startBuf, |
Steve Naroff | 4ade6d6 | 2009-09-23 17:52:52 +0000 | [diff] [blame] | 3456 | const char **endBuf, |
| 3457 | unsigned *startLine, |
| 3458 | unsigned *startColumn, |
| 3459 | unsigned *endLine, |
| 3460 | unsigned *endColumn); |
Douglas Gregor | 0a812cf | 2010-02-18 23:07:20 +0000 | [diff] [blame] | 3461 | CINDEX_LINKAGE void clang_enableStackTraces(void); |
Daniel Dunbar | 995aaf9 | 2010-11-04 01:26:29 +0000 | [diff] [blame] | 3462 | CINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void*), void *user_data, |
| 3463 | unsigned stack_size); |
| 3464 | |
Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 3465 | /** |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 3466 | * @} |
| 3467 | */ |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 3468 | |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 3469 | /** |
| 3470 | * \defgroup CINDEX_CODE_COMPLET Code completion |
| 3471 | * |
| 3472 | * Code completion involves taking an (incomplete) source file, along with |
| 3473 | * knowledge of where the user is actively editing that file, and suggesting |
| 3474 | * syntactically- and semantically-valid constructs that the user might want to |
| 3475 | * use at that particular point in the source code. These data structures and |
| 3476 | * routines provide support for code completion. |
| 3477 | * |
| 3478 | * @{ |
| 3479 | */ |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 3480 | |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 3481 | /** |
Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 3482 | * \brief A semantic string that describes a code-completion result. |
| 3483 | * |
| 3484 | * A semantic string that describes the formatting of a code-completion |
| 3485 | * result as a single "template" of text that should be inserted into the |
| 3486 | * source buffer when a particular code-completion result is selected. |
| 3487 | * Each semantic string is made up of some number of "chunks", each of which |
| 3488 | * contains some text along with a description of what that text means, e.g., |
| 3489 | * the name of the entity being referenced, whether the text chunk is part of |
| 3490 | * the template, or whether it is a "placeholder" that the user should replace |
| 3491 | * with actual code,of a specific kind. See \c CXCompletionChunkKind for a |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 3492 | * description of the different kinds of chunks. |
Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 3493 | */ |
| 3494 | typedef void *CXCompletionString; |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 3495 | |
Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 3496 | /** |
| 3497 | * \brief A single result of code completion. |
| 3498 | */ |
| 3499 | typedef struct { |
| 3500 | /** |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 3501 | * \brief The kind of entity that this completion refers to. |
Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 3502 | * |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 3503 | * The cursor kind will be a macro, keyword, or a declaration (one of the |
Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 3504 | * *Decl cursor kinds), describing the entity that the completion is |
| 3505 | * referring to. |
| 3506 | * |
| 3507 | * \todo In the future, we would like to provide a full cursor, to allow |
| 3508 | * the client to extract additional information from declaration. |
| 3509 | */ |
| 3510 | enum CXCursorKind CursorKind; |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 3511 | |
| 3512 | /** |
Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 3513 | * \brief The code-completion string that describes how to insert this |
| 3514 | * code-completion result into the editing buffer. |
| 3515 | */ |
| 3516 | CXCompletionString CompletionString; |
| 3517 | } CXCompletionResult; |
| 3518 | |
| 3519 | /** |
| 3520 | * \brief Describes a single piece of text within a code-completion string. |
| 3521 | * |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 3522 | * Each "chunk" within a code-completion string (\c CXCompletionString) is |
| 3523 | * either a piece of text with a specific "kind" that describes how that text |
Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 3524 | * should be interpreted by the client or is another completion string. |
| 3525 | */ |
| 3526 | enum CXCompletionChunkKind { |
| 3527 | /** |
| 3528 | * \brief A code-completion string that describes "optional" text that |
| 3529 | * could be a part of the template (but is not required). |
| 3530 | * |
| 3531 | * The Optional chunk is the only kind of chunk that has a code-completion |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 3532 | * string for its representation, which is accessible via |
Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 3533 | * \c clang_getCompletionChunkCompletionString(). The code-completion string |
| 3534 | * describes an additional part of the template that is completely optional. |
| 3535 | * For example, optional chunks can be used to describe the placeholders for |
| 3536 | * arguments that match up with defaulted function parameters, e.g. given: |
| 3537 | * |
| 3538 | * \code |
| 3539 | * void f(int x, float y = 3.14, double z = 2.71828); |
| 3540 | * \endcode |
| 3541 | * |
| 3542 | * The code-completion string for this function would contain: |
| 3543 | * - a TypedText chunk for "f". |
| 3544 | * - a LeftParen chunk for "(". |
| 3545 | * - a Placeholder chunk for "int x" |
| 3546 | * - an Optional chunk containing the remaining defaulted arguments, e.g., |
| 3547 | * - a Comma chunk for "," |
Daniel Dunbar | 7157018 | 2010-02-17 08:07:44 +0000 | [diff] [blame] | 3548 | * - a Placeholder chunk for "float y" |
Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 3549 | * - an Optional chunk containing the last defaulted argument: |
| 3550 | * - a Comma chunk for "," |
| 3551 | * - a Placeholder chunk for "double z" |
| 3552 | * - a RightParen chunk for ")" |
| 3553 | * |
Daniel Dunbar | 7157018 | 2010-02-17 08:07:44 +0000 | [diff] [blame] | 3554 | * There are many ways to handle Optional chunks. Two simple approaches are: |
Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 3555 | * - Completely ignore optional chunks, in which case the template for the |
| 3556 | * function "f" would only include the first parameter ("int x"). |
| 3557 | * - Fully expand all optional chunks, in which case the template for the |
| 3558 | * function "f" would have all of the parameters. |
| 3559 | */ |
| 3560 | CXCompletionChunk_Optional, |
| 3561 | /** |
| 3562 | * \brief Text that a user would be expected to type to get this |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 3563 | * code-completion result. |
Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 3564 | * |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 3565 | * There will be exactly one "typed text" chunk in a semantic string, which |
| 3566 | * will typically provide the spelling of a keyword or the name of a |
Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 3567 | * declaration that could be used at the current code point. Clients are |
| 3568 | * expected to filter the code-completion results based on the text in this |
| 3569 | * chunk. |
| 3570 | */ |
| 3571 | CXCompletionChunk_TypedText, |
| 3572 | /** |
| 3573 | * \brief Text that should be inserted as part of a code-completion result. |
| 3574 | * |
| 3575 | * A "text" chunk represents text that is part of the template to be |
| 3576 | * inserted into user code should this particular code-completion result |
| 3577 | * be selected. |
| 3578 | */ |
| 3579 | CXCompletionChunk_Text, |
| 3580 | /** |
| 3581 | * \brief Placeholder text that should be replaced by the user. |
| 3582 | * |
| 3583 | * A "placeholder" chunk marks a place where the user should insert text |
| 3584 | * into the code-completion template. For example, placeholders might mark |
| 3585 | * the function parameters for a function declaration, to indicate that the |
| 3586 | * user should provide arguments for each of those parameters. The actual |
| 3587 | * text in a placeholder is a suggestion for the text to display before |
| 3588 | * the user replaces the placeholder with real code. |
| 3589 | */ |
| 3590 | CXCompletionChunk_Placeholder, |
| 3591 | /** |
| 3592 | * \brief Informative text that should be displayed but never inserted as |
| 3593 | * part of the template. |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 3594 | * |
Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 3595 | * An "informative" chunk contains annotations that can be displayed to |
| 3596 | * help the user decide whether a particular code-completion result is the |
| 3597 | * right option, but which is not part of the actual template to be inserted |
| 3598 | * by code completion. |
| 3599 | */ |
| 3600 | CXCompletionChunk_Informative, |
| 3601 | /** |
| 3602 | * \brief Text that describes the current parameter when code-completion is |
| 3603 | * referring to function call, message send, or template specialization. |
| 3604 | * |
| 3605 | * A "current parameter" chunk occurs when code-completion is providing |
| 3606 | * information about a parameter corresponding to the argument at the |
| 3607 | * code-completion point. For example, given a function |
| 3608 | * |
| 3609 | * \code |
| 3610 | * int add(int x, int y); |
| 3611 | * \endcode |
| 3612 | * |
| 3613 | * and the source code \c add(, where the code-completion point is after the |
| 3614 | * "(", the code-completion string will contain a "current parameter" chunk |
| 3615 | * for "int x", indicating that the current argument will initialize that |
| 3616 | * parameter. After typing further, to \c add(17, (where the code-completion |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 3617 | * point is after the ","), the code-completion string will contain a |
Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 3618 | * "current paremeter" chunk to "int y". |
| 3619 | */ |
| 3620 | CXCompletionChunk_CurrentParameter, |
| 3621 | /** |
| 3622 | * \brief A left parenthesis ('('), used to initiate a function call or |
| 3623 | * signal the beginning of a function parameter list. |
| 3624 | */ |
| 3625 | CXCompletionChunk_LeftParen, |
| 3626 | /** |
| 3627 | * \brief A right parenthesis (')'), used to finish a function call or |
| 3628 | * signal the end of a function parameter list. |
| 3629 | */ |
| 3630 | CXCompletionChunk_RightParen, |
| 3631 | /** |
| 3632 | * \brief A left bracket ('['). |
| 3633 | */ |
| 3634 | CXCompletionChunk_LeftBracket, |
| 3635 | /** |
| 3636 | * \brief A right bracket (']'). |
| 3637 | */ |
| 3638 | CXCompletionChunk_RightBracket, |
| 3639 | /** |
| 3640 | * \brief A left brace ('{'). |
| 3641 | */ |
| 3642 | CXCompletionChunk_LeftBrace, |
| 3643 | /** |
| 3644 | * \brief A right brace ('}'). |
| 3645 | */ |
| 3646 | CXCompletionChunk_RightBrace, |
| 3647 | /** |
| 3648 | * \brief A left angle bracket ('<'). |
| 3649 | */ |
| 3650 | CXCompletionChunk_LeftAngle, |
| 3651 | /** |
| 3652 | * \brief A right angle bracket ('>'). |
| 3653 | */ |
| 3654 | CXCompletionChunk_RightAngle, |
| 3655 | /** |
| 3656 | * \brief A comma separator (','). |
| 3657 | */ |
Douglas Gregor | ff5ce6e | 2009-12-18 18:53:37 +0000 | [diff] [blame] | 3658 | CXCompletionChunk_Comma, |
| 3659 | /** |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 3660 | * \brief Text that specifies the result type of a given result. |
Douglas Gregor | ff5ce6e | 2009-12-18 18:53:37 +0000 | [diff] [blame] | 3661 | * |
| 3662 | * This special kind of informative chunk is not meant to be inserted into |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 3663 | * the text buffer. Rather, it is meant to illustrate the type that an |
Douglas Gregor | ff5ce6e | 2009-12-18 18:53:37 +0000 | [diff] [blame] | 3664 | * expression using the given completion string would have. |
| 3665 | */ |
Douglas Gregor | 01dfea0 | 2010-01-10 23:08:15 +0000 | [diff] [blame] | 3666 | CXCompletionChunk_ResultType, |
| 3667 | /** |
| 3668 | * \brief A colon (':'). |
| 3669 | */ |
| 3670 | CXCompletionChunk_Colon, |
| 3671 | /** |
| 3672 | * \brief A semicolon (';'). |
| 3673 | */ |
| 3674 | CXCompletionChunk_SemiColon, |
| 3675 | /** |
| 3676 | * \brief An '=' sign. |
| 3677 | */ |
| 3678 | CXCompletionChunk_Equal, |
| 3679 | /** |
| 3680 | * Horizontal space (' '). |
| 3681 | */ |
| 3682 | CXCompletionChunk_HorizontalSpace, |
| 3683 | /** |
| 3684 | * Vertical space ('\n'), after which it is generally a good idea to |
| 3685 | * perform indentation. |
| 3686 | */ |
| 3687 | CXCompletionChunk_VerticalSpace |
Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 3688 | }; |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 3689 | |
Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 3690 | /** |
| 3691 | * \brief Determine the kind of a particular chunk within a completion string. |
| 3692 | * |
| 3693 | * \param completion_string the completion string to query. |
| 3694 | * |
| 3695 | * \param chunk_number the 0-based index of the chunk in the completion string. |
| 3696 | * |
| 3697 | * \returns the kind of the chunk at the index \c chunk_number. |
| 3698 | */ |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 3699 | CINDEX_LINKAGE enum CXCompletionChunkKind |
Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 3700 | clang_getCompletionChunkKind(CXCompletionString completion_string, |
| 3701 | unsigned chunk_number); |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 3702 | |
Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 3703 | /** |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 3704 | * \brief Retrieve the text associated with a particular chunk within a |
Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 3705 | * completion string. |
| 3706 | * |
| 3707 | * \param completion_string the completion string to query. |
| 3708 | * |
| 3709 | * \param chunk_number the 0-based index of the chunk in the completion string. |
| 3710 | * |
| 3711 | * \returns the text associated with the chunk at index \c chunk_number. |
| 3712 | */ |
Ted Kremenek | 2ef6f8f | 2010-02-17 01:42:24 +0000 | [diff] [blame] | 3713 | CINDEX_LINKAGE CXString |
Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 3714 | clang_getCompletionChunkText(CXCompletionString completion_string, |
| 3715 | unsigned chunk_number); |
| 3716 | |
| 3717 | /** |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 3718 | * \brief Retrieve the completion string associated with a particular chunk |
Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 3719 | * within a completion string. |
| 3720 | * |
| 3721 | * \param completion_string the completion string to query. |
| 3722 | * |
| 3723 | * \param chunk_number the 0-based index of the chunk in the completion string. |
| 3724 | * |
| 3725 | * \returns the completion string associated with the chunk at index |
Erik Verbruggen | 6164ea1 | 2011-10-14 15:31:08 +0000 | [diff] [blame] | 3726 | * \c chunk_number. |
Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 3727 | */ |
| 3728 | CINDEX_LINKAGE CXCompletionString |
| 3729 | clang_getCompletionChunkCompletionString(CXCompletionString completion_string, |
| 3730 | unsigned chunk_number); |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 3731 | |
Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 3732 | /** |
| 3733 | * \brief Retrieve the number of chunks in the given code-completion string. |
| 3734 | */ |
| 3735 | CINDEX_LINKAGE unsigned |
| 3736 | clang_getNumCompletionChunks(CXCompletionString completion_string); |
| 3737 | |
| 3738 | /** |
Douglas Gregor | 12e1313 | 2010-05-26 22:00:08 +0000 | [diff] [blame] | 3739 | * \brief Determine the priority of this code completion. |
| 3740 | * |
| 3741 | * The priority of a code completion indicates how likely it is that this |
| 3742 | * particular completion is the completion that the user will select. The |
| 3743 | * priority is selected by various internal heuristics. |
| 3744 | * |
| 3745 | * \param completion_string The completion string to query. |
| 3746 | * |
| 3747 | * \returns The priority of this completion string. Smaller values indicate |
| 3748 | * higher-priority (more likely) completions. |
| 3749 | */ |
| 3750 | CINDEX_LINKAGE unsigned |
| 3751 | clang_getCompletionPriority(CXCompletionString completion_string); |
| 3752 | |
| 3753 | /** |
Douglas Gregor | 58ddb60 | 2010-08-23 23:00:57 +0000 | [diff] [blame] | 3754 | * \brief Determine the availability of the entity that this code-completion |
| 3755 | * string refers to. |
| 3756 | * |
| 3757 | * \param completion_string The completion string to query. |
| 3758 | * |
| 3759 | * \returns The availability of the completion string. |
| 3760 | */ |
| 3761 | CINDEX_LINKAGE enum CXAvailabilityKind |
| 3762 | clang_getCompletionAvailability(CXCompletionString completion_string); |
| 3763 | |
| 3764 | /** |
Erik Verbruggen | 6164ea1 | 2011-10-14 15:31:08 +0000 | [diff] [blame] | 3765 | * \brief Retrieve the number of annotations associated with the given |
| 3766 | * completion string. |
| 3767 | * |
| 3768 | * \param completion_string the completion string to query. |
| 3769 | * |
| 3770 | * \returns the number of annotations associated with the given completion |
| 3771 | * string. |
| 3772 | */ |
| 3773 | CINDEX_LINKAGE unsigned |
| 3774 | clang_getCompletionNumAnnotations(CXCompletionString completion_string); |
| 3775 | |
| 3776 | /** |
| 3777 | * \brief Retrieve the annotation associated with the given completion string. |
| 3778 | * |
| 3779 | * \param completion_string the completion string to query. |
| 3780 | * |
| 3781 | * \param annotation_number the 0-based index of the annotation of the |
| 3782 | * completion string. |
| 3783 | * |
| 3784 | * \returns annotation string associated with the completion at index |
| 3785 | * \c annotation_number, or a NULL string if that annotation is not available. |
| 3786 | */ |
| 3787 | CINDEX_LINKAGE CXString |
| 3788 | clang_getCompletionAnnotation(CXCompletionString completion_string, |
| 3789 | unsigned annotation_number); |
| 3790 | |
| 3791 | /** |
Douglas Gregor | ba10306 | 2012-03-27 23:34:16 +0000 | [diff] [blame] | 3792 | * \brief Retrieve the parent context of the given completion string. |
| 3793 | * |
| 3794 | * The parent context of a completion string is the semantic parent of |
| 3795 | * the declaration (if any) that the code completion represents. For example, |
| 3796 | * a code completion for an Objective-C method would have the method's class |
| 3797 | * or protocol as its context. |
| 3798 | * |
| 3799 | * \param completion_string The code completion string whose parent is |
| 3800 | * being queried. |
| 3801 | * |
| 3802 | * \param kind If non-NULL, will be set to the kind of the parent context, |
| 3803 | * or CXCursor_NotImplemented if there is no context. |
| 3804 | * |
| 3805 | * \param Returns the name of the completion parent, e.g., "NSObject" if |
| 3806 | * the completion string represents a method in the NSObject class. |
| 3807 | */ |
| 3808 | CINDEX_LINKAGE CXString |
| 3809 | clang_getCompletionParent(CXCompletionString completion_string, |
| 3810 | enum CXCursorKind *kind); |
| 3811 | /** |
Douglas Gregor | 8fa0a80 | 2011-08-04 20:04:59 +0000 | [diff] [blame] | 3812 | * \brief Retrieve a completion string for an arbitrary declaration or macro |
| 3813 | * definition cursor. |
| 3814 | * |
| 3815 | * \param cursor The cursor to query. |
| 3816 | * |
| 3817 | * \returns A non-context-sensitive completion string for declaration and macro |
| 3818 | * definition cursors, or NULL for other kinds of cursors. |
| 3819 | */ |
| 3820 | CINDEX_LINKAGE CXCompletionString |
| 3821 | clang_getCursorCompletionString(CXCursor cursor); |
| 3822 | |
| 3823 | /** |
Douglas Gregor | ec6762c | 2009-12-18 16:20:58 +0000 | [diff] [blame] | 3824 | * \brief Contains the results of code-completion. |
| 3825 | * |
| 3826 | * This data structure contains the results of code completion, as |
Douglas Gregor | e0cc52e | 2010-10-11 21:51:20 +0000 | [diff] [blame] | 3827 | * produced by \c clang_codeCompleteAt(). Its contents must be freed by |
Douglas Gregor | ec6762c | 2009-12-18 16:20:58 +0000 | [diff] [blame] | 3828 | * \c clang_disposeCodeCompleteResults. |
| 3829 | */ |
| 3830 | typedef struct { |
| 3831 | /** |
| 3832 | * \brief The code-completion results. |
| 3833 | */ |
| 3834 | CXCompletionResult *Results; |
| 3835 | |
| 3836 | /** |
| 3837 | * \brief The number of code-completion results stored in the |
| 3838 | * \c Results array. |
| 3839 | */ |
| 3840 | unsigned NumResults; |
| 3841 | } CXCodeCompleteResults; |
| 3842 | |
| 3843 | /** |
Douglas Gregor | cee235c | 2010-08-05 09:09:23 +0000 | [diff] [blame] | 3844 | * \brief Flags that can be passed to \c clang_codeCompleteAt() to |
| 3845 | * modify its behavior. |
| 3846 | * |
| 3847 | * The enumerators in this enumeration can be bitwise-OR'd together to |
| 3848 | * provide multiple options to \c clang_codeCompleteAt(). |
| 3849 | */ |
| 3850 | enum CXCodeComplete_Flags { |
| 3851 | /** |
| 3852 | * \brief Whether to include macros within the set of code |
| 3853 | * completions returned. |
| 3854 | */ |
| 3855 | CXCodeComplete_IncludeMacros = 0x01, |
| 3856 | |
| 3857 | /** |
| 3858 | * \brief Whether to include code patterns for language constructs |
| 3859 | * within the set of code completions, e.g., for loops. |
| 3860 | */ |
| 3861 | CXCodeComplete_IncludeCodePatterns = 0x02 |
| 3862 | }; |
| 3863 | |
| 3864 | /** |
Douglas Gregor | 3da626b | 2011-07-07 16:03:39 +0000 | [diff] [blame] | 3865 | * \brief Bits that represent the context under which completion is occurring. |
| 3866 | * |
| 3867 | * The enumerators in this enumeration may be bitwise-OR'd together if multiple |
| 3868 | * contexts are occurring simultaneously. |
| 3869 | */ |
| 3870 | enum CXCompletionContext { |
| 3871 | /** |
| 3872 | * \brief The context for completions is unexposed, as only Clang results |
| 3873 | * should be included. (This is equivalent to having no context bits set.) |
| 3874 | */ |
| 3875 | CXCompletionContext_Unexposed = 0, |
| 3876 | |
| 3877 | /** |
| 3878 | * \brief Completions for any possible type should be included in the results. |
| 3879 | */ |
| 3880 | CXCompletionContext_AnyType = 1 << 0, |
| 3881 | |
| 3882 | /** |
| 3883 | * \brief Completions for any possible value (variables, function calls, etc.) |
| 3884 | * should be included in the results. |
| 3885 | */ |
| 3886 | CXCompletionContext_AnyValue = 1 << 1, |
| 3887 | /** |
| 3888 | * \brief Completions for values that resolve to an Objective-C object should |
| 3889 | * be included in the results. |
| 3890 | */ |
| 3891 | CXCompletionContext_ObjCObjectValue = 1 << 2, |
| 3892 | /** |
| 3893 | * \brief Completions for values that resolve to an Objective-C selector |
| 3894 | * should be included in the results. |
| 3895 | */ |
| 3896 | CXCompletionContext_ObjCSelectorValue = 1 << 3, |
| 3897 | /** |
| 3898 | * \brief Completions for values that resolve to a C++ class type should be |
| 3899 | * included in the results. |
| 3900 | */ |
| 3901 | CXCompletionContext_CXXClassTypeValue = 1 << 4, |
| 3902 | |
| 3903 | /** |
| 3904 | * \brief Completions for fields of the member being accessed using the dot |
| 3905 | * operator should be included in the results. |
| 3906 | */ |
| 3907 | CXCompletionContext_DotMemberAccess = 1 << 5, |
| 3908 | /** |
| 3909 | * \brief Completions for fields of the member being accessed using the arrow |
| 3910 | * operator should be included in the results. |
| 3911 | */ |
| 3912 | CXCompletionContext_ArrowMemberAccess = 1 << 6, |
| 3913 | /** |
| 3914 | * \brief Completions for properties of the Objective-C object being accessed |
| 3915 | * using the dot operator should be included in the results. |
| 3916 | */ |
| 3917 | CXCompletionContext_ObjCPropertyAccess = 1 << 7, |
| 3918 | |
| 3919 | /** |
| 3920 | * \brief Completions for enum tags should be included in the results. |
| 3921 | */ |
| 3922 | CXCompletionContext_EnumTag = 1 << 8, |
| 3923 | /** |
| 3924 | * \brief Completions for union tags should be included in the results. |
| 3925 | */ |
| 3926 | CXCompletionContext_UnionTag = 1 << 9, |
| 3927 | /** |
| 3928 | * \brief Completions for struct tags should be included in the results. |
| 3929 | */ |
| 3930 | CXCompletionContext_StructTag = 1 << 10, |
| 3931 | |
| 3932 | /** |
| 3933 | * \brief Completions for C++ class names should be included in the results. |
| 3934 | */ |
| 3935 | CXCompletionContext_ClassTag = 1 << 11, |
| 3936 | /** |
| 3937 | * \brief Completions for C++ namespaces and namespace aliases should be |
| 3938 | * included in the results. |
| 3939 | */ |
| 3940 | CXCompletionContext_Namespace = 1 << 12, |
| 3941 | /** |
| 3942 | * \brief Completions for C++ nested name specifiers should be included in |
| 3943 | * the results. |
| 3944 | */ |
| 3945 | CXCompletionContext_NestedNameSpecifier = 1 << 13, |
| 3946 | |
| 3947 | /** |
| 3948 | * \brief Completions for Objective-C interfaces (classes) should be included |
| 3949 | * in the results. |
| 3950 | */ |
| 3951 | CXCompletionContext_ObjCInterface = 1 << 14, |
| 3952 | /** |
| 3953 | * \brief Completions for Objective-C protocols should be included in |
| 3954 | * the results. |
| 3955 | */ |
| 3956 | CXCompletionContext_ObjCProtocol = 1 << 15, |
| 3957 | /** |
| 3958 | * \brief Completions for Objective-C categories should be included in |
| 3959 | * the results. |
| 3960 | */ |
| 3961 | CXCompletionContext_ObjCCategory = 1 << 16, |
| 3962 | /** |
| 3963 | * \brief Completions for Objective-C instance messages should be included |
| 3964 | * in the results. |
| 3965 | */ |
| 3966 | CXCompletionContext_ObjCInstanceMessage = 1 << 17, |
| 3967 | /** |
| 3968 | * \brief Completions for Objective-C class messages should be included in |
| 3969 | * the results. |
| 3970 | */ |
| 3971 | CXCompletionContext_ObjCClassMessage = 1 << 18, |
| 3972 | /** |
| 3973 | * \brief Completions for Objective-C selector names should be included in |
| 3974 | * the results. |
| 3975 | */ |
| 3976 | CXCompletionContext_ObjCSelectorName = 1 << 19, |
| 3977 | |
| 3978 | /** |
| 3979 | * \brief Completions for preprocessor macro names should be included in |
| 3980 | * the results. |
| 3981 | */ |
| 3982 | CXCompletionContext_MacroName = 1 << 20, |
| 3983 | |
| 3984 | /** |
| 3985 | * \brief Natural language completions should be included in the results. |
| 3986 | */ |
| 3987 | CXCompletionContext_NaturalLanguage = 1 << 21, |
| 3988 | |
| 3989 | /** |
| 3990 | * \brief The current context is unknown, so set all contexts. |
| 3991 | */ |
| 3992 | CXCompletionContext_Unknown = ((1 << 22) - 1) |
| 3993 | }; |
| 3994 | |
| 3995 | /** |
Douglas Gregor | cee235c | 2010-08-05 09:09:23 +0000 | [diff] [blame] | 3996 | * \brief Returns a default set of code-completion options that can be |
| 3997 | * passed to\c clang_codeCompleteAt(). |
| 3998 | */ |
| 3999 | CINDEX_LINKAGE unsigned clang_defaultCodeCompleteOptions(void); |
| 4000 | |
| 4001 | /** |
Douglas Gregor | 1abc6bc | 2010-08-04 16:47:14 +0000 | [diff] [blame] | 4002 | * \brief Perform code completion at a given location in a translation unit. |
| 4003 | * |
| 4004 | * This function performs code completion at a particular file, line, and |
| 4005 | * column within source code, providing results that suggest potential |
| 4006 | * code snippets based on the context of the completion. The basic model |
| 4007 | * for code completion is that Clang will parse a complete source file, |
| 4008 | * performing syntax checking up to the location where code-completion has |
| 4009 | * been requested. At that point, a special code-completion token is passed |
| 4010 | * to the parser, which recognizes this token and determines, based on the |
| 4011 | * current location in the C/Objective-C/C++ grammar and the state of |
| 4012 | * semantic analysis, what completions to provide. These completions are |
| 4013 | * returned via a new \c CXCodeCompleteResults structure. |
| 4014 | * |
| 4015 | * Code completion itself is meant to be triggered by the client when the |
| 4016 | * user types punctuation characters or whitespace, at which point the |
| 4017 | * code-completion location will coincide with the cursor. For example, if \c p |
| 4018 | * is a pointer, code-completion might be triggered after the "-" and then |
| 4019 | * after the ">" in \c p->. When the code-completion location is afer the ">", |
| 4020 | * the completion results will provide, e.g., the members of the struct that |
| 4021 | * "p" points to. The client is responsible for placing the cursor at the |
| 4022 | * beginning of the token currently being typed, then filtering the results |
| 4023 | * based on the contents of the token. For example, when code-completing for |
| 4024 | * the expression \c p->get, the client should provide the location just after |
| 4025 | * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the |
| 4026 | * client can filter the results based on the current token text ("get"), only |
| 4027 | * showing those results that start with "get". The intent of this interface |
| 4028 | * is to separate the relatively high-latency acquisition of code-completion |
| 4029 | * results from the filtering of results on a per-character basis, which must |
| 4030 | * have a lower latency. |
| 4031 | * |
| 4032 | * \param TU The translation unit in which code-completion should |
| 4033 | * occur. The source files for this translation unit need not be |
| 4034 | * completely up-to-date (and the contents of those source files may |
| 4035 | * be overridden via \p unsaved_files). Cursors referring into the |
| 4036 | * translation unit may be invalidated by this invocation. |
| 4037 | * |
| 4038 | * \param complete_filename The name of the source file where code |
| 4039 | * completion should be performed. This filename may be any file |
| 4040 | * included in the translation unit. |
| 4041 | * |
| 4042 | * \param complete_line The line at which code-completion should occur. |
| 4043 | * |
| 4044 | * \param complete_column The column at which code-completion should occur. |
| 4045 | * Note that the column should point just after the syntactic construct that |
| 4046 | * initiated code completion, and not in the middle of a lexical token. |
| 4047 | * |
| 4048 | * \param unsaved_files the Tiles that have not yet been saved to disk |
| 4049 | * but may be required for parsing or code completion, including the |
| 4050 | * contents of those files. The contents and name of these files (as |
| 4051 | * specified by CXUnsavedFile) are copied when necessary, so the |
| 4052 | * client only needs to guarantee their validity until the call to |
| 4053 | * this function returns. |
| 4054 | * |
| 4055 | * \param num_unsaved_files The number of unsaved file entries in \p |
| 4056 | * unsaved_files. |
| 4057 | * |
Douglas Gregor | cee235c | 2010-08-05 09:09:23 +0000 | [diff] [blame] | 4058 | * \param options Extra options that control the behavior of code |
| 4059 | * completion, expressed as a bitwise OR of the enumerators of the |
| 4060 | * CXCodeComplete_Flags enumeration. The |
| 4061 | * \c clang_defaultCodeCompleteOptions() function returns a default set |
| 4062 | * of code-completion options. |
| 4063 | * |
Douglas Gregor | 1abc6bc | 2010-08-04 16:47:14 +0000 | [diff] [blame] | 4064 | * \returns If successful, a new \c CXCodeCompleteResults structure |
| 4065 | * containing code-completion results, which should eventually be |
| 4066 | * freed with \c clang_disposeCodeCompleteResults(). If code |
| 4067 | * completion fails, returns NULL. |
| 4068 | */ |
| 4069 | CINDEX_LINKAGE |
| 4070 | CXCodeCompleteResults *clang_codeCompleteAt(CXTranslationUnit TU, |
| 4071 | const char *complete_filename, |
| 4072 | unsigned complete_line, |
| 4073 | unsigned complete_column, |
| 4074 | struct CXUnsavedFile *unsaved_files, |
Douglas Gregor | cee235c | 2010-08-05 09:09:23 +0000 | [diff] [blame] | 4075 | unsigned num_unsaved_files, |
| 4076 | unsigned options); |
Douglas Gregor | 1abc6bc | 2010-08-04 16:47:14 +0000 | [diff] [blame] | 4077 | |
| 4078 | /** |
Douglas Gregor | 1e5e668 | 2010-08-26 13:48:20 +0000 | [diff] [blame] | 4079 | * \brief Sort the code-completion results in case-insensitive alphabetical |
| 4080 | * order. |
| 4081 | * |
| 4082 | * \param Results The set of results to sort. |
| 4083 | * \param NumResults The number of results in \p Results. |
| 4084 | */ |
| 4085 | CINDEX_LINKAGE |
| 4086 | void clang_sortCodeCompletionResults(CXCompletionResult *Results, |
| 4087 | unsigned NumResults); |
| 4088 | |
| 4089 | /** |
Douglas Gregor | ec6762c | 2009-12-18 16:20:58 +0000 | [diff] [blame] | 4090 | * \brief Free the given set of code-completion results. |
| 4091 | */ |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 4092 | CINDEX_LINKAGE |
Douglas Gregor | ec6762c | 2009-12-18 16:20:58 +0000 | [diff] [blame] | 4093 | void clang_disposeCodeCompleteResults(CXCodeCompleteResults *Results); |
Douglas Gregor | 58ddb60 | 2010-08-23 23:00:57 +0000 | [diff] [blame] | 4094 | |
Douglas Gregor | 20d416c | 2010-01-20 01:10:47 +0000 | [diff] [blame] | 4095 | /** |
Douglas Gregor | a88084b | 2010-02-18 18:08:43 +0000 | [diff] [blame] | 4096 | * \brief Determine the number of diagnostics produced prior to the |
| 4097 | * location where code completion was performed. |
| 4098 | */ |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 4099 | CINDEX_LINKAGE |
Douglas Gregor | a88084b | 2010-02-18 18:08:43 +0000 | [diff] [blame] | 4100 | unsigned clang_codeCompleteGetNumDiagnostics(CXCodeCompleteResults *Results); |
| 4101 | |
| 4102 | /** |
| 4103 | * \brief Retrieve a diagnostic associated with the given code completion. |
| 4104 | * |
| 4105 | * \param Result the code completion results to query. |
| 4106 | * \param Index the zero-based diagnostic number to retrieve. |
| 4107 | * |
| 4108 | * \returns the requested diagnostic. This diagnostic must be freed |
| 4109 | * via a call to \c clang_disposeDiagnostic(). |
| 4110 | */ |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 4111 | CINDEX_LINKAGE |
Douglas Gregor | a88084b | 2010-02-18 18:08:43 +0000 | [diff] [blame] | 4112 | CXDiagnostic clang_codeCompleteGetDiagnostic(CXCodeCompleteResults *Results, |
| 4113 | unsigned Index); |
| 4114 | |
| 4115 | /** |
Douglas Gregor | 3da626b | 2011-07-07 16:03:39 +0000 | [diff] [blame] | 4116 | * \brief Determines what compeltions are appropriate for the context |
| 4117 | * the given code completion. |
| 4118 | * |
| 4119 | * \param Results the code completion results to query |
| 4120 | * |
| 4121 | * \returns the kinds of completions that are appropriate for use |
| 4122 | * along with the given code completion results. |
| 4123 | */ |
| 4124 | CINDEX_LINKAGE |
| 4125 | unsigned long long clang_codeCompleteGetContexts( |
| 4126 | CXCodeCompleteResults *Results); |
Douglas Gregor | e081a61 | 2011-07-21 01:05:26 +0000 | [diff] [blame] | 4127 | |
| 4128 | /** |
| 4129 | * \brief Returns the cursor kind for the container for the current code |
| 4130 | * completion context. The container is only guaranteed to be set for |
| 4131 | * contexts where a container exists (i.e. member accesses or Objective-C |
| 4132 | * message sends); if there is not a container, this function will return |
| 4133 | * CXCursor_InvalidCode. |
| 4134 | * |
| 4135 | * \param Results the code completion results to query |
| 4136 | * |
| 4137 | * \param IsIncomplete on return, this value will be false if Clang has complete |
| 4138 | * information about the container. If Clang does not have complete |
| 4139 | * information, this value will be true. |
| 4140 | * |
| 4141 | * \returns the container kind, or CXCursor_InvalidCode if there is not a |
| 4142 | * container |
| 4143 | */ |
| 4144 | CINDEX_LINKAGE |
| 4145 | enum CXCursorKind clang_codeCompleteGetContainerKind( |
| 4146 | CXCodeCompleteResults *Results, |
| 4147 | unsigned *IsIncomplete); |
| 4148 | |
| 4149 | /** |
| 4150 | * \brief Returns the USR for the container for the current code completion |
| 4151 | * context. If there is not a container for the current context, this |
| 4152 | * function will return the empty string. |
| 4153 | * |
| 4154 | * \param Results the code completion results to query |
| 4155 | * |
| 4156 | * \returns the USR for the container |
| 4157 | */ |
| 4158 | CINDEX_LINKAGE |
| 4159 | CXString clang_codeCompleteGetContainerUSR(CXCodeCompleteResults *Results); |
Douglas Gregor | 3da626b | 2011-07-07 16:03:39 +0000 | [diff] [blame] | 4160 | |
Douglas Gregor | 0a47d69 | 2011-07-26 15:24:30 +0000 | [diff] [blame] | 4161 | |
| 4162 | /** |
| 4163 | * \brief Returns the currently-entered selector for an Objective-C message |
| 4164 | * send, formatted like "initWithFoo:bar:". Only guaranteed to return a |
| 4165 | * non-empty string for CXCompletionContext_ObjCInstanceMessage and |
| 4166 | * CXCompletionContext_ObjCClassMessage. |
| 4167 | * |
| 4168 | * \param Results the code completion results to query |
| 4169 | * |
| 4170 | * \returns the selector (or partial selector) that has been entered thus far |
| 4171 | * for an Objective-C message send. |
| 4172 | */ |
| 4173 | CINDEX_LINKAGE |
| 4174 | CXString clang_codeCompleteGetObjCSelector(CXCodeCompleteResults *Results); |
| 4175 | |
Douglas Gregor | 3da626b | 2011-07-07 16:03:39 +0000 | [diff] [blame] | 4176 | /** |
Douglas Gregor | 20d416c | 2010-01-20 01:10:47 +0000 | [diff] [blame] | 4177 | * @} |
| 4178 | */ |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 4179 | |
| 4180 | |
Ted Kremenek | 04bb716 | 2010-01-22 22:44:15 +0000 | [diff] [blame] | 4181 | /** |
| 4182 | * \defgroup CINDEX_MISC Miscellaneous utility functions |
| 4183 | * |
| 4184 | * @{ |
| 4185 | */ |
Ted Kremenek | 23e1ad0 | 2010-01-23 17:51:23 +0000 | [diff] [blame] | 4186 | |
| 4187 | /** |
| 4188 | * \brief Return a version string, suitable for showing to a user, but not |
| 4189 | * intended to be parsed (the format is not guaranteed to be stable). |
| 4190 | */ |
Ted Kremenek | a2a9d6e | 2010-02-12 22:54:40 +0000 | [diff] [blame] | 4191 | CINDEX_LINKAGE CXString clang_getClangVersion(); |
Ted Kremenek | 04bb716 | 2010-01-22 22:44:15 +0000 | [diff] [blame] | 4192 | |
Ted Kremenek | d2427dd | 2011-03-18 23:05:39 +0000 | [diff] [blame] | 4193 | |
| 4194 | /** |
| 4195 | * \brief Enable/disable crash recovery. |
| 4196 | * |
| 4197 | * \param Flag to indicate if crash recovery is enabled. A non-zero value |
| 4198 | * enables crash recovery, while 0 disables it. |
| 4199 | */ |
| 4200 | CINDEX_LINKAGE void clang_toggleCrashRecovery(unsigned isEnabled); |
| 4201 | |
Ted Kremenek | 16b55a7 | 2010-01-26 19:31:51 +0000 | [diff] [blame] | 4202 | /** |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 4203 | * \brief Visitor invoked for each file in a translation unit |
Ted Kremenek | 16b55a7 | 2010-01-26 19:31:51 +0000 | [diff] [blame] | 4204 | * (used with clang_getInclusions()). |
| 4205 | * |
| 4206 | * This visitor function will be invoked by clang_getInclusions() for each |
| 4207 | * file included (either at the top-level or by #include directives) within |
| 4208 | * a translation unit. The first argument is the file being included, and |
| 4209 | * the second and third arguments provide the inclusion stack. The |
| 4210 | * array is sorted in order of immediate inclusion. For example, |
| 4211 | * the first element refers to the location that included 'included_file'. |
| 4212 | */ |
| 4213 | typedef void (*CXInclusionVisitor)(CXFile included_file, |
| 4214 | CXSourceLocation* inclusion_stack, |
| 4215 | unsigned include_len, |
| 4216 | CXClientData client_data); |
| 4217 | |
| 4218 | /** |
| 4219 | * \brief Visit the set of preprocessor inclusions in a translation unit. |
| 4220 | * The visitor function is called with the provided data for every included |
| 4221 | * file. This does not include headers included by the PCH file (unless one |
| 4222 | * is inspecting the inclusions in the PCH file itself). |
| 4223 | */ |
| 4224 | CINDEX_LINKAGE void clang_getInclusions(CXTranslationUnit tu, |
| 4225 | CXInclusionVisitor visitor, |
| 4226 | CXClientData client_data); |
| 4227 | |
| 4228 | /** |
Ted Kremenek | 04bb716 | 2010-01-22 22:44:15 +0000 | [diff] [blame] | 4229 | * @} |
| 4230 | */ |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 4231 | |
Argyrios Kyrtzidis | 97c337c | 2011-07-11 20:15:00 +0000 | [diff] [blame] | 4232 | /** \defgroup CINDEX_REMAPPING Remapping functions |
| 4233 | * |
| 4234 | * @{ |
| 4235 | */ |
| 4236 | |
| 4237 | /** |
| 4238 | * \brief A remapping of original source files and their translated files. |
| 4239 | */ |
| 4240 | typedef void *CXRemapping; |
| 4241 | |
| 4242 | /** |
| 4243 | * \brief Retrieve a remapping. |
| 4244 | * |
| 4245 | * \param path the path that contains metadata about remappings. |
| 4246 | * |
| 4247 | * \returns the requested remapping. This remapping must be freed |
| 4248 | * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred. |
| 4249 | */ |
| 4250 | CINDEX_LINKAGE CXRemapping clang_getRemappings(const char *path); |
| 4251 | |
| 4252 | /** |
Ted Kremenek | 30660a8 | 2012-03-06 20:06:33 +0000 | [diff] [blame] | 4253 | * \brief Retrieve a remapping. |
| 4254 | * |
| 4255 | * \param filePaths pointer to an array of file paths containing remapping info. |
| 4256 | * |
| 4257 | * \param numFiles number of file paths. |
| 4258 | * |
| 4259 | * \returns the requested remapping. This remapping must be freed |
| 4260 | * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred. |
| 4261 | */ |
| 4262 | CINDEX_LINKAGE |
| 4263 | CXRemapping clang_getRemappingsFromFileList(const char **filePaths, |
| 4264 | unsigned numFiles); |
| 4265 | |
| 4266 | /** |
Argyrios Kyrtzidis | 97c337c | 2011-07-11 20:15:00 +0000 | [diff] [blame] | 4267 | * \brief Determine the number of remappings. |
| 4268 | */ |
| 4269 | CINDEX_LINKAGE unsigned clang_remap_getNumFiles(CXRemapping); |
| 4270 | |
| 4271 | /** |
| 4272 | * \brief Get the original and the associated filename from the remapping. |
| 4273 | * |
| 4274 | * \param original If non-NULL, will be set to the original filename. |
| 4275 | * |
| 4276 | * \param transformed If non-NULL, will be set to the filename that the original |
| 4277 | * is associated with. |
| 4278 | */ |
| 4279 | CINDEX_LINKAGE void clang_remap_getFilenames(CXRemapping, unsigned index, |
| 4280 | CXString *original, CXString *transformed); |
| 4281 | |
| 4282 | /** |
| 4283 | * \brief Dispose the remapping. |
| 4284 | */ |
| 4285 | CINDEX_LINKAGE void clang_remap_dispose(CXRemapping); |
| 4286 | |
| 4287 | /** |
| 4288 | * @} |
| 4289 | */ |
| 4290 | |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 4291 | /** \defgroup CINDEX_HIGH Higher level API functions |
| 4292 | * |
| 4293 | * @{ |
| 4294 | */ |
| 4295 | |
| 4296 | enum CXVisitorResult { |
| 4297 | CXVisit_Break, |
| 4298 | CXVisit_Continue |
| 4299 | }; |
| 4300 | |
| 4301 | typedef struct { |
| 4302 | void *context; |
| 4303 | enum CXVisitorResult (*visit)(void *context, CXCursor, CXSourceRange); |
| 4304 | } CXCursorAndRangeVisitor; |
| 4305 | |
| 4306 | /** |
| 4307 | * \brief Find references of a declaration in a specific file. |
| 4308 | * |
| 4309 | * \param cursor pointing to a declaration or a reference of one. |
| 4310 | * |
| 4311 | * \param file to search for references. |
| 4312 | * |
| 4313 | * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for |
| 4314 | * each reference found. |
| 4315 | * The CXSourceRange will point inside the file; if the reference is inside |
| 4316 | * a macro (and not a macro argument) the CXSourceRange will be invalid. |
| 4317 | */ |
| 4318 | CINDEX_LINKAGE void clang_findReferencesInFile(CXCursor cursor, CXFile file, |
| 4319 | CXCursorAndRangeVisitor visitor); |
| 4320 | |
| 4321 | #ifdef __has_feature |
| 4322 | # if __has_feature(blocks) |
| 4323 | |
| 4324 | typedef enum CXVisitorResult |
| 4325 | (^CXCursorAndRangeVisitorBlock)(CXCursor, CXSourceRange); |
| 4326 | |
| 4327 | CINDEX_LINKAGE |
| 4328 | void clang_findReferencesInFileWithBlock(CXCursor, CXFile, |
| 4329 | CXCursorAndRangeVisitorBlock); |
| 4330 | |
| 4331 | # endif |
| 4332 | #endif |
| 4333 | |
Argyrios Kyrtzidis | bd0ddf8 | 2011-10-27 17:36:12 +0000 | [diff] [blame] | 4334 | /** |
| 4335 | * \brief The client's data object that is associated with a CXFile. |
| 4336 | */ |
Argyrios Kyrtzidis | dd93c59 | 2011-11-11 00:23:36 +0000 | [diff] [blame] | 4337 | typedef void *CXIdxClientFile; |
Argyrios Kyrtzidis | bd0ddf8 | 2011-10-27 17:36:12 +0000 | [diff] [blame] | 4338 | |
| 4339 | /** |
Argyrios Kyrtzidis | 2957e6f | 2011-11-22 07:24:51 +0000 | [diff] [blame] | 4340 | * \brief The client's data object that is associated with a semantic entity. |
| 4341 | */ |
| 4342 | typedef void *CXIdxClientEntity; |
| 4343 | |
| 4344 | /** |
Argyrios Kyrtzidis | bd0ddf8 | 2011-10-27 17:36:12 +0000 | [diff] [blame] | 4345 | * \brief The client's data object that is associated with a semantic container |
| 4346 | * of entities. |
Argyrios Kyrtzidis | bd0ddf8 | 2011-10-27 17:36:12 +0000 | [diff] [blame] | 4347 | */ |
Argyrios Kyrtzidis | dd93c59 | 2011-11-11 00:23:36 +0000 | [diff] [blame] | 4348 | typedef void *CXIdxClientContainer; |
Argyrios Kyrtzidis | bd0ddf8 | 2011-10-27 17:36:12 +0000 | [diff] [blame] | 4349 | |
| 4350 | /** |
Argyrios Kyrtzidis | bd0ddf8 | 2011-10-27 17:36:12 +0000 | [diff] [blame] | 4351 | * \brief The client's data object that is associated with an AST file (PCH |
| 4352 | * or module). |
| 4353 | */ |
Argyrios Kyrtzidis | dd93c59 | 2011-11-11 00:23:36 +0000 | [diff] [blame] | 4354 | typedef void *CXIdxClientASTFile; |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 4355 | |
Argyrios Kyrtzidis | bd0ddf8 | 2011-10-27 17:36:12 +0000 | [diff] [blame] | 4356 | /** |
Argyrios Kyrtzidis | dd93c59 | 2011-11-11 00:23:36 +0000 | [diff] [blame] | 4357 | * \brief Source location passed to index callbacks. |
Argyrios Kyrtzidis | bd0ddf8 | 2011-10-27 17:36:12 +0000 | [diff] [blame] | 4358 | */ |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 4359 | typedef struct { |
| 4360 | void *ptr_data[2]; |
| 4361 | unsigned int_data; |
| 4362 | } CXIdxLoc; |
| 4363 | |
Argyrios Kyrtzidis | bd0ddf8 | 2011-10-27 17:36:12 +0000 | [diff] [blame] | 4364 | /** |
| 4365 | * \brief Data for \see ppIncludedFile callback. |
| 4366 | */ |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 4367 | typedef struct { |
Argyrios Kyrtzidis | bd0ddf8 | 2011-10-27 17:36:12 +0000 | [diff] [blame] | 4368 | /** |
| 4369 | * \brief Location of '#' in the #include/#import directive. |
| 4370 | */ |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 4371 | CXIdxLoc hashLoc; |
Argyrios Kyrtzidis | bd0ddf8 | 2011-10-27 17:36:12 +0000 | [diff] [blame] | 4372 | /** |
| 4373 | * \brief Filename as written in the #include/#import directive. |
| 4374 | */ |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 4375 | const char *filename; |
Argyrios Kyrtzidis | bd0ddf8 | 2011-10-27 17:36:12 +0000 | [diff] [blame] | 4376 | /** |
| 4377 | * \brief The actual file that the #include/#import directive resolved to. |
| 4378 | */ |
Argyrios Kyrtzidis | dd93c59 | 2011-11-11 00:23:36 +0000 | [diff] [blame] | 4379 | CXFile file; |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 4380 | int isImport; |
| 4381 | int isAngled; |
| 4382 | } CXIdxIncludedFileInfo; |
| 4383 | |
Argyrios Kyrtzidis | bd0ddf8 | 2011-10-27 17:36:12 +0000 | [diff] [blame] | 4384 | /** |
| 4385 | * \brief Data for \see importedASTFile callback. |
| 4386 | */ |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 4387 | typedef struct { |
| 4388 | CXFile file; |
Argyrios Kyrtzidis | bd0ddf8 | 2011-10-27 17:36:12 +0000 | [diff] [blame] | 4389 | /** |
| 4390 | * \brief Location where the file is imported. It is useful mostly for |
| 4391 | * modules. |
| 4392 | */ |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 4393 | CXIdxLoc loc; |
Argyrios Kyrtzidis | bd0ddf8 | 2011-10-27 17:36:12 +0000 | [diff] [blame] | 4394 | /** |
| 4395 | * \brief Non-zero if the AST file is a module otherwise it's a PCH. |
| 4396 | */ |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 4397 | int isModule; |
| 4398 | } CXIdxImportedASTFileInfo; |
| 4399 | |
Argyrios Kyrtzidis | dd93c59 | 2011-11-11 00:23:36 +0000 | [diff] [blame] | 4400 | typedef enum { |
| 4401 | CXIdxEntity_Unexposed = 0, |
| 4402 | CXIdxEntity_Typedef = 1, |
| 4403 | CXIdxEntity_Function = 2, |
| 4404 | CXIdxEntity_Variable = 3, |
| 4405 | CXIdxEntity_Field = 4, |
| 4406 | CXIdxEntity_EnumConstant = 5, |
| 4407 | |
| 4408 | CXIdxEntity_ObjCClass = 6, |
| 4409 | CXIdxEntity_ObjCProtocol = 7, |
| 4410 | CXIdxEntity_ObjCCategory = 8, |
| 4411 | |
Argyrios Kyrtzidis | c71d554 | 2011-11-14 22:39:19 +0000 | [diff] [blame] | 4412 | CXIdxEntity_ObjCInstanceMethod = 9, |
| 4413 | CXIdxEntity_ObjCClassMethod = 10, |
| 4414 | CXIdxEntity_ObjCProperty = 11, |
| 4415 | CXIdxEntity_ObjCIvar = 12, |
Argyrios Kyrtzidis | dd93c59 | 2011-11-11 00:23:36 +0000 | [diff] [blame] | 4416 | |
Argyrios Kyrtzidis | c71d554 | 2011-11-14 22:39:19 +0000 | [diff] [blame] | 4417 | CXIdxEntity_Enum = 13, |
| 4418 | CXIdxEntity_Struct = 14, |
| 4419 | CXIdxEntity_Union = 15, |
Argyrios Kyrtzidis | 2957e6f | 2011-11-22 07:24:51 +0000 | [diff] [blame] | 4420 | |
| 4421 | CXIdxEntity_CXXClass = 16, |
| 4422 | CXIdxEntity_CXXNamespace = 17, |
| 4423 | CXIdxEntity_CXXNamespaceAlias = 18, |
| 4424 | CXIdxEntity_CXXStaticVariable = 19, |
| 4425 | CXIdxEntity_CXXStaticMethod = 20, |
| 4426 | CXIdxEntity_CXXInstanceMethod = 21, |
| 4427 | CXIdxEntity_CXXConstructor = 22, |
| 4428 | CXIdxEntity_CXXDestructor = 23, |
| 4429 | CXIdxEntity_CXXConversionFunction = 24, |
Argyrios Kyrtzidis | 838d3c2 | 2011-12-07 20:44:12 +0000 | [diff] [blame] | 4430 | CXIdxEntity_CXXTypeAlias = 25 |
Argyrios Kyrtzidis | dd93c59 | 2011-11-11 00:23:36 +0000 | [diff] [blame] | 4431 | |
| 4432 | } CXIdxEntityKind; |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 4433 | |
Argyrios Kyrtzidis | 838d3c2 | 2011-12-07 20:44:12 +0000 | [diff] [blame] | 4434 | typedef enum { |
| 4435 | CXIdxEntityLang_None = 0, |
| 4436 | CXIdxEntityLang_C = 1, |
| 4437 | CXIdxEntityLang_ObjC = 2, |
| 4438 | CXIdxEntityLang_CXX = 3 |
| 4439 | } CXIdxEntityLanguage; |
| 4440 | |
Argyrios Kyrtzidis | 2957e6f | 2011-11-22 07:24:51 +0000 | [diff] [blame] | 4441 | /** |
| 4442 | * \brief Extra C++ template information for an entity. This can apply to: |
| 4443 | * CXIdxEntity_Function |
| 4444 | * CXIdxEntity_CXXClass |
| 4445 | * CXIdxEntity_CXXStaticMethod |
| 4446 | * CXIdxEntity_CXXInstanceMethod |
| 4447 | * CXIdxEntity_CXXConstructor |
| 4448 | * CXIdxEntity_CXXConversionFunction |
| 4449 | * CXIdxEntity_CXXTypeAlias |
| 4450 | */ |
| 4451 | typedef enum { |
| 4452 | CXIdxEntity_NonTemplate = 0, |
| 4453 | CXIdxEntity_Template = 1, |
| 4454 | CXIdxEntity_TemplatePartialSpecialization = 2, |
| 4455 | CXIdxEntity_TemplateSpecialization = 3 |
| 4456 | } CXIdxEntityCXXTemplateKind; |
| 4457 | |
Argyrios Kyrtzidis | b395c63 | 2011-11-18 00:26:51 +0000 | [diff] [blame] | 4458 | typedef enum { |
| 4459 | CXIdxAttr_Unexposed = 0, |
| 4460 | CXIdxAttr_IBAction = 1, |
| 4461 | CXIdxAttr_IBOutlet = 2, |
| 4462 | CXIdxAttr_IBOutletCollection = 3 |
| 4463 | } CXIdxAttrKind; |
| 4464 | |
| 4465 | typedef struct { |
| 4466 | CXIdxAttrKind kind; |
| 4467 | CXCursor cursor; |
| 4468 | CXIdxLoc loc; |
| 4469 | } CXIdxAttrInfo; |
| 4470 | |
| 4471 | typedef struct { |
Argyrios Kyrtzidis | 643d3ce | 2011-12-15 00:05:00 +0000 | [diff] [blame] | 4472 | CXIdxEntityKind kind; |
| 4473 | CXIdxEntityCXXTemplateKind templateKind; |
| 4474 | CXIdxEntityLanguage lang; |
| 4475 | const char *name; |
| 4476 | const char *USR; |
| 4477 | CXCursor cursor; |
| 4478 | const CXIdxAttrInfo *const *attributes; |
| 4479 | unsigned numAttributes; |
| 4480 | } CXIdxEntityInfo; |
| 4481 | |
| 4482 | typedef struct { |
| 4483 | CXCursor cursor; |
| 4484 | } CXIdxContainerInfo; |
| 4485 | |
| 4486 | typedef struct { |
Argyrios Kyrtzidis | b395c63 | 2011-11-18 00:26:51 +0000 | [diff] [blame] | 4487 | const CXIdxAttrInfo *attrInfo; |
| 4488 | const CXIdxEntityInfo *objcClass; |
| 4489 | CXCursor classCursor; |
| 4490 | CXIdxLoc classLoc; |
| 4491 | } CXIdxIBOutletCollectionAttrInfo; |
| 4492 | |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 4493 | typedef struct { |
Argyrios Kyrtzidis | 6ec43ad | 2011-11-12 02:16:30 +0000 | [diff] [blame] | 4494 | const CXIdxEntityInfo *entityInfo; |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 4495 | CXCursor cursor; |
| 4496 | CXIdxLoc loc; |
Argyrios Kyrtzidis | b1febb6 | 2011-12-07 20:44:19 +0000 | [diff] [blame] | 4497 | const CXIdxContainerInfo *semanticContainer; |
| 4498 | /** |
| 4499 | * \brief Generally same as \see semanticContainer but can be different in |
| 4500 | * cases like out-of-line C++ member functions. |
| 4501 | */ |
| 4502 | const CXIdxContainerInfo *lexicalContainer; |
Argyrios Kyrtzidis | dd93c59 | 2011-11-11 00:23:36 +0000 | [diff] [blame] | 4503 | int isRedeclaration; |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 4504 | int isDefinition; |
Argyrios Kyrtzidis | c71d554 | 2011-11-14 22:39:19 +0000 | [diff] [blame] | 4505 | int isContainer; |
Argyrios Kyrtzidis | 2957e6f | 2011-11-22 07:24:51 +0000 | [diff] [blame] | 4506 | const CXIdxContainerInfo *declAsContainer; |
Argyrios Kyrtzidis | c71d554 | 2011-11-14 22:39:19 +0000 | [diff] [blame] | 4507 | /** |
| 4508 | * \brief Whether the declaration exists in code or was created implicitly |
| 4509 | * by the compiler, e.g. implicit objc methods for properties. |
| 4510 | */ |
| 4511 | int isImplicit; |
Argyrios Kyrtzidis | b395c63 | 2011-11-18 00:26:51 +0000 | [diff] [blame] | 4512 | const CXIdxAttrInfo *const *attributes; |
| 4513 | unsigned numAttributes; |
Argyrios Kyrtzidis | dd93c59 | 2011-11-11 00:23:36 +0000 | [diff] [blame] | 4514 | } CXIdxDeclInfo; |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 4515 | |
Argyrios Kyrtzidis | dd93c59 | 2011-11-11 00:23:36 +0000 | [diff] [blame] | 4516 | typedef enum { |
| 4517 | CXIdxObjCContainer_ForwardRef = 0, |
| 4518 | CXIdxObjCContainer_Interface = 1, |
| 4519 | CXIdxObjCContainer_Implementation = 2 |
| 4520 | } CXIdxObjCContainerKind; |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 4521 | |
| 4522 | typedef struct { |
Argyrios Kyrtzidis | 6ec43ad | 2011-11-12 02:16:30 +0000 | [diff] [blame] | 4523 | const CXIdxDeclInfo *declInfo; |
Argyrios Kyrtzidis | dd93c59 | 2011-11-11 00:23:36 +0000 | [diff] [blame] | 4524 | CXIdxObjCContainerKind kind; |
| 4525 | } CXIdxObjCContainerDeclInfo; |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 4526 | |
| 4527 | typedef struct { |
Argyrios Kyrtzidis | 6ec43ad | 2011-11-12 02:16:30 +0000 | [diff] [blame] | 4528 | const CXIdxEntityInfo *base; |
| 4529 | CXCursor cursor; |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 4530 | CXIdxLoc loc; |
Argyrios Kyrtzidis | 6ec43ad | 2011-11-12 02:16:30 +0000 | [diff] [blame] | 4531 | } CXIdxBaseClassInfo; |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 4532 | |
| 4533 | typedef struct { |
Argyrios Kyrtzidis | 6ec43ad | 2011-11-12 02:16:30 +0000 | [diff] [blame] | 4534 | const CXIdxEntityInfo *protocol; |
| 4535 | CXCursor cursor; |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 4536 | CXIdxLoc loc; |
| 4537 | } CXIdxObjCProtocolRefInfo; |
| 4538 | |
| 4539 | typedef struct { |
Argyrios Kyrtzidis | 6ec43ad | 2011-11-12 02:16:30 +0000 | [diff] [blame] | 4540 | const CXIdxObjCProtocolRefInfo *const *protocols; |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 4541 | unsigned numProtocols; |
Argyrios Kyrtzidis | c71d554 | 2011-11-14 22:39:19 +0000 | [diff] [blame] | 4542 | } CXIdxObjCProtocolRefListInfo; |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 4543 | |
| 4544 | typedef struct { |
Argyrios Kyrtzidis | c71d554 | 2011-11-14 22:39:19 +0000 | [diff] [blame] | 4545 | const CXIdxObjCContainerDeclInfo *containerInfo; |
| 4546 | const CXIdxBaseClassInfo *superInfo; |
| 4547 | const CXIdxObjCProtocolRefListInfo *protocols; |
| 4548 | } CXIdxObjCInterfaceDeclInfo; |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 4549 | |
Argyrios Kyrtzidis | 2957e6f | 2011-11-22 07:24:51 +0000 | [diff] [blame] | 4550 | typedef struct { |
Argyrios Kyrtzidis | c10a4c8 | 2011-12-13 18:47:45 +0000 | [diff] [blame] | 4551 | const CXIdxObjCContainerDeclInfo *containerInfo; |
| 4552 | const CXIdxEntityInfo *objcClass; |
| 4553 | CXCursor classCursor; |
| 4554 | CXIdxLoc classLoc; |
| 4555 | const CXIdxObjCProtocolRefListInfo *protocols; |
| 4556 | } CXIdxObjCCategoryDeclInfo; |
| 4557 | |
| 4558 | typedef struct { |
Argyrios Kyrtzidis | 2957e6f | 2011-11-22 07:24:51 +0000 | [diff] [blame] | 4559 | const CXIdxDeclInfo *declInfo; |
Argyrios Kyrtzidis | 792db26 | 2012-02-28 17:50:33 +0000 | [diff] [blame] | 4560 | const CXIdxEntityInfo *getter; |
| 4561 | const CXIdxEntityInfo *setter; |
| 4562 | } CXIdxObjCPropertyDeclInfo; |
| 4563 | |
| 4564 | typedef struct { |
| 4565 | const CXIdxDeclInfo *declInfo; |
Argyrios Kyrtzidis | 2957e6f | 2011-11-22 07:24:51 +0000 | [diff] [blame] | 4566 | const CXIdxBaseClassInfo *const *bases; |
| 4567 | unsigned numBases; |
| 4568 | } CXIdxCXXClassDeclInfo; |
| 4569 | |
Argyrios Kyrtzidis | bd0ddf8 | 2011-10-27 17:36:12 +0000 | [diff] [blame] | 4570 | /** |
| 4571 | * \brief Data for \see indexEntityReference callback. |
| 4572 | */ |
Argyrios Kyrtzidis | aca19be | 2011-10-18 15:50:50 +0000 | [diff] [blame] | 4573 | typedef enum { |
Argyrios Kyrtzidis | bd0ddf8 | 2011-10-27 17:36:12 +0000 | [diff] [blame] | 4574 | /** |
| 4575 | * \brief The entity is referenced directly in user's code. |
| 4576 | */ |
Argyrios Kyrtzidis | aca19be | 2011-10-18 15:50:50 +0000 | [diff] [blame] | 4577 | CXIdxEntityRef_Direct = 1, |
Argyrios Kyrtzidis | bd0ddf8 | 2011-10-27 17:36:12 +0000 | [diff] [blame] | 4578 | /** |
Argyrios Kyrtzidis | b395c63 | 2011-11-18 00:26:51 +0000 | [diff] [blame] | 4579 | * \brief An implicit reference, e.g. a reference of an ObjC method via the |
| 4580 | * dot syntax. |
Argyrios Kyrtzidis | bd0ddf8 | 2011-10-27 17:36:12 +0000 | [diff] [blame] | 4581 | */ |
Argyrios Kyrtzidis | b395c63 | 2011-11-18 00:26:51 +0000 | [diff] [blame] | 4582 | CXIdxEntityRef_Implicit = 2 |
Argyrios Kyrtzidis | aca19be | 2011-10-18 15:50:50 +0000 | [diff] [blame] | 4583 | } CXIdxEntityRefKind; |
| 4584 | |
Argyrios Kyrtzidis | bd0ddf8 | 2011-10-27 17:36:12 +0000 | [diff] [blame] | 4585 | /** |
| 4586 | * \brief Data for \see indexEntityReference callback. |
| 4587 | */ |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 4588 | typedef struct { |
Argyrios Kyrtzidis | b1febb6 | 2011-12-07 20:44:19 +0000 | [diff] [blame] | 4589 | CXIdxEntityRefKind kind; |
Argyrios Kyrtzidis | bd0ddf8 | 2011-10-27 17:36:12 +0000 | [diff] [blame] | 4590 | /** |
| 4591 | * \brief Reference cursor. |
| 4592 | */ |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 4593 | CXCursor cursor; |
| 4594 | CXIdxLoc loc; |
Argyrios Kyrtzidis | bd0ddf8 | 2011-10-27 17:36:12 +0000 | [diff] [blame] | 4595 | /** |
| 4596 | * \brief The entity that gets referenced. |
| 4597 | */ |
Argyrios Kyrtzidis | 6ec43ad | 2011-11-12 02:16:30 +0000 | [diff] [blame] | 4598 | const CXIdxEntityInfo *referencedEntity; |
Argyrios Kyrtzidis | bd0ddf8 | 2011-10-27 17:36:12 +0000 | [diff] [blame] | 4599 | /** |
| 4600 | * \brief Immediate "parent" of the reference. For example: |
| 4601 | * |
| 4602 | * \code |
| 4603 | * Foo *var; |
| 4604 | * \endcode |
| 4605 | * |
| 4606 | * The parent of reference of type 'Foo' is the variable 'var'. |
Argyrios Kyrtzidis | e422e45 | 2011-12-13 18:47:41 +0000 | [diff] [blame] | 4607 | * For references inside statement bodies of functions/methods, |
| 4608 | * the parentEntity will be the function/method. |
Argyrios Kyrtzidis | bd0ddf8 | 2011-10-27 17:36:12 +0000 | [diff] [blame] | 4609 | */ |
Argyrios Kyrtzidis | 6ec43ad | 2011-11-12 02:16:30 +0000 | [diff] [blame] | 4610 | const CXIdxEntityInfo *parentEntity; |
Argyrios Kyrtzidis | bd0ddf8 | 2011-10-27 17:36:12 +0000 | [diff] [blame] | 4611 | /** |
Argyrios Kyrtzidis | e422e45 | 2011-12-13 18:47:41 +0000 | [diff] [blame] | 4612 | * \brief Lexical container context of the reference. |
Argyrios Kyrtzidis | bd0ddf8 | 2011-10-27 17:36:12 +0000 | [diff] [blame] | 4613 | */ |
Argyrios Kyrtzidis | 2957e6f | 2011-11-22 07:24:51 +0000 | [diff] [blame] | 4614 | const CXIdxContainerInfo *container; |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 4615 | } CXIdxEntityRefInfo; |
| 4616 | |
| 4617 | typedef struct { |
Argyrios Kyrtzidis | bd0ddf8 | 2011-10-27 17:36:12 +0000 | [diff] [blame] | 4618 | /** |
Argyrios Kyrtzidis | 6ec43ad | 2011-11-12 02:16:30 +0000 | [diff] [blame] | 4619 | * \brief Called periodically to check whether indexing should be aborted. |
| 4620 | * Should return 0 to continue, and non-zero to abort. |
| 4621 | */ |
| 4622 | int (*abortQuery)(CXClientData client_data, void *reserved); |
| 4623 | |
| 4624 | /** |
Argyrios Kyrtzidis | b395c63 | 2011-11-18 00:26:51 +0000 | [diff] [blame] | 4625 | * \brief Called at the end of indexing; passes the complete diagnostic set. |
Argyrios Kyrtzidis | bd0ddf8 | 2011-10-27 17:36:12 +0000 | [diff] [blame] | 4626 | */ |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 4627 | void (*diagnostic)(CXClientData client_data, |
Argyrios Kyrtzidis | b395c63 | 2011-11-18 00:26:51 +0000 | [diff] [blame] | 4628 | CXDiagnosticSet, void *reserved); |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 4629 | |
Argyrios Kyrtzidis | dd93c59 | 2011-11-11 00:23:36 +0000 | [diff] [blame] | 4630 | CXIdxClientFile (*enteredMainFile)(CXClientData client_data, |
| 4631 | CXFile mainFile, void *reserved); |
| 4632 | |
Argyrios Kyrtzidis | bd0ddf8 | 2011-10-27 17:36:12 +0000 | [diff] [blame] | 4633 | /** |
| 4634 | * \brief Called when a file gets #included/#imported. |
| 4635 | */ |
Argyrios Kyrtzidis | dd93c59 | 2011-11-11 00:23:36 +0000 | [diff] [blame] | 4636 | CXIdxClientFile (*ppIncludedFile)(CXClientData client_data, |
Argyrios Kyrtzidis | 6ec43ad | 2011-11-12 02:16:30 +0000 | [diff] [blame] | 4637 | const CXIdxIncludedFileInfo *); |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 4638 | |
Argyrios Kyrtzidis | bd0ddf8 | 2011-10-27 17:36:12 +0000 | [diff] [blame] | 4639 | /** |
| 4640 | * \brief Called when a AST file (PCH or module) gets imported. |
| 4641 | * |
| 4642 | * AST files will not get indexed (there will not be callbacks to index all |
| 4643 | * the entities in an AST file). The recommended action is that, if the AST |
| 4644 | * file is not already indexed, to block further indexing and initiate a new |
Argyrios Kyrtzidis | 6ec43ad | 2011-11-12 02:16:30 +0000 | [diff] [blame] | 4645 | * indexing job specific to the AST file. |
Argyrios Kyrtzidis | bd0ddf8 | 2011-10-27 17:36:12 +0000 | [diff] [blame] | 4646 | */ |
Argyrios Kyrtzidis | dd93c59 | 2011-11-11 00:23:36 +0000 | [diff] [blame] | 4647 | CXIdxClientASTFile (*importedASTFile)(CXClientData client_data, |
Argyrios Kyrtzidis | 6ec43ad | 2011-11-12 02:16:30 +0000 | [diff] [blame] | 4648 | const CXIdxImportedASTFileInfo *); |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 4649 | |
Argyrios Kyrtzidis | bd0ddf8 | 2011-10-27 17:36:12 +0000 | [diff] [blame] | 4650 | /** |
| 4651 | * \brief Called at the beginning of indexing a translation unit. |
| 4652 | */ |
Argyrios Kyrtzidis | dd93c59 | 2011-11-11 00:23:36 +0000 | [diff] [blame] | 4653 | CXIdxClientContainer (*startedTranslationUnit)(CXClientData client_data, |
Argyrios Kyrtzidis | 6ec43ad | 2011-11-12 02:16:30 +0000 | [diff] [blame] | 4654 | void *reserved); |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 4655 | |
Argyrios Kyrtzidis | 6ec43ad | 2011-11-12 02:16:30 +0000 | [diff] [blame] | 4656 | void (*indexDeclaration)(CXClientData client_data, |
Argyrios Kyrtzidis | 2957e6f | 2011-11-22 07:24:51 +0000 | [diff] [blame] | 4657 | const CXIdxDeclInfo *); |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 4658 | |
Argyrios Kyrtzidis | bd0ddf8 | 2011-10-27 17:36:12 +0000 | [diff] [blame] | 4659 | /** |
| 4660 | * \brief Called to index a reference of an entity. |
| 4661 | */ |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 4662 | void (*indexEntityReference)(CXClientData client_data, |
Argyrios Kyrtzidis | 6ec43ad | 2011-11-12 02:16:30 +0000 | [diff] [blame] | 4663 | const CXIdxEntityRefInfo *); |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 4664 | |
| 4665 | } IndexerCallbacks; |
| 4666 | |
NAKAMURA Takumi | ab336c1 | 2011-11-11 02:51:09 +0000 | [diff] [blame] | 4667 | CINDEX_LINKAGE int clang_index_isEntityObjCContainerKind(CXIdxEntityKind); |
Argyrios Kyrtzidis | 6ec43ad | 2011-11-12 02:16:30 +0000 | [diff] [blame] | 4668 | CINDEX_LINKAGE const CXIdxObjCContainerDeclInfo * |
| 4669 | clang_index_getObjCContainerDeclInfo(const CXIdxDeclInfo *); |
Argyrios Kyrtzidis | dd93c59 | 2011-11-11 00:23:36 +0000 | [diff] [blame] | 4670 | |
Argyrios Kyrtzidis | 6ec43ad | 2011-11-12 02:16:30 +0000 | [diff] [blame] | 4671 | CINDEX_LINKAGE const CXIdxObjCInterfaceDeclInfo * |
| 4672 | clang_index_getObjCInterfaceDeclInfo(const CXIdxDeclInfo *); |
| 4673 | |
NAKAMURA Takumi | ab336c1 | 2011-11-11 02:51:09 +0000 | [diff] [blame] | 4674 | CINDEX_LINKAGE |
Argyrios Kyrtzidis | 6ec43ad | 2011-11-12 02:16:30 +0000 | [diff] [blame] | 4675 | const CXIdxObjCCategoryDeclInfo * |
| 4676 | clang_index_getObjCCategoryDeclInfo(const CXIdxDeclInfo *); |
| 4677 | |
Argyrios Kyrtzidis | c71d554 | 2011-11-14 22:39:19 +0000 | [diff] [blame] | 4678 | CINDEX_LINKAGE const CXIdxObjCProtocolRefListInfo * |
| 4679 | clang_index_getObjCProtocolRefListInfo(const CXIdxDeclInfo *); |
Argyrios Kyrtzidis | dd93c59 | 2011-11-11 00:23:36 +0000 | [diff] [blame] | 4680 | |
Argyrios Kyrtzidis | 792db26 | 2012-02-28 17:50:33 +0000 | [diff] [blame] | 4681 | CINDEX_LINKAGE const CXIdxObjCPropertyDeclInfo * |
| 4682 | clang_index_getObjCPropertyDeclInfo(const CXIdxDeclInfo *); |
| 4683 | |
Argyrios Kyrtzidis | b395c63 | 2011-11-18 00:26:51 +0000 | [diff] [blame] | 4684 | CINDEX_LINKAGE const CXIdxIBOutletCollectionAttrInfo * |
| 4685 | clang_index_getIBOutletCollectionAttrInfo(const CXIdxAttrInfo *); |
| 4686 | |
Argyrios Kyrtzidis | 2957e6f | 2011-11-22 07:24:51 +0000 | [diff] [blame] | 4687 | CINDEX_LINKAGE const CXIdxCXXClassDeclInfo * |
| 4688 | clang_index_getCXXClassDeclInfo(const CXIdxDeclInfo *); |
| 4689 | |
| 4690 | /** |
| 4691 | * \brief For retrieving a custom CXIdxClientContainer attached to a |
| 4692 | * container. |
| 4693 | */ |
| 4694 | CINDEX_LINKAGE CXIdxClientContainer |
| 4695 | clang_index_getClientContainer(const CXIdxContainerInfo *); |
| 4696 | |
| 4697 | /** |
| 4698 | * \brief For setting a custom CXIdxClientContainer attached to a |
| 4699 | * container. |
| 4700 | */ |
| 4701 | CINDEX_LINKAGE void |
| 4702 | clang_index_setClientContainer(const CXIdxContainerInfo *,CXIdxClientContainer); |
| 4703 | |
| 4704 | /** |
| 4705 | * \brief For retrieving a custom CXIdxClientEntity attached to an entity. |
| 4706 | */ |
| 4707 | CINDEX_LINKAGE CXIdxClientEntity |
| 4708 | clang_index_getClientEntity(const CXIdxEntityInfo *); |
| 4709 | |
| 4710 | /** |
| 4711 | * \brief For setting a custom CXIdxClientEntity attached to an entity. |
| 4712 | */ |
| 4713 | CINDEX_LINKAGE void |
| 4714 | clang_index_setClientEntity(const CXIdxEntityInfo *, CXIdxClientEntity); |
| 4715 | |
| 4716 | /** |
| 4717 | * \brief An indexing action, to be applied to one or multiple translation units |
| 4718 | * but not on concurrent threads. If there are threads doing indexing |
| 4719 | * concurrently, they should use different CXIndexAction objects. |
| 4720 | */ |
| 4721 | typedef void *CXIndexAction; |
| 4722 | |
| 4723 | /** |
| 4724 | * \brief An indexing action, to be applied to one or multiple translation units |
| 4725 | * but not on concurrent threads. If there are threads doing indexing |
| 4726 | * concurrently, they should use different CXIndexAction objects. |
| 4727 | * |
| 4728 | * \param CIdx The index object with which the index action will be associated. |
| 4729 | */ |
| 4730 | CINDEX_LINKAGE CXIndexAction clang_IndexAction_create(CXIndex CIdx); |
| 4731 | |
| 4732 | /** |
| 4733 | * \brief Destroy the given index action. |
| 4734 | * |
| 4735 | * The index action must not be destroyed until all of the translation units |
| 4736 | * created within that index action have been destroyed. |
| 4737 | */ |
| 4738 | CINDEX_LINKAGE void clang_IndexAction_dispose(CXIndexAction); |
| 4739 | |
Argyrios Kyrtzidis | 21ee570 | 2011-11-15 06:20:16 +0000 | [diff] [blame] | 4740 | typedef enum { |
| 4741 | /** |
| 4742 | * \brief Used to indicate that no special indexing options are needed. |
| 4743 | */ |
| 4744 | CXIndexOpt_None = 0x0, |
| 4745 | |
| 4746 | /** |
| 4747 | * \brief Used to indicate that \see indexEntityReference should be invoked |
Argyrios Kyrtzidis | b395c63 | 2011-11-18 00:26:51 +0000 | [diff] [blame] | 4748 | * for only one reference of an entity per source file that does not also |
| 4749 | * include a declaration/definition of the entity. |
Argyrios Kyrtzidis | 21ee570 | 2011-11-15 06:20:16 +0000 | [diff] [blame] | 4750 | */ |
Argyrios Kyrtzidis | 2249074 | 2012-01-14 00:11:49 +0000 | [diff] [blame] | 4751 | CXIndexOpt_SuppressRedundantRefs = 0x1, |
| 4752 | |
| 4753 | /** |
| 4754 | * \brief Function-local symbols should be indexed. If this is not set |
| 4755 | * function-local symbols will be ignored. |
| 4756 | */ |
Argyrios Kyrtzidis | 58d2dbe | 2012-02-14 22:23:11 +0000 | [diff] [blame] | 4757 | CXIndexOpt_IndexFunctionLocalSymbols = 0x2, |
| 4758 | |
| 4759 | /** |
| 4760 | * \brief Implicit function/class template instantiations should be indexed. |
| 4761 | * If this is not set, implicit instantiations will be ignored. |
| 4762 | */ |
Argyrios Kyrtzidis | b49a29f | 2012-03-27 21:38:03 +0000 | [diff] [blame] | 4763 | CXIndexOpt_IndexImplicitTemplateInstantiations = 0x4, |
| 4764 | |
| 4765 | /** |
| 4766 | * \brief Suppress all compiler warnings when parsing for indexing. |
| 4767 | */ |
| 4768 | CXIndexOpt_SuppressWarnings = 0x8 |
Argyrios Kyrtzidis | 21ee570 | 2011-11-15 06:20:16 +0000 | [diff] [blame] | 4769 | } CXIndexOptFlags; |
| 4770 | |
Argyrios Kyrtzidis | bd0ddf8 | 2011-10-27 17:36:12 +0000 | [diff] [blame] | 4771 | /** |
| 4772 | * \brief Index the given source file and the translation unit corresponding |
| 4773 | * to that file via callbacks implemented through \see IndexerCallbacks. |
| 4774 | * |
| 4775 | * \param client_data pointer data supplied by the client, which will |
| 4776 | * be passed to the invoked callbacks. |
| 4777 | * |
| 4778 | * \param index_callbacks Pointer to indexing callbacks that the client |
| 4779 | * implements. |
| 4780 | * |
| 4781 | * \param index_callbacks_size Size of \see IndexerCallbacks structure that gets |
| 4782 | * passed in index_callbacks. |
| 4783 | * |
Argyrios Kyrtzidis | 21ee570 | 2011-11-15 06:20:16 +0000 | [diff] [blame] | 4784 | * \param index_options A bitmask of options that affects how indexing is |
| 4785 | * performed. This should be a bitwise OR of the CXIndexOpt_XXX flags. |
Argyrios Kyrtzidis | bd0ddf8 | 2011-10-27 17:36:12 +0000 | [diff] [blame] | 4786 | * |
| 4787 | * \param out_TU [out] pointer to store a CXTranslationUnit that can be reused |
| 4788 | * after indexing is finished. Set to NULL if you do not require it. |
| 4789 | * |
Argyrios Kyrtzidis | 21ee570 | 2011-11-15 06:20:16 +0000 | [diff] [blame] | 4790 | * \returns If there is a failure from which the there is no recovery, returns |
Argyrios Kyrtzidis | bd0ddf8 | 2011-10-27 17:36:12 +0000 | [diff] [blame] | 4791 | * non-zero, otherwise returns 0. |
Argyrios Kyrtzidis | 21ee570 | 2011-11-15 06:20:16 +0000 | [diff] [blame] | 4792 | * |
Argyrios Kyrtzidis | bd0ddf8 | 2011-10-27 17:36:12 +0000 | [diff] [blame] | 4793 | * The rest of the parameters are the same as \see clang_parseTranslationUnit. |
| 4794 | */ |
Argyrios Kyrtzidis | 2957e6f | 2011-11-22 07:24:51 +0000 | [diff] [blame] | 4795 | CINDEX_LINKAGE int clang_indexSourceFile(CXIndexAction, |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 4796 | CXClientData client_data, |
| 4797 | IndexerCallbacks *index_callbacks, |
| 4798 | unsigned index_callbacks_size, |
| 4799 | unsigned index_options, |
| 4800 | const char *source_filename, |
| 4801 | const char * const *command_line_args, |
| 4802 | int num_command_line_args, |
| 4803 | struct CXUnsavedFile *unsaved_files, |
| 4804 | unsigned num_unsaved_files, |
| 4805 | CXTranslationUnit *out_TU, |
| 4806 | unsigned TU_options); |
| 4807 | |
Argyrios Kyrtzidis | bd0ddf8 | 2011-10-27 17:36:12 +0000 | [diff] [blame] | 4808 | /** |
Argyrios Kyrtzidis | 21ee570 | 2011-11-15 06:20:16 +0000 | [diff] [blame] | 4809 | * \brief Index the given translation unit via callbacks implemented through |
| 4810 | * \see IndexerCallbacks. |
| 4811 | * |
| 4812 | * The order of callback invocations is not guaranteed to be the same as |
| 4813 | * when indexing a source file. The high level order will be: |
| 4814 | * |
| 4815 | * -Preprocessor callbacks invocations |
| 4816 | * -Declaration/reference callbacks invocations |
| 4817 | * -Diagnostic callback invocations |
| 4818 | * |
| 4819 | * The parameters are the same as \see clang_indexSourceFile. |
| 4820 | * |
| 4821 | * \returns If there is a failure from which the there is no recovery, returns |
| 4822 | * non-zero, otherwise returns 0. |
| 4823 | */ |
Argyrios Kyrtzidis | 2957e6f | 2011-11-22 07:24:51 +0000 | [diff] [blame] | 4824 | CINDEX_LINKAGE int clang_indexTranslationUnit(CXIndexAction, |
Argyrios Kyrtzidis | 21ee570 | 2011-11-15 06:20:16 +0000 | [diff] [blame] | 4825 | CXClientData client_data, |
| 4826 | IndexerCallbacks *index_callbacks, |
| 4827 | unsigned index_callbacks_size, |
Argyrios Kyrtzidis | 2957e6f | 2011-11-22 07:24:51 +0000 | [diff] [blame] | 4828 | unsigned index_options, |
| 4829 | CXTranslationUnit); |
Argyrios Kyrtzidis | 21ee570 | 2011-11-15 06:20:16 +0000 | [diff] [blame] | 4830 | |
| 4831 | /** |
Argyrios Kyrtzidis | bd0ddf8 | 2011-10-27 17:36:12 +0000 | [diff] [blame] | 4832 | * \brief Retrieve the CXIdxFile, file, line, column, and offset represented by |
| 4833 | * the given CXIdxLoc. |
| 4834 | * |
| 4835 | * If the location refers into a macro expansion, retrieves the |
| 4836 | * location of the macro expansion and if it refers into a macro argument |
| 4837 | * retrieves the location of the argument. |
| 4838 | */ |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 4839 | CINDEX_LINKAGE void clang_indexLoc_getFileLocation(CXIdxLoc loc, |
Argyrios Kyrtzidis | dd93c59 | 2011-11-11 00:23:36 +0000 | [diff] [blame] | 4840 | CXIdxClientFile *indexFile, |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 4841 | CXFile *file, |
| 4842 | unsigned *line, |
| 4843 | unsigned *column, |
| 4844 | unsigned *offset); |
| 4845 | |
Argyrios Kyrtzidis | bd0ddf8 | 2011-10-27 17:36:12 +0000 | [diff] [blame] | 4846 | /** |
| 4847 | * \brief Retrieve the CXSourceLocation represented by the given CXIdxLoc. |
| 4848 | */ |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 4849 | CINDEX_LINKAGE |
| 4850 | CXSourceLocation clang_indexLoc_getCXSourceLocation(CXIdxLoc loc); |
| 4851 | |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 4852 | /** |
| 4853 | * @} |
| 4854 | */ |
| 4855 | |
Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 4856 | /** |
| 4857 | * @} |
| 4858 | */ |
Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 4859 | |
Ted Kremenek | d2fa566 | 2009-08-26 22:36:44 +0000 | [diff] [blame] | 4860 | #ifdef __cplusplus |
| 4861 | } |
| 4862 | #endif |
| 4863 | #endif |
| 4864 | |