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