| 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 | */ | 
| Douglas Gregor | 58ddb60 | 2010-08-23 23:00:57 +0000 | [diff] [blame] | 118 | CXAvailability_NotAvailable | 
|  | 119 | }; | 
|  | 120 |  | 
| Douglas Gregor | 7f17376 | 2010-01-20 22:28:27 +0000 | [diff] [blame] | 121 | /** | 
| Douglas Gregor | 7f17376 | 2010-01-20 22:28:27 +0000 | [diff] [blame] | 122 | * \defgroup CINDEX_STRING String manipulation routines | 
|  | 123 | * | 
|  | 124 | * @{ | 
|  | 125 | */ | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 126 |  | 
| Douglas Gregor | 7f17376 | 2010-01-20 22:28:27 +0000 | [diff] [blame] | 127 | /** | 
|  | 128 | * \brief A character string. | 
|  | 129 | * | 
|  | 130 | * The \c CXString type is used to return strings from the interface when | 
|  | 131 | * the ownership of that string might different from one call to the next. | 
|  | 132 | * Use \c clang_getCString() to retrieve the string data and, once finished | 
|  | 133 | * with the string data, call \c clang_disposeString() to free the string. | 
| Steve Naroff | ef0cef6 | 2009-11-09 17:45:52 +0000 | [diff] [blame] | 134 | */ | 
|  | 135 | typedef struct { | 
| Ted Kremenek | a60ed47 | 2010-11-16 08:15:36 +0000 | [diff] [blame] | 136 | void *data; | 
| Ted Kremenek | ed12273 | 2010-11-16 01:56:27 +0000 | [diff] [blame] | 137 | unsigned private_flags; | 
| Steve Naroff | ef0cef6 | 2009-11-09 17:45:52 +0000 | [diff] [blame] | 138 | } CXString; | 
|  | 139 |  | 
| Douglas Gregor | 7f17376 | 2010-01-20 22:28:27 +0000 | [diff] [blame] | 140 | /** | 
|  | 141 | * \brief Retrieve the character data associated with the given string. | 
|  | 142 | */ | 
| Steve Naroff | ef0cef6 | 2009-11-09 17:45:52 +0000 | [diff] [blame] | 143 | CINDEX_LINKAGE const char *clang_getCString(CXString string); | 
|  | 144 |  | 
| Douglas Gregor | 7f17376 | 2010-01-20 22:28:27 +0000 | [diff] [blame] | 145 | /** | 
|  | 146 | * \brief Free the given string, | 
|  | 147 | */ | 
| Steve Naroff | ef0cef6 | 2009-11-09 17:45:52 +0000 | [diff] [blame] | 148 | CINDEX_LINKAGE void clang_disposeString(CXString string); | 
|  | 149 |  | 
| Douglas Gregor | 7f17376 | 2010-01-20 22:28:27 +0000 | [diff] [blame] | 150 | /** | 
|  | 151 | * @} | 
|  | 152 | */ | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 153 |  | 
|  | 154 | /** | 
| Steve Naroff | e56b4ba | 2009-10-20 14:46:24 +0000 | [diff] [blame] | 155 | * \brief clang_createIndex() provides a shared context for creating | 
|  | 156 | * translation units. It provides two options: | 
|  | 157 | * | 
|  | 158 | * - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local" | 
|  | 159 | * declarations (when loading any new translation units). A "local" declaration | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 160 | * 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] | 161 | * header that was used by the translation unit. If zero, all declarations | 
|  | 162 | * will be enumerated. | 
|  | 163 | * | 
| Steve Naroff | b4ece63 | 2009-10-20 16:36:34 +0000 | [diff] [blame] | 164 | * Here is an example: | 
|  | 165 | * | 
| Douglas Gregor | 0a812cf | 2010-02-18 23:07:20 +0000 | [diff] [blame] | 166 | *   // excludeDeclsFromPCH = 1, displayDiagnostics=1 | 
|  | 167 | *   Idx = clang_createIndex(1, 1); | 
| Steve Naroff | b4ece63 | 2009-10-20 16:36:34 +0000 | [diff] [blame] | 168 | * | 
|  | 169 | *   // IndexTest.pch was produced with the following command: | 
|  | 170 | *   // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch" | 
|  | 171 | *   TU = clang_createTranslationUnit(Idx, "IndexTest.pch"); | 
|  | 172 | * | 
|  | 173 | *   // This will load all the symbols from 'IndexTest.pch' | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 174 | *   clang_visitChildren(clang_getTranslationUnitCursor(TU), | 
| Douglas Gregor | 002a528 | 2010-01-20 21:37:00 +0000 | [diff] [blame] | 175 | *                       TranslationUnitVisitor, 0); | 
| Steve Naroff | b4ece63 | 2009-10-20 16:36:34 +0000 | [diff] [blame] | 176 | *   clang_disposeTranslationUnit(TU); | 
|  | 177 | * | 
|  | 178 | *   // This will load all the symbols from 'IndexTest.c', excluding symbols | 
|  | 179 | *   // from 'IndexTest.pch'. | 
| Daniel Dunbar | fd9f234 | 2010-01-25 00:43:14 +0000 | [diff] [blame] | 180 | *   char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" }; | 
|  | 181 | *   TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args, | 
|  | 182 | *                                                  0, 0); | 
| Douglas Gregor | b2cd487 | 2010-01-20 23:57:43 +0000 | [diff] [blame] | 183 | *   clang_visitChildren(clang_getTranslationUnitCursor(TU), | 
|  | 184 | *                       TranslationUnitVisitor, 0); | 
| Steve Naroff | b4ece63 | 2009-10-20 16:36:34 +0000 | [diff] [blame] | 185 | *   clang_disposeTranslationUnit(TU); | 
|  | 186 | * | 
|  | 187 | * This process of creating the 'pch', loading it separately, and using it (via | 
|  | 188 | * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks | 
|  | 189 | * (which gives the indexer the same performance benefit as the compiler). | 
| Steve Naroff | e56b4ba | 2009-10-20 14:46:24 +0000 | [diff] [blame] | 190 | */ | 
| Douglas Gregor | 0a812cf | 2010-02-18 23:07:20 +0000 | [diff] [blame] | 191 | CINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH, | 
|  | 192 | int displayDiagnostics); | 
| Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 193 |  | 
| Douglas Gregor | 0087e1a | 2010-02-08 23:03:06 +0000 | [diff] [blame] | 194 | /** | 
|  | 195 | * \brief Destroy the given index. | 
|  | 196 | * | 
|  | 197 | * The index must not be destroyed until all of the translation units created | 
|  | 198 | * within that index have been destroyed. | 
|  | 199 | */ | 
| Daniel Dunbar | 8506dde | 2009-12-03 01:54:28 +0000 | [diff] [blame] | 200 | CINDEX_LINKAGE void clang_disposeIndex(CXIndex index); | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 201 |  | 
|  | 202 | /** | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 203 | * \defgroup CINDEX_FILES File manipulation routines | 
| Douglas Gregor | f552544 | 2010-01-20 22:45:41 +0000 | [diff] [blame] | 204 | * | 
|  | 205 | * @{ | 
|  | 206 | */ | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 207 |  | 
| Douglas Gregor | f552544 | 2010-01-20 22:45:41 +0000 | [diff] [blame] | 208 | /** | 
|  | 209 | * \brief A particular source file that is part of a translation unit. | 
|  | 210 | */ | 
|  | 211 | typedef void *CXFile; | 
| 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 | /** | 
|  | 215 | * \brief Retrieve the complete file and path name of the given file. | 
| Steve Naroff | 8814503 | 2009-10-27 14:35:18 +0000 | [diff] [blame] | 216 | */ | 
| Ted Kremenek | 7484407 | 2010-02-17 00:41:20 +0000 | [diff] [blame] | 217 | CINDEX_LINKAGE CXString clang_getFileName(CXFile SFile); | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 218 |  | 
| Douglas Gregor | f552544 | 2010-01-20 22:45:41 +0000 | [diff] [blame] | 219 | /** | 
|  | 220 | * \brief Retrieve the last modification time of the given file. | 
|  | 221 | */ | 
| Douglas Gregor | 08b0e8d | 2009-10-31 15:48:08 +0000 | [diff] [blame] | 222 | CINDEX_LINKAGE time_t clang_getFileTime(CXFile SFile); | 
| Steve Naroff | 8814503 | 2009-10-27 14:35:18 +0000 | [diff] [blame] | 223 |  | 
| Douglas Gregor | 3c7313d | 2010-01-18 22:13:09 +0000 | [diff] [blame] | 224 | /** | 
| Douglas Gregor | dd3e554 | 2011-05-04 00:14:37 +0000 | [diff] [blame] | 225 | * \brief Determine whether the given header is guarded against | 
|  | 226 | * multiple inclusions, either with the conventional | 
|  | 227 | * #ifndef/#define/#endif macro guards or with #pragma once. | 
|  | 228 | */ | 
|  | 229 | CINDEX_LINKAGE unsigned | 
|  | 230 | clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu, CXFile file); | 
|  | 231 |  | 
|  | 232 | /** | 
| Douglas Gregor | b979034 | 2010-01-22 21:44:22 +0000 | [diff] [blame] | 233 | * \brief Retrieve a file handle within the given translation unit. | 
|  | 234 | * | 
|  | 235 | * \param tu the translation unit | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 236 | * | 
| Douglas Gregor | b979034 | 2010-01-22 21:44:22 +0000 | [diff] [blame] | 237 | * \param file_name the name of the file. | 
|  | 238 | * | 
|  | 239 | * \returns the file handle for the named file in the translation unit \p tu, | 
|  | 240 | * or a NULL file handle if the file was not a part of this translation unit. | 
|  | 241 | */ | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 242 | CINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu, | 
| Douglas Gregor | b979034 | 2010-01-22 21:44:22 +0000 | [diff] [blame] | 243 | const char *file_name); | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 244 |  | 
| Douglas Gregor | b979034 | 2010-01-22 21:44:22 +0000 | [diff] [blame] | 245 | /** | 
| Douglas Gregor | f552544 | 2010-01-20 22:45:41 +0000 | [diff] [blame] | 246 | * @} | 
|  | 247 | */ | 
|  | 248 |  | 
|  | 249 | /** | 
|  | 250 | * \defgroup CINDEX_LOCATIONS Physical source locations | 
|  | 251 | * | 
|  | 252 | * Clang represents physical source locations in its abstract syntax tree in | 
|  | 253 | * great detail, with file, line, and column information for the majority of | 
|  | 254 | * the tokens parsed in the source code. These data types and functions are | 
|  | 255 | * used to represent source location information, either for a particular | 
|  | 256 | * point in the program or for a range of points in the program, and extract | 
|  | 257 | * specific location information from those data types. | 
|  | 258 | * | 
|  | 259 | * @{ | 
|  | 260 | */ | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 261 |  | 
| Douglas Gregor | f552544 | 2010-01-20 22:45:41 +0000 | [diff] [blame] | 262 | /** | 
| Douglas Gregor | 1db19de | 2010-01-19 21:36:55 +0000 | [diff] [blame] | 263 | * \brief Identifies a specific source location within a translation | 
|  | 264 | * unit. | 
|  | 265 | * | 
| Chandler Carruth | 2017422 | 2011-08-31 16:53:37 +0000 | [diff] [blame] | 266 | * Use clang_getExpansionLocation() or clang_getSpellingLocation() | 
| Douglas Gregor | a9b06d4 | 2010-11-09 06:24:54 +0000 | [diff] [blame] | 267 | * to map a source location to a particular file, line, and column. | 
| Douglas Gregor | 3c7313d | 2010-01-18 22:13:09 +0000 | [diff] [blame] | 268 | */ | 
|  | 269 | typedef struct { | 
| Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 270 | void *ptr_data[2]; | 
| Douglas Gregor | 1db19de | 2010-01-19 21:36:55 +0000 | [diff] [blame] | 271 | unsigned int_data; | 
| Douglas Gregor | 3c7313d | 2010-01-18 22:13:09 +0000 | [diff] [blame] | 272 | } CXSourceLocation; | 
| Ted Kremenek | fe6fd3d | 2010-01-05 23:18:49 +0000 | [diff] [blame] | 273 |  | 
| Douglas Gregor | 3c7313d | 2010-01-18 22:13:09 +0000 | [diff] [blame] | 274 | /** | 
| Daniel Dunbar | d52864b | 2010-02-14 10:02:57 +0000 | [diff] [blame] | 275 | * \brief Identifies a half-open character range in the source code. | 
| Douglas Gregor | 3c7313d | 2010-01-18 22:13:09 +0000 | [diff] [blame] | 276 | * | 
| Douglas Gregor | 1db19de | 2010-01-19 21:36:55 +0000 | [diff] [blame] | 277 | * Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the | 
|  | 278 | * starting and end locations from a source range, respectively. | 
| Douglas Gregor | 3c7313d | 2010-01-18 22:13:09 +0000 | [diff] [blame] | 279 | */ | 
|  | 280 | typedef struct { | 
| Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 281 | void *ptr_data[2]; | 
| Douglas Gregor | 1db19de | 2010-01-19 21:36:55 +0000 | [diff] [blame] | 282 | unsigned begin_int_data; | 
|  | 283 | unsigned end_int_data; | 
| Douglas Gregor | 3c7313d | 2010-01-18 22:13:09 +0000 | [diff] [blame] | 284 | } CXSourceRange; | 
| Ted Kremenek | fe6fd3d | 2010-01-05 23:18:49 +0000 | [diff] [blame] | 285 |  | 
| Douglas Gregor | 1db19de | 2010-01-19 21:36:55 +0000 | [diff] [blame] | 286 | /** | 
| Douglas Gregor | b979034 | 2010-01-22 21:44:22 +0000 | [diff] [blame] | 287 | * \brief Retrieve a NULL (invalid) source location. | 
|  | 288 | */ | 
|  | 289 | CINDEX_LINKAGE CXSourceLocation clang_getNullLocation(); | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 290 |  | 
| Douglas Gregor | b979034 | 2010-01-22 21:44:22 +0000 | [diff] [blame] | 291 | /** | 
|  | 292 | * \determine Determine whether two source locations, which must refer into | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 293 | * 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] | 294 | * code. | 
|  | 295 | * | 
|  | 296 | * \returns non-zero if the source locations refer to the same location, zero | 
|  | 297 | * if they refer to different locations. | 
|  | 298 | */ | 
|  | 299 | CINDEX_LINKAGE unsigned clang_equalLocations(CXSourceLocation loc1, | 
|  | 300 | CXSourceLocation loc2); | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 301 |  | 
| Douglas Gregor | b979034 | 2010-01-22 21:44:22 +0000 | [diff] [blame] | 302 | /** | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 303 | * \brief Retrieves the source location associated with a given file/line/column | 
|  | 304 | * in a particular translation unit. | 
| Douglas Gregor | b979034 | 2010-01-22 21:44:22 +0000 | [diff] [blame] | 305 | */ | 
|  | 306 | CINDEX_LINKAGE CXSourceLocation clang_getLocation(CXTranslationUnit tu, | 
|  | 307 | CXFile file, | 
|  | 308 | unsigned line, | 
|  | 309 | unsigned column); | 
| David Chisnall | 83889a7 | 2010-10-15 17:07:39 +0000 | [diff] [blame] | 310 | /** | 
|  | 311 | * \brief Retrieves the source location associated with a given character offset | 
|  | 312 | * in a particular translation unit. | 
|  | 313 | */ | 
|  | 314 | CINDEX_LINKAGE CXSourceLocation clang_getLocationForOffset(CXTranslationUnit tu, | 
|  | 315 | CXFile file, | 
|  | 316 | unsigned offset); | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 317 |  | 
| Douglas Gregor | b979034 | 2010-01-22 21:44:22 +0000 | [diff] [blame] | 318 | /** | 
| Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 319 | * \brief Retrieve a NULL (invalid) source range. | 
|  | 320 | */ | 
|  | 321 | CINDEX_LINKAGE CXSourceRange clang_getNullRange(); | 
| Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 322 |  | 
| Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 323 | /** | 
| Douglas Gregor | b979034 | 2010-01-22 21:44:22 +0000 | [diff] [blame] | 324 | * \brief Retrieve a source range given the beginning and ending source | 
|  | 325 | * locations. | 
|  | 326 | */ | 
|  | 327 | CINDEX_LINKAGE CXSourceRange clang_getRange(CXSourceLocation begin, | 
|  | 328 | CXSourceLocation end); | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 329 |  | 
| Douglas Gregor | b979034 | 2010-01-22 21:44:22 +0000 | [diff] [blame] | 330 | /** | 
| Douglas Gregor | ab4e83b | 2011-07-23 19:35:14 +0000 | [diff] [blame] | 331 | * \brief Determine whether two ranges are equivalent. | 
|  | 332 | * | 
|  | 333 | * \returns non-zero if the ranges are the same, zero if they differ. | 
|  | 334 | */ | 
|  | 335 | CINDEX_LINKAGE unsigned clang_equalRanges(CXSourceRange range1, | 
|  | 336 | CXSourceRange range2); | 
|  | 337 |  | 
|  | 338 | /** | 
| Argyrios Kyrtzidis | de5db64 | 2011-09-28 18:14:21 +0000 | [diff] [blame] | 339 | * \brief Returns non-zero if \arg range is null. | 
|  | 340 | */ | 
|  | 341 | int clang_Range_isNull(CXSourceRange range); | 
|  | 342 |  | 
|  | 343 | /** | 
| Douglas Gregor | 46766dc | 2010-01-26 19:19:08 +0000 | [diff] [blame] | 344 | * \brief Retrieve the file, line, column, and offset represented by | 
|  | 345 | * the given source location. | 
| Douglas Gregor | 1db19de | 2010-01-19 21:36:55 +0000 | [diff] [blame] | 346 | * | 
| Chandler Carruth | 2017422 | 2011-08-31 16:53:37 +0000 | [diff] [blame] | 347 | * If the location refers into a macro expansion, retrieves the | 
|  | 348 | * location of the macro expansion. | 
| Douglas Gregor | a9b06d4 | 2010-11-09 06:24:54 +0000 | [diff] [blame] | 349 | * | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 350 | * \param location the location within a source file that will be decomposed | 
|  | 351 | * into its parts. | 
| Douglas Gregor | 1db19de | 2010-01-19 21:36:55 +0000 | [diff] [blame] | 352 | * | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 353 | * \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] | 354 | * source location points. | 
|  | 355 | * | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 356 | * \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] | 357 | * source location points. | 
|  | 358 | * | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 359 | * \param column [out] if non-NULL, will be set to the column to which the given | 
|  | 360 | * source location points. | 
| Douglas Gregor | 46766dc | 2010-01-26 19:19:08 +0000 | [diff] [blame] | 361 | * | 
|  | 362 | * \param offset [out] if non-NULL, will be set to the offset into the | 
|  | 363 | * buffer to which the given source location points. | 
| Douglas Gregor | 1db19de | 2010-01-19 21:36:55 +0000 | [diff] [blame] | 364 | */ | 
| Chandler Carruth | 2017422 | 2011-08-31 16:53:37 +0000 | [diff] [blame] | 365 | CINDEX_LINKAGE void clang_getExpansionLocation(CXSourceLocation location, | 
|  | 366 | CXFile *file, | 
|  | 367 | unsigned *line, | 
|  | 368 | unsigned *column, | 
|  | 369 | unsigned *offset); | 
|  | 370 |  | 
|  | 371 | /** | 
| Argyrios Kyrtzidis | e6be34d | 2011-09-13 21:49:08 +0000 | [diff] [blame] | 372 | * \brief Retrieve the file, line, column, and offset represented by | 
|  | 373 | * the given source location, as specified in a # line directive. | 
|  | 374 | * | 
|  | 375 | * Example: given the following source code in a file somefile.c | 
|  | 376 | * | 
|  | 377 | * #123 "dummy.c" 1 | 
|  | 378 | * | 
|  | 379 | * static int func(void) | 
|  | 380 | * { | 
|  | 381 | *     return 0; | 
|  | 382 | * } | 
|  | 383 | * | 
|  | 384 | * the location information returned by this function would be | 
|  | 385 | * | 
|  | 386 | * File: dummy.c Line: 124 Column: 12 | 
|  | 387 | * | 
|  | 388 | * whereas clang_getExpansionLocation would have returned | 
|  | 389 | * | 
|  | 390 | * File: somefile.c Line: 3 Column: 12 | 
|  | 391 | * | 
|  | 392 | * \param location the location within a source file that will be decomposed | 
|  | 393 | * into its parts. | 
|  | 394 | * | 
|  | 395 | * \param filename [out] if non-NULL, will be set to the filename of the | 
|  | 396 | * source location. Note that filenames returned will be for "virtual" files, | 
|  | 397 | * which don't necessarily exist on the machine running clang - e.g. when | 
|  | 398 | * parsing preprocessed output obtained from a different environment. If | 
|  | 399 | * a non-NULL value is passed in, remember to dispose of the returned value | 
|  | 400 | * using \c clang_disposeString() once you've finished with it. For an invalid | 
|  | 401 | * source location, an empty string is returned. | 
|  | 402 | * | 
|  | 403 | * \param line [out] if non-NULL, will be set to the line number of the | 
|  | 404 | * source location. For an invalid source location, zero is returned. | 
|  | 405 | * | 
|  | 406 | * \param column [out] if non-NULL, will be set to the column number of the | 
|  | 407 | * source location. For an invalid source location, zero is returned. | 
|  | 408 | */ | 
|  | 409 | CINDEX_LINKAGE void clang_getPresumedLocation(CXSourceLocation location, | 
|  | 410 | CXString *filename, | 
|  | 411 | unsigned *line, | 
|  | 412 | unsigned *column); | 
|  | 413 |  | 
|  | 414 | /** | 
| Chandler Carruth | 2017422 | 2011-08-31 16:53:37 +0000 | [diff] [blame] | 415 | * \brief Legacy API to retrieve the file, line, column, and offset represented | 
|  | 416 | * by the given source location. | 
|  | 417 | * | 
|  | 418 | * This interface has been replaced by the newer interface | 
|  | 419 | * \see clang_getExpansionLocation(). See that interface's documentation for | 
|  | 420 | * details. | 
|  | 421 | */ | 
| Douglas Gregor | 1db19de | 2010-01-19 21:36:55 +0000 | [diff] [blame] | 422 | CINDEX_LINKAGE void clang_getInstantiationLocation(CXSourceLocation location, | 
|  | 423 | CXFile *file, | 
|  | 424 | unsigned *line, | 
| Douglas Gregor | 46766dc | 2010-01-26 19:19:08 +0000 | [diff] [blame] | 425 | unsigned *column, | 
|  | 426 | unsigned *offset); | 
| Douglas Gregor | e69517c | 2010-01-26 03:07:15 +0000 | [diff] [blame] | 427 |  | 
|  | 428 | /** | 
| Douglas Gregor | a9b06d4 | 2010-11-09 06:24:54 +0000 | [diff] [blame] | 429 | * \brief Retrieve the file, line, column, and offset represented by | 
|  | 430 | * the given source location. | 
|  | 431 | * | 
|  | 432 | * If the location refers into a macro instantiation, return where the | 
|  | 433 | * location was originally spelled in the source file. | 
|  | 434 | * | 
|  | 435 | * \param location the location within a source file that will be decomposed | 
|  | 436 | * into its parts. | 
|  | 437 | * | 
|  | 438 | * \param file [out] if non-NULL, will be set to the file to which the given | 
|  | 439 | * source location points. | 
|  | 440 | * | 
|  | 441 | * \param line [out] if non-NULL, will be set to the line to which the given | 
|  | 442 | * source location points. | 
|  | 443 | * | 
|  | 444 | * \param column [out] if non-NULL, will be set to the column to which the given | 
|  | 445 | * source location points. | 
|  | 446 | * | 
|  | 447 | * \param offset [out] if non-NULL, will be set to the offset into the | 
|  | 448 | * buffer to which the given source location points. | 
|  | 449 | */ | 
|  | 450 | CINDEX_LINKAGE void clang_getSpellingLocation(CXSourceLocation location, | 
|  | 451 | CXFile *file, | 
|  | 452 | unsigned *line, | 
|  | 453 | unsigned *column, | 
|  | 454 | unsigned *offset); | 
|  | 455 |  | 
|  | 456 | /** | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 457 | * \brief Retrieve a source location representing the first character within a | 
|  | 458 | * source range. | 
| Douglas Gregor | 1db19de | 2010-01-19 21:36:55 +0000 | [diff] [blame] | 459 | */ | 
|  | 460 | CINDEX_LINKAGE CXSourceLocation clang_getRangeStart(CXSourceRange range); | 
|  | 461 |  | 
|  | 462 | /** | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 463 | * \brief Retrieve a source location representing the last character within a | 
|  | 464 | * source range. | 
| Douglas Gregor | 1db19de | 2010-01-19 21:36:55 +0000 | [diff] [blame] | 465 | */ | 
|  | 466 | CINDEX_LINKAGE CXSourceLocation clang_getRangeEnd(CXSourceRange range); | 
|  | 467 |  | 
| Douglas Gregor | f552544 | 2010-01-20 22:45:41 +0000 | [diff] [blame] | 468 | /** | 
|  | 469 | * @} | 
|  | 470 | */ | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 471 |  | 
|  | 472 | /** | 
| Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 473 | * \defgroup CINDEX_DIAG Diagnostic reporting | 
|  | 474 | * | 
|  | 475 | * @{ | 
|  | 476 | */ | 
|  | 477 |  | 
|  | 478 | /** | 
|  | 479 | * \brief Describes the severity of a particular diagnostic. | 
|  | 480 | */ | 
|  | 481 | enum CXDiagnosticSeverity { | 
|  | 482 | /** | 
| Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 483 | * \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] | 484 | * option. | 
|  | 485 | */ | 
|  | 486 | CXDiagnostic_Ignored = 0, | 
| Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 487 |  | 
| Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 488 | /** | 
|  | 489 | * \brief This diagnostic is a note that should be attached to the | 
|  | 490 | * previous (non-note) diagnostic. | 
|  | 491 | */ | 
|  | 492 | CXDiagnostic_Note    = 1, | 
|  | 493 |  | 
|  | 494 | /** | 
|  | 495 | * \brief This diagnostic indicates suspicious code that may not be | 
|  | 496 | * wrong. | 
|  | 497 | */ | 
|  | 498 | CXDiagnostic_Warning = 2, | 
|  | 499 |  | 
|  | 500 | /** | 
|  | 501 | * \brief This diagnostic indicates that the code is ill-formed. | 
|  | 502 | */ | 
|  | 503 | CXDiagnostic_Error   = 3, | 
|  | 504 |  | 
|  | 505 | /** | 
|  | 506 | * \brief This diagnostic indicates that the code is ill-formed such | 
|  | 507 | * that future parser recovery is unlikely to produce useful | 
|  | 508 | * results. | 
|  | 509 | */ | 
|  | 510 | CXDiagnostic_Fatal   = 4 | 
|  | 511 | }; | 
|  | 512 |  | 
|  | 513 | /** | 
| Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 514 | * \brief A single diagnostic, containing the diagnostic's severity, | 
|  | 515 | * location, text, source ranges, and fix-it hints. | 
|  | 516 | */ | 
|  | 517 | typedef void *CXDiagnostic; | 
|  | 518 |  | 
|  | 519 | /** | 
| Douglas Gregor | a88084b | 2010-02-18 18:08:43 +0000 | [diff] [blame] | 520 | * \brief Determine the number of diagnostics produced for the given | 
|  | 521 | * translation unit. | 
| Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 522 | */ | 
| Douglas Gregor | a88084b | 2010-02-18 18:08:43 +0000 | [diff] [blame] | 523 | CINDEX_LINKAGE unsigned clang_getNumDiagnostics(CXTranslationUnit Unit); | 
|  | 524 |  | 
|  | 525 | /** | 
|  | 526 | * \brief Retrieve a diagnostic associated with the given translation unit. | 
|  | 527 | * | 
|  | 528 | * \param Unit the translation unit to query. | 
|  | 529 | * \param Index the zero-based diagnostic number to retrieve. | 
|  | 530 | * | 
|  | 531 | * \returns the requested diagnostic. This diagnostic must be freed | 
|  | 532 | * via a call to \c clang_disposeDiagnostic(). | 
|  | 533 | */ | 
|  | 534 | CINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit, | 
|  | 535 | unsigned Index); | 
|  | 536 |  | 
|  | 537 | /** | 
|  | 538 | * \brief Destroy a diagnostic. | 
|  | 539 | */ | 
|  | 540 | CINDEX_LINKAGE void clang_disposeDiagnostic(CXDiagnostic Diagnostic); | 
| Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 541 |  | 
|  | 542 | /** | 
| Douglas Gregor | 0a812cf | 2010-02-18 23:07:20 +0000 | [diff] [blame] | 543 | * \brief Options to control the display of diagnostics. | 
|  | 544 | * | 
|  | 545 | * The values in this enum are meant to be combined to customize the | 
|  | 546 | * behavior of \c clang_displayDiagnostic(). | 
|  | 547 | */ | 
|  | 548 | enum CXDiagnosticDisplayOptions { | 
|  | 549 | /** | 
|  | 550 | * \brief Display the source-location information where the | 
|  | 551 | * diagnostic was located. | 
|  | 552 | * | 
|  | 553 | * When set, diagnostics will be prefixed by the file, line, and | 
|  | 554 | * (optionally) column to which the diagnostic refers. For example, | 
|  | 555 | * | 
|  | 556 | * \code | 
|  | 557 | * test.c:28: warning: extra tokens at end of #endif directive | 
|  | 558 | * \endcode | 
|  | 559 | * | 
|  | 560 | * This option corresponds to the clang flag \c -fshow-source-location. | 
|  | 561 | */ | 
|  | 562 | CXDiagnostic_DisplaySourceLocation = 0x01, | 
|  | 563 |  | 
|  | 564 | /** | 
|  | 565 | * \brief If displaying the source-location information of the | 
|  | 566 | * diagnostic, also include the column number. | 
|  | 567 | * | 
|  | 568 | * This option corresponds to the clang flag \c -fshow-column. | 
|  | 569 | */ | 
|  | 570 | CXDiagnostic_DisplayColumn = 0x02, | 
|  | 571 |  | 
|  | 572 | /** | 
|  | 573 | * \brief If displaying the source-location information of the | 
|  | 574 | * diagnostic, also include information about source ranges in a | 
|  | 575 | * machine-parsable format. | 
|  | 576 | * | 
| Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 577 | * This option corresponds to the clang flag | 
| Douglas Gregor | 0a812cf | 2010-02-18 23:07:20 +0000 | [diff] [blame] | 578 | * \c -fdiagnostics-print-source-range-info. | 
|  | 579 | */ | 
| Douglas Gregor | aa5f135 | 2010-11-19 16:18:16 +0000 | [diff] [blame] | 580 | CXDiagnostic_DisplaySourceRanges = 0x04, | 
|  | 581 |  | 
|  | 582 | /** | 
|  | 583 | * \brief Display the option name associated with this diagnostic, if any. | 
|  | 584 | * | 
|  | 585 | * The option name displayed (e.g., -Wconversion) will be placed in brackets | 
|  | 586 | * after the diagnostic text. This option corresponds to the clang flag | 
|  | 587 | * \c -fdiagnostics-show-option. | 
|  | 588 | */ | 
|  | 589 | CXDiagnostic_DisplayOption = 0x08, | 
|  | 590 |  | 
|  | 591 | /** | 
|  | 592 | * \brief Display the category number associated with this diagnostic, if any. | 
|  | 593 | * | 
|  | 594 | * The category number is displayed within brackets after the diagnostic text. | 
|  | 595 | * This option corresponds to the clang flag | 
|  | 596 | * \c -fdiagnostics-show-category=id. | 
|  | 597 | */ | 
|  | 598 | CXDiagnostic_DisplayCategoryId = 0x10, | 
|  | 599 |  | 
|  | 600 | /** | 
|  | 601 | * \brief Display the category name associated with this diagnostic, if any. | 
|  | 602 | * | 
|  | 603 | * The category name is displayed within brackets after the diagnostic text. | 
|  | 604 | * This option corresponds to the clang flag | 
|  | 605 | * \c -fdiagnostics-show-category=name. | 
|  | 606 | */ | 
|  | 607 | CXDiagnostic_DisplayCategoryName = 0x20 | 
| Douglas Gregor | 0a812cf | 2010-02-18 23:07:20 +0000 | [diff] [blame] | 608 | }; | 
|  | 609 |  | 
|  | 610 | /** | 
| Douglas Gregor | 274f190 | 2010-02-22 23:17:23 +0000 | [diff] [blame] | 611 | * \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] | 612 | * | 
| Douglas Gregor | 274f190 | 2010-02-22 23:17:23 +0000 | [diff] [blame] | 613 | * This routine will format the given diagnostic to a string, rendering | 
| Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 614 | * the diagnostic according to the various options given. The | 
|  | 615 | * \c clang_defaultDiagnosticDisplayOptions() function returns the set of | 
| Douglas Gregor | 0a812cf | 2010-02-18 23:07:20 +0000 | [diff] [blame] | 616 | * options that most closely mimics the behavior of the clang compiler. | 
|  | 617 | * | 
|  | 618 | * \param Diagnostic The diagnostic to print. | 
|  | 619 | * | 
| Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 620 | * \param Options A set of options that control the diagnostic display, | 
| Douglas Gregor | 0a812cf | 2010-02-18 23:07:20 +0000 | [diff] [blame] | 621 | * created by combining \c CXDiagnosticDisplayOptions values. | 
| Douglas Gregor | 274f190 | 2010-02-22 23:17:23 +0000 | [diff] [blame] | 622 | * | 
|  | 623 | * \returns A new string containing for formatted diagnostic. | 
| Douglas Gregor | 0a812cf | 2010-02-18 23:07:20 +0000 | [diff] [blame] | 624 | */ | 
| Douglas Gregor | 274f190 | 2010-02-22 23:17:23 +0000 | [diff] [blame] | 625 | CINDEX_LINKAGE CXString clang_formatDiagnostic(CXDiagnostic Diagnostic, | 
|  | 626 | unsigned Options); | 
| Douglas Gregor | 0a812cf | 2010-02-18 23:07:20 +0000 | [diff] [blame] | 627 |  | 
|  | 628 | /** | 
|  | 629 | * \brief Retrieve the set of display options most similar to the | 
|  | 630 | * default behavior of the clang compiler. | 
|  | 631 | * | 
|  | 632 | * \returns A set of display options suitable for use with \c | 
|  | 633 | * clang_displayDiagnostic(). | 
|  | 634 | */ | 
|  | 635 | CINDEX_LINKAGE unsigned clang_defaultDiagnosticDisplayOptions(void); | 
|  | 636 |  | 
|  | 637 | /** | 
| Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 638 | * \brief Determine the severity of the given diagnostic. | 
|  | 639 | */ | 
| Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 640 | CINDEX_LINKAGE enum CXDiagnosticSeverity | 
| Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 641 | clang_getDiagnosticSeverity(CXDiagnostic); | 
|  | 642 |  | 
|  | 643 | /** | 
|  | 644 | * \brief Retrieve the source location of the given diagnostic. | 
|  | 645 | * | 
|  | 646 | * This location is where Clang would print the caret ('^') when | 
|  | 647 | * displaying the diagnostic on the command line. | 
|  | 648 | */ | 
|  | 649 | CINDEX_LINKAGE CXSourceLocation clang_getDiagnosticLocation(CXDiagnostic); | 
|  | 650 |  | 
|  | 651 | /** | 
|  | 652 | * \brief Retrieve the text of the given diagnostic. | 
|  | 653 | */ | 
|  | 654 | CINDEX_LINKAGE CXString clang_getDiagnosticSpelling(CXDiagnostic); | 
| Douglas Gregor | a3890ba | 2010-02-08 23:11:56 +0000 | [diff] [blame] | 655 |  | 
|  | 656 | /** | 
| Douglas Gregor | aa5f135 | 2010-11-19 16:18:16 +0000 | [diff] [blame] | 657 | * \brief Retrieve the name of the command-line option that enabled this | 
|  | 658 | * diagnostic. | 
|  | 659 | * | 
|  | 660 | * \param Diag The diagnostic to be queried. | 
|  | 661 | * | 
|  | 662 | * \param Disable If non-NULL, will be set to the option that disables this | 
|  | 663 | * diagnostic (if any). | 
|  | 664 | * | 
|  | 665 | * \returns A string that contains the command-line option used to enable this | 
|  | 666 | * warning, such as "-Wconversion" or "-pedantic". | 
|  | 667 | */ | 
|  | 668 | CINDEX_LINKAGE CXString clang_getDiagnosticOption(CXDiagnostic Diag, | 
|  | 669 | CXString *Disable); | 
|  | 670 |  | 
|  | 671 | /** | 
|  | 672 | * \brief Retrieve the category number for this diagnostic. | 
|  | 673 | * | 
|  | 674 | * Diagnostics can be categorized into groups along with other, related | 
|  | 675 | * diagnostics (e.g., diagnostics under the same warning flag). This routine | 
|  | 676 | * retrieves the category number for the given diagnostic. | 
|  | 677 | * | 
|  | 678 | * \returns The number of the category that contains this diagnostic, or zero | 
|  | 679 | * if this diagnostic is uncategorized. | 
|  | 680 | */ | 
|  | 681 | CINDEX_LINKAGE unsigned clang_getDiagnosticCategory(CXDiagnostic); | 
|  | 682 |  | 
|  | 683 | /** | 
|  | 684 | * \brief Retrieve the name of a particular diagnostic category. | 
|  | 685 | * | 
|  | 686 | * \param Category A diagnostic category number, as returned by | 
|  | 687 | * \c clang_getDiagnosticCategory(). | 
|  | 688 | * | 
|  | 689 | * \returns The name of the given diagnostic category. | 
|  | 690 | */ | 
|  | 691 | CINDEX_LINKAGE CXString clang_getDiagnosticCategoryName(unsigned Category); | 
|  | 692 |  | 
|  | 693 | /** | 
| Douglas Gregor | a3890ba | 2010-02-08 23:11:56 +0000 | [diff] [blame] | 694 | * \brief Determine the number of source ranges associated with the given | 
|  | 695 | * diagnostic. | 
|  | 696 | */ | 
|  | 697 | CINDEX_LINKAGE unsigned clang_getDiagnosticNumRanges(CXDiagnostic); | 
| Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 698 |  | 
| Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 699 | /** | 
| Douglas Gregor | a3890ba | 2010-02-08 23:11:56 +0000 | [diff] [blame] | 700 | * \brief Retrieve a source range associated with the diagnostic. | 
| Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 701 | * | 
| Douglas Gregor | a3890ba | 2010-02-08 23:11:56 +0000 | [diff] [blame] | 702 | * A diagnostic's source ranges highlight important elements in the source | 
| Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 703 | * code. On the command line, Clang displays source ranges by | 
| Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 704 | * underlining them with '~' characters. | 
| Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 705 | * | 
| Douglas Gregor | a3890ba | 2010-02-08 23:11:56 +0000 | [diff] [blame] | 706 | * \param Diagnostic the diagnostic whose range is being extracted. | 
| Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 707 | * | 
| Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 708 | * \param Range the zero-based index specifying which range to | 
| Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 709 | * | 
| Douglas Gregor | a3890ba | 2010-02-08 23:11:56 +0000 | [diff] [blame] | 710 | * \returns the requested source range. | 
| Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 711 | */ | 
| Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 712 | CINDEX_LINKAGE CXSourceRange clang_getDiagnosticRange(CXDiagnostic Diagnostic, | 
| Douglas Gregor | a3890ba | 2010-02-08 23:11:56 +0000 | [diff] [blame] | 713 | unsigned Range); | 
| Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 714 |  | 
|  | 715 | /** | 
|  | 716 | * \brief Determine the number of fix-it hints associated with the | 
|  | 717 | * given diagnostic. | 
|  | 718 | */ | 
|  | 719 | CINDEX_LINKAGE unsigned clang_getDiagnosticNumFixIts(CXDiagnostic Diagnostic); | 
|  | 720 |  | 
|  | 721 | /** | 
| Douglas Gregor | 473d701 | 2010-02-19 18:16:06 +0000 | [diff] [blame] | 722 | * \brief Retrieve the replacement information for a given fix-it. | 
| Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 723 | * | 
| Douglas Gregor | 473d701 | 2010-02-19 18:16:06 +0000 | [diff] [blame] | 724 | * Fix-its are described in terms of a source range whose contents | 
|  | 725 | * should be replaced by a string. This approach generalizes over | 
|  | 726 | * three kinds of operations: removal of source code (the range covers | 
|  | 727 | * the code to be removed and the replacement string is empty), | 
|  | 728 | * replacement of source code (the range covers the code to be | 
|  | 729 | * replaced and the replacement string provides the new code), and | 
|  | 730 | * insertion (both the start and end of the range point at the | 
|  | 731 | * insertion location, and the replacement string provides the text to | 
|  | 732 | * insert). | 
| Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 733 | * | 
| Douglas Gregor | 473d701 | 2010-02-19 18:16:06 +0000 | [diff] [blame] | 734 | * \param Diagnostic The diagnostic whose fix-its are being queried. | 
|  | 735 | * | 
|  | 736 | * \param FixIt The zero-based index of the fix-it. | 
|  | 737 | * | 
|  | 738 | * \param ReplacementRange The source range whose contents will be | 
|  | 739 | * replaced with the returned replacement string. Note that source | 
|  | 740 | * ranges are half-open ranges [a, b), so the source code should be | 
|  | 741 | * replaced from a and up to (but not including) b. | 
|  | 742 | * | 
|  | 743 | * \returns A string containing text that should be replace the source | 
|  | 744 | * code indicated by the \c ReplacementRange. | 
| Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 745 | */ | 
| Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 746 | CINDEX_LINKAGE CXString clang_getDiagnosticFixIt(CXDiagnostic Diagnostic, | 
| Douglas Gregor | 473d701 | 2010-02-19 18:16:06 +0000 | [diff] [blame] | 747 | unsigned FixIt, | 
|  | 748 | CXSourceRange *ReplacementRange); | 
| Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 749 |  | 
|  | 750 | /** | 
|  | 751 | * @} | 
|  | 752 | */ | 
|  | 753 |  | 
|  | 754 | /** | 
|  | 755 | * \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation | 
|  | 756 | * | 
|  | 757 | * The routines in this group provide the ability to create and destroy | 
|  | 758 | * translation units from files, either by parsing the contents of the files or | 
|  | 759 | * by reading in a serialized representation of a translation unit. | 
|  | 760 | * | 
|  | 761 | * @{ | 
|  | 762 | */ | 
| Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 763 |  | 
| Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 764 | /** | 
|  | 765 | * \brief Get the original translation unit source file name. | 
|  | 766 | */ | 
|  | 767 | CINDEX_LINKAGE CXString | 
|  | 768 | clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit); | 
|  | 769 |  | 
|  | 770 | /** | 
|  | 771 | * \brief Return the CXTranslationUnit for a given source file and the provided | 
|  | 772 | * command line arguments one would pass to the compiler. | 
|  | 773 | * | 
|  | 774 | * Note: The 'source_filename' argument is optional.  If the caller provides a | 
|  | 775 | * NULL pointer, the name of the source file is expected to reside in the | 
|  | 776 | * specified command line arguments. | 
|  | 777 | * | 
|  | 778 | * Note: When encountered in 'clang_command_line_args', the following options | 
|  | 779 | * are ignored: | 
|  | 780 | * | 
|  | 781 | *   '-c' | 
|  | 782 | *   '-emit-ast' | 
|  | 783 | *   '-fsyntax-only' | 
|  | 784 | *   '-o <output file>'  (both '-o' and '<output file>' are ignored) | 
|  | 785 | * | 
| Ted Kremenek | 1ddb02c | 2010-11-08 04:28:51 +0000 | [diff] [blame] | 786 | * \param CIdx The index object with which the translation unit will be | 
|  | 787 | * associated. | 
| Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 788 | * | 
|  | 789 | * \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] | 790 | * source file is included in \p clang_command_line_args. | 
|  | 791 | * | 
|  | 792 | * \param num_clang_command_line_args The number of command-line arguments in | 
|  | 793 | * \p clang_command_line_args. | 
|  | 794 | * | 
|  | 795 | * \param clang_command_line_args The command-line arguments that would be | 
|  | 796 | * passed to the \c clang executable if it were being invoked out-of-process. | 
|  | 797 | * These command-line options will be parsed and will affect how the translation | 
|  | 798 | * unit is parsed. Note that the following options are ignored: '-c', | 
|  | 799 | * '-emit-ast', '-fsyntex-only' (which is the default), and '-o <output file>'. | 
| Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 800 | * | 
|  | 801 | * \param num_unsaved_files the number of unsaved file entries in \p | 
|  | 802 | * unsaved_files. | 
|  | 803 | * | 
|  | 804 | * \param unsaved_files the files that have not yet been saved to disk | 
|  | 805 | * but may be required for code completion, including the contents of | 
| Ted Kremenek | c6f530d | 2010-04-12 18:47:26 +0000 | [diff] [blame] | 806 | * those files.  The contents and name of these files (as specified by | 
|  | 807 | * CXUnsavedFile) are copied when necessary, so the client only needs to | 
|  | 808 | * guarantee their validity until the call to this function returns. | 
| Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 809 | */ | 
|  | 810 | CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnitFromSourceFile( | 
|  | 811 | CXIndex CIdx, | 
|  | 812 | const char *source_filename, | 
|  | 813 | int num_clang_command_line_args, | 
| Douglas Gregor | 2ef6944 | 2010-09-01 16:43:19 +0000 | [diff] [blame] | 814 | const char * const *clang_command_line_args, | 
| Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 815 | unsigned num_unsaved_files, | 
| Douglas Gregor | a88084b | 2010-02-18 18:08:43 +0000 | [diff] [blame] | 816 | struct CXUnsavedFile *unsaved_files); | 
| Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 817 |  | 
| Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 818 | /** | 
|  | 819 | * \brief Create a translation unit from an AST file (-emit-ast). | 
|  | 820 | */ | 
| Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 821 | CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnit(CXIndex, | 
| Douglas Gregor | a88084b | 2010-02-18 18:08:43 +0000 | [diff] [blame] | 822 | const char *ast_filename); | 
| Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 823 |  | 
| Douglas Gregor | 44c181a | 2010-07-23 00:33:23 +0000 | [diff] [blame] | 824 | /** | 
|  | 825 | * \brief Flags that control the creation of translation units. | 
|  | 826 | * | 
|  | 827 | * The enumerators in this enumeration type are meant to be bitwise | 
|  | 828 | * ORed together to specify which options should be used when | 
|  | 829 | * constructing the translation unit. | 
|  | 830 | */ | 
| Douglas Gregor | 5a43021 | 2010-07-21 18:52:53 +0000 | [diff] [blame] | 831 | enum CXTranslationUnit_Flags { | 
|  | 832 | /** | 
|  | 833 | * \brief Used to indicate that no special translation-unit options are | 
|  | 834 | * needed. | 
|  | 835 | */ | 
|  | 836 | CXTranslationUnit_None = 0x0, | 
|  | 837 |  | 
|  | 838 | /** | 
|  | 839 | * \brief Used to indicate that the parser should construct a "detailed" | 
|  | 840 | * preprocessing record, including all macro definitions and instantiations. | 
|  | 841 | * | 
|  | 842 | * Constructing a detailed preprocessing record requires more memory | 
|  | 843 | * and time to parse, since the information contained in the record | 
|  | 844 | * is usually not retained. However, it can be useful for | 
|  | 845 | * applications that require more detailed information about the | 
|  | 846 | * behavior of the preprocessor. | 
|  | 847 | */ | 
| Douglas Gregor | 44c181a | 2010-07-23 00:33:23 +0000 | [diff] [blame] | 848 | CXTranslationUnit_DetailedPreprocessingRecord = 0x01, | 
|  | 849 |  | 
|  | 850 | /** | 
| Douglas Gregor | b1c031b | 2010-08-09 22:28:58 +0000 | [diff] [blame] | 851 | * \brief Used to indicate that the translation unit is incomplete. | 
| Douglas Gregor | 44c181a | 2010-07-23 00:33:23 +0000 | [diff] [blame] | 852 | * | 
| Douglas Gregor | b1c031b | 2010-08-09 22:28:58 +0000 | [diff] [blame] | 853 | * When a translation unit is considered "incomplete", semantic | 
|  | 854 | * analysis that is typically performed at the end of the | 
|  | 855 | * translation unit will be suppressed. For example, this suppresses | 
|  | 856 | * the completion of tentative declarations in C and of | 
|  | 857 | * instantiation of implicitly-instantiation function templates in | 
|  | 858 | * C++. This option is typically used when parsing a header with the | 
|  | 859 | * intent of producing a precompiled header. | 
| Douglas Gregor | 44c181a | 2010-07-23 00:33:23 +0000 | [diff] [blame] | 860 | */ | 
| Douglas Gregor | b1c031b | 2010-08-09 22:28:58 +0000 | [diff] [blame] | 861 | CXTranslationUnit_Incomplete = 0x02, | 
| Douglas Gregor | 44c181a | 2010-07-23 00:33:23 +0000 | [diff] [blame] | 862 |  | 
|  | 863 | /** | 
|  | 864 | * \brief Used to indicate that the translation unit should be built with an | 
|  | 865 | * implicit precompiled header for the preamble. | 
|  | 866 | * | 
|  | 867 | * An implicit precompiled header is used as an optimization when a | 
|  | 868 | * particular translation unit is likely to be reparsed many times | 
|  | 869 | * when the sources aren't changing that often. In this case, an | 
|  | 870 | * implicit precompiled header will be built containing all of the | 
|  | 871 | * initial includes at the top of the main file (what we refer to as | 
|  | 872 | * the "preamble" of the file). In subsequent parses, if the | 
|  | 873 | * preamble or the files in it have not changed, \c | 
|  | 874 | * clang_reparseTranslationUnit() will re-use the implicit | 
|  | 875 | * precompiled header to improve parsing performance. | 
|  | 876 | */ | 
| Douglas Gregor | e1e13bf | 2010-08-11 15:58:42 +0000 | [diff] [blame] | 877 | CXTranslationUnit_PrecompiledPreamble = 0x04, | 
|  | 878 |  | 
|  | 879 | /** | 
|  | 880 | * \brief Used to indicate that the translation unit should cache some | 
|  | 881 | * code-completion results with each reparse of the source file. | 
|  | 882 | * | 
|  | 883 | * Caching of code-completion results is a performance optimization that | 
|  | 884 | * introduces some overhead to reparsing but improves the performance of | 
|  | 885 | * code-completion operations. | 
|  | 886 | */ | 
| Douglas Gregor | 99ba202 | 2010-10-27 17:24:53 +0000 | [diff] [blame] | 887 | CXTranslationUnit_CacheCompletionResults = 0x08, | 
|  | 888 | /** | 
| Douglas Gregor | b5af843 | 2011-08-25 22:54:01 +0000 | [diff] [blame] | 889 | * \brief DEPRECATED: Enable precompiled preambles in C++. | 
| Douglas Gregor | 99ba202 | 2010-10-27 17:24:53 +0000 | [diff] [blame] | 890 | * | 
|  | 891 | * Note: this is a *temporary* option that is available only while | 
| Douglas Gregor | b5af843 | 2011-08-25 22:54:01 +0000 | [diff] [blame] | 892 | * we are testing C++ precompiled preamble support. It is deprecated. | 
| Douglas Gregor | 99ba202 | 2010-10-27 17:24:53 +0000 | [diff] [blame] | 893 | */ | 
|  | 894 | CXTranslationUnit_CXXPrecompiledPreamble = 0x10, | 
|  | 895 |  | 
|  | 896 | /** | 
| Douglas Gregor | b5af843 | 2011-08-25 22:54:01 +0000 | [diff] [blame] | 897 | * \brief DEPRECATED: Enabled chained precompiled preambles in C++. | 
| Douglas Gregor | 99ba202 | 2010-10-27 17:24:53 +0000 | [diff] [blame] | 898 | * | 
|  | 899 | * Note: this is a *temporary* option that is available only while | 
| Douglas Gregor | b5af843 | 2011-08-25 22:54:01 +0000 | [diff] [blame] | 900 | * we are testing C++ precompiled preamble support. It is deprecated. | 
| Douglas Gregor | 99ba202 | 2010-10-27 17:24:53 +0000 | [diff] [blame] | 901 | */ | 
| Douglas Gregor | dca8ee8 | 2011-05-06 16:33:08 +0000 | [diff] [blame] | 902 | CXTranslationUnit_CXXChainedPCH = 0x20, | 
|  | 903 |  | 
|  | 904 | /** | 
|  | 905 | * \brief Used to indicate that the "detailed" preprocessing record, | 
| Chandler Carruth | fd14e91 | 2011-07-14 16:08:00 +0000 | [diff] [blame] | 906 | * if requested, should also contain nested macro expansions. | 
| Douglas Gregor | dca8ee8 | 2011-05-06 16:33:08 +0000 | [diff] [blame] | 907 | * | 
| Chandler Carruth | fd14e91 | 2011-07-14 16:08:00 +0000 | [diff] [blame] | 908 | * Nested macro expansions (i.e., macro expansions that occur | 
|  | 909 | * inside another macro expansion) can, in some code bases, require | 
| Douglas Gregor | dca8ee8 | 2011-05-06 16:33:08 +0000 | [diff] [blame] | 910 | * a large amount of storage to due preprocessor metaprogramming. Moreover, | 
|  | 911 | * its fairly rare that this information is useful for libclang clients. | 
|  | 912 | */ | 
| Chandler Carruth | ba7537f | 2011-07-14 09:02:10 +0000 | [diff] [blame] | 913 | CXTranslationUnit_NestedMacroExpansions = 0x40, | 
|  | 914 |  | 
|  | 915 | /** | 
|  | 916 | * \brief Legacy name to indicate that the "detailed" preprocessing record, | 
| Chandler Carruth | fd14e91 | 2011-07-14 16:08:00 +0000 | [diff] [blame] | 917 | * if requested, should contain nested macro expansions. | 
| Chandler Carruth | ba7537f | 2011-07-14 09:02:10 +0000 | [diff] [blame] | 918 | * | 
|  | 919 | * \see CXTranslationUnit_NestedMacroExpansions for the current name for this | 
|  | 920 | * value, and its semantics. This is just an alias. | 
|  | 921 | */ | 
|  | 922 | CXTranslationUnit_NestedMacroInstantiations = | 
|  | 923 | CXTranslationUnit_NestedMacroExpansions | 
| Douglas Gregor | 5a43021 | 2010-07-21 18:52:53 +0000 | [diff] [blame] | 924 | }; | 
|  | 925 |  | 
|  | 926 | /** | 
| Douglas Gregor | b1c031b | 2010-08-09 22:28:58 +0000 | [diff] [blame] | 927 | * \brief Returns the set of flags that is suitable for parsing a translation | 
|  | 928 | * unit that is being edited. | 
|  | 929 | * | 
|  | 930 | * The set of flags returned provide options for \c clang_parseTranslationUnit() | 
|  | 931 | * to indicate that the translation unit is likely to be reparsed many times, | 
|  | 932 | * either explicitly (via \c clang_reparseTranslationUnit()) or implicitly | 
|  | 933 | * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag | 
|  | 934 | * set contains an unspecified set of optimizations (e.g., the precompiled | 
|  | 935 | * preamble) geared toward improving the performance of these routines. The | 
|  | 936 | * set of optimizations enabled may change from one version to the next. | 
|  | 937 | */ | 
| Douglas Gregor | e1e13bf | 2010-08-11 15:58:42 +0000 | [diff] [blame] | 938 | CINDEX_LINKAGE unsigned clang_defaultEditingTranslationUnitOptions(void); | 
| Douglas Gregor | b1c031b | 2010-08-09 22:28:58 +0000 | [diff] [blame] | 939 |  | 
|  | 940 | /** | 
| Douglas Gregor | 5a43021 | 2010-07-21 18:52:53 +0000 | [diff] [blame] | 941 | * \brief Parse the given source file and the translation unit corresponding | 
|  | 942 | * to that file. | 
|  | 943 | * | 
|  | 944 | * This routine is the main entry point for the Clang C API, providing the | 
|  | 945 | * ability to parse a source file into a translation unit that can then be | 
|  | 946 | * queried by other functions in the API. This routine accepts a set of | 
|  | 947 | * command-line arguments so that the compilation can be configured in the same | 
|  | 948 | * way that the compiler is configured on the command line. | 
|  | 949 | * | 
|  | 950 | * \param CIdx The index object with which the translation unit will be | 
|  | 951 | * associated. | 
|  | 952 | * | 
|  | 953 | * \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] | 954 | * source file is included in \p command_line_args. | 
| Douglas Gregor | 5a43021 | 2010-07-21 18:52:53 +0000 | [diff] [blame] | 955 | * | 
|  | 956 | * \param command_line_args The command-line arguments that would be | 
|  | 957 | * passed to the \c clang executable if it were being invoked out-of-process. | 
|  | 958 | * These command-line options will be parsed and will affect how the translation | 
|  | 959 | * unit is parsed. Note that the following options are ignored: '-c', | 
|  | 960 | * '-emit-ast', '-fsyntex-only' (which is the default), and '-o <output file>'. | 
|  | 961 | * | 
|  | 962 | * \param num_command_line_args The number of command-line arguments in | 
|  | 963 | * \p command_line_args. | 
|  | 964 | * | 
|  | 965 | * \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] | 966 | * but may be required for parsing, including the contents of | 
| Douglas Gregor | 5a43021 | 2010-07-21 18:52:53 +0000 | [diff] [blame] | 967 | * those files.  The contents and name of these files (as specified by | 
|  | 968 | * CXUnsavedFile) are copied when necessary, so the client only needs to | 
|  | 969 | * guarantee their validity until the call to this function returns. | 
|  | 970 | * | 
|  | 971 | * \param num_unsaved_files the number of unsaved file entries in \p | 
|  | 972 | * unsaved_files. | 
|  | 973 | * | 
|  | 974 | * \param options A bitmask of options that affects how the translation unit | 
|  | 975 | * is managed but not its compilation. This should be a bitwise OR of the | 
|  | 976 | * CXTranslationUnit_XXX flags. | 
|  | 977 | * | 
|  | 978 | * \returns A new translation unit describing the parsed code and containing | 
|  | 979 | * any diagnostics produced by the compiler. If there is a failure from which | 
|  | 980 | * the compiler cannot recover, returns NULL. | 
|  | 981 | */ | 
|  | 982 | CINDEX_LINKAGE CXTranslationUnit clang_parseTranslationUnit(CXIndex CIdx, | 
|  | 983 | const char *source_filename, | 
| Douglas Gregor | 2ef6944 | 2010-09-01 16:43:19 +0000 | [diff] [blame] | 984 | const char * const *command_line_args, | 
| Douglas Gregor | 5a43021 | 2010-07-21 18:52:53 +0000 | [diff] [blame] | 985 | int num_command_line_args, | 
|  | 986 | struct CXUnsavedFile *unsaved_files, | 
|  | 987 | unsigned num_unsaved_files, | 
|  | 988 | unsigned options); | 
|  | 989 |  | 
| Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 990 | /** | 
| Douglas Gregor | 1999844 | 2010-08-13 15:35:05 +0000 | [diff] [blame] | 991 | * \brief Flags that control how translation units are saved. | 
|  | 992 | * | 
|  | 993 | * The enumerators in this enumeration type are meant to be bitwise | 
|  | 994 | * ORed together to specify which options should be used when | 
|  | 995 | * saving the translation unit. | 
|  | 996 | */ | 
|  | 997 | enum CXSaveTranslationUnit_Flags { | 
|  | 998 | /** | 
|  | 999 | * \brief Used to indicate that no special saving options are needed. | 
|  | 1000 | */ | 
|  | 1001 | CXSaveTranslationUnit_None = 0x0 | 
|  | 1002 | }; | 
|  | 1003 |  | 
|  | 1004 | /** | 
|  | 1005 | * \brief Returns the set of flags that is suitable for saving a translation | 
|  | 1006 | * unit. | 
|  | 1007 | * | 
|  | 1008 | * The set of flags returned provide options for | 
|  | 1009 | * \c clang_saveTranslationUnit() by default. The returned flag | 
|  | 1010 | * set contains an unspecified set of options that save translation units with | 
|  | 1011 | * the most commonly-requested data. | 
|  | 1012 | */ | 
|  | 1013 | CINDEX_LINKAGE unsigned clang_defaultSaveOptions(CXTranslationUnit TU); | 
|  | 1014 |  | 
|  | 1015 | /** | 
| Douglas Gregor | 39c411f | 2011-07-06 16:43:36 +0000 | [diff] [blame] | 1016 | * \brief Describes the kind of error that occurred (if any) in a call to | 
|  | 1017 | * \c clang_saveTranslationUnit(). | 
|  | 1018 | */ | 
|  | 1019 | enum CXSaveError { | 
|  | 1020 | /** | 
|  | 1021 | * \brief Indicates that no error occurred while saving a translation unit. | 
|  | 1022 | */ | 
|  | 1023 | CXSaveError_None = 0, | 
|  | 1024 |  | 
|  | 1025 | /** | 
|  | 1026 | * \brief Indicates that an unknown error occurred while attempting to save | 
|  | 1027 | * the file. | 
|  | 1028 | * | 
|  | 1029 | * This error typically indicates that file I/O failed when attempting to | 
|  | 1030 | * write the file. | 
|  | 1031 | */ | 
|  | 1032 | CXSaveError_Unknown = 1, | 
|  | 1033 |  | 
|  | 1034 | /** | 
|  | 1035 | * \brief Indicates that errors during translation prevented this attempt | 
|  | 1036 | * to save the translation unit. | 
|  | 1037 | * | 
|  | 1038 | * Errors that prevent the translation unit from being saved can be | 
|  | 1039 | * extracted using \c clang_getNumDiagnostics() and \c clang_getDiagnostic(). | 
|  | 1040 | */ | 
|  | 1041 | CXSaveError_TranslationErrors = 2, | 
|  | 1042 |  | 
|  | 1043 | /** | 
|  | 1044 | * \brief Indicates that the translation unit to be saved was somehow | 
|  | 1045 | * invalid (e.g., NULL). | 
|  | 1046 | */ | 
|  | 1047 | CXSaveError_InvalidTU = 3 | 
|  | 1048 | }; | 
|  | 1049 |  | 
|  | 1050 | /** | 
| Douglas Gregor | 7ae2faa | 2010-08-13 05:36:37 +0000 | [diff] [blame] | 1051 | * \brief Saves a translation unit into a serialized representation of | 
|  | 1052 | * that translation unit on disk. | 
|  | 1053 | * | 
|  | 1054 | * Any translation unit that was parsed without error can be saved | 
|  | 1055 | * into a file. The translation unit can then be deserialized into a | 
|  | 1056 | * new \c CXTranslationUnit with \c clang_createTranslationUnit() or, | 
|  | 1057 | * if it is an incomplete translation unit that corresponds to a | 
|  | 1058 | * header, used as a precompiled header when parsing other translation | 
|  | 1059 | * units. | 
|  | 1060 | * | 
|  | 1061 | * \param TU The translation unit to save. | 
| Douglas Gregor | 1999844 | 2010-08-13 15:35:05 +0000 | [diff] [blame] | 1062 | * | 
| Douglas Gregor | 7ae2faa | 2010-08-13 05:36:37 +0000 | [diff] [blame] | 1063 | * \param FileName The file to which the translation unit will be saved. | 
|  | 1064 | * | 
| Douglas Gregor | 1999844 | 2010-08-13 15:35:05 +0000 | [diff] [blame] | 1065 | * \param options A bitmask of options that affects how the translation unit | 
|  | 1066 | * is saved. This should be a bitwise OR of the | 
|  | 1067 | * CXSaveTranslationUnit_XXX flags. | 
|  | 1068 | * | 
| Douglas Gregor | 39c411f | 2011-07-06 16:43:36 +0000 | [diff] [blame] | 1069 | * \returns A value that will match one of the enumerators of the CXSaveError | 
|  | 1070 | * enumeration. Zero (CXSaveError_None) indicates that the translation unit was | 
|  | 1071 | * saved successfully, while a non-zero value indicates that a problem occurred. | 
| Douglas Gregor | 7ae2faa | 2010-08-13 05:36:37 +0000 | [diff] [blame] | 1072 | */ | 
|  | 1073 | CINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU, | 
| Douglas Gregor | 1999844 | 2010-08-13 15:35:05 +0000 | [diff] [blame] | 1074 | const char *FileName, | 
|  | 1075 | unsigned options); | 
| Douglas Gregor | 7ae2faa | 2010-08-13 05:36:37 +0000 | [diff] [blame] | 1076 |  | 
|  | 1077 | /** | 
| Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 1078 | * \brief Destroy the specified CXTranslationUnit object. | 
|  | 1079 | */ | 
|  | 1080 | CINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit); | 
| Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 1081 |  | 
| Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 1082 | /** | 
| Douglas Gregor | e1e13bf | 2010-08-11 15:58:42 +0000 | [diff] [blame] | 1083 | * \brief Flags that control the reparsing of translation units. | 
|  | 1084 | * | 
|  | 1085 | * The enumerators in this enumeration type are meant to be bitwise | 
|  | 1086 | * ORed together to specify which options should be used when | 
|  | 1087 | * reparsing the translation unit. | 
|  | 1088 | */ | 
|  | 1089 | enum CXReparse_Flags { | 
|  | 1090 | /** | 
|  | 1091 | * \brief Used to indicate that no special reparsing options are needed. | 
|  | 1092 | */ | 
|  | 1093 | CXReparse_None = 0x0 | 
|  | 1094 | }; | 
|  | 1095 |  | 
|  | 1096 | /** | 
|  | 1097 | * \brief Returns the set of flags that is suitable for reparsing a translation | 
|  | 1098 | * unit. | 
|  | 1099 | * | 
|  | 1100 | * The set of flags returned provide options for | 
|  | 1101 | * \c clang_reparseTranslationUnit() by default. The returned flag | 
|  | 1102 | * set contains an unspecified set of optimizations geared toward common uses | 
|  | 1103 | * of reparsing. The set of optimizations enabled may change from one version | 
|  | 1104 | * to the next. | 
|  | 1105 | */ | 
|  | 1106 | CINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU); | 
|  | 1107 |  | 
|  | 1108 | /** | 
| Douglas Gregor | abc563f | 2010-07-19 21:46:24 +0000 | [diff] [blame] | 1109 | * \brief Reparse the source files that produced this translation unit. | 
|  | 1110 | * | 
|  | 1111 | * This routine can be used to re-parse the source files that originally | 
|  | 1112 | * created the given translation unit, for example because those source files | 
|  | 1113 | * have changed (either on disk or as passed via \p unsaved_files). The | 
|  | 1114 | * source code will be reparsed with the same command-line options as it | 
|  | 1115 | * was originally parsed. | 
|  | 1116 | * | 
|  | 1117 | * Reparsing a translation unit invalidates all cursors and source locations | 
|  | 1118 | * that refer into that translation unit. This makes reparsing a translation | 
|  | 1119 | * unit semantically equivalent to destroying the translation unit and then | 
|  | 1120 | * creating a new translation unit with the same command-line arguments. | 
|  | 1121 | * However, it may be more efficient to reparse a translation | 
|  | 1122 | * unit using this routine. | 
|  | 1123 | * | 
|  | 1124 | * \param TU The translation unit whose contents will be re-parsed. The | 
|  | 1125 | * translation unit must originally have been built with | 
|  | 1126 | * \c clang_createTranslationUnitFromSourceFile(). | 
|  | 1127 | * | 
|  | 1128 | * \param num_unsaved_files The number of unsaved file entries in \p | 
|  | 1129 | * unsaved_files. | 
|  | 1130 | * | 
|  | 1131 | * \param unsaved_files The files that have not yet been saved to disk | 
|  | 1132 | * but may be required for parsing, including the contents of | 
|  | 1133 | * those files.  The contents and name of these files (as specified by | 
|  | 1134 | * CXUnsavedFile) are copied when necessary, so the client only needs to | 
|  | 1135 | * guarantee their validity until the call to this function returns. | 
|  | 1136 | * | 
| Douglas Gregor | e1e13bf | 2010-08-11 15:58:42 +0000 | [diff] [blame] | 1137 | * \param options A bitset of options composed of the flags in CXReparse_Flags. | 
|  | 1138 | * The function \c clang_defaultReparseOptions() produces a default set of | 
|  | 1139 | * options recommended for most uses, based on the translation unit. | 
|  | 1140 | * | 
| Douglas Gregor | abc563f | 2010-07-19 21:46:24 +0000 | [diff] [blame] | 1141 | * \returns 0 if the sources could be reparsed. A non-zero value will be | 
|  | 1142 | * returned if reparsing was impossible, such that the translation unit is | 
|  | 1143 | * invalid. In such cases, the only valid call for \p TU is | 
|  | 1144 | * \c clang_disposeTranslationUnit(TU). | 
|  | 1145 | */ | 
|  | 1146 | CINDEX_LINKAGE int clang_reparseTranslationUnit(CXTranslationUnit TU, | 
|  | 1147 | unsigned num_unsaved_files, | 
| Douglas Gregor | e1e13bf | 2010-08-11 15:58:42 +0000 | [diff] [blame] | 1148 | struct CXUnsavedFile *unsaved_files, | 
|  | 1149 | unsigned options); | 
| Ted Kremenek | 59fc1e5 | 2011-04-18 22:47:10 +0000 | [diff] [blame] | 1150 |  | 
|  | 1151 | /** | 
|  | 1152 | * \brief Categorizes how memory is being used by a translation unit. | 
|  | 1153 | */ | 
| Ted Kremenek | f787002 | 2011-04-20 16:41:07 +0000 | [diff] [blame] | 1154 | enum CXTUResourceUsageKind { | 
|  | 1155 | CXTUResourceUsage_AST = 1, | 
|  | 1156 | CXTUResourceUsage_Identifiers = 2, | 
|  | 1157 | CXTUResourceUsage_Selectors = 3, | 
|  | 1158 | CXTUResourceUsage_GlobalCompletionResults = 4, | 
| Ted Kremenek | 457aaf0 | 2011-04-28 04:10:31 +0000 | [diff] [blame] | 1159 | CXTUResourceUsage_SourceManagerContentCache = 5, | 
| Ted Kremenek | ba29bd2 | 2011-04-28 04:53:38 +0000 | [diff] [blame] | 1160 | CXTUResourceUsage_AST_SideTables = 6, | 
| Ted Kremenek | f61b831 | 2011-04-28 20:36:42 +0000 | [diff] [blame] | 1161 | CXTUResourceUsage_SourceManager_Membuffer_Malloc = 7, | 
| Ted Kremenek | e9b5f3d | 2011-04-28 23:46:20 +0000 | [diff] [blame] | 1162 | CXTUResourceUsage_SourceManager_Membuffer_MMap = 8, | 
|  | 1163 | CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc = 9, | 
|  | 1164 | CXTUResourceUsage_ExternalASTSource_Membuffer_MMap = 10, | 
| Ted Kremenek | 5e1db6a | 2011-05-04 01:38:46 +0000 | [diff] [blame] | 1165 | CXTUResourceUsage_Preprocessor = 11, | 
|  | 1166 | CXTUResourceUsage_PreprocessingRecord = 12, | 
| Ted Kremenek | ca7dc2b | 2011-07-26 23:46:06 +0000 | [diff] [blame] | 1167 | CXTUResourceUsage_SourceManager_DataStructures = 13, | 
| Ted Kremenek | d1194fb | 2011-07-26 23:46:11 +0000 | [diff] [blame] | 1168 | CXTUResourceUsage_Preprocessor_HeaderSearch = 14, | 
| Ted Kremenek | f787002 | 2011-04-20 16:41:07 +0000 | [diff] [blame] | 1169 | CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST, | 
|  | 1170 | CXTUResourceUsage_MEMORY_IN_BYTES_END = | 
| Ted Kremenek | d1194fb | 2011-07-26 23:46:11 +0000 | [diff] [blame] | 1171 | CXTUResourceUsage_Preprocessor_HeaderSearch, | 
| Ted Kremenek | f787002 | 2011-04-20 16:41:07 +0000 | [diff] [blame] | 1172 |  | 
|  | 1173 | CXTUResourceUsage_First = CXTUResourceUsage_AST, | 
| Ted Kremenek | d1194fb | 2011-07-26 23:46:11 +0000 | [diff] [blame] | 1174 | CXTUResourceUsage_Last = CXTUResourceUsage_Preprocessor_HeaderSearch | 
| Ted Kremenek | 59fc1e5 | 2011-04-18 22:47:10 +0000 | [diff] [blame] | 1175 | }; | 
|  | 1176 |  | 
|  | 1177 | /** | 
|  | 1178 | * \brief Returns the human-readable null-terminated C string that represents | 
| Ted Kremenek | f787002 | 2011-04-20 16:41:07 +0000 | [diff] [blame] | 1179 | *  the name of the memory category.  This string should never be freed. | 
| Ted Kremenek | 59fc1e5 | 2011-04-18 22:47:10 +0000 | [diff] [blame] | 1180 | */ | 
|  | 1181 | CINDEX_LINKAGE | 
| Ted Kremenek | f787002 | 2011-04-20 16:41:07 +0000 | [diff] [blame] | 1182 | const char *clang_getTUResourceUsageName(enum CXTUResourceUsageKind kind); | 
| Ted Kremenek | 59fc1e5 | 2011-04-18 22:47:10 +0000 | [diff] [blame] | 1183 |  | 
| Ted Kremenek | f787002 | 2011-04-20 16:41:07 +0000 | [diff] [blame] | 1184 | typedef struct CXTUResourceUsageEntry { | 
| Ted Kremenek | 59fc1e5 | 2011-04-18 22:47:10 +0000 | [diff] [blame] | 1185 | /* \brief The memory usage category. */ | 
| Ted Kremenek | f787002 | 2011-04-20 16:41:07 +0000 | [diff] [blame] | 1186 | enum CXTUResourceUsageKind kind; | 
|  | 1187 | /* \brief Amount of resources used. | 
|  | 1188 | The units will depend on the resource kind. */ | 
| Ted Kremenek | 59fc1e5 | 2011-04-18 22:47:10 +0000 | [diff] [blame] | 1189 | unsigned long amount; | 
| Ted Kremenek | f787002 | 2011-04-20 16:41:07 +0000 | [diff] [blame] | 1190 | } CXTUResourceUsageEntry; | 
| Ted Kremenek | 59fc1e5 | 2011-04-18 22:47:10 +0000 | [diff] [blame] | 1191 |  | 
|  | 1192 | /** | 
|  | 1193 | * \brief The memory usage of a CXTranslationUnit, broken into categories. | 
|  | 1194 | */ | 
| Ted Kremenek | f787002 | 2011-04-20 16:41:07 +0000 | [diff] [blame] | 1195 | typedef struct CXTUResourceUsage { | 
| Ted Kremenek | 59fc1e5 | 2011-04-18 22:47:10 +0000 | [diff] [blame] | 1196 | /* \brief Private data member, used for queries. */ | 
|  | 1197 | void *data; | 
|  | 1198 |  | 
|  | 1199 | /* \brief The number of entries in the 'entries' array. */ | 
|  | 1200 | unsigned numEntries; | 
|  | 1201 |  | 
|  | 1202 | /* \brief An array of key-value pairs, representing the breakdown of memory | 
|  | 1203 | usage. */ | 
| Ted Kremenek | f787002 | 2011-04-20 16:41:07 +0000 | [diff] [blame] | 1204 | CXTUResourceUsageEntry *entries; | 
| Ted Kremenek | 59fc1e5 | 2011-04-18 22:47:10 +0000 | [diff] [blame] | 1205 |  | 
| Ted Kremenek | f787002 | 2011-04-20 16:41:07 +0000 | [diff] [blame] | 1206 | } CXTUResourceUsage; | 
| Ted Kremenek | 59fc1e5 | 2011-04-18 22:47:10 +0000 | [diff] [blame] | 1207 |  | 
|  | 1208 | /** | 
|  | 1209 | * \brief Return the memory usage of a translation unit.  This object | 
| Ted Kremenek | f787002 | 2011-04-20 16:41:07 +0000 | [diff] [blame] | 1210 | *  should be released with clang_disposeCXTUResourceUsage(). | 
| Ted Kremenek | 59fc1e5 | 2011-04-18 22:47:10 +0000 | [diff] [blame] | 1211 | */ | 
| Ted Kremenek | f787002 | 2011-04-20 16:41:07 +0000 | [diff] [blame] | 1212 | CINDEX_LINKAGE CXTUResourceUsage clang_getCXTUResourceUsage(CXTranslationUnit TU); | 
| Ted Kremenek | 59fc1e5 | 2011-04-18 22:47:10 +0000 | [diff] [blame] | 1213 |  | 
| Ted Kremenek | f787002 | 2011-04-20 16:41:07 +0000 | [diff] [blame] | 1214 | CINDEX_LINKAGE void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage); | 
| Ted Kremenek | 59fc1e5 | 2011-04-18 22:47:10 +0000 | [diff] [blame] | 1215 |  | 
| Douglas Gregor | abc563f | 2010-07-19 21:46:24 +0000 | [diff] [blame] | 1216 | /** | 
| Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 1217 | * @} | 
|  | 1218 | */ | 
| Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 1219 |  | 
| Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 1220 | /** | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1221 | * \brief Describes the kind of entity that a cursor refers to. | 
|  | 1222 | */ | 
|  | 1223 | enum CXCursorKind { | 
|  | 1224 | /* Declarations */ | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1225 | /** | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1226 | * \brief A declaration whose specific kind is not exposed via this | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1227 | * interface. | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1228 | * | 
|  | 1229 | * Unexposed declarations have the same operations as any other kind | 
|  | 1230 | * of declaration; one can extract their location information, | 
|  | 1231 | * spelling, find their definitions, etc. However, the specific kind | 
|  | 1232 | * of the declaration is not reported. | 
|  | 1233 | */ | 
|  | 1234 | CXCursor_UnexposedDecl                 = 1, | 
|  | 1235 | /** \brief A C or C++ struct. */ | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1236 | CXCursor_StructDecl                    = 2, | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1237 | /** \brief A C or C++ union. */ | 
|  | 1238 | CXCursor_UnionDecl                     = 3, | 
|  | 1239 | /** \brief A C++ class. */ | 
|  | 1240 | CXCursor_ClassDecl                     = 4, | 
|  | 1241 | /** \brief An enumeration. */ | 
|  | 1242 | CXCursor_EnumDecl                      = 5, | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1243 | /** | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1244 | * \brief A field (in C) or non-static data member (in C++) in a | 
|  | 1245 | * struct, union, or C++ class. | 
|  | 1246 | */ | 
|  | 1247 | CXCursor_FieldDecl                     = 6, | 
|  | 1248 | /** \brief An enumerator constant. */ | 
|  | 1249 | CXCursor_EnumConstantDecl              = 7, | 
|  | 1250 | /** \brief A function. */ | 
|  | 1251 | CXCursor_FunctionDecl                  = 8, | 
|  | 1252 | /** \brief A variable. */ | 
|  | 1253 | CXCursor_VarDecl                       = 9, | 
|  | 1254 | /** \brief A function or method parameter. */ | 
|  | 1255 | CXCursor_ParmDecl                      = 10, | 
|  | 1256 | /** \brief An Objective-C @interface. */ | 
|  | 1257 | CXCursor_ObjCInterfaceDecl             = 11, | 
|  | 1258 | /** \brief An Objective-C @interface for a category. */ | 
|  | 1259 | CXCursor_ObjCCategoryDecl              = 12, | 
|  | 1260 | /** \brief An Objective-C @protocol declaration. */ | 
|  | 1261 | CXCursor_ObjCProtocolDecl              = 13, | 
|  | 1262 | /** \brief An Objective-C @property declaration. */ | 
|  | 1263 | CXCursor_ObjCPropertyDecl              = 14, | 
|  | 1264 | /** \brief An Objective-C instance variable. */ | 
|  | 1265 | CXCursor_ObjCIvarDecl                  = 15, | 
|  | 1266 | /** \brief An Objective-C instance method. */ | 
|  | 1267 | CXCursor_ObjCInstanceMethodDecl        = 16, | 
|  | 1268 | /** \brief An Objective-C class method. */ | 
|  | 1269 | CXCursor_ObjCClassMethodDecl           = 17, | 
|  | 1270 | /** \brief An Objective-C @implementation. */ | 
|  | 1271 | CXCursor_ObjCImplementationDecl        = 18, | 
|  | 1272 | /** \brief An Objective-C @implementation for a category. */ | 
|  | 1273 | CXCursor_ObjCCategoryImplDecl          = 19, | 
|  | 1274 | /** \brief A typedef */ | 
|  | 1275 | CXCursor_TypedefDecl                   = 20, | 
| Ted Kremenek | 8bd5a69 | 2010-04-13 23:39:06 +0000 | [diff] [blame] | 1276 | /** \brief A C++ class method. */ | 
|  | 1277 | CXCursor_CXXMethod                     = 21, | 
| Ted Kremenek | 8f06e0e | 2010-05-06 23:38:21 +0000 | [diff] [blame] | 1278 | /** \brief A C++ namespace. */ | 
|  | 1279 | CXCursor_Namespace                     = 22, | 
| Ted Kremenek | a0536d8 | 2010-05-07 01:04:29 +0000 | [diff] [blame] | 1280 | /** \brief A linkage specification, e.g. 'extern "C"'. */ | 
|  | 1281 | CXCursor_LinkageSpec                   = 23, | 
| Douglas Gregor | 01829d3 | 2010-08-31 14:41:23 +0000 | [diff] [blame] | 1282 | /** \brief A C++ constructor. */ | 
|  | 1283 | CXCursor_Constructor                   = 24, | 
|  | 1284 | /** \brief A C++ destructor. */ | 
|  | 1285 | CXCursor_Destructor                    = 25, | 
|  | 1286 | /** \brief A C++ conversion function. */ | 
|  | 1287 | CXCursor_ConversionFunction            = 26, | 
| Douglas Gregor | fe72e9c | 2010-08-31 17:01:39 +0000 | [diff] [blame] | 1288 | /** \brief A C++ template type parameter. */ | 
|  | 1289 | CXCursor_TemplateTypeParameter         = 27, | 
|  | 1290 | /** \brief A C++ non-type template parameter. */ | 
|  | 1291 | CXCursor_NonTypeTemplateParameter      = 28, | 
|  | 1292 | /** \brief A C++ template template parameter. */ | 
|  | 1293 | CXCursor_TemplateTemplateParameter     = 29, | 
|  | 1294 | /** \brief A C++ function template. */ | 
|  | 1295 | CXCursor_FunctionTemplate              = 30, | 
| Douglas Gregor | 39d6f07 | 2010-08-31 19:02:00 +0000 | [diff] [blame] | 1296 | /** \brief A C++ class template. */ | 
|  | 1297 | CXCursor_ClassTemplate                 = 31, | 
| Douglas Gregor | 74dbe64 | 2010-08-31 19:31:58 +0000 | [diff] [blame] | 1298 | /** \brief A C++ class template partial specialization. */ | 
|  | 1299 | CXCursor_ClassTemplatePartialSpecialization = 32, | 
| Douglas Gregor | 6931900 | 2010-08-31 23:48:11 +0000 | [diff] [blame] | 1300 | /** \brief A C++ namespace alias declaration. */ | 
|  | 1301 | CXCursor_NamespaceAlias                = 33, | 
| Douglas Gregor | 0a35bce | 2010-09-01 03:07:18 +0000 | [diff] [blame] | 1302 | /** \brief A C++ using directive. */ | 
|  | 1303 | CXCursor_UsingDirective                = 34, | 
| Richard Smith | 162e1c1 | 2011-04-15 14:24:37 +0000 | [diff] [blame] | 1304 | /** \brief A C++ using declaration. */ | 
| Douglas Gregor | 7e24256 | 2010-09-01 19:52:22 +0000 | [diff] [blame] | 1305 | CXCursor_UsingDeclaration              = 35, | 
| Richard Smith | 162e1c1 | 2011-04-15 14:24:37 +0000 | [diff] [blame] | 1306 | /** \brief A C++ alias declaration */ | 
|  | 1307 | CXCursor_TypeAliasDecl                 = 36, | 
| Douglas Gregor | 352697a | 2011-06-03 23:08:58 +0000 | [diff] [blame] | 1308 | /** \brief An Objective-C @synthesize definition. */ | 
|  | 1309 | CXCursor_ObjCSynthesizeDecl            = 37, | 
|  | 1310 | /** \brief An Objective-C @dynamic definition. */ | 
|  | 1311 | CXCursor_ObjCDynamicDecl               = 38, | 
| Argyrios Kyrtzidis | 2dfdb94 | 2011-09-30 17:58:23 +0000 | [diff] [blame^] | 1312 | /** \brief An access specifier. */ | 
|  | 1313 | CXCursor_CXXAccessSpecifier            = 39, | 
| Ted Kremenek | 50aa6ac | 2010-05-19 21:51:10 +0000 | [diff] [blame] | 1314 | CXCursor_FirstDecl                     = CXCursor_UnexposedDecl, | 
| Argyrios Kyrtzidis | 2dfdb94 | 2011-09-30 17:58:23 +0000 | [diff] [blame^] | 1315 | CXCursor_LastDecl                      = CXCursor_CXXAccessSpecifier, | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1316 |  | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1317 | /* References */ | 
|  | 1318 | CXCursor_FirstRef                      = 40, /* Decl references */ | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1319 | CXCursor_ObjCSuperClassRef             = 40, | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1320 | CXCursor_ObjCProtocolRef               = 41, | 
|  | 1321 | CXCursor_ObjCClassRef                  = 42, | 
|  | 1322 | /** | 
|  | 1323 | * \brief A reference to a type declaration. | 
|  | 1324 | * | 
|  | 1325 | * A type reference occurs anywhere where a type is named but not | 
|  | 1326 | * declared. For example, given: | 
|  | 1327 | * | 
|  | 1328 | * \code | 
|  | 1329 | * typedef unsigned size_type; | 
|  | 1330 | * size_type size; | 
|  | 1331 | * \endcode | 
|  | 1332 | * | 
|  | 1333 | * The typedef is a declaration of size_type (CXCursor_TypedefDecl), | 
|  | 1334 | * while the type of the variable "size" is referenced. The cursor | 
|  | 1335 | * referenced by the type of size is the typedef for size_type. | 
|  | 1336 | */ | 
|  | 1337 | CXCursor_TypeRef                       = 43, | 
| Ted Kremenek | 3064ef9 | 2010-08-27 21:34:58 +0000 | [diff] [blame] | 1338 | CXCursor_CXXBaseSpecifier              = 44, | 
| Douglas Gregor | 0b36e61 | 2010-08-31 20:37:03 +0000 | [diff] [blame] | 1339 | /** | 
| Douglas Gregor | a67e03f | 2010-09-09 21:42:20 +0000 | [diff] [blame] | 1340 | * \brief A reference to a class template, function template, template | 
|  | 1341 | * template parameter, or class template partial specialization. | 
| Douglas Gregor | 0b36e61 | 2010-08-31 20:37:03 +0000 | [diff] [blame] | 1342 | */ | 
|  | 1343 | CXCursor_TemplateRef                   = 45, | 
| Douglas Gregor | 6931900 | 2010-08-31 23:48:11 +0000 | [diff] [blame] | 1344 | /** | 
|  | 1345 | * \brief A reference to a namespace or namespace alias. | 
|  | 1346 | */ | 
|  | 1347 | CXCursor_NamespaceRef                  = 46, | 
| Douglas Gregor | a67e03f | 2010-09-09 21:42:20 +0000 | [diff] [blame] | 1348 | /** | 
| Douglas Gregor | 36897b0 | 2010-09-10 00:22:18 +0000 | [diff] [blame] | 1349 | * \brief A reference to a member of a struct, union, or class that occurs in | 
|  | 1350 | * some non-expression context, e.g., a designated initializer. | 
| Douglas Gregor | a67e03f | 2010-09-09 21:42:20 +0000 | [diff] [blame] | 1351 | */ | 
|  | 1352 | CXCursor_MemberRef                     = 47, | 
| Douglas Gregor | 36897b0 | 2010-09-10 00:22:18 +0000 | [diff] [blame] | 1353 | /** | 
|  | 1354 | * \brief A reference to a labeled statement. | 
|  | 1355 | * | 
|  | 1356 | * This cursor kind is used to describe the jump to "start_over" in the | 
|  | 1357 | * goto statement in the following example: | 
|  | 1358 | * | 
|  | 1359 | * \code | 
|  | 1360 | *   start_over: | 
|  | 1361 | *     ++counter; | 
|  | 1362 | * | 
|  | 1363 | *     goto start_over; | 
|  | 1364 | * \endcode | 
|  | 1365 | * | 
|  | 1366 | * A label reference cursor refers to a label statement. | 
|  | 1367 | */ | 
|  | 1368 | CXCursor_LabelRef                      = 48, | 
|  | 1369 |  | 
| Douglas Gregor | 1f60d9e | 2010-09-13 22:52:57 +0000 | [diff] [blame] | 1370 | /** | 
|  | 1371 | * \brief A reference to a set of overloaded functions or function templates | 
|  | 1372 | * that has not yet been resolved to a specific function or function template. | 
|  | 1373 | * | 
|  | 1374 | * An overloaded declaration reference cursor occurs in C++ templates where | 
|  | 1375 | * a dependent name refers to a function. For example: | 
|  | 1376 | * | 
|  | 1377 | * \code | 
|  | 1378 | * template<typename T> void swap(T&, T&); | 
|  | 1379 | * | 
|  | 1380 | * struct X { ... }; | 
|  | 1381 | * void swap(X&, X&); | 
|  | 1382 | * | 
|  | 1383 | * template<typename T> | 
|  | 1384 | * void reverse(T* first, T* last) { | 
|  | 1385 | *   while (first < last - 1) { | 
|  | 1386 | *     swap(*first, *--last); | 
|  | 1387 | *     ++first; | 
|  | 1388 | *   } | 
|  | 1389 | * } | 
|  | 1390 | * | 
|  | 1391 | * struct Y { }; | 
|  | 1392 | * void swap(Y&, Y&); | 
|  | 1393 | * \endcode | 
|  | 1394 | * | 
|  | 1395 | * Here, the identifier "swap" is associated with an overloaded declaration | 
|  | 1396 | * reference. In the template definition, "swap" refers to either of the two | 
|  | 1397 | * "swap" functions declared above, so both results will be available. At | 
|  | 1398 | * instantiation time, "swap" may also refer to other functions found via | 
|  | 1399 | * argument-dependent lookup (e.g., the "swap" function at the end of the | 
|  | 1400 | * example). | 
|  | 1401 | * | 
|  | 1402 | * The functions \c clang_getNumOverloadedDecls() and | 
|  | 1403 | * \c clang_getOverloadedDecl() can be used to retrieve the definitions | 
|  | 1404 | * referenced by this cursor. | 
|  | 1405 | */ | 
|  | 1406 | CXCursor_OverloadedDeclRef             = 49, | 
|  | 1407 |  | 
|  | 1408 | CXCursor_LastRef                       = CXCursor_OverloadedDeclRef, | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1409 |  | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1410 | /* Error conditions */ | 
|  | 1411 | CXCursor_FirstInvalid                  = 70, | 
|  | 1412 | CXCursor_InvalidFile                   = 70, | 
|  | 1413 | CXCursor_NoDeclFound                   = 71, | 
|  | 1414 | CXCursor_NotImplemented                = 72, | 
| Ted Kremenek | ebfa339 | 2010-03-19 20:39:03 +0000 | [diff] [blame] | 1415 | CXCursor_InvalidCode                   = 73, | 
|  | 1416 | CXCursor_LastInvalid                   = CXCursor_InvalidCode, | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1417 |  | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1418 | /* Expressions */ | 
|  | 1419 | CXCursor_FirstExpr                     = 100, | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1420 |  | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1421 | /** | 
|  | 1422 | * \brief An expression whose specific kind is not exposed via this | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1423 | * interface. | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1424 | * | 
|  | 1425 | * Unexposed expressions have the same operations as any other kind | 
|  | 1426 | * of expression; one can extract their location information, | 
|  | 1427 | * spelling, children, etc. However, the specific kind of the | 
|  | 1428 | * expression is not reported. | 
|  | 1429 | */ | 
|  | 1430 | CXCursor_UnexposedExpr                 = 100, | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1431 |  | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1432 | /** | 
|  | 1433 | * \brief An expression that refers to some value declaration, such | 
|  | 1434 | * as a function, varible, or enumerator. | 
|  | 1435 | */ | 
|  | 1436 | CXCursor_DeclRefExpr                   = 101, | 
| 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 a member of a struct, union, | 
|  | 1440 | * class, Objective-C class, etc. | 
|  | 1441 | */ | 
|  | 1442 | CXCursor_MemberRefExpr                 = 102, | 
| 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 | /** \brief An expression that calls a function. */ | 
|  | 1445 | CXCursor_CallExpr                      = 103, | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1446 |  | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1447 | /** \brief An expression that sends a message to an Objective-C | 
|  | 1448 | object or class. */ | 
|  | 1449 | CXCursor_ObjCMessageExpr               = 104, | 
| Ted Kremenek | 1ee6cad | 2010-04-11 21:47:37 +0000 | [diff] [blame] | 1450 |  | 
|  | 1451 | /** \brief An expression that represents a block literal. */ | 
|  | 1452 | CXCursor_BlockExpr                     = 105, | 
|  | 1453 |  | 
|  | 1454 | CXCursor_LastExpr                      = 105, | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1455 |  | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1456 | /* Statements */ | 
|  | 1457 | CXCursor_FirstStmt                     = 200, | 
|  | 1458 | /** | 
|  | 1459 | * \brief A statement whose specific kind is not exposed via this | 
|  | 1460 | * interface. | 
|  | 1461 | * | 
|  | 1462 | * Unexposed statements have the same operations as any other kind of | 
|  | 1463 | * statement; one can extract their location information, spelling, | 
|  | 1464 | * children, etc. However, the specific kind of the statement is not | 
|  | 1465 | * reported. | 
|  | 1466 | */ | 
|  | 1467 | CXCursor_UnexposedStmt                 = 200, | 
| Douglas Gregor | 36897b0 | 2010-09-10 00:22:18 +0000 | [diff] [blame] | 1468 |  | 
|  | 1469 | /** \brief A labelled statement in a function. | 
|  | 1470 | * | 
|  | 1471 | * This cursor kind is used to describe the "start_over:" label statement in | 
|  | 1472 | * the following example: | 
|  | 1473 | * | 
|  | 1474 | * \code | 
|  | 1475 | *   start_over: | 
|  | 1476 | *     ++counter; | 
|  | 1477 | * \endcode | 
|  | 1478 | * | 
|  | 1479 | */ | 
|  | 1480 | CXCursor_LabelStmt                     = 201, | 
|  | 1481 |  | 
|  | 1482 | CXCursor_LastStmt                      = CXCursor_LabelStmt, | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1483 |  | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1484 | /** | 
|  | 1485 | * \brief Cursor that represents the translation unit itself. | 
|  | 1486 | * | 
|  | 1487 | * The translation unit cursor exists primarily to act as the root | 
|  | 1488 | * cursor for traversing the contents of a translation unit. | 
|  | 1489 | */ | 
| Ted Kremenek | e77f443 | 2010-02-18 03:09:07 +0000 | [diff] [blame] | 1490 | CXCursor_TranslationUnit               = 300, | 
|  | 1491 |  | 
|  | 1492 | /* Attributes */ | 
|  | 1493 | CXCursor_FirstAttr                     = 400, | 
|  | 1494 | /** | 
|  | 1495 | * \brief An attribute whose specific kind is not exposed via this | 
|  | 1496 | * interface. | 
|  | 1497 | */ | 
|  | 1498 | CXCursor_UnexposedAttr                 = 400, | 
|  | 1499 |  | 
|  | 1500 | CXCursor_IBActionAttr                  = 401, | 
|  | 1501 | CXCursor_IBOutletAttr                  = 402, | 
| Ted Kremenek | 857e918 | 2010-05-19 17:38:06 +0000 | [diff] [blame] | 1502 | CXCursor_IBOutletCollectionAttr        = 403, | 
| Argyrios Kyrtzidis | 6639e92 | 2011-09-13 17:39:31 +0000 | [diff] [blame] | 1503 | CXCursor_CXXFinalAttr                  = 404, | 
|  | 1504 | CXCursor_CXXOverrideAttr               = 405, | 
|  | 1505 | CXCursor_LastAttr                      = CXCursor_CXXOverrideAttr, | 
| Douglas Gregor | 9f1e3ff | 2010-03-18 00:42:48 +0000 | [diff] [blame] | 1506 |  | 
|  | 1507 | /* Preprocessing */ | 
|  | 1508 | CXCursor_PreprocessingDirective        = 500, | 
| Douglas Gregor | 572feb2 | 2010-03-18 18:04:21 +0000 | [diff] [blame] | 1509 | CXCursor_MacroDefinition               = 501, | 
| Chandler Carruth | 9b2a0ac | 2011-07-14 08:41:15 +0000 | [diff] [blame] | 1510 | CXCursor_MacroExpansion                = 502, | 
|  | 1511 | CXCursor_MacroInstantiation            = CXCursor_MacroExpansion, | 
| Douglas Gregor | ecdcb88 | 2010-10-20 22:00:55 +0000 | [diff] [blame] | 1512 | CXCursor_InclusionDirective            = 503, | 
| Douglas Gregor | 9f1e3ff | 2010-03-18 00:42:48 +0000 | [diff] [blame] | 1513 | CXCursor_FirstPreprocessing            = CXCursor_PreprocessingDirective, | 
| Douglas Gregor | ecdcb88 | 2010-10-20 22:00:55 +0000 | [diff] [blame] | 1514 | CXCursor_LastPreprocessing             = CXCursor_InclusionDirective | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1515 | }; | 
|  | 1516 |  | 
|  | 1517 | /** | 
|  | 1518 | * \brief A cursor representing some element in the abstract syntax tree for | 
|  | 1519 | * a translation unit. | 
|  | 1520 | * | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1521 | * The cursor abstraction unifies the different kinds of entities in a | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1522 | * program--declaration, statements, expressions, references to declarations, | 
|  | 1523 | * etc.--under a single "cursor" abstraction with a common set of operations. | 
|  | 1524 | * Common operation for a cursor include: getting the physical location in | 
|  | 1525 | * a source file where the cursor points, getting the name associated with a | 
|  | 1526 | * cursor, and retrieving cursors for any child nodes of a particular cursor. | 
|  | 1527 | * | 
|  | 1528 | * Cursors can be produced in two specific ways. | 
|  | 1529 | * clang_getTranslationUnitCursor() produces a cursor for a translation unit, | 
|  | 1530 | * from which one can use clang_visitChildren() to explore the rest of the | 
|  | 1531 | * translation unit. clang_getCursor() maps from a physical source location | 
|  | 1532 | * to the entity that resides at that location, allowing one to map from the | 
|  | 1533 | * source code into the AST. | 
|  | 1534 | */ | 
|  | 1535 | typedef struct { | 
|  | 1536 | enum CXCursorKind kind; | 
|  | 1537 | void *data[3]; | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1538 | } CXCursor; | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1539 |  | 
|  | 1540 | /** | 
|  | 1541 | * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations | 
|  | 1542 | * | 
|  | 1543 | * @{ | 
|  | 1544 | */ | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1545 |  | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1546 | /** | 
|  | 1547 | * \brief Retrieve the NULL cursor, which represents no entity. | 
|  | 1548 | */ | 
|  | 1549 | CINDEX_LINKAGE CXCursor clang_getNullCursor(void); | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1550 |  | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1551 | /** | 
|  | 1552 | * \brief Retrieve the cursor that represents the given translation unit. | 
|  | 1553 | * | 
|  | 1554 | * The translation unit cursor can be used to start traversing the | 
|  | 1555 | * various declarations within the given translation unit. | 
|  | 1556 | */ | 
|  | 1557 | CINDEX_LINKAGE CXCursor clang_getTranslationUnitCursor(CXTranslationUnit); | 
|  | 1558 |  | 
|  | 1559 | /** | 
|  | 1560 | * \brief Determine whether two cursors are equivalent. | 
|  | 1561 | */ | 
|  | 1562 | CINDEX_LINKAGE unsigned clang_equalCursors(CXCursor, CXCursor); | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1563 |  | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1564 | /** | 
| Argyrios Kyrtzidis | b0d6eaa | 2011-09-27 00:30:30 +0000 | [diff] [blame] | 1565 | * \brief Returns non-zero if \arg cursor is null. | 
|  | 1566 | */ | 
| Argyrios Kyrtzidis | fa865df | 2011-09-27 04:14:36 +0000 | [diff] [blame] | 1567 | int clang_Cursor_isNull(CXCursor); | 
| Argyrios Kyrtzidis | b0d6eaa | 2011-09-27 00:30:30 +0000 | [diff] [blame] | 1568 |  | 
|  | 1569 | /** | 
| Douglas Gregor | 9ce5584 | 2010-11-20 00:09:34 +0000 | [diff] [blame] | 1570 | * \brief Compute a hash value for the given cursor. | 
|  | 1571 | */ | 
|  | 1572 | CINDEX_LINKAGE unsigned clang_hashCursor(CXCursor); | 
|  | 1573 |  | 
|  | 1574 | /** | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1575 | * \brief Retrieve the kind of the given cursor. | 
|  | 1576 | */ | 
|  | 1577 | CINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor); | 
|  | 1578 |  | 
|  | 1579 | /** | 
|  | 1580 | * \brief Determine whether the given cursor kind represents a declaration. | 
|  | 1581 | */ | 
|  | 1582 | CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind); | 
|  | 1583 |  | 
|  | 1584 | /** | 
|  | 1585 | * \brief Determine whether the given cursor kind represents a simple | 
|  | 1586 | * reference. | 
|  | 1587 | * | 
|  | 1588 | * Note that other kinds of cursors (such as expressions) can also refer to | 
|  | 1589 | * other cursors. Use clang_getCursorReferenced() to determine whether a | 
|  | 1590 | * particular cursor refers to another entity. | 
|  | 1591 | */ | 
|  | 1592 | CINDEX_LINKAGE unsigned clang_isReference(enum CXCursorKind); | 
|  | 1593 |  | 
|  | 1594 | /** | 
|  | 1595 | * \brief Determine whether the given cursor kind represents an expression. | 
|  | 1596 | */ | 
|  | 1597 | CINDEX_LINKAGE unsigned clang_isExpression(enum CXCursorKind); | 
|  | 1598 |  | 
|  | 1599 | /** | 
|  | 1600 | * \brief Determine whether the given cursor kind represents a statement. | 
|  | 1601 | */ | 
|  | 1602 | CINDEX_LINKAGE unsigned clang_isStatement(enum CXCursorKind); | 
|  | 1603 |  | 
|  | 1604 | /** | 
| Douglas Gregor | 8be80e1 | 2011-07-06 03:00:34 +0000 | [diff] [blame] | 1605 | * \brief Determine whether the given cursor kind represents an attribute. | 
|  | 1606 | */ | 
|  | 1607 | CINDEX_LINKAGE unsigned clang_isAttribute(enum CXCursorKind); | 
|  | 1608 |  | 
|  | 1609 | /** | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1610 | * \brief Determine whether the given cursor kind represents an invalid | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1611 | * cursor. | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1612 | */ | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1613 | CINDEX_LINKAGE unsigned clang_isInvalid(enum CXCursorKind); | 
|  | 1614 |  | 
|  | 1615 | /** | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1616 | * \brief Determine whether the given cursor kind represents a translation | 
|  | 1617 | * unit. | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1618 | */ | 
|  | 1619 | CINDEX_LINKAGE unsigned clang_isTranslationUnit(enum CXCursorKind); | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1620 |  | 
| Ted Kremenek | ad6eff6 | 2010-03-08 21:17:29 +0000 | [diff] [blame] | 1621 | /*** | 
| Douglas Gregor | 9f1e3ff | 2010-03-18 00:42:48 +0000 | [diff] [blame] | 1622 | * \brief Determine whether the given cursor represents a preprocessing | 
|  | 1623 | * element, such as a preprocessor directive or macro instantiation. | 
|  | 1624 | */ | 
|  | 1625 | CINDEX_LINKAGE unsigned clang_isPreprocessing(enum CXCursorKind); | 
|  | 1626 |  | 
|  | 1627 | /*** | 
| Ted Kremenek | ad6eff6 | 2010-03-08 21:17:29 +0000 | [diff] [blame] | 1628 | * \brief Determine whether the given cursor represents a currently | 
|  | 1629 | *  unexposed piece of the AST (e.g., CXCursor_UnexposedStmt). | 
|  | 1630 | */ | 
|  | 1631 | CINDEX_LINKAGE unsigned clang_isUnexposed(enum CXCursorKind); | 
|  | 1632 |  | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1633 | /** | 
| Ted Kremenek | 16b4259 | 2010-03-03 06:36:57 +0000 | [diff] [blame] | 1634 | * \brief Describe the linkage of the entity referred to by a cursor. | 
|  | 1635 | */ | 
|  | 1636 | enum CXLinkageKind { | 
|  | 1637 | /** \brief This value indicates that no linkage information is available | 
|  | 1638 | * for a provided CXCursor. */ | 
|  | 1639 | CXLinkage_Invalid, | 
|  | 1640 | /** | 
|  | 1641 | * \brief This is the linkage for variables, parameters, and so on that | 
|  | 1642 | *  have automatic storage.  This covers normal (non-extern) local variables. | 
|  | 1643 | */ | 
|  | 1644 | CXLinkage_NoLinkage, | 
|  | 1645 | /** \brief This is the linkage for static variables and static functions. */ | 
|  | 1646 | CXLinkage_Internal, | 
|  | 1647 | /** \brief This is the linkage for entities with external linkage that live | 
|  | 1648 | * in C++ anonymous namespaces.*/ | 
|  | 1649 | CXLinkage_UniqueExternal, | 
|  | 1650 | /** \brief This is the linkage for entities with true, external linkage. */ | 
|  | 1651 | CXLinkage_External | 
|  | 1652 | }; | 
|  | 1653 |  | 
|  | 1654 | /** | 
| Ted Kremenek | 45e1dae | 2010-04-12 21:22:16 +0000 | [diff] [blame] | 1655 | * \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] | 1656 | */ | 
|  | 1657 | CINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor); | 
|  | 1658 |  | 
|  | 1659 | /** | 
| Douglas Gregor | 58ddb60 | 2010-08-23 23:00:57 +0000 | [diff] [blame] | 1660 | * \brief Determine the availability of the entity that this cursor refers to. | 
|  | 1661 | * | 
|  | 1662 | * \param cursor The cursor to query. | 
|  | 1663 | * | 
|  | 1664 | * \returns The availability of the cursor. | 
|  | 1665 | */ | 
|  | 1666 | CINDEX_LINKAGE enum CXAvailabilityKind | 
|  | 1667 | clang_getCursorAvailability(CXCursor cursor); | 
|  | 1668 |  | 
|  | 1669 | /** | 
| Ted Kremenek | 45e1dae | 2010-04-12 21:22:16 +0000 | [diff] [blame] | 1670 | * \brief Describe the "language" of the entity referred to by a cursor. | 
|  | 1671 | */ | 
|  | 1672 | CINDEX_LINKAGE enum CXLanguageKind { | 
| Ted Kremenek | 6cd1e7c | 2010-04-14 20:58:32 +0000 | [diff] [blame] | 1673 | CXLanguage_Invalid = 0, | 
| Ted Kremenek | 45e1dae | 2010-04-12 21:22:16 +0000 | [diff] [blame] | 1674 | CXLanguage_C, | 
|  | 1675 | CXLanguage_ObjC, | 
| Ted Kremenek | 6cd1e7c | 2010-04-14 20:58:32 +0000 | [diff] [blame] | 1676 | CXLanguage_CPlusPlus | 
| Ted Kremenek | 45e1dae | 2010-04-12 21:22:16 +0000 | [diff] [blame] | 1677 | }; | 
|  | 1678 |  | 
|  | 1679 | /** | 
|  | 1680 | * \brief Determine the "language" of the entity referred to by a given cursor. | 
|  | 1681 | */ | 
|  | 1682 | CINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor); | 
|  | 1683 |  | 
| Argyrios Kyrtzidis | b0d6eaa | 2011-09-27 00:30:30 +0000 | [diff] [blame] | 1684 | /** | 
|  | 1685 | * \brief Returns the translation unit that a cursor originated from. | 
|  | 1686 | */ | 
|  | 1687 | CINDEX_LINKAGE CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor); | 
|  | 1688 |  | 
| Ted Kremenek | eca099b | 2010-12-08 23:43:14 +0000 | [diff] [blame] | 1689 |  | 
|  | 1690 | /** | 
|  | 1691 | * \brief A fast container representing a set of CXCursors. | 
|  | 1692 | */ | 
|  | 1693 | typedef struct CXCursorSetImpl *CXCursorSet; | 
|  | 1694 |  | 
|  | 1695 | /** | 
|  | 1696 | * \brief Creates an empty CXCursorSet. | 
|  | 1697 | */ | 
|  | 1698 | CINDEX_LINKAGE CXCursorSet clang_createCXCursorSet(); | 
|  | 1699 |  | 
|  | 1700 | /** | 
|  | 1701 | * \brief Disposes a CXCursorSet and releases its associated memory. | 
|  | 1702 | */ | 
|  | 1703 | CINDEX_LINKAGE void clang_disposeCXCursorSet(CXCursorSet cset); | 
|  | 1704 |  | 
|  | 1705 | /** | 
|  | 1706 | * \brief Queries a CXCursorSet to see if it contains a specific CXCursor. | 
|  | 1707 | * | 
|  | 1708 | * \returns non-zero if the set contains the specified cursor. | 
|  | 1709 | */ | 
|  | 1710 | CINDEX_LINKAGE unsigned clang_CXCursorSet_contains(CXCursorSet cset, | 
|  | 1711 | CXCursor cursor); | 
|  | 1712 |  | 
|  | 1713 | /** | 
|  | 1714 | * \brief Inserts a CXCursor into a CXCursorSet. | 
|  | 1715 | * | 
|  | 1716 | * \returns zero if the CXCursor was already in the set, and non-zero otherwise. | 
|  | 1717 | */ | 
|  | 1718 | CINDEX_LINKAGE unsigned clang_CXCursorSet_insert(CXCursorSet cset, | 
|  | 1719 | CXCursor cursor); | 
|  | 1720 |  | 
| Douglas Gregor | 2be5bc9 | 2010-09-22 21:22:29 +0000 | [diff] [blame] | 1721 | /** | 
|  | 1722 | * \brief Determine the semantic parent of the given cursor. | 
|  | 1723 | * | 
|  | 1724 | * The semantic parent of a cursor is the cursor that semantically contains | 
|  | 1725 | * the given \p cursor. For many declarations, the lexical and semantic parents | 
|  | 1726 | * are equivalent (the lexical parent is returned by | 
|  | 1727 | * \c clang_getCursorLexicalParent()). They diverge when declarations or | 
|  | 1728 | * definitions are provided out-of-line. For example: | 
|  | 1729 | * | 
|  | 1730 | * \code | 
|  | 1731 | * class C { | 
|  | 1732 | *  void f(); | 
|  | 1733 | * }; | 
|  | 1734 | * | 
|  | 1735 | * void C::f() { } | 
|  | 1736 | * \endcode | 
|  | 1737 | * | 
|  | 1738 | * In the out-of-line definition of \c C::f, the semantic parent is the | 
|  | 1739 | * the class \c C, of which this function is a member. The lexical parent is | 
|  | 1740 | * the place where the declaration actually occurs in the source code; in this | 
|  | 1741 | * case, the definition occurs in the translation unit. In general, the | 
|  | 1742 | * lexical parent for a given entity can change without affecting the semantics | 
|  | 1743 | * of the program, and the lexical parent of different declarations of the | 
|  | 1744 | * same entity may be different. Changing the semantic parent of a declaration, | 
|  | 1745 | * on the other hand, can have a major impact on semantics, and redeclarations | 
|  | 1746 | * of a particular entity should all have the same semantic context. | 
|  | 1747 | * | 
|  | 1748 | * In the example above, both declarations of \c C::f have \c C as their | 
|  | 1749 | * semantic context, while the lexical context of the first \c C::f is \c C | 
|  | 1750 | * 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] | 1751 | * | 
|  | 1752 | * For global declarations, the semantic parent is the translation unit. | 
| Douglas Gregor | 2be5bc9 | 2010-09-22 21:22:29 +0000 | [diff] [blame] | 1753 | */ | 
|  | 1754 | CINDEX_LINKAGE CXCursor clang_getCursorSemanticParent(CXCursor cursor); | 
|  | 1755 |  | 
|  | 1756 | /** | 
|  | 1757 | * \brief Determine the lexical parent of the given cursor. | 
|  | 1758 | * | 
|  | 1759 | * The lexical parent of a cursor is the cursor in which the given \p cursor | 
|  | 1760 | * was actually written. For many declarations, the lexical and semantic parents | 
|  | 1761 | * are equivalent (the semantic parent is returned by | 
|  | 1762 | * \c clang_getCursorSemanticParent()). They diverge when declarations or | 
|  | 1763 | * definitions are provided out-of-line. For example: | 
|  | 1764 | * | 
|  | 1765 | * \code | 
|  | 1766 | * class C { | 
|  | 1767 | *  void f(); | 
|  | 1768 | * }; | 
|  | 1769 | * | 
|  | 1770 | * void C::f() { } | 
|  | 1771 | * \endcode | 
|  | 1772 | * | 
|  | 1773 | * In the out-of-line definition of \c C::f, the semantic parent is the | 
|  | 1774 | * the class \c C, of which this function is a member. The lexical parent is | 
|  | 1775 | * the place where the declaration actually occurs in the source code; in this | 
|  | 1776 | * case, the definition occurs in the translation unit. In general, the | 
|  | 1777 | * lexical parent for a given entity can change without affecting the semantics | 
|  | 1778 | * of the program, and the lexical parent of different declarations of the | 
|  | 1779 | * same entity may be different. Changing the semantic parent of a declaration, | 
|  | 1780 | * on the other hand, can have a major impact on semantics, and redeclarations | 
|  | 1781 | * of a particular entity should all have the same semantic context. | 
|  | 1782 | * | 
|  | 1783 | * In the example above, both declarations of \c C::f have \c C as their | 
|  | 1784 | * semantic context, while the lexical context of the first \c C::f is \c C | 
|  | 1785 | * 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] | 1786 | * | 
|  | 1787 | * For declarations written in the global scope, the lexical parent is | 
|  | 1788 | * the translation unit. | 
| Douglas Gregor | 2be5bc9 | 2010-09-22 21:22:29 +0000 | [diff] [blame] | 1789 | */ | 
|  | 1790 | CINDEX_LINKAGE CXCursor clang_getCursorLexicalParent(CXCursor cursor); | 
| Douglas Gregor | 9f59234 | 2010-10-01 20:25:15 +0000 | [diff] [blame] | 1791 |  | 
|  | 1792 | /** | 
|  | 1793 | * \brief Determine the set of methods that are overridden by the given | 
|  | 1794 | * method. | 
|  | 1795 | * | 
|  | 1796 | * In both Objective-C and C++, a method (aka virtual member function, | 
|  | 1797 | * in C++) can override a virtual method in a base class. For | 
|  | 1798 | * Objective-C, a method is said to override any method in the class's | 
|  | 1799 | * interface (if we're coming from an implementation), its protocols, | 
|  | 1800 | * or its categories, that has the same selector and is of the same | 
|  | 1801 | * kind (class or instance). If no such method exists, the search | 
|  | 1802 | * continues to the class's superclass, its protocols, and its | 
|  | 1803 | * categories, and so on. | 
|  | 1804 | * | 
|  | 1805 | * For C++, a virtual member function overrides any virtual member | 
|  | 1806 | * function with the same signature that occurs in its base | 
|  | 1807 | * classes. With multiple inheritance, a virtual member function can | 
|  | 1808 | * override several virtual member functions coming from different | 
|  | 1809 | * base classes. | 
|  | 1810 | * | 
|  | 1811 | * In all cases, this function determines the immediate overridden | 
|  | 1812 | * method, rather than all of the overridden methods. For example, if | 
|  | 1813 | * a method is originally declared in a class A, then overridden in B | 
|  | 1814 | * (which in inherits from A) and also in C (which inherited from B), | 
|  | 1815 | * then the only overridden method returned from this function when | 
|  | 1816 | * invoked on C's method will be B's method. The client may then | 
|  | 1817 | * invoke this function again, given the previously-found overridden | 
|  | 1818 | * methods, to map out the complete method-override set. | 
|  | 1819 | * | 
|  | 1820 | * \param cursor A cursor representing an Objective-C or C++ | 
|  | 1821 | * method. This routine will compute the set of methods that this | 
|  | 1822 | * method overrides. | 
|  | 1823 | * | 
|  | 1824 | * \param overridden A pointer whose pointee will be replaced with a | 
|  | 1825 | * pointer to an array of cursors, representing the set of overridden | 
|  | 1826 | * methods. If there are no overridden methods, the pointee will be | 
|  | 1827 | * set to NULL. The pointee must be freed via a call to | 
|  | 1828 | * \c clang_disposeOverriddenCursors(). | 
|  | 1829 | * | 
|  | 1830 | * \param num_overridden A pointer to the number of overridden | 
|  | 1831 | * functions, will be set to the number of overridden functions in the | 
|  | 1832 | * array pointed to by \p overridden. | 
|  | 1833 | */ | 
|  | 1834 | CINDEX_LINKAGE void clang_getOverriddenCursors(CXCursor cursor, | 
|  | 1835 | CXCursor **overridden, | 
|  | 1836 | unsigned *num_overridden); | 
|  | 1837 |  | 
|  | 1838 | /** | 
|  | 1839 | * \brief Free the set of overridden cursors returned by \c | 
|  | 1840 | * clang_getOverriddenCursors(). | 
|  | 1841 | */ | 
|  | 1842 | CINDEX_LINKAGE void clang_disposeOverriddenCursors(CXCursor *overridden); | 
|  | 1843 |  | 
| Ted Kremenek | 45e1dae | 2010-04-12 21:22:16 +0000 | [diff] [blame] | 1844 | /** | 
| Douglas Gregor | ecdcb88 | 2010-10-20 22:00:55 +0000 | [diff] [blame] | 1845 | * \brief Retrieve the file that is included by the given inclusion directive | 
|  | 1846 | * cursor. | 
|  | 1847 | */ | 
|  | 1848 | CINDEX_LINKAGE CXFile clang_getIncludedFile(CXCursor cursor); | 
|  | 1849 |  | 
|  | 1850 | /** | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1851 | * @} | 
|  | 1852 | */ | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1853 |  | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1854 | /** | 
|  | 1855 | * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code | 
|  | 1856 | * | 
|  | 1857 | * Cursors represent a location within the Abstract Syntax Tree (AST). These | 
|  | 1858 | * routines help map between cursors and the physical locations where the | 
|  | 1859 | * described entities occur in the source code. The mapping is provided in | 
|  | 1860 | * both directions, so one can map from source code to the AST and back. | 
|  | 1861 | * | 
|  | 1862 | * @{ | 
| Steve Naroff | 5039819 | 2009-08-28 15:28:48 +0000 | [diff] [blame] | 1863 | */ | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1864 |  | 
| Steve Naroff | 6a6de8b | 2009-10-21 13:56:23 +0000 | [diff] [blame] | 1865 | /** | 
| Douglas Gregor | b979034 | 2010-01-22 21:44:22 +0000 | [diff] [blame] | 1866 | * \brief Map a source location to the cursor that describes the entity at that | 
|  | 1867 | * location in the source code. | 
|  | 1868 | * | 
|  | 1869 | * clang_getCursor() maps an arbitrary source location within a translation | 
|  | 1870 | * 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] | 1871 | * location. For example, given an expression \c x + y, invoking | 
| Douglas Gregor | b979034 | 2010-01-22 21:44:22 +0000 | [diff] [blame] | 1872 | * clang_getCursor() with a source location pointing to "x" will return the | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1873 | * cursor for "x"; similarly for "y". If the cursor points anywhere between | 
| Douglas Gregor | b979034 | 2010-01-22 21:44:22 +0000 | [diff] [blame] | 1874 | * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor() | 
|  | 1875 | * will return a cursor referring to the "+" expression. | 
|  | 1876 | * | 
|  | 1877 | * \returns a cursor representing the entity at the given source location, or | 
|  | 1878 | * a NULL cursor if no such entity can be found. | 
| Steve Naroff | 6a6de8b | 2009-10-21 13:56:23 +0000 | [diff] [blame] | 1879 | */ | 
| Douglas Gregor | b979034 | 2010-01-22 21:44:22 +0000 | [diff] [blame] | 1880 | CINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, CXSourceLocation); | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1881 |  | 
| Douglas Gregor | 98258af | 2010-01-18 22:46:11 +0000 | [diff] [blame] | 1882 | /** | 
|  | 1883 | * \brief Retrieve the physical location of the source constructor referenced | 
|  | 1884 | * by the given cursor. | 
|  | 1885 | * | 
|  | 1886 | * 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] | 1887 | * declaration, where the name of that declaration would occur if it is | 
|  | 1888 | * unnamed, or some keyword that introduces that particular declaration. | 
|  | 1889 | * The location of a reference is where that reference occurs within the | 
| Douglas Gregor | 98258af | 2010-01-18 22:46:11 +0000 | [diff] [blame] | 1890 | * source code. | 
|  | 1891 | */ | 
|  | 1892 | CINDEX_LINKAGE CXSourceLocation clang_getCursorLocation(CXCursor); | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1893 |  | 
| Douglas Gregor | b699866 | 2010-01-19 19:34:47 +0000 | [diff] [blame] | 1894 | /** | 
|  | 1895 | * \brief Retrieve the physical extent of the source construct referenced by | 
| Douglas Gregor | a7bde20 | 2010-01-19 00:34:46 +0000 | [diff] [blame] | 1896 | * the given cursor. | 
|  | 1897 | * | 
|  | 1898 | * The extent of a cursor starts with the file/line/column pointing at the | 
|  | 1899 | * first character within the source construct that the cursor refers to and | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 1900 | * ends with the last character withinin that source construct. For a | 
| Douglas Gregor | a7bde20 | 2010-01-19 00:34:46 +0000 | [diff] [blame] | 1901 | * declaration, the extent covers the declaration itself. For a reference, | 
|  | 1902 | * the extent covers the location of the reference (e.g., where the referenced | 
|  | 1903 | * entity was actually used). | 
|  | 1904 | */ | 
|  | 1905 | CINDEX_LINKAGE CXSourceRange clang_getCursorExtent(CXCursor); | 
| Douglas Gregor | c5d1e93 | 2010-01-19 01:20:04 +0000 | [diff] [blame] | 1906 |  | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1907 | /** | 
|  | 1908 | * @} | 
|  | 1909 | */ | 
| Ted Kremenek | 95f3355 | 2010-08-26 01:42:22 +0000 | [diff] [blame] | 1910 |  | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 1911 | /** | 
| Ted Kremenek | 8e0ac17 | 2010-05-14 21:29:26 +0000 | [diff] [blame] | 1912 | * \defgroup CINDEX_TYPES Type information for CXCursors | 
|  | 1913 | * | 
|  | 1914 | * @{ | 
|  | 1915 | */ | 
|  | 1916 |  | 
|  | 1917 | /** | 
|  | 1918 | * \brief Describes the kind of type | 
|  | 1919 | */ | 
|  | 1920 | enum CXTypeKind { | 
|  | 1921 | /** | 
|  | 1922 | * \brief Reprents an invalid type (e.g., where no type is available). | 
|  | 1923 | */ | 
|  | 1924 | CXType_Invalid = 0, | 
|  | 1925 |  | 
|  | 1926 | /** | 
|  | 1927 | * \brief A type whose specific kind is not exposed via this | 
|  | 1928 | * interface. | 
|  | 1929 | */ | 
|  | 1930 | CXType_Unexposed = 1, | 
|  | 1931 |  | 
|  | 1932 | /* Builtin types */ | 
|  | 1933 | CXType_Void = 2, | 
|  | 1934 | CXType_Bool = 3, | 
|  | 1935 | CXType_Char_U = 4, | 
|  | 1936 | CXType_UChar = 5, | 
|  | 1937 | CXType_Char16 = 6, | 
|  | 1938 | CXType_Char32 = 7, | 
|  | 1939 | CXType_UShort = 8, | 
|  | 1940 | CXType_UInt = 9, | 
|  | 1941 | CXType_ULong = 10, | 
|  | 1942 | CXType_ULongLong = 11, | 
|  | 1943 | CXType_UInt128 = 12, | 
|  | 1944 | CXType_Char_S = 13, | 
|  | 1945 | CXType_SChar = 14, | 
|  | 1946 | CXType_WChar = 15, | 
|  | 1947 | CXType_Short = 16, | 
|  | 1948 | CXType_Int = 17, | 
|  | 1949 | CXType_Long = 18, | 
|  | 1950 | CXType_LongLong = 19, | 
|  | 1951 | CXType_Int128 = 20, | 
|  | 1952 | CXType_Float = 21, | 
|  | 1953 | CXType_Double = 22, | 
|  | 1954 | CXType_LongDouble = 23, | 
|  | 1955 | CXType_NullPtr = 24, | 
|  | 1956 | CXType_Overload = 25, | 
|  | 1957 | CXType_Dependent = 26, | 
|  | 1958 | CXType_ObjCId = 27, | 
|  | 1959 | CXType_ObjCClass = 28, | 
|  | 1960 | CXType_ObjCSel = 29, | 
|  | 1961 | CXType_FirstBuiltin = CXType_Void, | 
|  | 1962 | CXType_LastBuiltin  = CXType_ObjCSel, | 
|  | 1963 |  | 
|  | 1964 | CXType_Complex = 100, | 
|  | 1965 | CXType_Pointer = 101, | 
|  | 1966 | CXType_BlockPointer = 102, | 
|  | 1967 | CXType_LValueReference = 103, | 
|  | 1968 | CXType_RValueReference = 104, | 
|  | 1969 | CXType_Record = 105, | 
|  | 1970 | CXType_Enum = 106, | 
|  | 1971 | CXType_Typedef = 107, | 
|  | 1972 | CXType_ObjCInterface = 108, | 
| Ted Kremenek | 04c3cf3 | 2010-06-21 20:15:39 +0000 | [diff] [blame] | 1973 | CXType_ObjCObjectPointer = 109, | 
|  | 1974 | CXType_FunctionNoProto = 110, | 
| Argyrios Kyrtzidis | 5f0bfc5 | 2011-09-27 17:44:34 +0000 | [diff] [blame] | 1975 | CXType_FunctionProto = 111, | 
|  | 1976 | CXType_ConstantArray = 112 | 
| Ted Kremenek | 8e0ac17 | 2010-05-14 21:29:26 +0000 | [diff] [blame] | 1977 | }; | 
|  | 1978 |  | 
|  | 1979 | /** | 
|  | 1980 | * \brief The type of an element in the abstract syntax tree. | 
|  | 1981 | * | 
|  | 1982 | */ | 
|  | 1983 | typedef struct { | 
|  | 1984 | enum CXTypeKind kind; | 
|  | 1985 | void *data[2]; | 
|  | 1986 | } CXType; | 
|  | 1987 |  | 
|  | 1988 | /** | 
|  | 1989 | * \brief Retrieve the type of a CXCursor (if any). | 
|  | 1990 | */ | 
|  | 1991 | CINDEX_LINKAGE CXType clang_getCursorType(CXCursor C); | 
|  | 1992 |  | 
|  | 1993 | /** | 
|  | 1994 | * \determine Determine whether two CXTypes represent the same type. | 
|  | 1995 | * | 
|  | 1996 | * \returns non-zero if the CXTypes represent the same type and | 
|  | 1997 | zero otherwise. | 
|  | 1998 | */ | 
|  | 1999 | CINDEX_LINKAGE unsigned clang_equalTypes(CXType A, CXType B); | 
|  | 2000 |  | 
|  | 2001 | /** | 
|  | 2002 | * \brief Return the canonical type for a CXType. | 
|  | 2003 | * | 
|  | 2004 | * Clang's type system explicitly models typedefs and all the ways | 
|  | 2005 | * a specific type can be represented.  The canonical type is the underlying | 
|  | 2006 | * type with all the "sugar" removed.  For example, if 'T' is a typedef | 
|  | 2007 | * for 'int', the canonical type for 'T' would be 'int'. | 
|  | 2008 | */ | 
|  | 2009 | CINDEX_LINKAGE CXType clang_getCanonicalType(CXType T); | 
|  | 2010 |  | 
|  | 2011 | /** | 
| Douglas Gregor | e72fb6f | 2011-01-27 16:27:11 +0000 | [diff] [blame] | 2012 | *  \determine Determine whether a CXType has the "const" qualifier set, | 
|  | 2013 | *  without looking through typedefs that may have added "const" at a different level. | 
|  | 2014 | */ | 
|  | 2015 | CINDEX_LINKAGE unsigned clang_isConstQualifiedType(CXType T); | 
|  | 2016 |  | 
|  | 2017 | /** | 
|  | 2018 | *  \determine Determine whether a CXType has the "volatile" qualifier set, | 
|  | 2019 | *  without looking through typedefs that may have added "volatile" at a different level. | 
|  | 2020 | */ | 
|  | 2021 | CINDEX_LINKAGE unsigned clang_isVolatileQualifiedType(CXType T); | 
|  | 2022 |  | 
|  | 2023 | /** | 
|  | 2024 | *  \determine Determine whether a CXType has the "restrict" qualifier set, | 
|  | 2025 | *  without looking through typedefs that may have added "restrict" at a different level. | 
|  | 2026 | */ | 
|  | 2027 | CINDEX_LINKAGE unsigned clang_isRestrictQualifiedType(CXType T); | 
|  | 2028 |  | 
|  | 2029 | /** | 
| Ted Kremenek | 8e0ac17 | 2010-05-14 21:29:26 +0000 | [diff] [blame] | 2030 | * \brief For pointer types, returns the type of the pointee. | 
|  | 2031 | * | 
|  | 2032 | */ | 
|  | 2033 | CINDEX_LINKAGE CXType clang_getPointeeType(CXType T); | 
|  | 2034 |  | 
|  | 2035 | /** | 
|  | 2036 | * \brief Return the cursor for the declaration of the given type. | 
|  | 2037 | */ | 
|  | 2038 | CINDEX_LINKAGE CXCursor clang_getTypeDeclaration(CXType T); | 
|  | 2039 |  | 
| David Chisnall | 5389f48 | 2010-12-30 14:05:53 +0000 | [diff] [blame] | 2040 | /** | 
|  | 2041 | * Returns the Objective-C type encoding for the specified declaration. | 
|  | 2042 | */ | 
|  | 2043 | CINDEX_LINKAGE CXString clang_getDeclObjCTypeEncoding(CXCursor C); | 
| Ted Kremenek | 8e0ac17 | 2010-05-14 21:29:26 +0000 | [diff] [blame] | 2044 |  | 
|  | 2045 | /** | 
|  | 2046 | * \brief Retrieve the spelling of a given CXTypeKind. | 
|  | 2047 | */ | 
|  | 2048 | CINDEX_LINKAGE CXString clang_getTypeKindSpelling(enum CXTypeKind K); | 
|  | 2049 |  | 
|  | 2050 | /** | 
| Ted Kremenek | 9a14084 | 2010-06-21 20:48:56 +0000 | [diff] [blame] | 2051 | * \brief Retrieve the result type associated with a function type. | 
| Ted Kremenek | 04c3cf3 | 2010-06-21 20:15:39 +0000 | [diff] [blame] | 2052 | */ | 
|  | 2053 | CINDEX_LINKAGE CXType clang_getResultType(CXType T); | 
|  | 2054 |  | 
|  | 2055 | /** | 
| Ted Kremenek | 9a14084 | 2010-06-21 20:48:56 +0000 | [diff] [blame] | 2056 | * \brief Retrieve the result type associated with a given cursor.  This only | 
|  | 2057 | *  returns a valid type of the cursor refers to a function or method. | 
|  | 2058 | */ | 
|  | 2059 | CINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C); | 
|  | 2060 |  | 
|  | 2061 | /** | 
| Ted Kremenek | 3ce9e7d | 2010-07-30 00:14:11 +0000 | [diff] [blame] | 2062 | * \brief Return 1 if the CXType is a POD (plain old data) type, and 0 | 
|  | 2063 | *  otherwise. | 
|  | 2064 | */ | 
|  | 2065 | CINDEX_LINKAGE unsigned clang_isPODType(CXType T); | 
|  | 2066 |  | 
|  | 2067 | /** | 
| Argyrios Kyrtzidis | 5f0bfc5 | 2011-09-27 17:44:34 +0000 | [diff] [blame] | 2068 | * \brief Return the element type of an array type. | 
|  | 2069 | * | 
|  | 2070 | * If a non-array type is passed in, an invalid type is returned. | 
|  | 2071 | */ | 
|  | 2072 | CINDEX_LINKAGE CXType clang_getArrayElementType(CXType T); | 
|  | 2073 |  | 
|  | 2074 | /** | 
|  | 2075 | * \brief Return the the array size of a constant array. | 
|  | 2076 | * | 
|  | 2077 | * If a non-array type is passed in, -1 is returned. | 
|  | 2078 | */ | 
|  | 2079 | CINDEX_LINKAGE long long clang_getArraySize(CXType T); | 
|  | 2080 |  | 
|  | 2081 | /** | 
| Ted Kremenek | 3064ef9 | 2010-08-27 21:34:58 +0000 | [diff] [blame] | 2082 | * \brief Returns 1 if the base class specified by the cursor with kind | 
|  | 2083 | *   CX_CXXBaseSpecifier is virtual. | 
|  | 2084 | */ | 
|  | 2085 | CINDEX_LINKAGE unsigned clang_isVirtualBase(CXCursor); | 
|  | 2086 |  | 
|  | 2087 | /** | 
|  | 2088 | * \brief Represents the C++ access control level to a base class for a | 
|  | 2089 | * cursor with kind CX_CXXBaseSpecifier. | 
|  | 2090 | */ | 
|  | 2091 | enum CX_CXXAccessSpecifier { | 
|  | 2092 | CX_CXXInvalidAccessSpecifier, | 
|  | 2093 | CX_CXXPublic, | 
|  | 2094 | CX_CXXProtected, | 
|  | 2095 | CX_CXXPrivate | 
|  | 2096 | }; | 
|  | 2097 |  | 
|  | 2098 | /** | 
|  | 2099 | * \brief Returns the access control level for the C++ base specifier | 
| Argyrios Kyrtzidis | 2dfdb94 | 2011-09-30 17:58:23 +0000 | [diff] [blame^] | 2100 | * represented by a cursor with kind CXCursor_CXXBaseSpecifier or | 
|  | 2101 | * CXCursor_AccessSpecifier. | 
| Ted Kremenek | 3064ef9 | 2010-08-27 21:34:58 +0000 | [diff] [blame] | 2102 | */ | 
|  | 2103 | CINDEX_LINKAGE enum CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor); | 
|  | 2104 |  | 
|  | 2105 | /** | 
| Douglas Gregor | 1f60d9e | 2010-09-13 22:52:57 +0000 | [diff] [blame] | 2106 | * \brief Determine the number of overloaded declarations referenced by a | 
|  | 2107 | * \c CXCursor_OverloadedDeclRef cursor. | 
|  | 2108 | * | 
|  | 2109 | * \param cursor The cursor whose overloaded declarations are being queried. | 
|  | 2110 | * | 
|  | 2111 | * \returns The number of overloaded declarations referenced by \c cursor. If it | 
|  | 2112 | * is not a \c CXCursor_OverloadedDeclRef cursor, returns 0. | 
|  | 2113 | */ | 
|  | 2114 | CINDEX_LINKAGE unsigned clang_getNumOverloadedDecls(CXCursor cursor); | 
|  | 2115 |  | 
|  | 2116 | /** | 
|  | 2117 | * \brief Retrieve a cursor for one of the overloaded declarations referenced | 
|  | 2118 | * by a \c CXCursor_OverloadedDeclRef cursor. | 
|  | 2119 | * | 
|  | 2120 | * \param cursor The cursor whose overloaded declarations are being queried. | 
|  | 2121 | * | 
|  | 2122 | * \param index The zero-based index into the set of overloaded declarations in | 
|  | 2123 | * the cursor. | 
|  | 2124 | * | 
|  | 2125 | * \returns A cursor representing the declaration referenced by the given | 
|  | 2126 | * \c cursor at the specified \c index. If the cursor does not have an | 
|  | 2127 | * associated set of overloaded declarations, or if the index is out of bounds, | 
|  | 2128 | * returns \c clang_getNullCursor(); | 
|  | 2129 | */ | 
|  | 2130 | CINDEX_LINKAGE CXCursor clang_getOverloadedDecl(CXCursor cursor, | 
|  | 2131 | unsigned index); | 
|  | 2132 |  | 
|  | 2133 | /** | 
| Ted Kremenek | 8e0ac17 | 2010-05-14 21:29:26 +0000 | [diff] [blame] | 2134 | * @} | 
|  | 2135 | */ | 
| Ted Kremenek | 95f3355 | 2010-08-26 01:42:22 +0000 | [diff] [blame] | 2136 |  | 
|  | 2137 | /** | 
| Ted Kremenek | ad72f4d | 2010-08-27 21:34:51 +0000 | [diff] [blame] | 2138 | * \defgroup CINDEX_ATTRIBUTES Information for attributes | 
| Ted Kremenek | 95f3355 | 2010-08-26 01:42:22 +0000 | [diff] [blame] | 2139 | * | 
|  | 2140 | * @{ | 
|  | 2141 | */ | 
|  | 2142 |  | 
|  | 2143 |  | 
|  | 2144 | /** | 
|  | 2145 | * \brief For cursors representing an iboutletcollection attribute, | 
|  | 2146 | *  this function returns the collection element type. | 
|  | 2147 | * | 
|  | 2148 | */ | 
|  | 2149 | CINDEX_LINKAGE CXType clang_getIBOutletCollectionType(CXCursor); | 
|  | 2150 |  | 
|  | 2151 | /** | 
|  | 2152 | * @} | 
|  | 2153 | */ | 
| Ted Kremenek | 8e0ac17 | 2010-05-14 21:29:26 +0000 | [diff] [blame] | 2154 |  | 
|  | 2155 | /** | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2156 | * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors | 
|  | 2157 | * | 
|  | 2158 | * These routines provide the ability to traverse the abstract syntax tree | 
|  | 2159 | * using cursors. | 
|  | 2160 | * | 
|  | 2161 | * @{ | 
|  | 2162 | */ | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2163 |  | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2164 | /** | 
|  | 2165 | * \brief Describes how the traversal of the children of a particular | 
|  | 2166 | * cursor should proceed after visiting a particular child cursor. | 
|  | 2167 | * | 
|  | 2168 | * A value of this enumeration type should be returned by each | 
|  | 2169 | * \c CXCursorVisitor to indicate how clang_visitChildren() proceed. | 
|  | 2170 | */ | 
|  | 2171 | enum CXChildVisitResult { | 
|  | 2172 | /** | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2173 | * \brief Terminates the cursor traversal. | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2174 | */ | 
|  | 2175 | CXChildVisit_Break, | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2176 | /** | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2177 | * \brief Continues the cursor traversal with the next sibling of | 
|  | 2178 | * the cursor just visited, without visiting its children. | 
|  | 2179 | */ | 
|  | 2180 | CXChildVisit_Continue, | 
|  | 2181 | /** | 
|  | 2182 | * \brief Recursively traverse the children of this cursor, using | 
|  | 2183 | * the same visitor and client data. | 
|  | 2184 | */ | 
|  | 2185 | CXChildVisit_Recurse | 
|  | 2186 | }; | 
|  | 2187 |  | 
|  | 2188 | /** | 
|  | 2189 | * \brief Visitor invoked for each cursor found by a traversal. | 
|  | 2190 | * | 
|  | 2191 | * This visitor function will be invoked for each cursor found by | 
|  | 2192 | * clang_visitCursorChildren(). Its first argument is the cursor being | 
|  | 2193 | * visited, its second argument is the parent visitor for that cursor, | 
|  | 2194 | * and its third argument is the client data provided to | 
|  | 2195 | * clang_visitCursorChildren(). | 
|  | 2196 | * | 
|  | 2197 | * The visitor should return one of the \c CXChildVisitResult values | 
|  | 2198 | * to direct clang_visitCursorChildren(). | 
|  | 2199 | */ | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2200 | typedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor, | 
|  | 2201 | CXCursor parent, | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2202 | CXClientData client_data); | 
|  | 2203 |  | 
|  | 2204 | /** | 
|  | 2205 | * \brief Visit the children of a particular cursor. | 
|  | 2206 | * | 
|  | 2207 | * This function visits all the direct children of the given cursor, | 
|  | 2208 | * invoking the given \p visitor function with the cursors of each | 
|  | 2209 | * visited child. The traversal may be recursive, if the visitor returns | 
|  | 2210 | * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if | 
|  | 2211 | * the visitor returns \c CXChildVisit_Break. | 
|  | 2212 | * | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2213 | * \param parent the cursor whose child may be visited. All kinds of | 
| Daniel Dunbar | a57259e | 2010-01-24 04:10:31 +0000 | [diff] [blame] | 2214 | * cursors can be visited, including invalid cursors (which, by | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2215 | * definition, have no children). | 
|  | 2216 | * | 
|  | 2217 | * \param visitor the visitor function that will be invoked for each | 
|  | 2218 | * child of \p parent. | 
|  | 2219 | * | 
|  | 2220 | * \param client_data pointer data supplied by the client, which will | 
|  | 2221 | * be passed to the visitor each time it is invoked. | 
|  | 2222 | * | 
|  | 2223 | * \returns a non-zero value if the traversal was terminated | 
|  | 2224 | * prematurely by the visitor returning \c CXChildVisit_Break. | 
|  | 2225 | */ | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2226 | CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent, | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2227 | CXCursorVisitor visitor, | 
|  | 2228 | CXClientData client_data); | 
| David Chisnall | 3387c65 | 2010-11-03 14:12:26 +0000 | [diff] [blame] | 2229 | #ifdef __has_feature | 
|  | 2230 | #  if __has_feature(blocks) | 
|  | 2231 | /** | 
|  | 2232 | * \brief Visitor invoked for each cursor found by a traversal. | 
|  | 2233 | * | 
|  | 2234 | * This visitor block will be invoked for each cursor found by | 
|  | 2235 | * clang_visitChildrenWithBlock(). Its first argument is the cursor being | 
|  | 2236 | * visited, its second argument is the parent visitor for that cursor. | 
|  | 2237 | * | 
|  | 2238 | * The visitor should return one of the \c CXChildVisitResult values | 
|  | 2239 | * to direct clang_visitChildrenWithBlock(). | 
|  | 2240 | */ | 
|  | 2241 | typedef enum CXChildVisitResult | 
|  | 2242 | (^CXCursorVisitorBlock)(CXCursor cursor, CXCursor parent); | 
|  | 2243 |  | 
|  | 2244 | /** | 
|  | 2245 | * Visits the children of a cursor using the specified block.  Behaves | 
|  | 2246 | * identically to clang_visitChildren() in all other respects. | 
|  | 2247 | */ | 
|  | 2248 | unsigned clang_visitChildrenWithBlock(CXCursor parent, | 
|  | 2249 | CXCursorVisitorBlock block); | 
|  | 2250 | #  endif | 
|  | 2251 | #endif | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2252 |  | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2253 | /** | 
|  | 2254 | * @} | 
|  | 2255 | */ | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2256 |  | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2257 | /** | 
|  | 2258 | * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST | 
|  | 2259 | * | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2260 | * These routines provide the ability to determine references within and | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2261 | * across translation units, by providing the names of the entities referenced | 
|  | 2262 | * by cursors, follow reference cursors to the declarations they reference, | 
|  | 2263 | * and associate declarations with their definitions. | 
|  | 2264 | * | 
|  | 2265 | * @{ | 
|  | 2266 | */ | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2267 |  | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2268 | /** | 
|  | 2269 | * \brief Retrieve a Unified Symbol Resolution (USR) for the entity referenced | 
|  | 2270 | * by the given cursor. | 
|  | 2271 | * | 
|  | 2272 | * A Unified Symbol Resolution (USR) is a string that identifies a particular | 
|  | 2273 | * entity (function, class, variable, etc.) within a program. USRs can be | 
|  | 2274 | * compared across translation units to determine, e.g., when references in | 
|  | 2275 | * one translation refer to an entity defined in another translation unit. | 
|  | 2276 | */ | 
|  | 2277 | CINDEX_LINKAGE CXString clang_getCursorUSR(CXCursor); | 
|  | 2278 |  | 
|  | 2279 | /** | 
| Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 2280 | * \brief Construct a USR for a specified Objective-C class. | 
|  | 2281 | */ | 
|  | 2282 | CINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name); | 
|  | 2283 |  | 
|  | 2284 | /** | 
|  | 2285 | * \brief Construct a USR for a specified Objective-C category. | 
|  | 2286 | */ | 
|  | 2287 | CINDEX_LINKAGE CXString | 
| Ted Kremenek | 66ccaec | 2010-03-15 17:38:58 +0000 | [diff] [blame] | 2288 | clang_constructUSR_ObjCCategory(const char *class_name, | 
| Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 2289 | const char *category_name); | 
|  | 2290 |  | 
|  | 2291 | /** | 
|  | 2292 | * \brief Construct a USR for a specified Objective-C protocol. | 
|  | 2293 | */ | 
|  | 2294 | CINDEX_LINKAGE CXString | 
|  | 2295 | clang_constructUSR_ObjCProtocol(const char *protocol_name); | 
|  | 2296 |  | 
|  | 2297 |  | 
|  | 2298 | /** | 
|  | 2299 | * \brief Construct a USR for a specified Objective-C instance variable and | 
|  | 2300 | *   the USR for its containing class. | 
|  | 2301 | */ | 
|  | 2302 | CINDEX_LINKAGE CXString clang_constructUSR_ObjCIvar(const char *name, | 
|  | 2303 | CXString classUSR); | 
|  | 2304 |  | 
|  | 2305 | /** | 
|  | 2306 | * \brief Construct a USR for a specified Objective-C method and | 
|  | 2307 | *   the USR for its containing class. | 
|  | 2308 | */ | 
|  | 2309 | CINDEX_LINKAGE CXString clang_constructUSR_ObjCMethod(const char *name, | 
|  | 2310 | unsigned isInstanceMethod, | 
|  | 2311 | CXString classUSR); | 
|  | 2312 |  | 
|  | 2313 | /** | 
|  | 2314 | * \brief Construct a USR for a specified Objective-C property and the USR | 
|  | 2315 | *  for its containing class. | 
|  | 2316 | */ | 
|  | 2317 | CINDEX_LINKAGE CXString clang_constructUSR_ObjCProperty(const char *property, | 
|  | 2318 | CXString classUSR); | 
|  | 2319 |  | 
|  | 2320 | /** | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2321 | * \brief Retrieve a name for the entity referenced by this cursor. | 
|  | 2322 | */ | 
|  | 2323 | CINDEX_LINKAGE CXString clang_getCursorSpelling(CXCursor); | 
|  | 2324 |  | 
| Douglas Gregor | 358559d | 2010-10-02 22:49:11 +0000 | [diff] [blame] | 2325 | /** | 
|  | 2326 | * \brief Retrieve the display name for the entity referenced by this cursor. | 
|  | 2327 | * | 
|  | 2328 | * The display name contains extra information that helps identify the cursor, | 
|  | 2329 | * such as the parameters of a function or template or the arguments of a | 
|  | 2330 | * class template specialization. | 
|  | 2331 | */ | 
|  | 2332 | CINDEX_LINKAGE CXString clang_getCursorDisplayName(CXCursor); | 
|  | 2333 |  | 
| Douglas Gregor | c5d1e93 | 2010-01-19 01:20:04 +0000 | [diff] [blame] | 2334 | /** \brief For a cursor that is a reference, retrieve a cursor representing the | 
|  | 2335 | * entity that it references. | 
|  | 2336 | * | 
|  | 2337 | * Reference cursors refer to other entities in the AST. For example, an | 
|  | 2338 | * Objective-C superclass reference cursor refers to an Objective-C class. | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2339 | * This function produces the cursor for the Objective-C class from the | 
| Douglas Gregor | c5d1e93 | 2010-01-19 01:20:04 +0000 | [diff] [blame] | 2340 | * cursor for the superclass reference. If the input cursor is a declaration or | 
|  | 2341 | * definition, it returns that declaration or definition unchanged. | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2342 | * Otherwise, returns the NULL cursor. | 
| Douglas Gregor | c5d1e93 | 2010-01-19 01:20:04 +0000 | [diff] [blame] | 2343 | */ | 
|  | 2344 | CINDEX_LINKAGE CXCursor clang_getCursorReferenced(CXCursor); | 
| Douglas Gregor | b699866 | 2010-01-19 19:34:47 +0000 | [diff] [blame] | 2345 |  | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2346 | /** | 
| Douglas Gregor | b699866 | 2010-01-19 19:34:47 +0000 | [diff] [blame] | 2347 | *  \brief For a cursor that is either a reference to or a declaration | 
|  | 2348 | *  of some entity, retrieve a cursor that describes the definition of | 
|  | 2349 | *  that entity. | 
|  | 2350 | * | 
|  | 2351 | *  Some entities can be declared multiple times within a translation | 
|  | 2352 | *  unit, but only one of those declarations can also be a | 
|  | 2353 | *  definition. For example, given: | 
|  | 2354 | * | 
|  | 2355 | *  \code | 
|  | 2356 | *  int f(int, int); | 
|  | 2357 | *  int g(int x, int y) { return f(x, y); } | 
|  | 2358 | *  int f(int a, int b) { return a + b; } | 
|  | 2359 | *  int f(int, int); | 
|  | 2360 | *  \endcode | 
|  | 2361 | * | 
|  | 2362 | *  there are three declarations of the function "f", but only the | 
|  | 2363 | *  second one is a definition. The clang_getCursorDefinition() | 
|  | 2364 | *  function will take any cursor pointing to a declaration of "f" | 
|  | 2365 | *  (the first or fourth lines of the example) or a cursor referenced | 
|  | 2366 | *  that uses "f" (the call to "f' inside "g") and will return a | 
|  | 2367 | *  declaration cursor pointing to the definition (the second "f" | 
|  | 2368 | *  declaration). | 
|  | 2369 | * | 
|  | 2370 | *  If given a cursor for which there is no corresponding definition, | 
|  | 2371 | *  e.g., because there is no definition of that entity within this | 
|  | 2372 | *  translation unit, returns a NULL cursor. | 
|  | 2373 | */ | 
|  | 2374 | CINDEX_LINKAGE CXCursor clang_getCursorDefinition(CXCursor); | 
|  | 2375 |  | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2376 | /** | 
| Douglas Gregor | b699866 | 2010-01-19 19:34:47 +0000 | [diff] [blame] | 2377 | * \brief Determine whether the declaration pointed to by this cursor | 
|  | 2378 | * is also a definition of that entity. | 
|  | 2379 | */ | 
|  | 2380 | CINDEX_LINKAGE unsigned clang_isCursorDefinition(CXCursor); | 
|  | 2381 |  | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2382 | /** | 
| Douglas Gregor | 1a9d050 | 2010-11-19 23:44:15 +0000 | [diff] [blame] | 2383 | * \brief Retrieve the canonical cursor corresponding to the given cursor. | 
|  | 2384 | * | 
|  | 2385 | * In the C family of languages, many kinds of entities can be declared several | 
|  | 2386 | * times within a single translation unit. For example, a structure type can | 
|  | 2387 | * be forward-declared (possibly multiple times) and later defined: | 
|  | 2388 | * | 
|  | 2389 | * \code | 
|  | 2390 | * struct X; | 
|  | 2391 | * struct X; | 
|  | 2392 | * struct X { | 
|  | 2393 | *   int member; | 
|  | 2394 | * }; | 
|  | 2395 | * \endcode | 
|  | 2396 | * | 
|  | 2397 | * The declarations and the definition of \c X are represented by three | 
|  | 2398 | * different cursors, all of which are declarations of the same underlying | 
|  | 2399 | * entity. One of these cursor is considered the "canonical" cursor, which | 
|  | 2400 | * is effectively the representative for the underlying entity. One can | 
|  | 2401 | * determine if two cursors are declarations of the same underlying entity by | 
|  | 2402 | * comparing their canonical cursors. | 
|  | 2403 | * | 
|  | 2404 | * \returns The canonical cursor for the entity referred to by the given cursor. | 
|  | 2405 | */ | 
|  | 2406 | CINDEX_LINKAGE CXCursor clang_getCanonicalCursor(CXCursor); | 
|  | 2407 |  | 
|  | 2408 | /** | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2409 | * @} | 
|  | 2410 | */ | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2411 |  | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2412 | /** | 
| Ted Kremenek | 9ada39a | 2010-05-17 20:06:56 +0000 | [diff] [blame] | 2413 | * \defgroup CINDEX_CPP C++ AST introspection | 
|  | 2414 | * | 
|  | 2415 | * The routines in this group provide access information in the ASTs specific | 
|  | 2416 | * to C++ language features. | 
|  | 2417 | * | 
|  | 2418 | * @{ | 
|  | 2419 | */ | 
|  | 2420 |  | 
|  | 2421 | /** | 
| Douglas Gregor | 49f6f54 | 2010-08-31 22:12:17 +0000 | [diff] [blame] | 2422 | * \brief Determine if a C++ member function or member function template is | 
|  | 2423 | * declared 'static'. | 
| Ted Kremenek | 9ada39a | 2010-05-17 20:06:56 +0000 | [diff] [blame] | 2424 | */ | 
|  | 2425 | CINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C); | 
|  | 2426 |  | 
|  | 2427 | /** | 
| Douglas Gregor | 211924b | 2011-05-12 15:17:24 +0000 | [diff] [blame] | 2428 | * \brief Determine if a C++ member function or member function template is | 
|  | 2429 | * explicitly declared 'virtual' or if it overrides a virtual method from | 
|  | 2430 | * one of the base classes. | 
|  | 2431 | */ | 
|  | 2432 | CINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual(CXCursor C); | 
|  | 2433 |  | 
|  | 2434 | /** | 
| Douglas Gregor | 49f6f54 | 2010-08-31 22:12:17 +0000 | [diff] [blame] | 2435 | * \brief Given a cursor that represents a template, determine | 
|  | 2436 | * the cursor kind of the specializations would be generated by instantiating | 
|  | 2437 | * the template. | 
|  | 2438 | * | 
|  | 2439 | * This routine can be used to determine what flavor of function template, | 
|  | 2440 | * class template, or class template partial specialization is stored in the | 
|  | 2441 | * cursor. For example, it can describe whether a class template cursor is | 
|  | 2442 | * declared with "struct", "class" or "union". | 
|  | 2443 | * | 
|  | 2444 | * \param C The cursor to query. This cursor should represent a template | 
|  | 2445 | * declaration. | 
|  | 2446 | * | 
|  | 2447 | * \returns The cursor kind of the specializations that would be generated | 
|  | 2448 | * by instantiating the template \p C. If \p C is not a template, returns | 
|  | 2449 | * \c CXCursor_NoDeclFound. | 
|  | 2450 | */ | 
|  | 2451 | CINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind(CXCursor C); | 
|  | 2452 |  | 
|  | 2453 | /** | 
| Douglas Gregor | e0329ac | 2010-09-02 00:07:54 +0000 | [diff] [blame] | 2454 | * \brief Given a cursor that may represent a specialization or instantiation | 
|  | 2455 | * of a template, retrieve the cursor that represents the template that it | 
|  | 2456 | * specializes or from which it was instantiated. | 
|  | 2457 | * | 
|  | 2458 | * This routine determines the template involved both for explicit | 
|  | 2459 | * specializations of templates and for implicit instantiations of the template, | 
|  | 2460 | * both of which are referred to as "specializations". For a class template | 
|  | 2461 | * specialization (e.g., \c std::vector<bool>), this routine will return | 
|  | 2462 | * either the primary template (\c std::vector) or, if the specialization was | 
|  | 2463 | * instantiated from a class template partial specialization, the class template | 
|  | 2464 | * partial specialization. For a class template partial specialization and a | 
|  | 2465 | * function template specialization (including instantiations), this | 
|  | 2466 | * this routine will return the specialized template. | 
|  | 2467 | * | 
|  | 2468 | * For members of a class template (e.g., member functions, member classes, or | 
|  | 2469 | * static data members), returns the specialized or instantiated member. | 
|  | 2470 | * Although not strictly "templates" in the C++ language, members of class | 
|  | 2471 | * templates have the same notions of specializations and instantiations that | 
|  | 2472 | * templates do, so this routine treats them similarly. | 
|  | 2473 | * | 
|  | 2474 | * \param C A cursor that may be a specialization of a template or a member | 
|  | 2475 | * of a template. | 
|  | 2476 | * | 
|  | 2477 | * \returns If the given cursor is a specialization or instantiation of a | 
|  | 2478 | * template or a member thereof, the template or member that it specializes or | 
|  | 2479 | * from which it was instantiated. Otherwise, returns a NULL cursor. | 
|  | 2480 | */ | 
|  | 2481 | CINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate(CXCursor C); | 
| Douglas Gregor | 430d7a1 | 2011-07-25 17:48:11 +0000 | [diff] [blame] | 2482 |  | 
|  | 2483 | /** | 
|  | 2484 | * \brief Given a cursor that references something else, return the source range | 
|  | 2485 | * covering that reference. | 
|  | 2486 | * | 
|  | 2487 | * \param C A cursor pointing to a member reference, a declaration reference, or | 
|  | 2488 | * an operator call. | 
|  | 2489 | * \param NameFlags A bitset with three independent flags: | 
|  | 2490 | * CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and | 
|  | 2491 | * CXNameRange_WantSinglePiece. | 
|  | 2492 | * \param PieceIndex For contiguous names or when passing the flag | 
|  | 2493 | * CXNameRange_WantSinglePiece, only one piece with index 0 is | 
|  | 2494 | * available. When the CXNameRange_WantSinglePiece flag is not passed for a | 
|  | 2495 | * non-contiguous names, this index can be used to retreive the individual | 
|  | 2496 | * pieces of the name. See also CXNameRange_WantSinglePiece. | 
|  | 2497 | * | 
|  | 2498 | * \returns The piece of the name pointed to by the given cursor. If there is no | 
|  | 2499 | * name, or if the PieceIndex is out-of-range, a null-cursor will be returned. | 
|  | 2500 | */ | 
| Francois Pichet | 48a8d14 | 2011-07-25 22:00:44 +0000 | [diff] [blame] | 2501 | CINDEX_LINKAGE CXSourceRange clang_getCursorReferenceNameRange(CXCursor C, | 
|  | 2502 | unsigned NameFlags, | 
| Douglas Gregor | 430d7a1 | 2011-07-25 17:48:11 +0000 | [diff] [blame] | 2503 | unsigned PieceIndex); | 
|  | 2504 |  | 
|  | 2505 | enum CXNameRefFlags { | 
|  | 2506 | /** | 
|  | 2507 | * \brief Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the | 
|  | 2508 | * range. | 
|  | 2509 | */ | 
|  | 2510 | CXNameRange_WantQualifier = 0x1, | 
|  | 2511 |  | 
|  | 2512 | /** | 
|  | 2513 | * \brief Include the explicit template arguments, e.g. <int> in x.f<int>, in | 
|  | 2514 | * the range. | 
|  | 2515 | */ | 
|  | 2516 | CXNameRange_WantTemplateArgs = 0x2, | 
|  | 2517 |  | 
|  | 2518 | /** | 
|  | 2519 | * \brief If the name is non-contiguous, return the full spanning range. | 
|  | 2520 | * | 
|  | 2521 | * Non-contiguous names occur in Objective-C when a selector with two or more | 
|  | 2522 | * parameters is used, or in C++ when using an operator: | 
|  | 2523 | * \code | 
|  | 2524 | * [object doSomething:here withValue:there]; // ObjC | 
|  | 2525 | * return some_vector[1]; // C++ | 
|  | 2526 | * \endcode | 
|  | 2527 | */ | 
|  | 2528 | CXNameRange_WantSinglePiece = 0x4 | 
|  | 2529 | }; | 
| Douglas Gregor | e0329ac | 2010-09-02 00:07:54 +0000 | [diff] [blame] | 2530 |  | 
|  | 2531 | /** | 
| Ted Kremenek | 9ada39a | 2010-05-17 20:06:56 +0000 | [diff] [blame] | 2532 | * @} | 
|  | 2533 | */ | 
|  | 2534 |  | 
|  | 2535 | /** | 
| Douglas Gregor | 0045e9f | 2010-01-26 18:31:56 +0000 | [diff] [blame] | 2536 | * \defgroup CINDEX_LEX Token extraction and manipulation | 
|  | 2537 | * | 
|  | 2538 | * The routines in this group provide access to the tokens within a | 
|  | 2539 | * translation unit, along with a semantic mapping of those tokens to | 
|  | 2540 | * their corresponding cursors. | 
| Douglas Gregor | fc8ea23 | 2010-01-26 17:06:03 +0000 | [diff] [blame] | 2541 | * | 
|  | 2542 | * @{ | 
|  | 2543 | */ | 
|  | 2544 |  | 
|  | 2545 | /** | 
|  | 2546 | * \brief Describes a kind of token. | 
|  | 2547 | */ | 
|  | 2548 | typedef enum CXTokenKind { | 
|  | 2549 | /** | 
|  | 2550 | * \brief A token that contains some kind of punctuation. | 
|  | 2551 | */ | 
|  | 2552 | CXToken_Punctuation, | 
| Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 2553 |  | 
| Douglas Gregor | fc8ea23 | 2010-01-26 17:06:03 +0000 | [diff] [blame] | 2554 | /** | 
| Douglas Gregor | 0045e9f | 2010-01-26 18:31:56 +0000 | [diff] [blame] | 2555 | * \brief A language keyword. | 
| Douglas Gregor | fc8ea23 | 2010-01-26 17:06:03 +0000 | [diff] [blame] | 2556 | */ | 
|  | 2557 | CXToken_Keyword, | 
| Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 2558 |  | 
| Douglas Gregor | fc8ea23 | 2010-01-26 17:06:03 +0000 | [diff] [blame] | 2559 | /** | 
|  | 2560 | * \brief An identifier (that is not a keyword). | 
|  | 2561 | */ | 
|  | 2562 | CXToken_Identifier, | 
| Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 2563 |  | 
| Douglas Gregor | fc8ea23 | 2010-01-26 17:06:03 +0000 | [diff] [blame] | 2564 | /** | 
|  | 2565 | * \brief A numeric, string, or character literal. | 
|  | 2566 | */ | 
|  | 2567 | CXToken_Literal, | 
| Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 2568 |  | 
| Douglas Gregor | fc8ea23 | 2010-01-26 17:06:03 +0000 | [diff] [blame] | 2569 | /** | 
|  | 2570 | * \brief A comment. | 
|  | 2571 | */ | 
|  | 2572 | CXToken_Comment | 
|  | 2573 | } CXTokenKind; | 
|  | 2574 |  | 
|  | 2575 | /** | 
|  | 2576 | * \brief Describes a single preprocessing token. | 
|  | 2577 | */ | 
|  | 2578 | typedef struct { | 
|  | 2579 | unsigned int_data[4]; | 
|  | 2580 | void *ptr_data; | 
|  | 2581 | } CXToken; | 
|  | 2582 |  | 
|  | 2583 | /** | 
|  | 2584 | * \brief Determine the kind of the given token. | 
|  | 2585 | */ | 
|  | 2586 | CINDEX_LINKAGE CXTokenKind clang_getTokenKind(CXToken); | 
| Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 2587 |  | 
| Douglas Gregor | fc8ea23 | 2010-01-26 17:06:03 +0000 | [diff] [blame] | 2588 | /** | 
|  | 2589 | * \brief Determine the spelling of the given token. | 
|  | 2590 | * | 
|  | 2591 | * The spelling of a token is the textual representation of that token, e.g., | 
|  | 2592 | * the text of an identifier or keyword. | 
|  | 2593 | */ | 
|  | 2594 | CINDEX_LINKAGE CXString clang_getTokenSpelling(CXTranslationUnit, CXToken); | 
| Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 2595 |  | 
| Douglas Gregor | fc8ea23 | 2010-01-26 17:06:03 +0000 | [diff] [blame] | 2596 | /** | 
|  | 2597 | * \brief Retrieve the source location of the given token. | 
|  | 2598 | */ | 
| Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 2599 | CINDEX_LINKAGE CXSourceLocation clang_getTokenLocation(CXTranslationUnit, | 
| Douglas Gregor | fc8ea23 | 2010-01-26 17:06:03 +0000 | [diff] [blame] | 2600 | CXToken); | 
| Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 2601 |  | 
| Douglas Gregor | fc8ea23 | 2010-01-26 17:06:03 +0000 | [diff] [blame] | 2602 | /** | 
|  | 2603 | * \brief Retrieve a source range that covers the given token. | 
|  | 2604 | */ | 
|  | 2605 | CINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken); | 
|  | 2606 |  | 
|  | 2607 | /** | 
|  | 2608 | * \brief Tokenize the source code described by the given range into raw | 
|  | 2609 | * lexical tokens. | 
|  | 2610 | * | 
|  | 2611 | * \param TU the translation unit whose text is being tokenized. | 
|  | 2612 | * | 
|  | 2613 | * \param Range the source range in which text should be tokenized. All of the | 
|  | 2614 | * tokens produced by tokenization will fall within this source range, | 
|  | 2615 | * | 
|  | 2616 | * \param Tokens this pointer will be set to point to the array of tokens | 
|  | 2617 | * that occur within the given source range. The returned pointer must be | 
|  | 2618 | * freed with clang_disposeTokens() before the translation unit is destroyed. | 
|  | 2619 | * | 
|  | 2620 | * \param NumTokens will be set to the number of tokens in the \c *Tokens | 
|  | 2621 | * array. | 
|  | 2622 | * | 
|  | 2623 | */ | 
|  | 2624 | CINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range, | 
|  | 2625 | CXToken **Tokens, unsigned *NumTokens); | 
| Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 2626 |  | 
| Douglas Gregor | fc8ea23 | 2010-01-26 17:06:03 +0000 | [diff] [blame] | 2627 | /** | 
|  | 2628 | * \brief Annotate the given set of tokens by providing cursors for each token | 
|  | 2629 | * that can be mapped to a specific entity within the abstract syntax tree. | 
|  | 2630 | * | 
| Douglas Gregor | 0045e9f | 2010-01-26 18:31:56 +0000 | [diff] [blame] | 2631 | * This token-annotation routine is equivalent to invoking | 
|  | 2632 | * clang_getCursor() for the source locations of each of the | 
|  | 2633 | * tokens. The cursors provided are filtered, so that only those | 
|  | 2634 | * cursors that have a direct correspondence to the token are | 
|  | 2635 | * accepted. For example, given a function call \c f(x), | 
|  | 2636 | * clang_getCursor() would provide the following cursors: | 
|  | 2637 | * | 
|  | 2638 | *   * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'. | 
|  | 2639 | *   * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'. | 
|  | 2640 | *   * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'. | 
|  | 2641 | * | 
|  | 2642 | * Only the first and last of these cursors will occur within the | 
|  | 2643 | * annotate, since the tokens "f" and "x' directly refer to a function | 
|  | 2644 | * and a variable, respectively, but the parentheses are just a small | 
|  | 2645 | * part of the full syntax of the function call expression, which is | 
|  | 2646 | * not provided as an annotation. | 
| Douglas Gregor | fc8ea23 | 2010-01-26 17:06:03 +0000 | [diff] [blame] | 2647 | * | 
|  | 2648 | * \param TU the translation unit that owns the given tokens. | 
|  | 2649 | * | 
|  | 2650 | * \param Tokens the set of tokens to annotate. | 
|  | 2651 | * | 
|  | 2652 | * \param NumTokens the number of tokens in \p Tokens. | 
|  | 2653 | * | 
|  | 2654 | * \param Cursors an array of \p NumTokens cursors, whose contents will be | 
|  | 2655 | * replaced with the cursors corresponding to each token. | 
|  | 2656 | */ | 
|  | 2657 | CINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU, | 
|  | 2658 | CXToken *Tokens, unsigned NumTokens, | 
|  | 2659 | CXCursor *Cursors); | 
| Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 2660 |  | 
| Douglas Gregor | fc8ea23 | 2010-01-26 17:06:03 +0000 | [diff] [blame] | 2661 | /** | 
|  | 2662 | * \brief Free the given set of tokens. | 
|  | 2663 | */ | 
| Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 2664 | CINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU, | 
| Douglas Gregor | fc8ea23 | 2010-01-26 17:06:03 +0000 | [diff] [blame] | 2665 | CXToken *Tokens, unsigned NumTokens); | 
| Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 2666 |  | 
| Douglas Gregor | fc8ea23 | 2010-01-26 17:06:03 +0000 | [diff] [blame] | 2667 | /** | 
|  | 2668 | * @} | 
|  | 2669 | */ | 
| Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 2670 |  | 
| Douglas Gregor | fc8ea23 | 2010-01-26 17:06:03 +0000 | [diff] [blame] | 2671 | /** | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2672 | * \defgroup CINDEX_DEBUG Debugging facilities | 
|  | 2673 | * | 
|  | 2674 | * These routines are used for testing and debugging, only, and should not | 
|  | 2675 | * be relied upon. | 
|  | 2676 | * | 
|  | 2677 | * @{ | 
|  | 2678 | */ | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2679 |  | 
| Steve Naroff | 4ade6d6 | 2009-09-23 17:52:52 +0000 | [diff] [blame] | 2680 | /* for debug/testing */ | 
| Ted Kremenek | e68fff6 | 2010-02-17 00:41:32 +0000 | [diff] [blame] | 2681 | CINDEX_LINKAGE CXString clang_getCursorKindSpelling(enum CXCursorKind Kind); | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2682 | CINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(CXCursor, | 
|  | 2683 | const char **startBuf, | 
| Steve Naroff | 4ade6d6 | 2009-09-23 17:52:52 +0000 | [diff] [blame] | 2684 | const char **endBuf, | 
|  | 2685 | unsigned *startLine, | 
|  | 2686 | unsigned *startColumn, | 
|  | 2687 | unsigned *endLine, | 
|  | 2688 | unsigned *endColumn); | 
| Douglas Gregor | 0a812cf | 2010-02-18 23:07:20 +0000 | [diff] [blame] | 2689 | CINDEX_LINKAGE void clang_enableStackTraces(void); | 
| Daniel Dunbar | 995aaf9 | 2010-11-04 01:26:29 +0000 | [diff] [blame] | 2690 | CINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void*), void *user_data, | 
|  | 2691 | unsigned stack_size); | 
|  | 2692 |  | 
| Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 2693 | /** | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2694 | * @} | 
|  | 2695 | */ | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2696 |  | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2697 | /** | 
|  | 2698 | * \defgroup CINDEX_CODE_COMPLET Code completion | 
|  | 2699 | * | 
|  | 2700 | * Code completion involves taking an (incomplete) source file, along with | 
|  | 2701 | * knowledge of where the user is actively editing that file, and suggesting | 
|  | 2702 | * syntactically- and semantically-valid constructs that the user might want to | 
|  | 2703 | * use at that particular point in the source code. These data structures and | 
|  | 2704 | * routines provide support for code completion. | 
|  | 2705 | * | 
|  | 2706 | * @{ | 
|  | 2707 | */ | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2708 |  | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 2709 | /** | 
| Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 2710 | * \brief A semantic string that describes a code-completion result. | 
|  | 2711 | * | 
|  | 2712 | * A semantic string that describes the formatting of a code-completion | 
|  | 2713 | * result as a single "template" of text that should be inserted into the | 
|  | 2714 | * source buffer when a particular code-completion result is selected. | 
|  | 2715 | * Each semantic string is made up of some number of "chunks", each of which | 
|  | 2716 | * contains some text along with a description of what that text means, e.g., | 
|  | 2717 | * the name of the entity being referenced, whether the text chunk is part of | 
|  | 2718 | * the template, or whether it is a "placeholder" that the user should replace | 
|  | 2719 | * with actual code,of a specific kind. See \c CXCompletionChunkKind for a | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2720 | * description of the different kinds of chunks. | 
| Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 2721 | */ | 
|  | 2722 | typedef void *CXCompletionString; | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2723 |  | 
| Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 2724 | /** | 
|  | 2725 | * \brief A single result of code completion. | 
|  | 2726 | */ | 
|  | 2727 | typedef struct { | 
|  | 2728 | /** | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2729 | * \brief The kind of entity that this completion refers to. | 
| Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 2730 | * | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2731 | * 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] | 2732 | * *Decl cursor kinds), describing the entity that the completion is | 
|  | 2733 | * referring to. | 
|  | 2734 | * | 
|  | 2735 | * \todo In the future, we would like to provide a full cursor, to allow | 
|  | 2736 | * the client to extract additional information from declaration. | 
|  | 2737 | */ | 
|  | 2738 | enum CXCursorKind CursorKind; | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2739 |  | 
|  | 2740 | /** | 
| Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 2741 | * \brief The code-completion string that describes how to insert this | 
|  | 2742 | * code-completion result into the editing buffer. | 
|  | 2743 | */ | 
|  | 2744 | CXCompletionString CompletionString; | 
|  | 2745 | } CXCompletionResult; | 
|  | 2746 |  | 
|  | 2747 | /** | 
|  | 2748 | * \brief Describes a single piece of text within a code-completion string. | 
|  | 2749 | * | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2750 | * Each "chunk" within a code-completion string (\c CXCompletionString) is | 
|  | 2751 | * 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] | 2752 | * should be interpreted by the client or is another completion string. | 
|  | 2753 | */ | 
|  | 2754 | enum CXCompletionChunkKind { | 
|  | 2755 | /** | 
|  | 2756 | * \brief A code-completion string that describes "optional" text that | 
|  | 2757 | * could be a part of the template (but is not required). | 
|  | 2758 | * | 
|  | 2759 | * 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] | 2760 | * string for its representation, which is accessible via | 
| Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 2761 | * \c clang_getCompletionChunkCompletionString(). The code-completion string | 
|  | 2762 | * describes an additional part of the template that is completely optional. | 
|  | 2763 | * For example, optional chunks can be used to describe the placeholders for | 
|  | 2764 | * arguments that match up with defaulted function parameters, e.g. given: | 
|  | 2765 | * | 
|  | 2766 | * \code | 
|  | 2767 | * void f(int x, float y = 3.14, double z = 2.71828); | 
|  | 2768 | * \endcode | 
|  | 2769 | * | 
|  | 2770 | * The code-completion string for this function would contain: | 
|  | 2771 | *   - a TypedText chunk for "f". | 
|  | 2772 | *   - a LeftParen chunk for "(". | 
|  | 2773 | *   - a Placeholder chunk for "int x" | 
|  | 2774 | *   - an Optional chunk containing the remaining defaulted arguments, e.g., | 
|  | 2775 | *       - a Comma chunk for "," | 
| Daniel Dunbar | 7157018 | 2010-02-17 08:07:44 +0000 | [diff] [blame] | 2776 | *       - a Placeholder chunk for "float y" | 
| Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 2777 | *       - an Optional chunk containing the last defaulted argument: | 
|  | 2778 | *           - a Comma chunk for "," | 
|  | 2779 | *           - a Placeholder chunk for "double z" | 
|  | 2780 | *   - a RightParen chunk for ")" | 
|  | 2781 | * | 
| Daniel Dunbar | 7157018 | 2010-02-17 08:07:44 +0000 | [diff] [blame] | 2782 | * There are many ways to handle Optional chunks. Two simple approaches are: | 
| Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 2783 | *   - Completely ignore optional chunks, in which case the template for the | 
|  | 2784 | *     function "f" would only include the first parameter ("int x"). | 
|  | 2785 | *   - Fully expand all optional chunks, in which case the template for the | 
|  | 2786 | *     function "f" would have all of the parameters. | 
|  | 2787 | */ | 
|  | 2788 | CXCompletionChunk_Optional, | 
|  | 2789 | /** | 
|  | 2790 | * \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] | 2791 | * code-completion result. | 
| Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 2792 | * | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2793 | * There will be exactly one "typed text" chunk in a semantic string, which | 
|  | 2794 | * 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] | 2795 | * declaration that could be used at the current code point. Clients are | 
|  | 2796 | * expected to filter the code-completion results based on the text in this | 
|  | 2797 | * chunk. | 
|  | 2798 | */ | 
|  | 2799 | CXCompletionChunk_TypedText, | 
|  | 2800 | /** | 
|  | 2801 | * \brief Text that should be inserted as part of a code-completion result. | 
|  | 2802 | * | 
|  | 2803 | * A "text" chunk represents text that is part of the template to be | 
|  | 2804 | * inserted into user code should this particular code-completion result | 
|  | 2805 | * be selected. | 
|  | 2806 | */ | 
|  | 2807 | CXCompletionChunk_Text, | 
|  | 2808 | /** | 
|  | 2809 | * \brief Placeholder text that should be replaced by the user. | 
|  | 2810 | * | 
|  | 2811 | * A "placeholder" chunk marks a place where the user should insert text | 
|  | 2812 | * into the code-completion template. For example, placeholders might mark | 
|  | 2813 | * the function parameters for a function declaration, to indicate that the | 
|  | 2814 | * user should provide arguments for each of those parameters. The actual | 
|  | 2815 | * text in a placeholder is a suggestion for the text to display before | 
|  | 2816 | * the user replaces the placeholder with real code. | 
|  | 2817 | */ | 
|  | 2818 | CXCompletionChunk_Placeholder, | 
|  | 2819 | /** | 
|  | 2820 | * \brief Informative text that should be displayed but never inserted as | 
|  | 2821 | * part of the template. | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2822 | * | 
| Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 2823 | * An "informative" chunk contains annotations that can be displayed to | 
|  | 2824 | * help the user decide whether a particular code-completion result is the | 
|  | 2825 | * right option, but which is not part of the actual template to be inserted | 
|  | 2826 | * by code completion. | 
|  | 2827 | */ | 
|  | 2828 | CXCompletionChunk_Informative, | 
|  | 2829 | /** | 
|  | 2830 | * \brief Text that describes the current parameter when code-completion is | 
|  | 2831 | * referring to function call, message send, or template specialization. | 
|  | 2832 | * | 
|  | 2833 | * A "current parameter" chunk occurs when code-completion is providing | 
|  | 2834 | * information about a parameter corresponding to the argument at the | 
|  | 2835 | * code-completion point. For example, given a function | 
|  | 2836 | * | 
|  | 2837 | * \code | 
|  | 2838 | * int add(int x, int y); | 
|  | 2839 | * \endcode | 
|  | 2840 | * | 
|  | 2841 | * and the source code \c add(, where the code-completion point is after the | 
|  | 2842 | * "(", the code-completion string will contain a "current parameter" chunk | 
|  | 2843 | * for "int x", indicating that the current argument will initialize that | 
|  | 2844 | * parameter. After typing further, to \c add(17, (where the code-completion | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2845 | * point is after the ","), the code-completion string will contain a | 
| Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 2846 | * "current paremeter" chunk to "int y". | 
|  | 2847 | */ | 
|  | 2848 | CXCompletionChunk_CurrentParameter, | 
|  | 2849 | /** | 
|  | 2850 | * \brief A left parenthesis ('('), used to initiate a function call or | 
|  | 2851 | * signal the beginning of a function parameter list. | 
|  | 2852 | */ | 
|  | 2853 | CXCompletionChunk_LeftParen, | 
|  | 2854 | /** | 
|  | 2855 | * \brief A right parenthesis (')'), used to finish a function call or | 
|  | 2856 | * signal the end of a function parameter list. | 
|  | 2857 | */ | 
|  | 2858 | CXCompletionChunk_RightParen, | 
|  | 2859 | /** | 
|  | 2860 | * \brief A left bracket ('['). | 
|  | 2861 | */ | 
|  | 2862 | CXCompletionChunk_LeftBracket, | 
|  | 2863 | /** | 
|  | 2864 | * \brief A right bracket (']'). | 
|  | 2865 | */ | 
|  | 2866 | CXCompletionChunk_RightBracket, | 
|  | 2867 | /** | 
|  | 2868 | * \brief A left brace ('{'). | 
|  | 2869 | */ | 
|  | 2870 | CXCompletionChunk_LeftBrace, | 
|  | 2871 | /** | 
|  | 2872 | * \brief A right brace ('}'). | 
|  | 2873 | */ | 
|  | 2874 | CXCompletionChunk_RightBrace, | 
|  | 2875 | /** | 
|  | 2876 | * \brief A left angle bracket ('<'). | 
|  | 2877 | */ | 
|  | 2878 | CXCompletionChunk_LeftAngle, | 
|  | 2879 | /** | 
|  | 2880 | * \brief A right angle bracket ('>'). | 
|  | 2881 | */ | 
|  | 2882 | CXCompletionChunk_RightAngle, | 
|  | 2883 | /** | 
|  | 2884 | * \brief A comma separator (','). | 
|  | 2885 | */ | 
| Douglas Gregor | ff5ce6e | 2009-12-18 18:53:37 +0000 | [diff] [blame] | 2886 | CXCompletionChunk_Comma, | 
|  | 2887 | /** | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2888 | * \brief Text that specifies the result type of a given result. | 
| Douglas Gregor | ff5ce6e | 2009-12-18 18:53:37 +0000 | [diff] [blame] | 2889 | * | 
|  | 2890 | * 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] | 2891 | * 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] | 2892 | * expression using the given completion string would have. | 
|  | 2893 | */ | 
| Douglas Gregor | 01dfea0 | 2010-01-10 23:08:15 +0000 | [diff] [blame] | 2894 | CXCompletionChunk_ResultType, | 
|  | 2895 | /** | 
|  | 2896 | * \brief A colon (':'). | 
|  | 2897 | */ | 
|  | 2898 | CXCompletionChunk_Colon, | 
|  | 2899 | /** | 
|  | 2900 | * \brief A semicolon (';'). | 
|  | 2901 | */ | 
|  | 2902 | CXCompletionChunk_SemiColon, | 
|  | 2903 | /** | 
|  | 2904 | * \brief An '=' sign. | 
|  | 2905 | */ | 
|  | 2906 | CXCompletionChunk_Equal, | 
|  | 2907 | /** | 
|  | 2908 | * Horizontal space (' '). | 
|  | 2909 | */ | 
|  | 2910 | CXCompletionChunk_HorizontalSpace, | 
|  | 2911 | /** | 
|  | 2912 | * Vertical space ('\n'), after which it is generally a good idea to | 
|  | 2913 | * perform indentation. | 
|  | 2914 | */ | 
|  | 2915 | CXCompletionChunk_VerticalSpace | 
| Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 2916 | }; | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2917 |  | 
| Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 2918 | /** | 
|  | 2919 | * \brief Determine the kind of a particular chunk within a completion string. | 
|  | 2920 | * | 
|  | 2921 | * \param completion_string the completion string to query. | 
|  | 2922 | * | 
|  | 2923 | * \param chunk_number the 0-based index of the chunk in the completion string. | 
|  | 2924 | * | 
|  | 2925 | * \returns the kind of the chunk at the index \c chunk_number. | 
|  | 2926 | */ | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2927 | CINDEX_LINKAGE enum CXCompletionChunkKind | 
| Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 2928 | clang_getCompletionChunkKind(CXCompletionString completion_string, | 
|  | 2929 | unsigned chunk_number); | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2930 |  | 
| Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 2931 | /** | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2932 | * \brief Retrieve the text associated with a particular chunk within a | 
| Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 2933 | * completion string. | 
|  | 2934 | * | 
|  | 2935 | * \param completion_string the completion string to query. | 
|  | 2936 | * | 
|  | 2937 | * \param chunk_number the 0-based index of the chunk in the completion string. | 
|  | 2938 | * | 
|  | 2939 | * \returns the text associated with the chunk at index \c chunk_number. | 
|  | 2940 | */ | 
| Ted Kremenek | 2ef6f8f | 2010-02-17 01:42:24 +0000 | [diff] [blame] | 2941 | CINDEX_LINKAGE CXString | 
| Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 2942 | clang_getCompletionChunkText(CXCompletionString completion_string, | 
|  | 2943 | unsigned chunk_number); | 
|  | 2944 |  | 
|  | 2945 | /** | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2946 | * \brief Retrieve the completion string associated with a particular chunk | 
| Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 2947 | * within a completion string. | 
|  | 2948 | * | 
|  | 2949 | * \param completion_string the completion string to query. | 
|  | 2950 | * | 
|  | 2951 | * \param chunk_number the 0-based index of the chunk in the completion string. | 
|  | 2952 | * | 
|  | 2953 | * \returns the completion string associated with the chunk at index | 
|  | 2954 | * \c chunk_number, or NULL if that chunk is not represented by a completion | 
|  | 2955 | * string. | 
|  | 2956 | */ | 
|  | 2957 | CINDEX_LINKAGE CXCompletionString | 
|  | 2958 | clang_getCompletionChunkCompletionString(CXCompletionString completion_string, | 
|  | 2959 | unsigned chunk_number); | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 2960 |  | 
| Douglas Gregor | 0c8296d | 2009-11-07 00:00:49 +0000 | [diff] [blame] | 2961 | /** | 
|  | 2962 | * \brief Retrieve the number of chunks in the given code-completion string. | 
|  | 2963 | */ | 
|  | 2964 | CINDEX_LINKAGE unsigned | 
|  | 2965 | clang_getNumCompletionChunks(CXCompletionString completion_string); | 
|  | 2966 |  | 
|  | 2967 | /** | 
| Douglas Gregor | 12e1313 | 2010-05-26 22:00:08 +0000 | [diff] [blame] | 2968 | * \brief Determine the priority of this code completion. | 
|  | 2969 | * | 
|  | 2970 | * The priority of a code completion indicates how likely it is that this | 
|  | 2971 | * particular completion is the completion that the user will select. The | 
|  | 2972 | * priority is selected by various internal heuristics. | 
|  | 2973 | * | 
|  | 2974 | * \param completion_string The completion string to query. | 
|  | 2975 | * | 
|  | 2976 | * \returns The priority of this completion string. Smaller values indicate | 
|  | 2977 | * higher-priority (more likely) completions. | 
|  | 2978 | */ | 
|  | 2979 | CINDEX_LINKAGE unsigned | 
|  | 2980 | clang_getCompletionPriority(CXCompletionString completion_string); | 
|  | 2981 |  | 
|  | 2982 | /** | 
| Douglas Gregor | 58ddb60 | 2010-08-23 23:00:57 +0000 | [diff] [blame] | 2983 | * \brief Determine the availability of the entity that this code-completion | 
|  | 2984 | * string refers to. | 
|  | 2985 | * | 
|  | 2986 | * \param completion_string The completion string to query. | 
|  | 2987 | * | 
|  | 2988 | * \returns The availability of the completion string. | 
|  | 2989 | */ | 
|  | 2990 | CINDEX_LINKAGE enum CXAvailabilityKind | 
|  | 2991 | clang_getCompletionAvailability(CXCompletionString completion_string); | 
|  | 2992 |  | 
|  | 2993 | /** | 
| Douglas Gregor | 8fa0a80 | 2011-08-04 20:04:59 +0000 | [diff] [blame] | 2994 | * \brief Retrieve a completion string for an arbitrary declaration or macro | 
|  | 2995 | * definition cursor. | 
|  | 2996 | * | 
|  | 2997 | * \param cursor The cursor to query. | 
|  | 2998 | * | 
|  | 2999 | * \returns A non-context-sensitive completion string for declaration and macro | 
|  | 3000 | * definition cursors, or NULL for other kinds of cursors. | 
|  | 3001 | */ | 
|  | 3002 | CINDEX_LINKAGE CXCompletionString | 
|  | 3003 | clang_getCursorCompletionString(CXCursor cursor); | 
|  | 3004 |  | 
|  | 3005 | /** | 
| Douglas Gregor | ec6762c | 2009-12-18 16:20:58 +0000 | [diff] [blame] | 3006 | * \brief Contains the results of code-completion. | 
|  | 3007 | * | 
|  | 3008 | * This data structure contains the results of code completion, as | 
| Douglas Gregor | e0cc52e | 2010-10-11 21:51:20 +0000 | [diff] [blame] | 3009 | * produced by \c clang_codeCompleteAt(). Its contents must be freed by | 
| Douglas Gregor | ec6762c | 2009-12-18 16:20:58 +0000 | [diff] [blame] | 3010 | * \c clang_disposeCodeCompleteResults. | 
|  | 3011 | */ | 
|  | 3012 | typedef struct { | 
|  | 3013 | /** | 
|  | 3014 | * \brief The code-completion results. | 
|  | 3015 | */ | 
|  | 3016 | CXCompletionResult *Results; | 
|  | 3017 |  | 
|  | 3018 | /** | 
|  | 3019 | * \brief The number of code-completion results stored in the | 
|  | 3020 | * \c Results array. | 
|  | 3021 | */ | 
|  | 3022 | unsigned NumResults; | 
|  | 3023 | } CXCodeCompleteResults; | 
|  | 3024 |  | 
|  | 3025 | /** | 
| Douglas Gregor | cee235c | 2010-08-05 09:09:23 +0000 | [diff] [blame] | 3026 | * \brief Flags that can be passed to \c clang_codeCompleteAt() to | 
|  | 3027 | * modify its behavior. | 
|  | 3028 | * | 
|  | 3029 | * The enumerators in this enumeration can be bitwise-OR'd together to | 
|  | 3030 | * provide multiple options to \c clang_codeCompleteAt(). | 
|  | 3031 | */ | 
|  | 3032 | enum CXCodeComplete_Flags { | 
|  | 3033 | /** | 
|  | 3034 | * \brief Whether to include macros within the set of code | 
|  | 3035 | * completions returned. | 
|  | 3036 | */ | 
|  | 3037 | CXCodeComplete_IncludeMacros = 0x01, | 
|  | 3038 |  | 
|  | 3039 | /** | 
|  | 3040 | * \brief Whether to include code patterns for language constructs | 
|  | 3041 | * within the set of code completions, e.g., for loops. | 
|  | 3042 | */ | 
|  | 3043 | CXCodeComplete_IncludeCodePatterns = 0x02 | 
|  | 3044 | }; | 
|  | 3045 |  | 
|  | 3046 | /** | 
| Douglas Gregor | 3da626b | 2011-07-07 16:03:39 +0000 | [diff] [blame] | 3047 | * \brief Bits that represent the context under which completion is occurring. | 
|  | 3048 | * | 
|  | 3049 | * The enumerators in this enumeration may be bitwise-OR'd together if multiple | 
|  | 3050 | * contexts are occurring simultaneously. | 
|  | 3051 | */ | 
|  | 3052 | enum CXCompletionContext { | 
|  | 3053 | /** | 
|  | 3054 | * \brief The context for completions is unexposed, as only Clang results | 
|  | 3055 | * should be included. (This is equivalent to having no context bits set.) | 
|  | 3056 | */ | 
|  | 3057 | CXCompletionContext_Unexposed = 0, | 
|  | 3058 |  | 
|  | 3059 | /** | 
|  | 3060 | * \brief Completions for any possible type should be included in the results. | 
|  | 3061 | */ | 
|  | 3062 | CXCompletionContext_AnyType = 1 << 0, | 
|  | 3063 |  | 
|  | 3064 | /** | 
|  | 3065 | * \brief Completions for any possible value (variables, function calls, etc.) | 
|  | 3066 | * should be included in the results. | 
|  | 3067 | */ | 
|  | 3068 | CXCompletionContext_AnyValue = 1 << 1, | 
|  | 3069 | /** | 
|  | 3070 | * \brief Completions for values that resolve to an Objective-C object should | 
|  | 3071 | * be included in the results. | 
|  | 3072 | */ | 
|  | 3073 | CXCompletionContext_ObjCObjectValue = 1 << 2, | 
|  | 3074 | /** | 
|  | 3075 | * \brief Completions for values that resolve to an Objective-C selector | 
|  | 3076 | * should be included in the results. | 
|  | 3077 | */ | 
|  | 3078 | CXCompletionContext_ObjCSelectorValue = 1 << 3, | 
|  | 3079 | /** | 
|  | 3080 | * \brief Completions for values that resolve to a C++ class type should be | 
|  | 3081 | * included in the results. | 
|  | 3082 | */ | 
|  | 3083 | CXCompletionContext_CXXClassTypeValue = 1 << 4, | 
|  | 3084 |  | 
|  | 3085 | /** | 
|  | 3086 | * \brief Completions for fields of the member being accessed using the dot | 
|  | 3087 | * operator should be included in the results. | 
|  | 3088 | */ | 
|  | 3089 | CXCompletionContext_DotMemberAccess = 1 << 5, | 
|  | 3090 | /** | 
|  | 3091 | * \brief Completions for fields of the member being accessed using the arrow | 
|  | 3092 | * operator should be included in the results. | 
|  | 3093 | */ | 
|  | 3094 | CXCompletionContext_ArrowMemberAccess = 1 << 6, | 
|  | 3095 | /** | 
|  | 3096 | * \brief Completions for properties of the Objective-C object being accessed | 
|  | 3097 | * using the dot operator should be included in the results. | 
|  | 3098 | */ | 
|  | 3099 | CXCompletionContext_ObjCPropertyAccess = 1 << 7, | 
|  | 3100 |  | 
|  | 3101 | /** | 
|  | 3102 | * \brief Completions for enum tags should be included in the results. | 
|  | 3103 | */ | 
|  | 3104 | CXCompletionContext_EnumTag = 1 << 8, | 
|  | 3105 | /** | 
|  | 3106 | * \brief Completions for union tags should be included in the results. | 
|  | 3107 | */ | 
|  | 3108 | CXCompletionContext_UnionTag = 1 << 9, | 
|  | 3109 | /** | 
|  | 3110 | * \brief Completions for struct tags should be included in the results. | 
|  | 3111 | */ | 
|  | 3112 | CXCompletionContext_StructTag = 1 << 10, | 
|  | 3113 |  | 
|  | 3114 | /** | 
|  | 3115 | * \brief Completions for C++ class names should be included in the results. | 
|  | 3116 | */ | 
|  | 3117 | CXCompletionContext_ClassTag = 1 << 11, | 
|  | 3118 | /** | 
|  | 3119 | * \brief Completions for C++ namespaces and namespace aliases should be | 
|  | 3120 | * included in the results. | 
|  | 3121 | */ | 
|  | 3122 | CXCompletionContext_Namespace = 1 << 12, | 
|  | 3123 | /** | 
|  | 3124 | * \brief Completions for C++ nested name specifiers should be included in | 
|  | 3125 | * the results. | 
|  | 3126 | */ | 
|  | 3127 | CXCompletionContext_NestedNameSpecifier = 1 << 13, | 
|  | 3128 |  | 
|  | 3129 | /** | 
|  | 3130 | * \brief Completions for Objective-C interfaces (classes) should be included | 
|  | 3131 | * in the results. | 
|  | 3132 | */ | 
|  | 3133 | CXCompletionContext_ObjCInterface = 1 << 14, | 
|  | 3134 | /** | 
|  | 3135 | * \brief Completions for Objective-C protocols should be included in | 
|  | 3136 | * the results. | 
|  | 3137 | */ | 
|  | 3138 | CXCompletionContext_ObjCProtocol = 1 << 15, | 
|  | 3139 | /** | 
|  | 3140 | * \brief Completions for Objective-C categories should be included in | 
|  | 3141 | * the results. | 
|  | 3142 | */ | 
|  | 3143 | CXCompletionContext_ObjCCategory = 1 << 16, | 
|  | 3144 | /** | 
|  | 3145 | * \brief Completions for Objective-C instance messages should be included | 
|  | 3146 | * in the results. | 
|  | 3147 | */ | 
|  | 3148 | CXCompletionContext_ObjCInstanceMessage = 1 << 17, | 
|  | 3149 | /** | 
|  | 3150 | * \brief Completions for Objective-C class messages should be included in | 
|  | 3151 | * the results. | 
|  | 3152 | */ | 
|  | 3153 | CXCompletionContext_ObjCClassMessage = 1 << 18, | 
|  | 3154 | /** | 
|  | 3155 | * \brief Completions for Objective-C selector names should be included in | 
|  | 3156 | * the results. | 
|  | 3157 | */ | 
|  | 3158 | CXCompletionContext_ObjCSelectorName = 1 << 19, | 
|  | 3159 |  | 
|  | 3160 | /** | 
|  | 3161 | * \brief Completions for preprocessor macro names should be included in | 
|  | 3162 | * the results. | 
|  | 3163 | */ | 
|  | 3164 | CXCompletionContext_MacroName = 1 << 20, | 
|  | 3165 |  | 
|  | 3166 | /** | 
|  | 3167 | * \brief Natural language completions should be included in the results. | 
|  | 3168 | */ | 
|  | 3169 | CXCompletionContext_NaturalLanguage = 1 << 21, | 
|  | 3170 |  | 
|  | 3171 | /** | 
|  | 3172 | * \brief The current context is unknown, so set all contexts. | 
|  | 3173 | */ | 
|  | 3174 | CXCompletionContext_Unknown = ((1 << 22) - 1) | 
|  | 3175 | }; | 
|  | 3176 |  | 
|  | 3177 | /** | 
| Douglas Gregor | cee235c | 2010-08-05 09:09:23 +0000 | [diff] [blame] | 3178 | * \brief Returns a default set of code-completion options that can be | 
|  | 3179 | * passed to\c clang_codeCompleteAt(). | 
|  | 3180 | */ | 
|  | 3181 | CINDEX_LINKAGE unsigned clang_defaultCodeCompleteOptions(void); | 
|  | 3182 |  | 
|  | 3183 | /** | 
| Douglas Gregor | 1abc6bc | 2010-08-04 16:47:14 +0000 | [diff] [blame] | 3184 | * \brief Perform code completion at a given location in a translation unit. | 
|  | 3185 | * | 
|  | 3186 | * This function performs code completion at a particular file, line, and | 
|  | 3187 | * column within source code, providing results that suggest potential | 
|  | 3188 | * code snippets based on the context of the completion. The basic model | 
|  | 3189 | * for code completion is that Clang will parse a complete source file, | 
|  | 3190 | * performing syntax checking up to the location where code-completion has | 
|  | 3191 | * been requested. At that point, a special code-completion token is passed | 
|  | 3192 | * to the parser, which recognizes this token and determines, based on the | 
|  | 3193 | * current location in the C/Objective-C/C++ grammar and the state of | 
|  | 3194 | * semantic analysis, what completions to provide. These completions are | 
|  | 3195 | * returned via a new \c CXCodeCompleteResults structure. | 
|  | 3196 | * | 
|  | 3197 | * Code completion itself is meant to be triggered by the client when the | 
|  | 3198 | * user types punctuation characters or whitespace, at which point the | 
|  | 3199 | * code-completion location will coincide with the cursor. For example, if \c p | 
|  | 3200 | * is a pointer, code-completion might be triggered after the "-" and then | 
|  | 3201 | * after the ">" in \c p->. When the code-completion location is afer the ">", | 
|  | 3202 | * the completion results will provide, e.g., the members of the struct that | 
|  | 3203 | * "p" points to. The client is responsible for placing the cursor at the | 
|  | 3204 | * beginning of the token currently being typed, then filtering the results | 
|  | 3205 | * based on the contents of the token. For example, when code-completing for | 
|  | 3206 | * the expression \c p->get, the client should provide the location just after | 
|  | 3207 | * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the | 
|  | 3208 | * client can filter the results based on the current token text ("get"), only | 
|  | 3209 | * showing those results that start with "get". The intent of this interface | 
|  | 3210 | * is to separate the relatively high-latency acquisition of code-completion | 
|  | 3211 | * results from the filtering of results on a per-character basis, which must | 
|  | 3212 | * have a lower latency. | 
|  | 3213 | * | 
|  | 3214 | * \param TU The translation unit in which code-completion should | 
|  | 3215 | * occur. The source files for this translation unit need not be | 
|  | 3216 | * completely up-to-date (and the contents of those source files may | 
|  | 3217 | * be overridden via \p unsaved_files). Cursors referring into the | 
|  | 3218 | * translation unit may be invalidated by this invocation. | 
|  | 3219 | * | 
|  | 3220 | * \param complete_filename The name of the source file where code | 
|  | 3221 | * completion should be performed. This filename may be any file | 
|  | 3222 | * included in the translation unit. | 
|  | 3223 | * | 
|  | 3224 | * \param complete_line The line at which code-completion should occur. | 
|  | 3225 | * | 
|  | 3226 | * \param complete_column The column at which code-completion should occur. | 
|  | 3227 | * Note that the column should point just after the syntactic construct that | 
|  | 3228 | * initiated code completion, and not in the middle of a lexical token. | 
|  | 3229 | * | 
|  | 3230 | * \param unsaved_files the Tiles that have not yet been saved to disk | 
|  | 3231 | * but may be required for parsing or code completion, including the | 
|  | 3232 | * contents of those files.  The contents and name of these files (as | 
|  | 3233 | * specified by CXUnsavedFile) are copied when necessary, so the | 
|  | 3234 | * client only needs to guarantee their validity until the call to | 
|  | 3235 | * this function returns. | 
|  | 3236 | * | 
|  | 3237 | * \param num_unsaved_files The number of unsaved file entries in \p | 
|  | 3238 | * unsaved_files. | 
|  | 3239 | * | 
| Douglas Gregor | cee235c | 2010-08-05 09:09:23 +0000 | [diff] [blame] | 3240 | * \param options Extra options that control the behavior of code | 
|  | 3241 | * completion, expressed as a bitwise OR of the enumerators of the | 
|  | 3242 | * CXCodeComplete_Flags enumeration. The | 
|  | 3243 | * \c clang_defaultCodeCompleteOptions() function returns a default set | 
|  | 3244 | * of code-completion options. | 
|  | 3245 | * | 
| Douglas Gregor | 1abc6bc | 2010-08-04 16:47:14 +0000 | [diff] [blame] | 3246 | * \returns If successful, a new \c CXCodeCompleteResults structure | 
|  | 3247 | * containing code-completion results, which should eventually be | 
|  | 3248 | * freed with \c clang_disposeCodeCompleteResults(). If code | 
|  | 3249 | * completion fails, returns NULL. | 
|  | 3250 | */ | 
|  | 3251 | CINDEX_LINKAGE | 
|  | 3252 | CXCodeCompleteResults *clang_codeCompleteAt(CXTranslationUnit TU, | 
|  | 3253 | const char *complete_filename, | 
|  | 3254 | unsigned complete_line, | 
|  | 3255 | unsigned complete_column, | 
|  | 3256 | struct CXUnsavedFile *unsaved_files, | 
| Douglas Gregor | cee235c | 2010-08-05 09:09:23 +0000 | [diff] [blame] | 3257 | unsigned num_unsaved_files, | 
|  | 3258 | unsigned options); | 
| Douglas Gregor | 1abc6bc | 2010-08-04 16:47:14 +0000 | [diff] [blame] | 3259 |  | 
|  | 3260 | /** | 
| Douglas Gregor | 1e5e668 | 2010-08-26 13:48:20 +0000 | [diff] [blame] | 3261 | * \brief Sort the code-completion results in case-insensitive alphabetical | 
|  | 3262 | * order. | 
|  | 3263 | * | 
|  | 3264 | * \param Results The set of results to sort. | 
|  | 3265 | * \param NumResults The number of results in \p Results. | 
|  | 3266 | */ | 
|  | 3267 | CINDEX_LINKAGE | 
|  | 3268 | void clang_sortCodeCompletionResults(CXCompletionResult *Results, | 
|  | 3269 | unsigned NumResults); | 
|  | 3270 |  | 
|  | 3271 | /** | 
| Douglas Gregor | ec6762c | 2009-12-18 16:20:58 +0000 | [diff] [blame] | 3272 | * \brief Free the given set of code-completion results. | 
|  | 3273 | */ | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 3274 | CINDEX_LINKAGE | 
| Douglas Gregor | ec6762c | 2009-12-18 16:20:58 +0000 | [diff] [blame] | 3275 | void clang_disposeCodeCompleteResults(CXCodeCompleteResults *Results); | 
| Douglas Gregor | 58ddb60 | 2010-08-23 23:00:57 +0000 | [diff] [blame] | 3276 |  | 
| Douglas Gregor | 20d416c | 2010-01-20 01:10:47 +0000 | [diff] [blame] | 3277 | /** | 
| Douglas Gregor | a88084b | 2010-02-18 18:08:43 +0000 | [diff] [blame] | 3278 | * \brief Determine the number of diagnostics produced prior to the | 
|  | 3279 | * location where code completion was performed. | 
|  | 3280 | */ | 
| Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 3281 | CINDEX_LINKAGE | 
| Douglas Gregor | a88084b | 2010-02-18 18:08:43 +0000 | [diff] [blame] | 3282 | unsigned clang_codeCompleteGetNumDiagnostics(CXCodeCompleteResults *Results); | 
|  | 3283 |  | 
|  | 3284 | /** | 
|  | 3285 | * \brief Retrieve a diagnostic associated with the given code completion. | 
|  | 3286 | * | 
|  | 3287 | * \param Result the code completion results to query. | 
|  | 3288 | * \param Index the zero-based diagnostic number to retrieve. | 
|  | 3289 | * | 
|  | 3290 | * \returns the requested diagnostic. This diagnostic must be freed | 
|  | 3291 | * via a call to \c clang_disposeDiagnostic(). | 
|  | 3292 | */ | 
| Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 3293 | CINDEX_LINKAGE | 
| Douglas Gregor | a88084b | 2010-02-18 18:08:43 +0000 | [diff] [blame] | 3294 | CXDiagnostic clang_codeCompleteGetDiagnostic(CXCodeCompleteResults *Results, | 
|  | 3295 | unsigned Index); | 
|  | 3296 |  | 
|  | 3297 | /** | 
| Douglas Gregor | 3da626b | 2011-07-07 16:03:39 +0000 | [diff] [blame] | 3298 | * \brief Determines what compeltions are appropriate for the context | 
|  | 3299 | * the given code completion. | 
|  | 3300 | * | 
|  | 3301 | * \param Results the code completion results to query | 
|  | 3302 | * | 
|  | 3303 | * \returns the kinds of completions that are appropriate for use | 
|  | 3304 | * along with the given code completion results. | 
|  | 3305 | */ | 
|  | 3306 | CINDEX_LINKAGE | 
|  | 3307 | unsigned long long clang_codeCompleteGetContexts( | 
|  | 3308 | CXCodeCompleteResults *Results); | 
| Douglas Gregor | e081a61 | 2011-07-21 01:05:26 +0000 | [diff] [blame] | 3309 |  | 
|  | 3310 | /** | 
|  | 3311 | * \brief Returns the cursor kind for the container for the current code | 
|  | 3312 | * completion context. The container is only guaranteed to be set for | 
|  | 3313 | * contexts where a container exists (i.e. member accesses or Objective-C | 
|  | 3314 | * message sends); if there is not a container, this function will return | 
|  | 3315 | * CXCursor_InvalidCode. | 
|  | 3316 | * | 
|  | 3317 | * \param Results the code completion results to query | 
|  | 3318 | * | 
|  | 3319 | * \param IsIncomplete on return, this value will be false if Clang has complete | 
|  | 3320 | * information about the container. If Clang does not have complete | 
|  | 3321 | * information, this value will be true. | 
|  | 3322 | * | 
|  | 3323 | * \returns the container kind, or CXCursor_InvalidCode if there is not a | 
|  | 3324 | * container | 
|  | 3325 | */ | 
|  | 3326 | CINDEX_LINKAGE | 
|  | 3327 | enum CXCursorKind clang_codeCompleteGetContainerKind( | 
|  | 3328 | CXCodeCompleteResults *Results, | 
|  | 3329 | unsigned *IsIncomplete); | 
|  | 3330 |  | 
|  | 3331 | /** | 
|  | 3332 | * \brief Returns the USR for the container for the current code completion | 
|  | 3333 | * context. If there is not a container for the current context, this | 
|  | 3334 | * function will return the empty string. | 
|  | 3335 | * | 
|  | 3336 | * \param Results the code completion results to query | 
|  | 3337 | * | 
|  | 3338 | * \returns the USR for the container | 
|  | 3339 | */ | 
|  | 3340 | CINDEX_LINKAGE | 
|  | 3341 | CXString clang_codeCompleteGetContainerUSR(CXCodeCompleteResults *Results); | 
| Douglas Gregor | 3da626b | 2011-07-07 16:03:39 +0000 | [diff] [blame] | 3342 |  | 
| Douglas Gregor | 0a47d69 | 2011-07-26 15:24:30 +0000 | [diff] [blame] | 3343 |  | 
|  | 3344 | /** | 
|  | 3345 | * \brief Returns the currently-entered selector for an Objective-C message | 
|  | 3346 | * send, formatted like "initWithFoo:bar:". Only guaranteed to return a | 
|  | 3347 | * non-empty string for CXCompletionContext_ObjCInstanceMessage and | 
|  | 3348 | * CXCompletionContext_ObjCClassMessage. | 
|  | 3349 | * | 
|  | 3350 | * \param Results the code completion results to query | 
|  | 3351 | * | 
|  | 3352 | * \returns the selector (or partial selector) that has been entered thus far | 
|  | 3353 | * for an Objective-C message send. | 
|  | 3354 | */ | 
|  | 3355 | CINDEX_LINKAGE | 
|  | 3356 | CXString clang_codeCompleteGetObjCSelector(CXCodeCompleteResults *Results); | 
|  | 3357 |  | 
| Douglas Gregor | 3da626b | 2011-07-07 16:03:39 +0000 | [diff] [blame] | 3358 | /** | 
| Douglas Gregor | 20d416c | 2010-01-20 01:10:47 +0000 | [diff] [blame] | 3359 | * @} | 
|  | 3360 | */ | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 3361 |  | 
|  | 3362 |  | 
| Ted Kremenek | 04bb716 | 2010-01-22 22:44:15 +0000 | [diff] [blame] | 3363 | /** | 
|  | 3364 | * \defgroup CINDEX_MISC Miscellaneous utility functions | 
|  | 3365 | * | 
|  | 3366 | * @{ | 
|  | 3367 | */ | 
| Ted Kremenek | 23e1ad0 | 2010-01-23 17:51:23 +0000 | [diff] [blame] | 3368 |  | 
|  | 3369 | /** | 
|  | 3370 | * \brief Return a version string, suitable for showing to a user, but not | 
|  | 3371 | *        intended to be parsed (the format is not guaranteed to be stable). | 
|  | 3372 | */ | 
| Ted Kremenek | a2a9d6e | 2010-02-12 22:54:40 +0000 | [diff] [blame] | 3373 | CINDEX_LINKAGE CXString clang_getClangVersion(); | 
| Ted Kremenek | 04bb716 | 2010-01-22 22:44:15 +0000 | [diff] [blame] | 3374 |  | 
| Ted Kremenek | d2427dd | 2011-03-18 23:05:39 +0000 | [diff] [blame] | 3375 |  | 
|  | 3376 | /** | 
|  | 3377 | * \brief Enable/disable crash recovery. | 
|  | 3378 | * | 
|  | 3379 | * \param Flag to indicate if crash recovery is enabled.  A non-zero value | 
|  | 3380 | *        enables crash recovery, while 0 disables it. | 
|  | 3381 | */ | 
|  | 3382 | CINDEX_LINKAGE void clang_toggleCrashRecovery(unsigned isEnabled); | 
|  | 3383 |  | 
| Ted Kremenek | 16b55a7 | 2010-01-26 19:31:51 +0000 | [diff] [blame] | 3384 | /** | 
| Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 3385 | * \brief Visitor invoked for each file in a translation unit | 
| Ted Kremenek | 16b55a7 | 2010-01-26 19:31:51 +0000 | [diff] [blame] | 3386 | *        (used with clang_getInclusions()). | 
|  | 3387 | * | 
|  | 3388 | * This visitor function will be invoked by clang_getInclusions() for each | 
|  | 3389 | * file included (either at the top-level or by #include directives) within | 
|  | 3390 | * a translation unit.  The first argument is the file being included, and | 
|  | 3391 | * the second and third arguments provide the inclusion stack.  The | 
|  | 3392 | * array is sorted in order of immediate inclusion.  For example, | 
|  | 3393 | * the first element refers to the location that included 'included_file'. | 
|  | 3394 | */ | 
|  | 3395 | typedef void (*CXInclusionVisitor)(CXFile included_file, | 
|  | 3396 | CXSourceLocation* inclusion_stack, | 
|  | 3397 | unsigned include_len, | 
|  | 3398 | CXClientData client_data); | 
|  | 3399 |  | 
|  | 3400 | /** | 
|  | 3401 | * \brief Visit the set of preprocessor inclusions in a translation unit. | 
|  | 3402 | *   The visitor function is called with the provided data for every included | 
|  | 3403 | *   file.  This does not include headers included by the PCH file (unless one | 
|  | 3404 | *   is inspecting the inclusions in the PCH file itself). | 
|  | 3405 | */ | 
|  | 3406 | CINDEX_LINKAGE void clang_getInclusions(CXTranslationUnit tu, | 
|  | 3407 | CXInclusionVisitor visitor, | 
|  | 3408 | CXClientData client_data); | 
|  | 3409 |  | 
|  | 3410 | /** | 
| Ted Kremenek | 04bb716 | 2010-01-22 22:44:15 +0000 | [diff] [blame] | 3411 | * @} | 
|  | 3412 | */ | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 3413 |  | 
| Argyrios Kyrtzidis | 97c337c | 2011-07-11 20:15:00 +0000 | [diff] [blame] | 3414 | /** \defgroup CINDEX_REMAPPING Remapping functions | 
|  | 3415 | * | 
|  | 3416 | * @{ | 
|  | 3417 | */ | 
|  | 3418 |  | 
|  | 3419 | /** | 
|  | 3420 | * \brief A remapping of original source files and their translated files. | 
|  | 3421 | */ | 
|  | 3422 | typedef void *CXRemapping; | 
|  | 3423 |  | 
|  | 3424 | /** | 
|  | 3425 | * \brief Retrieve a remapping. | 
|  | 3426 | * | 
|  | 3427 | * \param path the path that contains metadata about remappings. | 
|  | 3428 | * | 
|  | 3429 | * \returns the requested remapping. This remapping must be freed | 
|  | 3430 | * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred. | 
|  | 3431 | */ | 
|  | 3432 | CINDEX_LINKAGE CXRemapping clang_getRemappings(const char *path); | 
|  | 3433 |  | 
|  | 3434 | /** | 
|  | 3435 | * \brief Determine the number of remappings. | 
|  | 3436 | */ | 
|  | 3437 | CINDEX_LINKAGE unsigned clang_remap_getNumFiles(CXRemapping); | 
|  | 3438 |  | 
|  | 3439 | /** | 
|  | 3440 | * \brief Get the original and the associated filename from the remapping. | 
|  | 3441 | * | 
|  | 3442 | * \param original If non-NULL, will be set to the original filename. | 
|  | 3443 | * | 
|  | 3444 | * \param transformed If non-NULL, will be set to the filename that the original | 
|  | 3445 | * is associated with. | 
|  | 3446 | */ | 
|  | 3447 | CINDEX_LINKAGE void clang_remap_getFilenames(CXRemapping, unsigned index, | 
|  | 3448 | CXString *original, CXString *transformed); | 
|  | 3449 |  | 
|  | 3450 | /** | 
|  | 3451 | * \brief Dispose the remapping. | 
|  | 3452 | */ | 
|  | 3453 | CINDEX_LINKAGE void clang_remap_dispose(CXRemapping); | 
|  | 3454 |  | 
|  | 3455 | /** | 
|  | 3456 | * @} | 
|  | 3457 | */ | 
|  | 3458 |  | 
| Douglas Gregor | c42fefa | 2010-01-22 22:29:16 +0000 | [diff] [blame] | 3459 | /** | 
|  | 3460 | * @} | 
|  | 3461 | */ | 
| Daniel Dunbar | 1efcf3d | 2010-01-24 02:54:26 +0000 | [diff] [blame] | 3462 |  | 
| Ted Kremenek | d2fa566 | 2009-08-26 22:36:44 +0000 | [diff] [blame] | 3463 | #ifdef __cplusplus | 
|  | 3464 | } | 
|  | 3465 | #endif | 
|  | 3466 | #endif | 
|  | 3467 |  |