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