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