blob: 34c8fc1d2ba0b1c8f60239fa12b7b27a5191128e [file] [log] [blame]
Ted Kremenekb60d87c2009-08-26 22:36:44 +00001/*===-- clang-c/Index.h - Indexing Public C Interface -------------*- C -*-===*\
2|* *|
3|* The LLVM Compiler Infrastructure *|
4|* *|
5|* This file is distributed under the University of Illinois Open Source *|
6|* License. See LICENSE.TXT for details. *|
7|* *|
8|*===----------------------------------------------------------------------===*|
9|* *|
10|* This header provides a public inferface to a Clang library for extracting *|
11|* high-level symbol information from source files without exposing the full *|
12|* Clang C++ API. *|
13|* *|
14\*===----------------------------------------------------------------------===*/
15
16#ifndef CLANG_C_INDEX_H
17#define CLANG_C_INDEX_H
18
Chandler Carruthaacafe52009-12-17 09:27:29 +000019#include <time.h>
Steve Naroff6231f182009-10-27 14:35:18 +000020
Arnaud A. de Grandmaison0271b322012-06-28 22:01:06 +000021#include "clang-c/Platform.h"
22#include "clang-c/CXString.h"
23
Argyrios Kyrtzidis1c4db8d2012-11-06 21:21:49 +000024/**
25 * \brief The version constants for the libclang API.
26 * CINDEX_VERSION_MINOR should increase when there are API additions.
27 * CINDEX_VERSION_MAJOR is intended for "major" source/ABI breaking changes.
28 *
29 * The policy about the libclang API was always to keep it source and ABI
30 * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
31 */
Argyrios Kyrtzidis5b216ed2012-10-29 23:24:44 +000032#define CINDEX_VERSION_MAJOR 0
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +000033#define CINDEX_VERSION_MINOR 21
Argyrios Kyrtzidis5b216ed2012-10-29 23:24:44 +000034
35#define CINDEX_VERSION_ENCODE(major, minor) ( \
36 ((major) * 10000) \
37 + ((minor) * 1))
38
39#define CINDEX_VERSION CINDEX_VERSION_ENCODE( \
40 CINDEX_VERSION_MAJOR, \
41 CINDEX_VERSION_MINOR )
42
43#define CINDEX_VERSION_STRINGIZE_(major, minor) \
44 #major"."#minor
45#define CINDEX_VERSION_STRINGIZE(major, minor) \
46 CINDEX_VERSION_STRINGIZE_(major, minor)
47
48#define CINDEX_VERSION_STRING CINDEX_VERSION_STRINGIZE( \
49 CINDEX_VERSION_MAJOR, \
50 CINDEX_VERSION_MINOR)
51
Ted Kremenekb60d87c2009-08-26 22:36:44 +000052#ifdef __cplusplus
53extern "C" {
54#endif
55
Douglas Gregor4a4e0eb2011-02-23 17:45:25 +000056/** \defgroup CINDEX libclang: C Interface to Clang
Douglas Gregor52606ff2010-01-20 01:10:47 +000057 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +000058 * The C Interface to Clang provides a relatively small API that exposes
Douglas Gregorc8e390c2010-01-20 22:45:41 +000059 * facilities for parsing source code into an abstract syntax tree (AST),
60 * loading already-parsed ASTs, traversing the AST, associating
61 * physical source locations with elements within the AST, and other
62 * facilities that support Clang-based development tools.
Douglas Gregor52606ff2010-01-20 01:10:47 +000063 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +000064 * This C interface to Clang will never provide all of the information
Douglas Gregorc8e390c2010-01-20 22:45:41 +000065 * representation stored in Clang's C++ AST, nor should it: the intent is to
66 * maintain an API that is relatively stable from one release to the next,
67 * providing only the basic functionality needed to support development tools.
Daniel Dunbar62ebf252010-01-24 02:54:26 +000068 *
69 * To avoid namespace pollution, data types are prefixed with "CX" and
Douglas Gregorc8e390c2010-01-20 22:45:41 +000070 * functions are prefixed with "clang_".
Douglas Gregor52606ff2010-01-20 01:10:47 +000071 *
72 * @{
73 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +000074
Douglas Gregor802f12f2010-01-20 22:28:27 +000075/**
76 * \brief An "index" that consists of a set of translation units that would
77 * typically be linked together into an executable or library.
78 */
79typedef void *CXIndex;
Steve Naroffd5e8e862009-08-27 19:51:58 +000080
Douglas Gregor802f12f2010-01-20 22:28:27 +000081/**
82 * \brief A single translation unit, which resides in an index.
83 */
Ted Kremenek7df92ae2010-11-17 23:24:11 +000084typedef struct CXTranslationUnitImpl *CXTranslationUnit;
Steve Naroffd5e8e862009-08-27 19:51:58 +000085
Douglas Gregor802f12f2010-01-20 22:28:27 +000086/**
Douglas Gregor6007cf22010-01-22 22:29:16 +000087 * \brief Opaque pointer representing client data that will be passed through
88 * to various callbacks and visitors.
Douglas Gregor802f12f2010-01-20 22:28:27 +000089 */
Douglas Gregor6007cf22010-01-22 22:29:16 +000090typedef void *CXClientData;
Daniel Dunbar62ebf252010-01-24 02:54:26 +000091
Douglas Gregor9485bf92009-12-02 09:21:34 +000092/**
93 * \brief Provides the contents of a file that has not yet been saved to disk.
94 *
95 * Each CXUnsavedFile instance provides the name of a file on the
96 * system along with the current contents of that file that have not
97 * yet been saved to disk.
98 */
99struct CXUnsavedFile {
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000100 /**
101 * \brief The file whose contents have not yet been saved.
Douglas Gregor9485bf92009-12-02 09:21:34 +0000102 *
103 * This file must already exist in the file system.
104 */
105 const char *Filename;
106
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000107 /**
Douglas Gregor89a56c52010-02-27 01:32:48 +0000108 * \brief A buffer containing the unsaved contents of this file.
Douglas Gregor9485bf92009-12-02 09:21:34 +0000109 */
110 const char *Contents;
111
112 /**
Douglas Gregor89a56c52010-02-27 01:32:48 +0000113 * \brief The length of the unsaved contents of this buffer.
Douglas Gregor9485bf92009-12-02 09:21:34 +0000114 */
115 unsigned long Length;
116};
117
Peter Collingbourne5caf5af2010-08-24 00:31:37 +0000118/**
119 * \brief Describes the availability of a particular entity, which indicates
120 * whether the use of this entity will result in a warning or error due to
121 * it being deprecated or unavailable.
122 */
Douglas Gregorf757a122010-08-23 23:00:57 +0000123enum CXAvailabilityKind {
Peter Collingbourne5caf5af2010-08-24 00:31:37 +0000124 /**
125 * \brief The entity is available.
126 */
Douglas Gregorf757a122010-08-23 23:00:57 +0000127 CXAvailability_Available,
Peter Collingbourne5caf5af2010-08-24 00:31:37 +0000128 /**
129 * \brief The entity is available, but has been deprecated (and its use is
130 * not recommended).
131 */
Douglas Gregorf757a122010-08-23 23:00:57 +0000132 CXAvailability_Deprecated,
Peter Collingbourne5caf5af2010-08-24 00:31:37 +0000133 /**
134 * \brief The entity is not available; any use of it will be an error.
135 */
Erik Verbruggen2e657ff2011-10-06 07:27:49 +0000136 CXAvailability_NotAvailable,
137 /**
138 * \brief The entity is available, but not accessible; any use of it will be
139 * an error.
140 */
141 CXAvailability_NotAccessible
Douglas Gregorf757a122010-08-23 23:00:57 +0000142};
Douglas Gregord6225d32012-05-08 00:14:45 +0000143
144/**
145 * \brief Describes a version number of the form major.minor.subminor.
146 */
147typedef struct CXVersion {
148 /**
149 * \brief The major version number, e.g., the '10' in '10.7.3'. A negative
150 * value indicates that there is no version number at all.
151 */
152 int Major;
153 /**
154 * \brief The minor version number, e.g., the '7' in '10.7.3'. This value
155 * will be negative if no minor version number was provided, e.g., for
156 * version '10'.
157 */
158 int Minor;
159 /**
160 * \brief The subminor version number, e.g., the '3' in '10.7.3'. This value
161 * will be negative if no minor or subminor version number was provided,
162 * e.g., in version '10' or '10.7'.
163 */
164 int Subminor;
165} CXVersion;
Douglas Gregorf757a122010-08-23 23:00:57 +0000166
Douglas Gregor802f12f2010-01-20 22:28:27 +0000167/**
James Dennett574cb4c2012-06-15 05:41:51 +0000168 * \brief Provides a shared context for creating translation units.
169 *
170 * It provides two options:
Steve Naroff531e2842009-10-20 14:46:24 +0000171 *
172 * - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local"
173 * declarations (when loading any new translation units). A "local" declaration
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000174 * is one that belongs in the translation unit itself and not in a precompiled
Steve Naroff531e2842009-10-20 14:46:24 +0000175 * header that was used by the translation unit. If zero, all declarations
176 * will be enumerated.
177 *
Steve Naroffbb4568a2009-10-20 16:36:34 +0000178 * Here is an example:
179 *
James Dennett574cb4c2012-06-15 05:41:51 +0000180 * \code
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000181 * // excludeDeclsFromPCH = 1, displayDiagnostics=1
182 * Idx = clang_createIndex(1, 1);
Steve Naroffbb4568a2009-10-20 16:36:34 +0000183 *
184 * // IndexTest.pch was produced with the following command:
185 * // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch"
186 * TU = clang_createTranslationUnit(Idx, "IndexTest.pch");
187 *
188 * // This will load all the symbols from 'IndexTest.pch'
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000189 * clang_visitChildren(clang_getTranslationUnitCursor(TU),
Douglas Gregor990b5762010-01-20 21:37:00 +0000190 * TranslationUnitVisitor, 0);
Steve Naroffbb4568a2009-10-20 16:36:34 +0000191 * clang_disposeTranslationUnit(TU);
192 *
193 * // This will load all the symbols from 'IndexTest.c', excluding symbols
194 * // from 'IndexTest.pch'.
Daniel Dunbard0159262010-01-25 00:43:14 +0000195 * char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" };
196 * TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args,
197 * 0, 0);
Douglas Gregorfed36b12010-01-20 23:57:43 +0000198 * clang_visitChildren(clang_getTranslationUnitCursor(TU),
199 * TranslationUnitVisitor, 0);
Steve Naroffbb4568a2009-10-20 16:36:34 +0000200 * clang_disposeTranslationUnit(TU);
James Dennett574cb4c2012-06-15 05:41:51 +0000201 * \endcode
Steve Naroffbb4568a2009-10-20 16:36:34 +0000202 *
203 * This process of creating the 'pch', loading it separately, and using it (via
204 * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks
205 * (which gives the indexer the same performance benefit as the compiler).
Steve Naroff531e2842009-10-20 14:46:24 +0000206 */
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000207CINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH,
208 int displayDiagnostics);
Ted Kremenekd071c602010-03-13 02:50:34 +0000209
Douglas Gregor408bb742010-02-08 23:03:06 +0000210/**
211 * \brief Destroy the given index.
212 *
213 * The index must not be destroyed until all of the translation units created
214 * within that index have been destroyed.
215 */
Daniel Dunbar11089662009-12-03 01:54:28 +0000216CINDEX_LINKAGE void clang_disposeIndex(CXIndex index);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000217
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000218typedef enum {
219 /**
220 * \brief Used to indicate that no special CXIndex options are needed.
221 */
222 CXGlobalOpt_None = 0x0,
223
224 /**
225 * \brief Used to indicate that threads that libclang creates for indexing
226 * purposes should use background priority.
James Dennett574cb4c2012-06-15 05:41:51 +0000227 *
228 * Affects #clang_indexSourceFile, #clang_indexTranslationUnit,
229 * #clang_parseTranslationUnit, #clang_saveTranslationUnit.
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000230 */
231 CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1,
232
233 /**
234 * \brief Used to indicate that threads that libclang creates for editing
235 * purposes should use background priority.
James Dennett574cb4c2012-06-15 05:41:51 +0000236 *
237 * Affects #clang_reparseTranslationUnit, #clang_codeCompleteAt,
238 * #clang_annotateTokens
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000239 */
240 CXGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2,
241
242 /**
243 * \brief Used to indicate that all threads that libclang creates should use
244 * background priority.
245 */
246 CXGlobalOpt_ThreadBackgroundPriorityForAll =
247 CXGlobalOpt_ThreadBackgroundPriorityForIndexing |
248 CXGlobalOpt_ThreadBackgroundPriorityForEditing
249
250} CXGlobalOptFlags;
251
252/**
James Dennett574cb4c2012-06-15 05:41:51 +0000253 * \brief Sets general options associated with a CXIndex.
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000254 *
255 * For example:
256 * \code
257 * CXIndex idx = ...;
258 * clang_CXIndex_setGlobalOptions(idx,
259 * clang_CXIndex_getGlobalOptions(idx) |
260 * CXGlobalOpt_ThreadBackgroundPriorityForIndexing);
261 * \endcode
262 *
263 * \param options A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags.
264 */
265CINDEX_LINKAGE void clang_CXIndex_setGlobalOptions(CXIndex, unsigned options);
266
267/**
268 * \brief Gets the general options associated with a CXIndex.
269 *
270 * \returns A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags that
271 * are associated with the given CXIndex object.
272 */
273CINDEX_LINKAGE unsigned clang_CXIndex_getGlobalOptions(CXIndex);
274
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000275/**
Douglas Gregor6007cf22010-01-22 22:29:16 +0000276 * \defgroup CINDEX_FILES File manipulation routines
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000277 *
278 * @{
279 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000280
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000281/**
282 * \brief A particular source file that is part of a translation unit.
283 */
284typedef void *CXFile;
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000285
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000286
287/**
288 * \brief Retrieve the complete file and path name of the given file.
Steve Naroff6231f182009-10-27 14:35:18 +0000289 */
Ted Kremenekc560b682010-02-17 00:41:20 +0000290CINDEX_LINKAGE CXString clang_getFileName(CXFile SFile);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000291
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000292/**
293 * \brief Retrieve the last modification time of the given file.
294 */
Douglas Gregor249c1212009-10-31 15:48:08 +0000295CINDEX_LINKAGE time_t clang_getFileTime(CXFile SFile);
Steve Naroff6231f182009-10-27 14:35:18 +0000296
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000297/**
Argyrios Kyrtzidisac08b262013-01-26 04:52:52 +0000298 * \brief Uniquely identifies a CXFile, that refers to the same underlying file,
299 * across an indexing session.
300 */
301typedef struct {
302 unsigned long long data[3];
303} CXFileUniqueID;
304
305/**
306 * \brief Retrieve the unique ID for the given \c file.
307 *
308 * \param file the file to get the ID for.
309 * \param outID stores the returned CXFileUniqueID.
310 * \returns If there was a failure getting the unique ID, returns non-zero,
311 * otherwise returns 0.
312*/
313CINDEX_LINKAGE int clang_getFileUniqueID(CXFile file, CXFileUniqueID *outID);
314
315/**
Douglas Gregor37aa4932011-05-04 00:14:37 +0000316 * \brief Determine whether the given header is guarded against
317 * multiple inclusions, either with the conventional
James Dennett574cb4c2012-06-15 05:41:51 +0000318 * \#ifndef/\#define/\#endif macro guards or with \#pragma once.
Douglas Gregor37aa4932011-05-04 00:14:37 +0000319 */
320CINDEX_LINKAGE unsigned
321clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu, CXFile file);
322
323/**
Douglas Gregor816fd362010-01-22 21:44:22 +0000324 * \brief Retrieve a file handle within the given translation unit.
325 *
326 * \param tu the translation unit
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000327 *
Douglas Gregor816fd362010-01-22 21:44:22 +0000328 * \param file_name the name of the file.
329 *
330 * \returns the file handle for the named file in the translation unit \p tu,
331 * or a NULL file handle if the file was not a part of this translation unit.
332 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000333CINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu,
Douglas Gregor816fd362010-01-22 21:44:22 +0000334 const char *file_name);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000335
Douglas Gregor816fd362010-01-22 21:44:22 +0000336/**
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000337 * @}
338 */
339
340/**
341 * \defgroup CINDEX_LOCATIONS Physical source locations
342 *
343 * Clang represents physical source locations in its abstract syntax tree in
344 * great detail, with file, line, and column information for the majority of
345 * the tokens parsed in the source code. These data types and functions are
346 * used to represent source location information, either for a particular
347 * point in the program or for a range of points in the program, and extract
348 * specific location information from those data types.
349 *
350 * @{
351 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000352
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000353/**
Douglas Gregor4f46e782010-01-19 21:36:55 +0000354 * \brief Identifies a specific source location within a translation
355 * unit.
356 *
Chandler Carruth4aa01ef2011-08-31 16:53:37 +0000357 * Use clang_getExpansionLocation() or clang_getSpellingLocation()
Douglas Gregor229bebd2010-11-09 06:24:54 +0000358 * to map a source location to a particular file, line, and column.
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000359 */
360typedef struct {
Argyrios Kyrtzidis49d9d0292013-01-11 22:29:47 +0000361 const void *ptr_data[2];
Douglas Gregor4f46e782010-01-19 21:36:55 +0000362 unsigned int_data;
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000363} CXSourceLocation;
Ted Kremeneka44d99c2010-01-05 23:18:49 +0000364
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000365/**
Daniel Dunbar02968e52010-02-14 10:02:57 +0000366 * \brief Identifies a half-open character range in the source code.
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000367 *
Douglas Gregor4f46e782010-01-19 21:36:55 +0000368 * Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the
369 * starting and end locations from a source range, respectively.
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000370 */
371typedef struct {
Argyrios Kyrtzidis49d9d0292013-01-11 22:29:47 +0000372 const void *ptr_data[2];
Douglas Gregor4f46e782010-01-19 21:36:55 +0000373 unsigned begin_int_data;
374 unsigned end_int_data;
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000375} CXSourceRange;
Ted Kremeneka44d99c2010-01-05 23:18:49 +0000376
Douglas Gregor4f46e782010-01-19 21:36:55 +0000377/**
Douglas Gregor816fd362010-01-22 21:44:22 +0000378 * \brief Retrieve a NULL (invalid) source location.
379 */
NAKAMURA Takumieacd6672013-01-10 02:12:38 +0000380CINDEX_LINKAGE CXSourceLocation clang_getNullLocation(void);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000381
Douglas Gregor816fd362010-01-22 21:44:22 +0000382/**
James Dennett574cb4c2012-06-15 05:41:51 +0000383 * \brief Determine whether two source locations, which must refer into
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000384 * the same translation unit, refer to exactly the same point in the source
Douglas Gregor816fd362010-01-22 21:44:22 +0000385 * code.
386 *
387 * \returns non-zero if the source locations refer to the same location, zero
388 * if they refer to different locations.
389 */
390CINDEX_LINKAGE unsigned clang_equalLocations(CXSourceLocation loc1,
391 CXSourceLocation loc2);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000392
Douglas Gregor816fd362010-01-22 21:44:22 +0000393/**
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000394 * \brief Retrieves the source location associated with a given file/line/column
395 * in a particular translation unit.
Douglas Gregor816fd362010-01-22 21:44:22 +0000396 */
397CINDEX_LINKAGE CXSourceLocation clang_getLocation(CXTranslationUnit tu,
398 CXFile file,
399 unsigned line,
400 unsigned column);
David Chisnall2e16ac52010-10-15 17:07:39 +0000401/**
402 * \brief Retrieves the source location associated with a given character offset
403 * in a particular translation unit.
404 */
405CINDEX_LINKAGE CXSourceLocation clang_getLocationForOffset(CXTranslationUnit tu,
406 CXFile file,
407 unsigned offset);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000408
Douglas Gregor816fd362010-01-22 21:44:22 +0000409/**
Argyrios Kyrtzidis25f7af12013-04-12 17:06:51 +0000410 * \brief Returns non-zero if the given source location is in a system header.
411 */
412CINDEX_LINKAGE int clang_Location_isInSystemHeader(CXSourceLocation location);
413
414/**
Stefanus Du Toitdb51c632013-08-08 17:48:14 +0000415 * \brief Returns non-zero if the given source location is in the main file of
416 * the corresponding translation unit.
417 */
418CINDEX_LINKAGE int clang_Location_isFromMainFile(CXSourceLocation location);
419
420/**
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000421 * \brief Retrieve a NULL (invalid) source range.
422 */
NAKAMURA Takumieacd6672013-01-10 02:12:38 +0000423CINDEX_LINKAGE CXSourceRange clang_getNullRange(void);
Ted Kremenekd071c602010-03-13 02:50:34 +0000424
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000425/**
Douglas Gregor816fd362010-01-22 21:44:22 +0000426 * \brief Retrieve a source range given the beginning and ending source
427 * locations.
428 */
429CINDEX_LINKAGE CXSourceRange clang_getRange(CXSourceLocation begin,
430 CXSourceLocation end);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000431
Douglas Gregor816fd362010-01-22 21:44:22 +0000432/**
Douglas Gregor757e38b2011-07-23 19:35:14 +0000433 * \brief Determine whether two ranges are equivalent.
434 *
435 * \returns non-zero if the ranges are the same, zero if they differ.
436 */
437CINDEX_LINKAGE unsigned clang_equalRanges(CXSourceRange range1,
438 CXSourceRange range2);
439
440/**
Dmitri Gribenko8994e0c2012-09-13 13:11:20 +0000441 * \brief Returns non-zero if \p range is null.
Argyrios Kyrtzidise7e42912011-09-28 18:14:21 +0000442 */
Erik Verbruggend610b0f2011-10-06 12:11:57 +0000443CINDEX_LINKAGE int clang_Range_isNull(CXSourceRange range);
Argyrios Kyrtzidise7e42912011-09-28 18:14:21 +0000444
445/**
Douglas Gregor9bd6db52010-01-26 19:19:08 +0000446 * \brief Retrieve the file, line, column, and offset represented by
447 * the given source location.
Douglas Gregor4f46e782010-01-19 21:36:55 +0000448 *
Chandler Carruth4aa01ef2011-08-31 16:53:37 +0000449 * If the location refers into a macro expansion, retrieves the
450 * location of the macro expansion.
Douglas Gregor229bebd2010-11-09 06:24:54 +0000451 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000452 * \param location the location within a source file that will be decomposed
453 * into its parts.
Douglas Gregor4f46e782010-01-19 21:36:55 +0000454 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000455 * \param file [out] if non-NULL, will be set to the file to which the given
Douglas Gregor4f46e782010-01-19 21:36:55 +0000456 * source location points.
457 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000458 * \param line [out] if non-NULL, will be set to the line to which the given
Douglas Gregor4f46e782010-01-19 21:36:55 +0000459 * source location points.
460 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000461 * \param column [out] if non-NULL, will be set to the column to which the given
462 * source location points.
Douglas Gregor9bd6db52010-01-26 19:19:08 +0000463 *
464 * \param offset [out] if non-NULL, will be set to the offset into the
465 * buffer to which the given source location points.
Douglas Gregor4f46e782010-01-19 21:36:55 +0000466 */
Chandler Carruth4aa01ef2011-08-31 16:53:37 +0000467CINDEX_LINKAGE void clang_getExpansionLocation(CXSourceLocation location,
468 CXFile *file,
469 unsigned *line,
470 unsigned *column,
471 unsigned *offset);
472
473/**
Argyrios Kyrtzidis91672b32011-09-13 21:49:08 +0000474 * \brief Retrieve the file, line, column, and offset represented by
475 * the given source location, as specified in a # line directive.
476 *
477 * Example: given the following source code in a file somefile.c
478 *
James Dennett574cb4c2012-06-15 05:41:51 +0000479 * \code
Argyrios Kyrtzidis91672b32011-09-13 21:49:08 +0000480 * #123 "dummy.c" 1
481 *
482 * static int func(void)
483 * {
484 * return 0;
485 * }
James Dennett574cb4c2012-06-15 05:41:51 +0000486 * \endcode
Argyrios Kyrtzidis91672b32011-09-13 21:49:08 +0000487 *
488 * the location information returned by this function would be
489 *
490 * File: dummy.c Line: 124 Column: 12
491 *
492 * whereas clang_getExpansionLocation would have returned
493 *
494 * File: somefile.c Line: 3 Column: 12
495 *
496 * \param location the location within a source file that will be decomposed
497 * into its parts.
498 *
499 * \param filename [out] if non-NULL, will be set to the filename of the
500 * source location. Note that filenames returned will be for "virtual" files,
501 * which don't necessarily exist on the machine running clang - e.g. when
502 * parsing preprocessed output obtained from a different environment. If
503 * a non-NULL value is passed in, remember to dispose of the returned value
504 * using \c clang_disposeString() once you've finished with it. For an invalid
505 * source location, an empty string is returned.
506 *
507 * \param line [out] if non-NULL, will be set to the line number of the
508 * source location. For an invalid source location, zero is returned.
509 *
510 * \param column [out] if non-NULL, will be set to the column number of the
511 * source location. For an invalid source location, zero is returned.
512 */
513CINDEX_LINKAGE void clang_getPresumedLocation(CXSourceLocation location,
514 CXString *filename,
515 unsigned *line,
516 unsigned *column);
517
518/**
Chandler Carruth4aa01ef2011-08-31 16:53:37 +0000519 * \brief Legacy API to retrieve the file, line, column, and offset represented
520 * by the given source location.
521 *
522 * This interface has been replaced by the newer interface
James Dennett574cb4c2012-06-15 05:41:51 +0000523 * #clang_getExpansionLocation(). See that interface's documentation for
Chandler Carruth4aa01ef2011-08-31 16:53:37 +0000524 * details.
525 */
Douglas Gregor4f46e782010-01-19 21:36:55 +0000526CINDEX_LINKAGE void clang_getInstantiationLocation(CXSourceLocation location,
527 CXFile *file,
528 unsigned *line,
Douglas Gregor9bd6db52010-01-26 19:19:08 +0000529 unsigned *column,
530 unsigned *offset);
Douglas Gregor47751d62010-01-26 03:07:15 +0000531
532/**
Douglas Gregor229bebd2010-11-09 06:24:54 +0000533 * \brief Retrieve the file, line, column, and offset represented by
534 * the given source location.
535 *
536 * If the location refers into a macro instantiation, return where the
537 * location was originally spelled in the source file.
538 *
539 * \param location the location within a source file that will be decomposed
540 * into its parts.
541 *
542 * \param file [out] if non-NULL, will be set to the file to which the given
543 * source location points.
544 *
545 * \param line [out] if non-NULL, will be set to the line to which the given
546 * source location points.
547 *
548 * \param column [out] if non-NULL, will be set to the column to which the given
549 * source location points.
550 *
551 * \param offset [out] if non-NULL, will be set to the offset into the
552 * buffer to which the given source location points.
553 */
554CINDEX_LINKAGE void clang_getSpellingLocation(CXSourceLocation location,
555 CXFile *file,
556 unsigned *line,
557 unsigned *column,
558 unsigned *offset);
559
560/**
Argyrios Kyrtzidis56be7162013-01-04 18:30:13 +0000561 * \brief Retrieve the file, line, column, and offset represented by
562 * the given source location.
563 *
564 * If the location refers into a macro expansion, return where the macro was
565 * expanded or where the macro argument was written, if the location points at
566 * a macro argument.
567 *
568 * \param location the location within a source file that will be decomposed
569 * into its parts.
570 *
571 * \param file [out] if non-NULL, will be set to the file to which the given
572 * source location points.
573 *
574 * \param line [out] if non-NULL, will be set to the line to which the given
575 * source location points.
576 *
577 * \param column [out] if non-NULL, will be set to the column to which the given
578 * source location points.
579 *
580 * \param offset [out] if non-NULL, will be set to the offset into the
581 * buffer to which the given source location points.
582 */
583CINDEX_LINKAGE void clang_getFileLocation(CXSourceLocation location,
584 CXFile *file,
585 unsigned *line,
586 unsigned *column,
587 unsigned *offset);
588
589/**
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000590 * \brief Retrieve a source location representing the first character within a
591 * source range.
Douglas Gregor4f46e782010-01-19 21:36:55 +0000592 */
593CINDEX_LINKAGE CXSourceLocation clang_getRangeStart(CXSourceRange range);
594
595/**
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000596 * \brief Retrieve a source location representing the last character within a
597 * source range.
Douglas Gregor4f46e782010-01-19 21:36:55 +0000598 */
599CINDEX_LINKAGE CXSourceLocation clang_getRangeEnd(CXSourceRange range);
600
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000601/**
Argyrios Kyrtzidis0e282ef2013-12-06 18:55:45 +0000602 * \brief Identifies an array of ranges.
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000603 */
604typedef struct {
605 /** \brief The number of ranges in the \c ranges array. */
606 unsigned count;
607 /**
Argyrios Kyrtzidis0e282ef2013-12-06 18:55:45 +0000608 * \brief An array of \c CXSourceRanges.
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000609 */
610 CXSourceRange *ranges;
Argyrios Kyrtzidis0e282ef2013-12-06 18:55:45 +0000611} CXSourceRangeList;
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000612
613/**
614 * \brief Retrieve all ranges that were skipped by the preprocessor.
Argyrios Kyrtzidis0e282ef2013-12-06 18:55:45 +0000615 *
616 * The preprocessor will skip lines when they are surrounded by an
617 * if/ifdef/ifndef directive whose condition does not evaluate to true.
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000618 */
Argyrios Kyrtzidis0e282ef2013-12-06 18:55:45 +0000619CINDEX_LINKAGE CXSourceRangeList *clang_getSkippedRanges(CXTranslationUnit tu,
620 CXFile file);
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000621
622/**
Argyrios Kyrtzidis0e282ef2013-12-06 18:55:45 +0000623 * \brief Destroy the given \c CXSourceRangeList.
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000624 */
Argyrios Kyrtzidis0e282ef2013-12-06 18:55:45 +0000625CINDEX_LINKAGE void clang_disposeSourceRangeList(CXSourceRangeList *ranges);
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000626
627/**
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000628 * @}
629 */
Douglas Gregor6007cf22010-01-22 22:29:16 +0000630
631/**
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000632 * \defgroup CINDEX_DIAG Diagnostic reporting
633 *
634 * @{
635 */
636
637/**
638 * \brief Describes the severity of a particular diagnostic.
639 */
640enum CXDiagnosticSeverity {
641 /**
Ted Kremenekd071c602010-03-13 02:50:34 +0000642 * \brief A diagnostic that has been suppressed, e.g., by a command-line
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000643 * option.
644 */
645 CXDiagnostic_Ignored = 0,
Ted Kremenekd071c602010-03-13 02:50:34 +0000646
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000647 /**
648 * \brief This diagnostic is a note that should be attached to the
649 * previous (non-note) diagnostic.
650 */
651 CXDiagnostic_Note = 1,
652
653 /**
654 * \brief This diagnostic indicates suspicious code that may not be
655 * wrong.
656 */
657 CXDiagnostic_Warning = 2,
658
659 /**
660 * \brief This diagnostic indicates that the code is ill-formed.
661 */
662 CXDiagnostic_Error = 3,
663
664 /**
665 * \brief This diagnostic indicates that the code is ill-formed such
666 * that future parser recovery is unlikely to produce useful
667 * results.
668 */
669 CXDiagnostic_Fatal = 4
670};
671
672/**
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000673 * \brief A single diagnostic, containing the diagnostic's severity,
674 * location, text, source ranges, and fix-it hints.
675 */
676typedef void *CXDiagnostic;
677
678/**
Ted Kremenekd010ba42011-11-10 08:43:12 +0000679 * \brief A group of CXDiagnostics.
680 */
681typedef void *CXDiagnosticSet;
682
683/**
684 * \brief Determine the number of diagnostics in a CXDiagnosticSet.
685 */
686CINDEX_LINKAGE unsigned clang_getNumDiagnosticsInSet(CXDiagnosticSet Diags);
687
688/**
689 * \brief Retrieve a diagnostic associated with the given CXDiagnosticSet.
690 *
James Dennett574cb4c2012-06-15 05:41:51 +0000691 * \param Diags the CXDiagnosticSet to query.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000692 * \param Index the zero-based diagnostic number to retrieve.
693 *
694 * \returns the requested diagnostic. This diagnostic must be freed
695 * via a call to \c clang_disposeDiagnostic().
696 */
697CINDEX_LINKAGE CXDiagnostic clang_getDiagnosticInSet(CXDiagnosticSet Diags,
698 unsigned Index);
699
700
701/**
702 * \brief Describes the kind of error that occurred (if any) in a call to
703 * \c clang_loadDiagnostics.
704 */
705enum CXLoadDiag_Error {
706 /**
707 * \brief Indicates that no error occurred.
708 */
709 CXLoadDiag_None = 0,
710
711 /**
712 * \brief Indicates that an unknown error occurred while attempting to
713 * deserialize diagnostics.
714 */
715 CXLoadDiag_Unknown = 1,
716
717 /**
718 * \brief Indicates that the file containing the serialized diagnostics
719 * could not be opened.
720 */
721 CXLoadDiag_CannotLoad = 2,
722
723 /**
724 * \brief Indicates that the serialized diagnostics file is invalid or
James Dennett574cb4c2012-06-15 05:41:51 +0000725 * corrupt.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000726 */
727 CXLoadDiag_InvalidFile = 3
728};
729
730/**
731 * \brief Deserialize a set of diagnostics from a Clang diagnostics bitcode
James Dennett574cb4c2012-06-15 05:41:51 +0000732 * file.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000733 *
James Dennett574cb4c2012-06-15 05:41:51 +0000734 * \param file The name of the file to deserialize.
735 * \param error A pointer to a enum value recording if there was a problem
Ted Kremenekd010ba42011-11-10 08:43:12 +0000736 * deserializing the diagnostics.
James Dennett574cb4c2012-06-15 05:41:51 +0000737 * \param errorString A pointer to a CXString for recording the error string
Ted Kremenekd010ba42011-11-10 08:43:12 +0000738 * if the file was not successfully loaded.
739 *
740 * \returns A loaded CXDiagnosticSet if successful, and NULL otherwise. These
James Dennett574cb4c2012-06-15 05:41:51 +0000741 * diagnostics should be released using clang_disposeDiagnosticSet().
Ted Kremenekd010ba42011-11-10 08:43:12 +0000742 */
743CINDEX_LINKAGE CXDiagnosticSet clang_loadDiagnostics(const char *file,
744 enum CXLoadDiag_Error *error,
745 CXString *errorString);
746
747/**
748 * \brief Release a CXDiagnosticSet and all of its contained diagnostics.
749 */
750CINDEX_LINKAGE void clang_disposeDiagnosticSet(CXDiagnosticSet Diags);
751
752/**
James Dennett574cb4c2012-06-15 05:41:51 +0000753 * \brief Retrieve the child diagnostics of a CXDiagnostic.
754 *
755 * This CXDiagnosticSet does not need to be released by
Sylvestre Ledrud29d97c2013-11-17 09:46:45 +0000756 * clang_disposeDiagnosticSet.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000757 */
758CINDEX_LINKAGE CXDiagnosticSet clang_getChildDiagnostics(CXDiagnostic D);
759
760/**
Douglas Gregor33cdd812010-02-18 18:08:43 +0000761 * \brief Determine the number of diagnostics produced for the given
762 * translation unit.
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000763 */
Douglas Gregor33cdd812010-02-18 18:08:43 +0000764CINDEX_LINKAGE unsigned clang_getNumDiagnostics(CXTranslationUnit Unit);
765
766/**
767 * \brief Retrieve a diagnostic associated with the given translation unit.
768 *
769 * \param Unit the translation unit to query.
770 * \param Index the zero-based diagnostic number to retrieve.
771 *
772 * \returns the requested diagnostic. This diagnostic must be freed
773 * via a call to \c clang_disposeDiagnostic().
774 */
775CINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit,
776 unsigned Index);
777
778/**
Ted Kremenekb4a8b052011-12-09 22:28:32 +0000779 * \brief Retrieve the complete set of diagnostics associated with a
780 * translation unit.
781 *
782 * \param Unit the translation unit to query.
783 */
784CINDEX_LINKAGE CXDiagnosticSet
785 clang_getDiagnosticSetFromTU(CXTranslationUnit Unit);
786
787/**
Douglas Gregor33cdd812010-02-18 18:08:43 +0000788 * \brief Destroy a diagnostic.
789 */
790CINDEX_LINKAGE void clang_disposeDiagnostic(CXDiagnostic Diagnostic);
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000791
792/**
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000793 * \brief Options to control the display of diagnostics.
794 *
795 * The values in this enum are meant to be combined to customize the
Sylvestre Ledrud29d97c2013-11-17 09:46:45 +0000796 * behavior of \c clang_formatDiagnostic().
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000797 */
798enum CXDiagnosticDisplayOptions {
799 /**
800 * \brief Display the source-location information where the
801 * diagnostic was located.
802 *
803 * When set, diagnostics will be prefixed by the file, line, and
804 * (optionally) column to which the diagnostic refers. For example,
805 *
806 * \code
807 * test.c:28: warning: extra tokens at end of #endif directive
808 * \endcode
809 *
810 * This option corresponds to the clang flag \c -fshow-source-location.
811 */
812 CXDiagnostic_DisplaySourceLocation = 0x01,
813
814 /**
815 * \brief If displaying the source-location information of the
816 * diagnostic, also include the column number.
817 *
818 * This option corresponds to the clang flag \c -fshow-column.
819 */
820 CXDiagnostic_DisplayColumn = 0x02,
821
822 /**
823 * \brief If displaying the source-location information of the
824 * diagnostic, also include information about source ranges in a
825 * machine-parsable format.
826 *
Ted Kremenekd071c602010-03-13 02:50:34 +0000827 * This option corresponds to the clang flag
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000828 * \c -fdiagnostics-print-source-range-info.
829 */
Douglas Gregora750e8e2010-11-19 16:18:16 +0000830 CXDiagnostic_DisplaySourceRanges = 0x04,
831
832 /**
833 * \brief Display the option name associated with this diagnostic, if any.
834 *
835 * The option name displayed (e.g., -Wconversion) will be placed in brackets
836 * after the diagnostic text. This option corresponds to the clang flag
837 * \c -fdiagnostics-show-option.
838 */
839 CXDiagnostic_DisplayOption = 0x08,
840
841 /**
842 * \brief Display the category number associated with this diagnostic, if any.
843 *
844 * The category number is displayed within brackets after the diagnostic text.
845 * This option corresponds to the clang flag
846 * \c -fdiagnostics-show-category=id.
847 */
848 CXDiagnostic_DisplayCategoryId = 0x10,
849
850 /**
851 * \brief Display the category name associated with this diagnostic, if any.
852 *
853 * The category name is displayed within brackets after the diagnostic text.
854 * This option corresponds to the clang flag
855 * \c -fdiagnostics-show-category=name.
856 */
857 CXDiagnostic_DisplayCategoryName = 0x20
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000858};
859
860/**
Douglas Gregord770f732010-02-22 23:17:23 +0000861 * \brief Format the given diagnostic in a manner that is suitable for display.
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000862 *
Douglas Gregord770f732010-02-22 23:17:23 +0000863 * This routine will format the given diagnostic to a string, rendering
Ted Kremenekd071c602010-03-13 02:50:34 +0000864 * the diagnostic according to the various options given. The
865 * \c clang_defaultDiagnosticDisplayOptions() function returns the set of
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000866 * options that most closely mimics the behavior of the clang compiler.
867 *
868 * \param Diagnostic The diagnostic to print.
869 *
Ted Kremenekd071c602010-03-13 02:50:34 +0000870 * \param Options A set of options that control the diagnostic display,
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000871 * created by combining \c CXDiagnosticDisplayOptions values.
Douglas Gregord770f732010-02-22 23:17:23 +0000872 *
873 * \returns A new string containing for formatted diagnostic.
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000874 */
Douglas Gregord770f732010-02-22 23:17:23 +0000875CINDEX_LINKAGE CXString clang_formatDiagnostic(CXDiagnostic Diagnostic,
876 unsigned Options);
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000877
878/**
879 * \brief Retrieve the set of display options most similar to the
880 * default behavior of the clang compiler.
881 *
882 * \returns A set of display options suitable for use with \c
Sylvestre Ledrud29d97c2013-11-17 09:46:45 +0000883 * clang_formatDiagnostic().
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000884 */
885CINDEX_LINKAGE unsigned clang_defaultDiagnosticDisplayOptions(void);
886
887/**
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000888 * \brief Determine the severity of the given diagnostic.
889 */
Ted Kremenekd071c602010-03-13 02:50:34 +0000890CINDEX_LINKAGE enum CXDiagnosticSeverity
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000891clang_getDiagnosticSeverity(CXDiagnostic);
892
893/**
894 * \brief Retrieve the source location of the given diagnostic.
895 *
896 * This location is where Clang would print the caret ('^') when
897 * displaying the diagnostic on the command line.
898 */
899CINDEX_LINKAGE CXSourceLocation clang_getDiagnosticLocation(CXDiagnostic);
900
901/**
902 * \brief Retrieve the text of the given diagnostic.
903 */
904CINDEX_LINKAGE CXString clang_getDiagnosticSpelling(CXDiagnostic);
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +0000905
906/**
Douglas Gregora750e8e2010-11-19 16:18:16 +0000907 * \brief Retrieve the name of the command-line option that enabled this
908 * diagnostic.
909 *
910 * \param Diag The diagnostic to be queried.
911 *
912 * \param Disable If non-NULL, will be set to the option that disables this
913 * diagnostic (if any).
914 *
915 * \returns A string that contains the command-line option used to enable this
916 * warning, such as "-Wconversion" or "-pedantic".
917 */
918CINDEX_LINKAGE CXString clang_getDiagnosticOption(CXDiagnostic Diag,
919 CXString *Disable);
920
921/**
922 * \brief Retrieve the category number for this diagnostic.
923 *
924 * Diagnostics can be categorized into groups along with other, related
925 * diagnostics (e.g., diagnostics under the same warning flag). This routine
926 * retrieves the category number for the given diagnostic.
927 *
928 * \returns The number of the category that contains this diagnostic, or zero
929 * if this diagnostic is uncategorized.
930 */
931CINDEX_LINKAGE unsigned clang_getDiagnosticCategory(CXDiagnostic);
932
933/**
Ted Kremenek26a6d492012-04-12 00:03:31 +0000934 * \brief Retrieve the name of a particular diagnostic category. This
935 * is now deprecated. Use clang_getDiagnosticCategoryText()
936 * instead.
Douglas Gregora750e8e2010-11-19 16:18:16 +0000937 *
938 * \param Category A diagnostic category number, as returned by
939 * \c clang_getDiagnosticCategory().
940 *
941 * \returns The name of the given diagnostic category.
942 */
Ted Kremenek26a6d492012-04-12 00:03:31 +0000943CINDEX_DEPRECATED CINDEX_LINKAGE
944CXString clang_getDiagnosticCategoryName(unsigned Category);
945
946/**
947 * \brief Retrieve the diagnostic category text for a given diagnostic.
948 *
Ted Kremenek26a6d492012-04-12 00:03:31 +0000949 * \returns The text of the given diagnostic category.
950 */
951CINDEX_LINKAGE CXString clang_getDiagnosticCategoryText(CXDiagnostic);
Douglas Gregora750e8e2010-11-19 16:18:16 +0000952
953/**
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +0000954 * \brief Determine the number of source ranges associated with the given
955 * diagnostic.
956 */
957CINDEX_LINKAGE unsigned clang_getDiagnosticNumRanges(CXDiagnostic);
Ted Kremenekd071c602010-03-13 02:50:34 +0000958
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000959/**
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +0000960 * \brief Retrieve a source range associated with the diagnostic.
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000961 *
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +0000962 * A diagnostic's source ranges highlight important elements in the source
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000963 * code. On the command line, Clang displays source ranges by
Ted Kremenekd071c602010-03-13 02:50:34 +0000964 * underlining them with '~' characters.
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000965 *
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +0000966 * \param Diagnostic the diagnostic whose range is being extracted.
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000967 *
Ted Kremenekd071c602010-03-13 02:50:34 +0000968 * \param Range the zero-based index specifying which range to
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000969 *
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +0000970 * \returns the requested source range.
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000971 */
Ted Kremenekd071c602010-03-13 02:50:34 +0000972CINDEX_LINKAGE CXSourceRange clang_getDiagnosticRange(CXDiagnostic Diagnostic,
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +0000973 unsigned Range);
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000974
975/**
976 * \brief Determine the number of fix-it hints associated with the
977 * given diagnostic.
978 */
979CINDEX_LINKAGE unsigned clang_getDiagnosticNumFixIts(CXDiagnostic Diagnostic);
980
981/**
Douglas Gregor836ec942010-02-19 18:16:06 +0000982 * \brief Retrieve the replacement information for a given fix-it.
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000983 *
Douglas Gregor836ec942010-02-19 18:16:06 +0000984 * Fix-its are described in terms of a source range whose contents
985 * should be replaced by a string. This approach generalizes over
986 * three kinds of operations: removal of source code (the range covers
987 * the code to be removed and the replacement string is empty),
988 * replacement of source code (the range covers the code to be
989 * replaced and the replacement string provides the new code), and
990 * insertion (both the start and end of the range point at the
991 * insertion location, and the replacement string provides the text to
992 * insert).
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000993 *
Douglas Gregor836ec942010-02-19 18:16:06 +0000994 * \param Diagnostic The diagnostic whose fix-its are being queried.
995 *
996 * \param FixIt The zero-based index of the fix-it.
997 *
998 * \param ReplacementRange The source range whose contents will be
999 * replaced with the returned replacement string. Note that source
1000 * ranges are half-open ranges [a, b), so the source code should be
1001 * replaced from a and up to (but not including) b.
1002 *
1003 * \returns A string containing text that should be replace the source
1004 * code indicated by the \c ReplacementRange.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001005 */
Ted Kremenekd071c602010-03-13 02:50:34 +00001006CINDEX_LINKAGE CXString clang_getDiagnosticFixIt(CXDiagnostic Diagnostic,
Douglas Gregor836ec942010-02-19 18:16:06 +00001007 unsigned FixIt,
1008 CXSourceRange *ReplacementRange);
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001009
1010/**
1011 * @}
1012 */
1013
1014/**
1015 * \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation
1016 *
1017 * The routines in this group provide the ability to create and destroy
1018 * translation units from files, either by parsing the contents of the files or
1019 * by reading in a serialized representation of a translation unit.
1020 *
1021 * @{
1022 */
Ted Kremenekd071c602010-03-13 02:50:34 +00001023
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001024/**
1025 * \brief Get the original translation unit source file name.
1026 */
1027CINDEX_LINKAGE CXString
1028clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit);
1029
1030/**
1031 * \brief Return the CXTranslationUnit for a given source file and the provided
1032 * command line arguments one would pass to the compiler.
1033 *
1034 * Note: The 'source_filename' argument is optional. If the caller provides a
1035 * NULL pointer, the name of the source file is expected to reside in the
1036 * specified command line arguments.
1037 *
1038 * Note: When encountered in 'clang_command_line_args', the following options
1039 * are ignored:
1040 *
1041 * '-c'
1042 * '-emit-ast'
1043 * '-fsyntax-only'
James Dennett574cb4c2012-06-15 05:41:51 +00001044 * '-o \<output file>' (both '-o' and '\<output file>' are ignored)
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001045 *
Ted Kremenekbd4972442010-11-08 04:28:51 +00001046 * \param CIdx The index object with which the translation unit will be
1047 * associated.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001048 *
James Dennett574cb4c2012-06-15 05:41:51 +00001049 * \param source_filename The name of the source file to load, or NULL if the
Ted Kremenekbd4972442010-11-08 04:28:51 +00001050 * source file is included in \p clang_command_line_args.
1051 *
1052 * \param num_clang_command_line_args The number of command-line arguments in
1053 * \p clang_command_line_args.
1054 *
1055 * \param clang_command_line_args The command-line arguments that would be
1056 * passed to the \c clang executable if it were being invoked out-of-process.
1057 * These command-line options will be parsed and will affect how the translation
1058 * unit is parsed. Note that the following options are ignored: '-c',
James Dennett574cb4c2012-06-15 05:41:51 +00001059 * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001060 *
1061 * \param num_unsaved_files the number of unsaved file entries in \p
1062 * unsaved_files.
1063 *
1064 * \param unsaved_files the files that have not yet been saved to disk
1065 * but may be required for code completion, including the contents of
Ted Kremenekde24a942010-04-12 18:47:26 +00001066 * those files. The contents and name of these files (as specified by
1067 * CXUnsavedFile) are copied when necessary, so the client only needs to
1068 * guarantee their validity until the call to this function returns.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001069 */
1070CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnitFromSourceFile(
1071 CXIndex CIdx,
1072 const char *source_filename,
1073 int num_clang_command_line_args,
Douglas Gregor57879fa2010-09-01 16:43:19 +00001074 const char * const *clang_command_line_args,
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001075 unsigned num_unsaved_files,
Douglas Gregor33cdd812010-02-18 18:08:43 +00001076 struct CXUnsavedFile *unsaved_files);
Ted Kremenekd071c602010-03-13 02:50:34 +00001077
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001078/**
1079 * \brief Create a translation unit from an AST file (-emit-ast).
1080 */
Ted Kremenekd071c602010-03-13 02:50:34 +00001081CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnit(CXIndex,
Douglas Gregor33cdd812010-02-18 18:08:43 +00001082 const char *ast_filename);
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001083
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001084/**
1085 * \brief Flags that control the creation of translation units.
1086 *
1087 * The enumerators in this enumeration type are meant to be bitwise
1088 * ORed together to specify which options should be used when
1089 * constructing the translation unit.
1090 */
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001091enum CXTranslationUnit_Flags {
1092 /**
1093 * \brief Used to indicate that no special translation-unit options are
1094 * needed.
1095 */
1096 CXTranslationUnit_None = 0x0,
1097
1098 /**
1099 * \brief Used to indicate that the parser should construct a "detailed"
1100 * preprocessing record, including all macro definitions and instantiations.
1101 *
1102 * Constructing a detailed preprocessing record requires more memory
1103 * and time to parse, since the information contained in the record
1104 * is usually not retained. However, it can be useful for
1105 * applications that require more detailed information about the
1106 * behavior of the preprocessor.
1107 */
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001108 CXTranslationUnit_DetailedPreprocessingRecord = 0x01,
1109
1110 /**
Douglas Gregor4a47bca2010-08-09 22:28:58 +00001111 * \brief Used to indicate that the translation unit is incomplete.
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001112 *
Douglas Gregor4a47bca2010-08-09 22:28:58 +00001113 * When a translation unit is considered "incomplete", semantic
1114 * analysis that is typically performed at the end of the
1115 * translation unit will be suppressed. For example, this suppresses
1116 * the completion of tentative declarations in C and of
1117 * instantiation of implicitly-instantiation function templates in
1118 * C++. This option is typically used when parsing a header with the
1119 * intent of producing a precompiled header.
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001120 */
Douglas Gregor4a47bca2010-08-09 22:28:58 +00001121 CXTranslationUnit_Incomplete = 0x02,
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001122
1123 /**
1124 * \brief Used to indicate that the translation unit should be built with an
1125 * implicit precompiled header for the preamble.
1126 *
1127 * An implicit precompiled header is used as an optimization when a
1128 * particular translation unit is likely to be reparsed many times
1129 * when the sources aren't changing that often. In this case, an
1130 * implicit precompiled header will be built containing all of the
1131 * initial includes at the top of the main file (what we refer to as
1132 * the "preamble" of the file). In subsequent parses, if the
1133 * preamble or the files in it have not changed, \c
1134 * clang_reparseTranslationUnit() will re-use the implicit
1135 * precompiled header to improve parsing performance.
1136 */
Douglas Gregorde051182010-08-11 15:58:42 +00001137 CXTranslationUnit_PrecompiledPreamble = 0x04,
1138
1139 /**
1140 * \brief Used to indicate that the translation unit should cache some
1141 * code-completion results with each reparse of the source file.
1142 *
1143 * Caching of code-completion results is a performance optimization that
1144 * introduces some overhead to reparsing but improves the performance of
1145 * code-completion operations.
1146 */
Douglas Gregorf5a18542010-10-27 17:24:53 +00001147 CXTranslationUnit_CacheCompletionResults = 0x08,
Argyrios Kyrtzidis0db720f2012-10-11 16:05:00 +00001148
Douglas Gregorf5a18542010-10-27 17:24:53 +00001149 /**
Argyrios Kyrtzidis0db720f2012-10-11 16:05:00 +00001150 * \brief Used to indicate that the translation unit will be serialized with
1151 * \c clang_saveTranslationUnit.
Douglas Gregorf5a18542010-10-27 17:24:53 +00001152 *
Argyrios Kyrtzidis0db720f2012-10-11 16:05:00 +00001153 * This option is typically used when parsing a header with the intent of
1154 * producing a precompiled header.
Douglas Gregorf5a18542010-10-27 17:24:53 +00001155 */
Argyrios Kyrtzidis0db720f2012-10-11 16:05:00 +00001156 CXTranslationUnit_ForSerialization = 0x10,
Douglas Gregorf5a18542010-10-27 17:24:53 +00001157
1158 /**
Douglas Gregor2ed0ee12011-08-25 22:54:01 +00001159 * \brief DEPRECATED: Enabled chained precompiled preambles in C++.
Douglas Gregorf5a18542010-10-27 17:24:53 +00001160 *
1161 * Note: this is a *temporary* option that is available only while
Douglas Gregor2ed0ee12011-08-25 22:54:01 +00001162 * we are testing C++ precompiled preamble support. It is deprecated.
Douglas Gregorf5a18542010-10-27 17:24:53 +00001163 */
Erik Verbruggen6e922512012-04-12 10:11:59 +00001164 CXTranslationUnit_CXXChainedPCH = 0x20,
1165
1166 /**
1167 * \brief Used to indicate that function/method bodies should be skipped while
1168 * parsing.
1169 *
1170 * This option can be used to search for declarations/definitions while
1171 * ignoring the usages.
1172 */
Dmitri Gribenko3292d062012-07-02 17:35:10 +00001173 CXTranslationUnit_SkipFunctionBodies = 0x40,
1174
1175 /**
1176 * \brief Used to indicate that brief documentation comments should be
1177 * included into the set of code completions returned from this translation
1178 * unit.
1179 */
1180 CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 0x80
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001181};
1182
1183/**
Douglas Gregor4a47bca2010-08-09 22:28:58 +00001184 * \brief Returns the set of flags that is suitable for parsing a translation
1185 * unit that is being edited.
1186 *
1187 * The set of flags returned provide options for \c clang_parseTranslationUnit()
1188 * to indicate that the translation unit is likely to be reparsed many times,
1189 * either explicitly (via \c clang_reparseTranslationUnit()) or implicitly
1190 * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag
1191 * set contains an unspecified set of optimizations (e.g., the precompiled
1192 * preamble) geared toward improving the performance of these routines. The
1193 * set of optimizations enabled may change from one version to the next.
1194 */
Douglas Gregorde051182010-08-11 15:58:42 +00001195CINDEX_LINKAGE unsigned clang_defaultEditingTranslationUnitOptions(void);
Douglas Gregor4a47bca2010-08-09 22:28:58 +00001196
1197/**
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001198 * \brief Parse the given source file and the translation unit corresponding
1199 * to that file.
1200 *
1201 * This routine is the main entry point for the Clang C API, providing the
1202 * ability to parse a source file into a translation unit that can then be
1203 * queried by other functions in the API. This routine accepts a set of
1204 * command-line arguments so that the compilation can be configured in the same
1205 * way that the compiler is configured on the command line.
1206 *
1207 * \param CIdx The index object with which the translation unit will be
1208 * associated.
1209 *
1210 * \param source_filename The name of the source file to load, or NULL if the
Ted Kremenekbd4972442010-11-08 04:28:51 +00001211 * source file is included in \p command_line_args.
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001212 *
1213 * \param command_line_args The command-line arguments that would be
1214 * passed to the \c clang executable if it were being invoked out-of-process.
1215 * These command-line options will be parsed and will affect how the translation
1216 * unit is parsed. Note that the following options are ignored: '-c',
James Dennett574cb4c2012-06-15 05:41:51 +00001217 * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001218 *
1219 * \param num_command_line_args The number of command-line arguments in
1220 * \p command_line_args.
1221 *
1222 * \param unsaved_files the files that have not yet been saved to disk
Douglas Gregor8e984da2010-08-04 16:47:14 +00001223 * but may be required for parsing, including the contents of
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001224 * those files. The contents and name of these files (as specified by
1225 * CXUnsavedFile) are copied when necessary, so the client only needs to
1226 * guarantee their validity until the call to this function returns.
1227 *
1228 * \param num_unsaved_files the number of unsaved file entries in \p
1229 * unsaved_files.
1230 *
1231 * \param options A bitmask of options that affects how the translation unit
1232 * is managed but not its compilation. This should be a bitwise OR of the
1233 * CXTranslationUnit_XXX flags.
1234 *
1235 * \returns A new translation unit describing the parsed code and containing
1236 * any diagnostics produced by the compiler. If there is a failure from which
1237 * the compiler cannot recover, returns NULL.
1238 */
1239CINDEX_LINKAGE CXTranslationUnit clang_parseTranslationUnit(CXIndex CIdx,
1240 const char *source_filename,
Douglas Gregor57879fa2010-09-01 16:43:19 +00001241 const char * const *command_line_args,
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001242 int num_command_line_args,
1243 struct CXUnsavedFile *unsaved_files,
1244 unsigned num_unsaved_files,
1245 unsigned options);
1246
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001247/**
Douglas Gregor6bb92ec2010-08-13 15:35:05 +00001248 * \brief Flags that control how translation units are saved.
1249 *
1250 * The enumerators in this enumeration type are meant to be bitwise
1251 * ORed together to specify which options should be used when
1252 * saving the translation unit.
1253 */
1254enum CXSaveTranslationUnit_Flags {
1255 /**
1256 * \brief Used to indicate that no special saving options are needed.
1257 */
1258 CXSaveTranslationUnit_None = 0x0
1259};
1260
1261/**
1262 * \brief Returns the set of flags that is suitable for saving a translation
1263 * unit.
1264 *
1265 * The set of flags returned provide options for
1266 * \c clang_saveTranslationUnit() by default. The returned flag
1267 * set contains an unspecified set of options that save translation units with
1268 * the most commonly-requested data.
1269 */
1270CINDEX_LINKAGE unsigned clang_defaultSaveOptions(CXTranslationUnit TU);
1271
1272/**
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001273 * \brief Describes the kind of error that occurred (if any) in a call to
1274 * \c clang_saveTranslationUnit().
1275 */
1276enum CXSaveError {
1277 /**
1278 * \brief Indicates that no error occurred while saving a translation unit.
1279 */
1280 CXSaveError_None = 0,
1281
1282 /**
1283 * \brief Indicates that an unknown error occurred while attempting to save
1284 * the file.
1285 *
1286 * This error typically indicates that file I/O failed when attempting to
1287 * write the file.
1288 */
1289 CXSaveError_Unknown = 1,
1290
1291 /**
1292 * \brief Indicates that errors during translation prevented this attempt
1293 * to save the translation unit.
1294 *
1295 * Errors that prevent the translation unit from being saved can be
1296 * extracted using \c clang_getNumDiagnostics() and \c clang_getDiagnostic().
1297 */
1298 CXSaveError_TranslationErrors = 2,
1299
1300 /**
1301 * \brief Indicates that the translation unit to be saved was somehow
1302 * invalid (e.g., NULL).
1303 */
1304 CXSaveError_InvalidTU = 3
1305};
1306
1307/**
Douglas Gregore9386682010-08-13 05:36:37 +00001308 * \brief Saves a translation unit into a serialized representation of
1309 * that translation unit on disk.
1310 *
1311 * Any translation unit that was parsed without error can be saved
1312 * into a file. The translation unit can then be deserialized into a
1313 * new \c CXTranslationUnit with \c clang_createTranslationUnit() or,
1314 * if it is an incomplete translation unit that corresponds to a
1315 * header, used as a precompiled header when parsing other translation
1316 * units.
1317 *
1318 * \param TU The translation unit to save.
Douglas Gregor6bb92ec2010-08-13 15:35:05 +00001319 *
Douglas Gregore9386682010-08-13 05:36:37 +00001320 * \param FileName The file to which the translation unit will be saved.
1321 *
Douglas Gregor6bb92ec2010-08-13 15:35:05 +00001322 * \param options A bitmask of options that affects how the translation unit
1323 * is saved. This should be a bitwise OR of the
1324 * CXSaveTranslationUnit_XXX flags.
1325 *
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001326 * \returns A value that will match one of the enumerators of the CXSaveError
1327 * enumeration. Zero (CXSaveError_None) indicates that the translation unit was
1328 * saved successfully, while a non-zero value indicates that a problem occurred.
Douglas Gregore9386682010-08-13 05:36:37 +00001329 */
1330CINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU,
Douglas Gregor6bb92ec2010-08-13 15:35:05 +00001331 const char *FileName,
1332 unsigned options);
Douglas Gregore9386682010-08-13 05:36:37 +00001333
1334/**
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001335 * \brief Destroy the specified CXTranslationUnit object.
1336 */
1337CINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit);
Ted Kremenekd071c602010-03-13 02:50:34 +00001338
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001339/**
Douglas Gregorde051182010-08-11 15:58:42 +00001340 * \brief Flags that control the reparsing of translation units.
1341 *
1342 * The enumerators in this enumeration type are meant to be bitwise
1343 * ORed together to specify which options should be used when
1344 * reparsing the translation unit.
1345 */
1346enum CXReparse_Flags {
1347 /**
1348 * \brief Used to indicate that no special reparsing options are needed.
1349 */
1350 CXReparse_None = 0x0
1351};
1352
1353/**
1354 * \brief Returns the set of flags that is suitable for reparsing a translation
1355 * unit.
1356 *
1357 * The set of flags returned provide options for
1358 * \c clang_reparseTranslationUnit() by default. The returned flag
1359 * set contains an unspecified set of optimizations geared toward common uses
1360 * of reparsing. The set of optimizations enabled may change from one version
1361 * to the next.
1362 */
1363CINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU);
1364
1365/**
Douglas Gregoraa21cc42010-07-19 21:46:24 +00001366 * \brief Reparse the source files that produced this translation unit.
1367 *
1368 * This routine can be used to re-parse the source files that originally
1369 * created the given translation unit, for example because those source files
1370 * have changed (either on disk or as passed via \p unsaved_files). The
1371 * source code will be reparsed with the same command-line options as it
1372 * was originally parsed.
1373 *
1374 * Reparsing a translation unit invalidates all cursors and source locations
1375 * that refer into that translation unit. This makes reparsing a translation
1376 * unit semantically equivalent to destroying the translation unit and then
1377 * creating a new translation unit with the same command-line arguments.
1378 * However, it may be more efficient to reparse a translation
1379 * unit using this routine.
1380 *
1381 * \param TU The translation unit whose contents will be re-parsed. The
1382 * translation unit must originally have been built with
1383 * \c clang_createTranslationUnitFromSourceFile().
1384 *
1385 * \param num_unsaved_files The number of unsaved file entries in \p
1386 * unsaved_files.
1387 *
1388 * \param unsaved_files The files that have not yet been saved to disk
1389 * but may be required for parsing, including the contents of
1390 * those files. The contents and name of these files (as specified by
1391 * CXUnsavedFile) are copied when necessary, so the client only needs to
1392 * guarantee their validity until the call to this function returns.
1393 *
Douglas Gregorde051182010-08-11 15:58:42 +00001394 * \param options A bitset of options composed of the flags in CXReparse_Flags.
1395 * The function \c clang_defaultReparseOptions() produces a default set of
1396 * options recommended for most uses, based on the translation unit.
1397 *
Douglas Gregoraa21cc42010-07-19 21:46:24 +00001398 * \returns 0 if the sources could be reparsed. A non-zero value will be
1399 * returned if reparsing was impossible, such that the translation unit is
1400 * invalid. In such cases, the only valid call for \p TU is
1401 * \c clang_disposeTranslationUnit(TU).
1402 */
1403CINDEX_LINKAGE int clang_reparseTranslationUnit(CXTranslationUnit TU,
1404 unsigned num_unsaved_files,
Douglas Gregorde051182010-08-11 15:58:42 +00001405 struct CXUnsavedFile *unsaved_files,
1406 unsigned options);
Ted Kremenek83f642e2011-04-18 22:47:10 +00001407
1408/**
1409 * \brief Categorizes how memory is being used by a translation unit.
1410 */
Ted Kremenek23324122011-04-20 16:41:07 +00001411enum CXTUResourceUsageKind {
1412 CXTUResourceUsage_AST = 1,
1413 CXTUResourceUsage_Identifiers = 2,
1414 CXTUResourceUsage_Selectors = 3,
1415 CXTUResourceUsage_GlobalCompletionResults = 4,
Ted Kremenek21735e62011-04-28 04:10:31 +00001416 CXTUResourceUsage_SourceManagerContentCache = 5,
Ted Kremenekf5df0ce2011-04-28 04:53:38 +00001417 CXTUResourceUsage_AST_SideTables = 6,
Ted Kremenek8d587902011-04-28 20:36:42 +00001418 CXTUResourceUsage_SourceManager_Membuffer_Malloc = 7,
Ted Kremenek5e1ed7b2011-04-28 23:46:20 +00001419 CXTUResourceUsage_SourceManager_Membuffer_MMap = 8,
1420 CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc = 9,
1421 CXTUResourceUsage_ExternalASTSource_Membuffer_MMap = 10,
Ted Kremenek2160a0d2011-05-04 01:38:46 +00001422 CXTUResourceUsage_Preprocessor = 11,
1423 CXTUResourceUsage_PreprocessingRecord = 12,
Ted Kremenek120992a2011-07-26 23:46:06 +00001424 CXTUResourceUsage_SourceManager_DataStructures = 13,
Ted Kremenekfbcce6f2011-07-26 23:46:11 +00001425 CXTUResourceUsage_Preprocessor_HeaderSearch = 14,
Ted Kremenek23324122011-04-20 16:41:07 +00001426 CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST,
1427 CXTUResourceUsage_MEMORY_IN_BYTES_END =
Ted Kremenekfbcce6f2011-07-26 23:46:11 +00001428 CXTUResourceUsage_Preprocessor_HeaderSearch,
Ted Kremenek23324122011-04-20 16:41:07 +00001429
1430 CXTUResourceUsage_First = CXTUResourceUsage_AST,
Ted Kremenekfbcce6f2011-07-26 23:46:11 +00001431 CXTUResourceUsage_Last = CXTUResourceUsage_Preprocessor_HeaderSearch
Ted Kremenek83f642e2011-04-18 22:47:10 +00001432};
1433
1434/**
1435 * \brief Returns the human-readable null-terminated C string that represents
Ted Kremenek23324122011-04-20 16:41:07 +00001436 * the name of the memory category. This string should never be freed.
Ted Kremenek83f642e2011-04-18 22:47:10 +00001437 */
1438CINDEX_LINKAGE
Ted Kremenek23324122011-04-20 16:41:07 +00001439const char *clang_getTUResourceUsageName(enum CXTUResourceUsageKind kind);
Ted Kremenek83f642e2011-04-18 22:47:10 +00001440
Ted Kremenek23324122011-04-20 16:41:07 +00001441typedef struct CXTUResourceUsageEntry {
Ted Kremenek83f642e2011-04-18 22:47:10 +00001442 /* \brief The memory usage category. */
Ted Kremenek23324122011-04-20 16:41:07 +00001443 enum CXTUResourceUsageKind kind;
1444 /* \brief Amount of resources used.
1445 The units will depend on the resource kind. */
Ted Kremenek83f642e2011-04-18 22:47:10 +00001446 unsigned long amount;
Ted Kremenek23324122011-04-20 16:41:07 +00001447} CXTUResourceUsageEntry;
Ted Kremenek83f642e2011-04-18 22:47:10 +00001448
1449/**
1450 * \brief The memory usage of a CXTranslationUnit, broken into categories.
1451 */
Ted Kremenek23324122011-04-20 16:41:07 +00001452typedef struct CXTUResourceUsage {
Ted Kremenek83f642e2011-04-18 22:47:10 +00001453 /* \brief Private data member, used for queries. */
1454 void *data;
1455
1456 /* \brief The number of entries in the 'entries' array. */
1457 unsigned numEntries;
1458
1459 /* \brief An array of key-value pairs, representing the breakdown of memory
1460 usage. */
Ted Kremenek23324122011-04-20 16:41:07 +00001461 CXTUResourceUsageEntry *entries;
Ted Kremenek83f642e2011-04-18 22:47:10 +00001462
Ted Kremenek23324122011-04-20 16:41:07 +00001463} CXTUResourceUsage;
Ted Kremenek83f642e2011-04-18 22:47:10 +00001464
1465/**
1466 * \brief Return the memory usage of a translation unit. This object
Ted Kremenek23324122011-04-20 16:41:07 +00001467 * should be released with clang_disposeCXTUResourceUsage().
Ted Kremenek83f642e2011-04-18 22:47:10 +00001468 */
Ted Kremenek23324122011-04-20 16:41:07 +00001469CINDEX_LINKAGE CXTUResourceUsage clang_getCXTUResourceUsage(CXTranslationUnit TU);
Ted Kremenek83f642e2011-04-18 22:47:10 +00001470
Ted Kremenek23324122011-04-20 16:41:07 +00001471CINDEX_LINKAGE void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage);
Ted Kremenek83f642e2011-04-18 22:47:10 +00001472
Douglas Gregoraa21cc42010-07-19 21:46:24 +00001473/**
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001474 * @}
1475 */
Ted Kremenekd071c602010-03-13 02:50:34 +00001476
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001477/**
Douglas Gregor6007cf22010-01-22 22:29:16 +00001478 * \brief Describes the kind of entity that a cursor refers to.
1479 */
1480enum CXCursorKind {
1481 /* Declarations */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001482 /**
Douglas Gregor6007cf22010-01-22 22:29:16 +00001483 * \brief A declaration whose specific kind is not exposed via this
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001484 * interface.
Douglas Gregor6007cf22010-01-22 22:29:16 +00001485 *
1486 * Unexposed declarations have the same operations as any other kind
1487 * of declaration; one can extract their location information,
1488 * spelling, find their definitions, etc. However, the specific kind
1489 * of the declaration is not reported.
1490 */
1491 CXCursor_UnexposedDecl = 1,
1492 /** \brief A C or C++ struct. */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001493 CXCursor_StructDecl = 2,
Douglas Gregor6007cf22010-01-22 22:29:16 +00001494 /** \brief A C or C++ union. */
1495 CXCursor_UnionDecl = 3,
1496 /** \brief A C++ class. */
1497 CXCursor_ClassDecl = 4,
1498 /** \brief An enumeration. */
1499 CXCursor_EnumDecl = 5,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001500 /**
Douglas Gregor6007cf22010-01-22 22:29:16 +00001501 * \brief A field (in C) or non-static data member (in C++) in a
1502 * struct, union, or C++ class.
1503 */
1504 CXCursor_FieldDecl = 6,
1505 /** \brief An enumerator constant. */
1506 CXCursor_EnumConstantDecl = 7,
1507 /** \brief A function. */
1508 CXCursor_FunctionDecl = 8,
1509 /** \brief A variable. */
1510 CXCursor_VarDecl = 9,
1511 /** \brief A function or method parameter. */
1512 CXCursor_ParmDecl = 10,
James Dennett1355bd12012-06-11 06:19:40 +00001513 /** \brief An Objective-C \@interface. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001514 CXCursor_ObjCInterfaceDecl = 11,
James Dennett1355bd12012-06-11 06:19:40 +00001515 /** \brief An Objective-C \@interface for a category. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001516 CXCursor_ObjCCategoryDecl = 12,
James Dennett1355bd12012-06-11 06:19:40 +00001517 /** \brief An Objective-C \@protocol declaration. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001518 CXCursor_ObjCProtocolDecl = 13,
James Dennett1355bd12012-06-11 06:19:40 +00001519 /** \brief An Objective-C \@property declaration. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001520 CXCursor_ObjCPropertyDecl = 14,
1521 /** \brief An Objective-C instance variable. */
1522 CXCursor_ObjCIvarDecl = 15,
1523 /** \brief An Objective-C instance method. */
1524 CXCursor_ObjCInstanceMethodDecl = 16,
1525 /** \brief An Objective-C class method. */
1526 CXCursor_ObjCClassMethodDecl = 17,
James Dennett1355bd12012-06-11 06:19:40 +00001527 /** \brief An Objective-C \@implementation. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001528 CXCursor_ObjCImplementationDecl = 18,
James Dennett1355bd12012-06-11 06:19:40 +00001529 /** \brief An Objective-C \@implementation for a category. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001530 CXCursor_ObjCCategoryImplDecl = 19,
1531 /** \brief A typedef */
1532 CXCursor_TypedefDecl = 20,
Ted Kremenek225b8e32010-04-13 23:39:06 +00001533 /** \brief A C++ class method. */
1534 CXCursor_CXXMethod = 21,
Ted Kremenekbd67fb22010-05-06 23:38:21 +00001535 /** \brief A C++ namespace. */
1536 CXCursor_Namespace = 22,
Ted Kremenekb80cba52010-05-07 01:04:29 +00001537 /** \brief A linkage specification, e.g. 'extern "C"'. */
1538 CXCursor_LinkageSpec = 23,
Douglas Gregor12bca222010-08-31 14:41:23 +00001539 /** \brief A C++ constructor. */
1540 CXCursor_Constructor = 24,
1541 /** \brief A C++ destructor. */
1542 CXCursor_Destructor = 25,
1543 /** \brief A C++ conversion function. */
1544 CXCursor_ConversionFunction = 26,
Douglas Gregor713602b2010-08-31 17:01:39 +00001545 /** \brief A C++ template type parameter. */
1546 CXCursor_TemplateTypeParameter = 27,
1547 /** \brief A C++ non-type template parameter. */
1548 CXCursor_NonTypeTemplateParameter = 28,
1549 /** \brief A C++ template template parameter. */
1550 CXCursor_TemplateTemplateParameter = 29,
1551 /** \brief A C++ function template. */
1552 CXCursor_FunctionTemplate = 30,
Douglas Gregor1fbaeb12010-08-31 19:02:00 +00001553 /** \brief A C++ class template. */
1554 CXCursor_ClassTemplate = 31,
Douglas Gregorf96abb22010-08-31 19:31:58 +00001555 /** \brief A C++ class template partial specialization. */
1556 CXCursor_ClassTemplatePartialSpecialization = 32,
Douglas Gregora89314e2010-08-31 23:48:11 +00001557 /** \brief A C++ namespace alias declaration. */
1558 CXCursor_NamespaceAlias = 33,
Douglas Gregor01a430132010-09-01 03:07:18 +00001559 /** \brief A C++ using directive. */
1560 CXCursor_UsingDirective = 34,
Richard Smithdda56e42011-04-15 14:24:37 +00001561 /** \brief A C++ using declaration. */
Douglas Gregora9aa29c2010-09-01 19:52:22 +00001562 CXCursor_UsingDeclaration = 35,
Richard Smithdda56e42011-04-15 14:24:37 +00001563 /** \brief A C++ alias declaration */
1564 CXCursor_TypeAliasDecl = 36,
James Dennett574cb4c2012-06-15 05:41:51 +00001565 /** \brief An Objective-C \@synthesize definition. */
Douglas Gregor4cd65962011-06-03 23:08:58 +00001566 CXCursor_ObjCSynthesizeDecl = 37,
James Dennett574cb4c2012-06-15 05:41:51 +00001567 /** \brief An Objective-C \@dynamic definition. */
Douglas Gregor4cd65962011-06-03 23:08:58 +00001568 CXCursor_ObjCDynamicDecl = 38,
Argyrios Kyrtzidis12afd702011-09-30 17:58:23 +00001569 /** \brief An access specifier. */
1570 CXCursor_CXXAccessSpecifier = 39,
Douglas Gregor4c362d52011-10-05 19:00:14 +00001571
Ted Kremenek08de5c12010-05-19 21:51:10 +00001572 CXCursor_FirstDecl = CXCursor_UnexposedDecl,
Argyrios Kyrtzidis12afd702011-09-30 17:58:23 +00001573 CXCursor_LastDecl = CXCursor_CXXAccessSpecifier,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001574
Douglas Gregor6007cf22010-01-22 22:29:16 +00001575 /* References */
1576 CXCursor_FirstRef = 40, /* Decl references */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001577 CXCursor_ObjCSuperClassRef = 40,
Douglas Gregor6007cf22010-01-22 22:29:16 +00001578 CXCursor_ObjCProtocolRef = 41,
1579 CXCursor_ObjCClassRef = 42,
1580 /**
1581 * \brief A reference to a type declaration.
1582 *
1583 * A type reference occurs anywhere where a type is named but not
1584 * declared. For example, given:
1585 *
1586 * \code
1587 * typedef unsigned size_type;
1588 * size_type size;
1589 * \endcode
1590 *
1591 * The typedef is a declaration of size_type (CXCursor_TypedefDecl),
1592 * while the type of the variable "size" is referenced. The cursor
1593 * referenced by the type of size is the typedef for size_type.
1594 */
1595 CXCursor_TypeRef = 43,
Ted Kremenekae9e2212010-08-27 21:34:58 +00001596 CXCursor_CXXBaseSpecifier = 44,
Douglas Gregora23e8f72010-08-31 20:37:03 +00001597 /**
Douglas Gregorf3af3112010-09-09 21:42:20 +00001598 * \brief A reference to a class template, function template, template
1599 * template parameter, or class template partial specialization.
Douglas Gregora23e8f72010-08-31 20:37:03 +00001600 */
1601 CXCursor_TemplateRef = 45,
Douglas Gregora89314e2010-08-31 23:48:11 +00001602 /**
1603 * \brief A reference to a namespace or namespace alias.
1604 */
1605 CXCursor_NamespaceRef = 46,
Douglas Gregorf3af3112010-09-09 21:42:20 +00001606 /**
Douglas Gregora93ab662010-09-10 00:22:18 +00001607 * \brief A reference to a member of a struct, union, or class that occurs in
1608 * some non-expression context, e.g., a designated initializer.
Douglas Gregorf3af3112010-09-09 21:42:20 +00001609 */
1610 CXCursor_MemberRef = 47,
Douglas Gregora93ab662010-09-10 00:22:18 +00001611 /**
1612 * \brief A reference to a labeled statement.
1613 *
1614 * This cursor kind is used to describe the jump to "start_over" in the
1615 * goto statement in the following example:
1616 *
1617 * \code
1618 * start_over:
1619 * ++counter;
1620 *
1621 * goto start_over;
1622 * \endcode
1623 *
1624 * A label reference cursor refers to a label statement.
1625 */
1626 CXCursor_LabelRef = 48,
1627
Douglas Gregor16a2bdd2010-09-13 22:52:57 +00001628 /**
1629 * \brief A reference to a set of overloaded functions or function templates
1630 * that has not yet been resolved to a specific function or function template.
1631 *
1632 * An overloaded declaration reference cursor occurs in C++ templates where
1633 * a dependent name refers to a function. For example:
1634 *
1635 * \code
1636 * template<typename T> void swap(T&, T&);
1637 *
1638 * struct X { ... };
1639 * void swap(X&, X&);
1640 *
1641 * template<typename T>
1642 * void reverse(T* first, T* last) {
1643 * while (first < last - 1) {
1644 * swap(*first, *--last);
1645 * ++first;
1646 * }
1647 * }
1648 *
1649 * struct Y { };
1650 * void swap(Y&, Y&);
1651 * \endcode
1652 *
1653 * Here, the identifier "swap" is associated with an overloaded declaration
1654 * reference. In the template definition, "swap" refers to either of the two
1655 * "swap" functions declared above, so both results will be available. At
1656 * instantiation time, "swap" may also refer to other functions found via
1657 * argument-dependent lookup (e.g., the "swap" function at the end of the
1658 * example).
1659 *
1660 * The functions \c clang_getNumOverloadedDecls() and
1661 * \c clang_getOverloadedDecl() can be used to retrieve the definitions
1662 * referenced by this cursor.
1663 */
1664 CXCursor_OverloadedDeclRef = 49,
1665
Douglas Gregor30093832012-02-15 00:54:55 +00001666 /**
1667 * \brief A reference to a variable that occurs in some non-expression
1668 * context, e.g., a C++ lambda capture list.
1669 */
1670 CXCursor_VariableRef = 50,
1671
1672 CXCursor_LastRef = CXCursor_VariableRef,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001673
Douglas Gregor6007cf22010-01-22 22:29:16 +00001674 /* Error conditions */
1675 CXCursor_FirstInvalid = 70,
1676 CXCursor_InvalidFile = 70,
1677 CXCursor_NoDeclFound = 71,
1678 CXCursor_NotImplemented = 72,
Ted Kremeneke184ac52010-03-19 20:39:03 +00001679 CXCursor_InvalidCode = 73,
1680 CXCursor_LastInvalid = CXCursor_InvalidCode,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001681
Douglas Gregor6007cf22010-01-22 22:29:16 +00001682 /* Expressions */
1683 CXCursor_FirstExpr = 100,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001684
Douglas Gregor6007cf22010-01-22 22:29:16 +00001685 /**
1686 * \brief An expression whose specific kind is not exposed via this
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001687 * interface.
Douglas Gregor6007cf22010-01-22 22:29:16 +00001688 *
1689 * Unexposed expressions have the same operations as any other kind
1690 * of expression; one can extract their location information,
1691 * spelling, children, etc. However, the specific kind of the
1692 * expression is not reported.
1693 */
1694 CXCursor_UnexposedExpr = 100,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001695
Douglas Gregor6007cf22010-01-22 22:29:16 +00001696 /**
1697 * \brief An expression that refers to some value declaration, such
1698 * as a function, varible, or enumerator.
1699 */
1700 CXCursor_DeclRefExpr = 101,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001701
Douglas Gregor6007cf22010-01-22 22:29:16 +00001702 /**
1703 * \brief An expression that refers to a member of a struct, union,
1704 * class, Objective-C class, etc.
1705 */
1706 CXCursor_MemberRefExpr = 102,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001707
Douglas Gregor6007cf22010-01-22 22:29:16 +00001708 /** \brief An expression that calls a function. */
1709 CXCursor_CallExpr = 103,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001710
Douglas Gregor6007cf22010-01-22 22:29:16 +00001711 /** \brief An expression that sends a message to an Objective-C
1712 object or class. */
1713 CXCursor_ObjCMessageExpr = 104,
Ted Kremenek33b9a422010-04-11 21:47:37 +00001714
1715 /** \brief An expression that represents a block literal. */
1716 CXCursor_BlockExpr = 105,
1717
Douglas Gregor4c362d52011-10-05 19:00:14 +00001718 /** \brief An integer literal.
1719 */
1720 CXCursor_IntegerLiteral = 106,
1721
1722 /** \brief A floating point number literal.
1723 */
1724 CXCursor_FloatingLiteral = 107,
1725
1726 /** \brief An imaginary number literal.
1727 */
1728 CXCursor_ImaginaryLiteral = 108,
1729
1730 /** \brief A string literal.
1731 */
1732 CXCursor_StringLiteral = 109,
1733
1734 /** \brief A character literal.
1735 */
1736 CXCursor_CharacterLiteral = 110,
1737
1738 /** \brief A parenthesized expression, e.g. "(1)".
1739 *
1740 * This AST node is only formed if full location information is requested.
1741 */
1742 CXCursor_ParenExpr = 111,
1743
1744 /** \brief This represents the unary-expression's (except sizeof and
1745 * alignof).
1746 */
1747 CXCursor_UnaryOperator = 112,
1748
1749 /** \brief [C99 6.5.2.1] Array Subscripting.
1750 */
1751 CXCursor_ArraySubscriptExpr = 113,
1752
1753 /** \brief A builtin binary operation expression such as "x + y" or
1754 * "x <= y".
1755 */
1756 CXCursor_BinaryOperator = 114,
1757
1758 /** \brief Compound assignment such as "+=".
1759 */
1760 CXCursor_CompoundAssignOperator = 115,
1761
1762 /** \brief The ?: ternary operator.
1763 */
1764 CXCursor_ConditionalOperator = 116,
1765
1766 /** \brief An explicit cast in C (C99 6.5.4) or a C-style cast in C++
1767 * (C++ [expr.cast]), which uses the syntax (Type)expr.
1768 *
1769 * For example: (int)f.
1770 */
1771 CXCursor_CStyleCastExpr = 117,
1772
1773 /** \brief [C99 6.5.2.5]
1774 */
1775 CXCursor_CompoundLiteralExpr = 118,
1776
1777 /** \brief Describes an C or C++ initializer list.
1778 */
1779 CXCursor_InitListExpr = 119,
1780
1781 /** \brief The GNU address of label extension, representing &&label.
1782 */
1783 CXCursor_AddrLabelExpr = 120,
1784
1785 /** \brief This is the GNU Statement Expression extension: ({int X=4; X;})
1786 */
1787 CXCursor_StmtExpr = 121,
1788
Benjamin Kramere56f3932011-12-23 17:00:35 +00001789 /** \brief Represents a C11 generic selection.
Douglas Gregor4c362d52011-10-05 19:00:14 +00001790 */
1791 CXCursor_GenericSelectionExpr = 122,
1792
1793 /** \brief Implements the GNU __null extension, which is a name for a null
1794 * pointer constant that has integral type (e.g., int or long) and is the same
1795 * size and alignment as a pointer.
1796 *
1797 * The __null extension is typically only used by system headers, which define
1798 * NULL as __null in C++ rather than using 0 (which is an integer that may not
1799 * match the size of a pointer).
1800 */
1801 CXCursor_GNUNullExpr = 123,
1802
1803 /** \brief C++'s static_cast<> expression.
1804 */
1805 CXCursor_CXXStaticCastExpr = 124,
1806
1807 /** \brief C++'s dynamic_cast<> expression.
1808 */
1809 CXCursor_CXXDynamicCastExpr = 125,
1810
1811 /** \brief C++'s reinterpret_cast<> expression.
1812 */
1813 CXCursor_CXXReinterpretCastExpr = 126,
1814
1815 /** \brief C++'s const_cast<> expression.
1816 */
1817 CXCursor_CXXConstCastExpr = 127,
1818
1819 /** \brief Represents an explicit C++ type conversion that uses "functional"
1820 * notion (C++ [expr.type.conv]).
1821 *
1822 * Example:
1823 * \code
1824 * x = int(0.5);
1825 * \endcode
1826 */
1827 CXCursor_CXXFunctionalCastExpr = 128,
1828
1829 /** \brief A C++ typeid expression (C++ [expr.typeid]).
1830 */
1831 CXCursor_CXXTypeidExpr = 129,
1832
1833 /** \brief [C++ 2.13.5] C++ Boolean Literal.
1834 */
1835 CXCursor_CXXBoolLiteralExpr = 130,
1836
1837 /** \brief [C++0x 2.14.7] C++ Pointer Literal.
1838 */
1839 CXCursor_CXXNullPtrLiteralExpr = 131,
1840
1841 /** \brief Represents the "this" expression in C++
1842 */
1843 CXCursor_CXXThisExpr = 132,
1844
1845 /** \brief [C++ 15] C++ Throw Expression.
1846 *
1847 * This handles 'throw' and 'throw' assignment-expression. When
1848 * assignment-expression isn't present, Op will be null.
1849 */
1850 CXCursor_CXXThrowExpr = 133,
1851
1852 /** \brief A new expression for memory allocation and constructor calls, e.g:
1853 * "new CXXNewExpr(foo)".
1854 */
1855 CXCursor_CXXNewExpr = 134,
1856
1857 /** \brief A delete expression for memory deallocation and destructor calls,
1858 * e.g. "delete[] pArray".
1859 */
1860 CXCursor_CXXDeleteExpr = 135,
1861
1862 /** \brief A unary expression.
1863 */
1864 CXCursor_UnaryExpr = 136,
1865
Douglas Gregor910c37c2011-11-11 22:35:18 +00001866 /** \brief An Objective-C string literal i.e. @"foo".
Douglas Gregor4c362d52011-10-05 19:00:14 +00001867 */
1868 CXCursor_ObjCStringLiteral = 137,
1869
James Dennett574cb4c2012-06-15 05:41:51 +00001870 /** \brief An Objective-C \@encode expression.
Douglas Gregor4c362d52011-10-05 19:00:14 +00001871 */
1872 CXCursor_ObjCEncodeExpr = 138,
1873
James Dennett574cb4c2012-06-15 05:41:51 +00001874 /** \brief An Objective-C \@selector expression.
Douglas Gregor4c362d52011-10-05 19:00:14 +00001875 */
1876 CXCursor_ObjCSelectorExpr = 139,
1877
James Dennett1355bd12012-06-11 06:19:40 +00001878 /** \brief An Objective-C \@protocol expression.
Douglas Gregor4c362d52011-10-05 19:00:14 +00001879 */
1880 CXCursor_ObjCProtocolExpr = 140,
1881
1882 /** \brief An Objective-C "bridged" cast expression, which casts between
1883 * Objective-C pointers and C pointers, transferring ownership in the process.
1884 *
1885 * \code
1886 * NSString *str = (__bridge_transfer NSString *)CFCreateString();
1887 * \endcode
1888 */
1889 CXCursor_ObjCBridgedCastExpr = 141,
1890
1891 /** \brief Represents a C++0x pack expansion that produces a sequence of
1892 * expressions.
1893 *
1894 * A pack expansion expression contains a pattern (which itself is an
1895 * expression) followed by an ellipsis. For example:
1896 *
1897 * \code
1898 * template<typename F, typename ...Types>
1899 * void forward(F f, Types &&...args) {
1900 * f(static_cast<Types&&>(args)...);
1901 * }
1902 * \endcode
1903 */
1904 CXCursor_PackExpansionExpr = 142,
1905
1906 /** \brief Represents an expression that computes the length of a parameter
1907 * pack.
1908 *
1909 * \code
1910 * template<typename ...Types>
1911 * struct count {
1912 * static const unsigned value = sizeof...(Types);
1913 * };
1914 * \endcode
1915 */
1916 CXCursor_SizeOfPackExpr = 143,
1917
Douglas Gregor30093832012-02-15 00:54:55 +00001918 /* \brief Represents a C++ lambda expression that produces a local function
1919 * object.
1920 *
1921 * \code
1922 * void abssort(float *x, unsigned N) {
1923 * std::sort(x, x + N,
1924 * [](float a, float b) {
1925 * return std::abs(a) < std::abs(b);
1926 * });
1927 * }
1928 * \endcode
1929 */
1930 CXCursor_LambdaExpr = 144,
1931
Ted Kremenek77006f62012-03-06 20:06:06 +00001932 /** \brief Objective-c Boolean Literal.
1933 */
1934 CXCursor_ObjCBoolLiteralExpr = 145,
1935
Argyrios Kyrtzidisc2233be2013-04-23 17:57:17 +00001936 /** \brief Represents the "self" expression in a ObjC method.
1937 */
1938 CXCursor_ObjCSelfExpr = 146,
1939
1940 CXCursor_LastExpr = CXCursor_ObjCSelfExpr,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001941
Douglas Gregor6007cf22010-01-22 22:29:16 +00001942 /* Statements */
1943 CXCursor_FirstStmt = 200,
1944 /**
1945 * \brief A statement whose specific kind is not exposed via this
1946 * interface.
1947 *
1948 * Unexposed statements have the same operations as any other kind of
1949 * statement; one can extract their location information, spelling,
1950 * children, etc. However, the specific kind of the statement is not
1951 * reported.
1952 */
1953 CXCursor_UnexposedStmt = 200,
Douglas Gregora93ab662010-09-10 00:22:18 +00001954
1955 /** \brief A labelled statement in a function.
1956 *
1957 * This cursor kind is used to describe the "start_over:" label statement in
1958 * the following example:
1959 *
1960 * \code
1961 * start_over:
1962 * ++counter;
1963 * \endcode
1964 *
1965 */
1966 CXCursor_LabelStmt = 201,
Douglas Gregor4c362d52011-10-05 19:00:14 +00001967
1968 /** \brief A group of statements like { stmt stmt }.
1969 *
1970 * This cursor kind is used to describe compound statements, e.g. function
1971 * bodies.
1972 */
1973 CXCursor_CompoundStmt = 202,
1974
Benjamin Kramer2501f142013-10-20 11:47:15 +00001975 /** \brief A case statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00001976 */
1977 CXCursor_CaseStmt = 203,
1978
1979 /** \brief A default statement.
1980 */
1981 CXCursor_DefaultStmt = 204,
1982
1983 /** \brief An if statement
1984 */
1985 CXCursor_IfStmt = 205,
1986
1987 /** \brief A switch statement.
1988 */
1989 CXCursor_SwitchStmt = 206,
1990
1991 /** \brief A while statement.
1992 */
1993 CXCursor_WhileStmt = 207,
1994
1995 /** \brief A do statement.
1996 */
1997 CXCursor_DoStmt = 208,
1998
1999 /** \brief A for statement.
2000 */
2001 CXCursor_ForStmt = 209,
2002
2003 /** \brief A goto statement.
2004 */
2005 CXCursor_GotoStmt = 210,
2006
2007 /** \brief An indirect goto statement.
2008 */
2009 CXCursor_IndirectGotoStmt = 211,
2010
2011 /** \brief A continue statement.
2012 */
2013 CXCursor_ContinueStmt = 212,
2014
2015 /** \brief A break statement.
2016 */
2017 CXCursor_BreakStmt = 213,
2018
2019 /** \brief A return statement.
2020 */
2021 CXCursor_ReturnStmt = 214,
2022
Chad Rosierde70e0e2012-08-25 00:11:56 +00002023 /** \brief A GCC inline assembly statement extension.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002024 */
Chad Rosierde70e0e2012-08-25 00:11:56 +00002025 CXCursor_GCCAsmStmt = 215,
Argyrios Kyrtzidis5eae0732012-09-24 19:27:20 +00002026 CXCursor_AsmStmt = CXCursor_GCCAsmStmt,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002027
James Dennett574cb4c2012-06-15 05:41:51 +00002028 /** \brief Objective-C's overall \@try-\@catch-\@finally statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002029 */
2030 CXCursor_ObjCAtTryStmt = 216,
2031
James Dennett574cb4c2012-06-15 05:41:51 +00002032 /** \brief Objective-C's \@catch statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002033 */
2034 CXCursor_ObjCAtCatchStmt = 217,
2035
James Dennett574cb4c2012-06-15 05:41:51 +00002036 /** \brief Objective-C's \@finally statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002037 */
2038 CXCursor_ObjCAtFinallyStmt = 218,
2039
James Dennett574cb4c2012-06-15 05:41:51 +00002040 /** \brief Objective-C's \@throw statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002041 */
2042 CXCursor_ObjCAtThrowStmt = 219,
2043
James Dennett574cb4c2012-06-15 05:41:51 +00002044 /** \brief Objective-C's \@synchronized statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002045 */
2046 CXCursor_ObjCAtSynchronizedStmt = 220,
2047
2048 /** \brief Objective-C's autorelease pool statement.
2049 */
2050 CXCursor_ObjCAutoreleasePoolStmt = 221,
2051
2052 /** \brief Objective-C's collection statement.
2053 */
2054 CXCursor_ObjCForCollectionStmt = 222,
2055
2056 /** \brief C++'s catch statement.
2057 */
2058 CXCursor_CXXCatchStmt = 223,
2059
2060 /** \brief C++'s try statement.
2061 */
2062 CXCursor_CXXTryStmt = 224,
2063
2064 /** \brief C++'s for (* : *) statement.
2065 */
2066 CXCursor_CXXForRangeStmt = 225,
2067
2068 /** \brief Windows Structured Exception Handling's try statement.
2069 */
2070 CXCursor_SEHTryStmt = 226,
2071
2072 /** \brief Windows Structured Exception Handling's except statement.
2073 */
2074 CXCursor_SEHExceptStmt = 227,
2075
2076 /** \brief Windows Structured Exception Handling's finally statement.
2077 */
2078 CXCursor_SEHFinallyStmt = 228,
2079
Chad Rosier32503022012-06-11 20:47:18 +00002080 /** \brief A MS inline assembly statement extension.
2081 */
2082 CXCursor_MSAsmStmt = 229,
2083
Douglas Gregor4c362d52011-10-05 19:00:14 +00002084 /** \brief The null satement ";": C99 6.8.3p3.
2085 *
2086 * This cursor kind is used to describe the null statement.
2087 */
2088 CXCursor_NullStmt = 230,
2089
2090 /** \brief Adaptor class for mixing declarations with statements and
2091 * expressions.
2092 */
2093 CXCursor_DeclStmt = 231,
2094
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002095 /** \brief OpenMP parallel directive.
2096 */
2097 CXCursor_OMPParallelDirective = 232,
2098
2099 CXCursor_LastStmt = CXCursor_OMPParallelDirective,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002100
Douglas Gregor6007cf22010-01-22 22:29:16 +00002101 /**
2102 * \brief Cursor that represents the translation unit itself.
2103 *
2104 * The translation unit cursor exists primarily to act as the root
2105 * cursor for traversing the contents of a translation unit.
2106 */
Ted Kremenekbff31432010-02-18 03:09:07 +00002107 CXCursor_TranslationUnit = 300,
2108
Bill Wendling44426052012-12-20 19:22:21 +00002109 /* Attributes */
Ted Kremenekbff31432010-02-18 03:09:07 +00002110 CXCursor_FirstAttr = 400,
2111 /**
2112 * \brief An attribute whose specific kind is not exposed via this
2113 * interface.
2114 */
2115 CXCursor_UnexposedAttr = 400,
2116
2117 CXCursor_IBActionAttr = 401,
2118 CXCursor_IBOutletAttr = 402,
Ted Kremenek26bde772010-05-19 17:38:06 +00002119 CXCursor_IBOutletCollectionAttr = 403,
Argyrios Kyrtzidis2cb4e3c2011-09-13 17:39:31 +00002120 CXCursor_CXXFinalAttr = 404,
2121 CXCursor_CXXOverrideAttr = 405,
Erik Verbruggenca98f2a2011-10-13 09:41:32 +00002122 CXCursor_AnnotateAttr = 406,
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00002123 CXCursor_AsmLabelAttr = 407,
Argyrios Kyrtzidis16834f12013-09-25 00:14:38 +00002124 CXCursor_PackedAttr = 408,
2125 CXCursor_LastAttr = CXCursor_PackedAttr,
Douglas Gregor92a524f2010-03-18 00:42:48 +00002126
2127 /* Preprocessing */
2128 CXCursor_PreprocessingDirective = 500,
Douglas Gregor06d6d322010-03-18 18:04:21 +00002129 CXCursor_MacroDefinition = 501,
Chandler Carruth9e4704a2011-07-14 08:41:15 +00002130 CXCursor_MacroExpansion = 502,
2131 CXCursor_MacroInstantiation = CXCursor_MacroExpansion,
Douglas Gregor796d76a2010-10-20 22:00:55 +00002132 CXCursor_InclusionDirective = 503,
Douglas Gregor92a524f2010-03-18 00:42:48 +00002133 CXCursor_FirstPreprocessing = CXCursor_PreprocessingDirective,
Argyrios Kyrtzidis50e5b1d2012-10-05 00:22:24 +00002134 CXCursor_LastPreprocessing = CXCursor_InclusionDirective,
2135
2136 /* Extra Declarations */
2137 /**
2138 * \brief A module import declaration.
2139 */
2140 CXCursor_ModuleImportDecl = 600,
2141 CXCursor_FirstExtraDecl = CXCursor_ModuleImportDecl,
2142 CXCursor_LastExtraDecl = CXCursor_ModuleImportDecl
Douglas Gregor6007cf22010-01-22 22:29:16 +00002143};
2144
2145/**
2146 * \brief A cursor representing some element in the abstract syntax tree for
2147 * a translation unit.
2148 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002149 * The cursor abstraction unifies the different kinds of entities in a
Douglas Gregor6007cf22010-01-22 22:29:16 +00002150 * program--declaration, statements, expressions, references to declarations,
2151 * etc.--under a single "cursor" abstraction with a common set of operations.
2152 * Common operation for a cursor include: getting the physical location in
2153 * a source file where the cursor points, getting the name associated with a
2154 * cursor, and retrieving cursors for any child nodes of a particular cursor.
2155 *
2156 * Cursors can be produced in two specific ways.
2157 * clang_getTranslationUnitCursor() produces a cursor for a translation unit,
2158 * from which one can use clang_visitChildren() to explore the rest of the
2159 * translation unit. clang_getCursor() maps from a physical source location
2160 * to the entity that resides at that location, allowing one to map from the
2161 * source code into the AST.
2162 */
2163typedef struct {
2164 enum CXCursorKind kind;
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00002165 int xdata;
Dmitri Gribenkoba2f7462013-01-11 21:01:49 +00002166 const void *data[3];
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002167} CXCursor;
Douglas Gregor6007cf22010-01-22 22:29:16 +00002168
2169/**
Dmitri Gribenko5e4fe002012-07-20 21:34:34 +00002170 * \brief A comment AST node.
2171 */
2172typedef struct {
Dmitri Gribenko7acbf002012-09-10 20:32:42 +00002173 const void *ASTNode;
2174 CXTranslationUnit TranslationUnit;
Dmitri Gribenko5e4fe002012-07-20 21:34:34 +00002175} CXComment;
2176
2177/**
Douglas Gregor6007cf22010-01-22 22:29:16 +00002178 * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations
2179 *
2180 * @{
2181 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002182
Douglas Gregor6007cf22010-01-22 22:29:16 +00002183/**
2184 * \brief Retrieve the NULL cursor, which represents no entity.
2185 */
2186CINDEX_LINKAGE CXCursor clang_getNullCursor(void);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002187
Douglas Gregor6007cf22010-01-22 22:29:16 +00002188/**
2189 * \brief Retrieve the cursor that represents the given translation unit.
2190 *
2191 * The translation unit cursor can be used to start traversing the
2192 * various declarations within the given translation unit.
2193 */
2194CINDEX_LINKAGE CXCursor clang_getTranslationUnitCursor(CXTranslationUnit);
2195
2196/**
2197 * \brief Determine whether two cursors are equivalent.
2198 */
2199CINDEX_LINKAGE unsigned clang_equalCursors(CXCursor, CXCursor);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002200
Douglas Gregor6007cf22010-01-22 22:29:16 +00002201/**
Dmitri Gribenko8994e0c2012-09-13 13:11:20 +00002202 * \brief Returns non-zero if \p cursor is null.
Argyrios Kyrtzidisd6e9fa52011-09-27 00:30:30 +00002203 */
Dmitri Gribenko8994e0c2012-09-13 13:11:20 +00002204CINDEX_LINKAGE int clang_Cursor_isNull(CXCursor cursor);
Argyrios Kyrtzidisd6e9fa52011-09-27 00:30:30 +00002205
2206/**
Douglas Gregor06a3f302010-11-20 00:09:34 +00002207 * \brief Compute a hash value for the given cursor.
2208 */
2209CINDEX_LINKAGE unsigned clang_hashCursor(CXCursor);
2210
2211/**
Douglas Gregor6007cf22010-01-22 22:29:16 +00002212 * \brief Retrieve the kind of the given cursor.
2213 */
2214CINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor);
2215
2216/**
2217 * \brief Determine whether the given cursor kind represents a declaration.
2218 */
2219CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind);
2220
2221/**
2222 * \brief Determine whether the given cursor kind represents a simple
2223 * reference.
2224 *
2225 * Note that other kinds of cursors (such as expressions) can also refer to
2226 * other cursors. Use clang_getCursorReferenced() to determine whether a
2227 * particular cursor refers to another entity.
2228 */
2229CINDEX_LINKAGE unsigned clang_isReference(enum CXCursorKind);
2230
2231/**
2232 * \brief Determine whether the given cursor kind represents an expression.
2233 */
2234CINDEX_LINKAGE unsigned clang_isExpression(enum CXCursorKind);
2235
2236/**
2237 * \brief Determine whether the given cursor kind represents a statement.
2238 */
2239CINDEX_LINKAGE unsigned clang_isStatement(enum CXCursorKind);
2240
2241/**
Douglas Gregora98034a2011-07-06 03:00:34 +00002242 * \brief Determine whether the given cursor kind represents an attribute.
2243 */
2244CINDEX_LINKAGE unsigned clang_isAttribute(enum CXCursorKind);
2245
2246/**
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002247 * \brief Determine whether the given cursor kind represents an invalid
Douglas Gregor6007cf22010-01-22 22:29:16 +00002248 * cursor.
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002249 */
Douglas Gregor6007cf22010-01-22 22:29:16 +00002250CINDEX_LINKAGE unsigned clang_isInvalid(enum CXCursorKind);
2251
2252/**
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002253 * \brief Determine whether the given cursor kind represents a translation
2254 * unit.
Douglas Gregor6007cf22010-01-22 22:29:16 +00002255 */
2256CINDEX_LINKAGE unsigned clang_isTranslationUnit(enum CXCursorKind);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002257
Ted Kremenekff9021b2010-03-08 21:17:29 +00002258/***
Douglas Gregor92a524f2010-03-18 00:42:48 +00002259 * \brief Determine whether the given cursor represents a preprocessing
2260 * element, such as a preprocessor directive or macro instantiation.
2261 */
2262CINDEX_LINKAGE unsigned clang_isPreprocessing(enum CXCursorKind);
2263
2264/***
Ted Kremenekff9021b2010-03-08 21:17:29 +00002265 * \brief Determine whether the given cursor represents a currently
2266 * unexposed piece of the AST (e.g., CXCursor_UnexposedStmt).
2267 */
2268CINDEX_LINKAGE unsigned clang_isUnexposed(enum CXCursorKind);
2269
Douglas Gregor6007cf22010-01-22 22:29:16 +00002270/**
Ted Kremenekfb4961d2010-03-03 06:36:57 +00002271 * \brief Describe the linkage of the entity referred to by a cursor.
2272 */
2273enum CXLinkageKind {
2274 /** \brief This value indicates that no linkage information is available
2275 * for a provided CXCursor. */
2276 CXLinkage_Invalid,
2277 /**
2278 * \brief This is the linkage for variables, parameters, and so on that
2279 * have automatic storage. This covers normal (non-extern) local variables.
2280 */
2281 CXLinkage_NoLinkage,
2282 /** \brief This is the linkage for static variables and static functions. */
2283 CXLinkage_Internal,
2284 /** \brief This is the linkage for entities with external linkage that live
2285 * in C++ anonymous namespaces.*/
2286 CXLinkage_UniqueExternal,
2287 /** \brief This is the linkage for entities with true, external linkage. */
2288 CXLinkage_External
2289};
2290
2291/**
Ted Kremenek4ed29252010-04-12 21:22:16 +00002292 * \brief Determine the linkage of the entity referred to by a given cursor.
Ted Kremenekfb4961d2010-03-03 06:36:57 +00002293 */
2294CINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor);
2295
2296/**
Douglas Gregord6225d32012-05-08 00:14:45 +00002297 * \brief Determine the availability of the entity that this cursor refers to,
2298 * taking the current target platform into account.
Douglas Gregorf757a122010-08-23 23:00:57 +00002299 *
2300 * \param cursor The cursor to query.
2301 *
2302 * \returns The availability of the cursor.
2303 */
2304CINDEX_LINKAGE enum CXAvailabilityKind
2305clang_getCursorAvailability(CXCursor cursor);
2306
2307/**
Douglas Gregord6225d32012-05-08 00:14:45 +00002308 * Describes the availability of a given entity on a particular platform, e.g.,
2309 * a particular class might only be available on Mac OS 10.7 or newer.
2310 */
2311typedef struct CXPlatformAvailability {
2312 /**
2313 * \brief A string that describes the platform for which this structure
2314 * provides availability information.
2315 *
2316 * Possible values are "ios" or "macosx".
2317 */
2318 CXString Platform;
2319 /**
2320 * \brief The version number in which this entity was introduced.
2321 */
2322 CXVersion Introduced;
2323 /**
2324 * \brief The version number in which this entity was deprecated (but is
2325 * still available).
2326 */
2327 CXVersion Deprecated;
2328 /**
2329 * \brief The version number in which this entity was obsoleted, and therefore
2330 * is no longer available.
2331 */
2332 CXVersion Obsoleted;
2333 /**
2334 * \brief Whether the entity is unconditionally unavailable on this platform.
2335 */
2336 int Unavailable;
2337 /**
2338 * \brief An optional message to provide to a user of this API, e.g., to
2339 * suggest replacement APIs.
2340 */
2341 CXString Message;
2342} CXPlatformAvailability;
2343
2344/**
2345 * \brief Determine the availability of the entity that this cursor refers to
2346 * on any platforms for which availability information is known.
2347 *
2348 * \param cursor The cursor to query.
2349 *
2350 * \param always_deprecated If non-NULL, will be set to indicate whether the
2351 * entity is deprecated on all platforms.
2352 *
2353 * \param deprecated_message If non-NULL, will be set to the message text
2354 * provided along with the unconditional deprecation of this entity. The client
2355 * is responsible for deallocating this string.
2356 *
James Dennett574cb4c2012-06-15 05:41:51 +00002357 * \param always_unavailable If non-NULL, will be set to indicate whether the
Douglas Gregord6225d32012-05-08 00:14:45 +00002358 * entity is unavailable on all platforms.
2359 *
2360 * \param unavailable_message If non-NULL, will be set to the message text
2361 * provided along with the unconditional unavailability of this entity. The
2362 * client is responsible for deallocating this string.
2363 *
2364 * \param availability If non-NULL, an array of CXPlatformAvailability instances
2365 * that will be populated with platform availability information, up to either
2366 * the number of platforms for which availability information is available (as
2367 * returned by this function) or \c availability_size, whichever is smaller.
2368 *
2369 * \param availability_size The number of elements available in the
2370 * \c availability array.
2371 *
2372 * \returns The number of platforms (N) for which availability information is
2373 * available (which is unrelated to \c availability_size).
2374 *
2375 * Note that the client is responsible for calling
2376 * \c clang_disposeCXPlatformAvailability to free each of the
2377 * platform-availability structures returned. There are
2378 * \c min(N, availability_size) such structures.
2379 */
2380CINDEX_LINKAGE int
2381clang_getCursorPlatformAvailability(CXCursor cursor,
2382 int *always_deprecated,
2383 CXString *deprecated_message,
2384 int *always_unavailable,
2385 CXString *unavailable_message,
2386 CXPlatformAvailability *availability,
2387 int availability_size);
2388
2389/**
2390 * \brief Free the memory associated with a \c CXPlatformAvailability structure.
2391 */
2392CINDEX_LINKAGE void
2393clang_disposeCXPlatformAvailability(CXPlatformAvailability *availability);
2394
2395/**
Ted Kremenek4ed29252010-04-12 21:22:16 +00002396 * \brief Describe the "language" of the entity referred to by a cursor.
2397 */
Reid Kleckner9e3bc722013-12-30 17:48:49 +00002398enum CXLanguageKind {
Ted Kremenekee457512010-04-14 20:58:32 +00002399 CXLanguage_Invalid = 0,
Ted Kremenek4ed29252010-04-12 21:22:16 +00002400 CXLanguage_C,
2401 CXLanguage_ObjC,
Ted Kremenekee457512010-04-14 20:58:32 +00002402 CXLanguage_CPlusPlus
Ted Kremenek4ed29252010-04-12 21:22:16 +00002403};
2404
2405/**
2406 * \brief Determine the "language" of the entity referred to by a given cursor.
2407 */
2408CINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor);
2409
Argyrios Kyrtzidisd6e9fa52011-09-27 00:30:30 +00002410/**
2411 * \brief Returns the translation unit that a cursor originated from.
2412 */
2413CINDEX_LINKAGE CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor);
2414
Ted Kremenekc0b98662013-04-24 07:17:12 +00002415
2416/**
2417 * \brief A fast container representing a set of CXCursors.
2418 */
2419typedef struct CXCursorSetImpl *CXCursorSet;
2420
2421/**
2422 * \brief Creates an empty CXCursorSet.
2423 */
2424CINDEX_LINKAGE CXCursorSet clang_createCXCursorSet(void);
2425
2426/**
2427 * \brief Disposes a CXCursorSet and releases its associated memory.
2428 */
2429CINDEX_LINKAGE void clang_disposeCXCursorSet(CXCursorSet cset);
2430
2431/**
2432 * \brief Queries a CXCursorSet to see if it contains a specific CXCursor.
2433 *
2434 * \returns non-zero if the set contains the specified cursor.
2435*/
2436CINDEX_LINKAGE unsigned clang_CXCursorSet_contains(CXCursorSet cset,
2437 CXCursor cursor);
2438
2439/**
2440 * \brief Inserts a CXCursor into a CXCursorSet.
2441 *
2442 * \returns zero if the CXCursor was already in the set, and non-zero otherwise.
2443*/
2444CINDEX_LINKAGE unsigned clang_CXCursorSet_insert(CXCursorSet cset,
2445 CXCursor cursor);
2446
Douglas Gregor0576ce72010-09-22 21:22:29 +00002447/**
2448 * \brief Determine the semantic parent of the given cursor.
2449 *
2450 * The semantic parent of a cursor is the cursor that semantically contains
2451 * the given \p cursor. For many declarations, the lexical and semantic parents
2452 * are equivalent (the lexical parent is returned by
2453 * \c clang_getCursorLexicalParent()). They diverge when declarations or
2454 * definitions are provided out-of-line. For example:
2455 *
2456 * \code
2457 * class C {
2458 * void f();
2459 * };
2460 *
2461 * void C::f() { }
2462 * \endcode
2463 *
2464 * In the out-of-line definition of \c C::f, the semantic parent is the
2465 * the class \c C, of which this function is a member. The lexical parent is
2466 * the place where the declaration actually occurs in the source code; in this
2467 * case, the definition occurs in the translation unit. In general, the
2468 * lexical parent for a given entity can change without affecting the semantics
2469 * of the program, and the lexical parent of different declarations of the
2470 * same entity may be different. Changing the semantic parent of a declaration,
2471 * on the other hand, can have a major impact on semantics, and redeclarations
2472 * of a particular entity should all have the same semantic context.
2473 *
2474 * In the example above, both declarations of \c C::f have \c C as their
2475 * semantic context, while the lexical context of the first \c C::f is \c C
2476 * and the lexical context of the second \c C::f is the translation unit.
Douglas Gregor7ecd19e2010-12-21 07:55:45 +00002477 *
2478 * For global declarations, the semantic parent is the translation unit.
Douglas Gregor0576ce72010-09-22 21:22:29 +00002479 */
2480CINDEX_LINKAGE CXCursor clang_getCursorSemanticParent(CXCursor cursor);
2481
2482/**
2483 * \brief Determine the lexical parent of the given cursor.
2484 *
2485 * The lexical parent of a cursor is the cursor in which the given \p cursor
2486 * was actually written. For many declarations, the lexical and semantic parents
2487 * are equivalent (the semantic parent is returned by
2488 * \c clang_getCursorSemanticParent()). They diverge when declarations or
2489 * definitions are provided out-of-line. For example:
2490 *
2491 * \code
2492 * class C {
2493 * void f();
2494 * };
2495 *
2496 * void C::f() { }
2497 * \endcode
2498 *
2499 * In the out-of-line definition of \c C::f, the semantic parent is the
2500 * the class \c C, of which this function is a member. The lexical parent is
2501 * the place where the declaration actually occurs in the source code; in this
2502 * case, the definition occurs in the translation unit. In general, the
2503 * lexical parent for a given entity can change without affecting the semantics
2504 * of the program, and the lexical parent of different declarations of the
2505 * same entity may be different. Changing the semantic parent of a declaration,
2506 * on the other hand, can have a major impact on semantics, and redeclarations
2507 * of a particular entity should all have the same semantic context.
2508 *
2509 * In the example above, both declarations of \c C::f have \c C as their
2510 * semantic context, while the lexical context of the first \c C::f is \c C
2511 * and the lexical context of the second \c C::f is the translation unit.
Douglas Gregor7ecd19e2010-12-21 07:55:45 +00002512 *
2513 * For declarations written in the global scope, the lexical parent is
2514 * the translation unit.
Douglas Gregor0576ce72010-09-22 21:22:29 +00002515 */
2516CINDEX_LINKAGE CXCursor clang_getCursorLexicalParent(CXCursor cursor);
Douglas Gregor99a26af2010-10-01 20:25:15 +00002517
2518/**
2519 * \brief Determine the set of methods that are overridden by the given
2520 * method.
2521 *
2522 * In both Objective-C and C++, a method (aka virtual member function,
2523 * in C++) can override a virtual method in a base class. For
2524 * Objective-C, a method is said to override any method in the class's
Argyrios Kyrtzidisbfb24252012-03-08 00:20:03 +00002525 * base class, its protocols, or its categories' protocols, that has the same
2526 * selector and is of the same kind (class or instance).
2527 * If no such method exists, the search continues to the class's superclass,
2528 * its protocols, and its categories, and so on. A method from an Objective-C
2529 * implementation is considered to override the same methods as its
2530 * corresponding method in the interface.
Douglas Gregor99a26af2010-10-01 20:25:15 +00002531 *
2532 * For C++, a virtual member function overrides any virtual member
2533 * function with the same signature that occurs in its base
2534 * classes. With multiple inheritance, a virtual member function can
2535 * override several virtual member functions coming from different
2536 * base classes.
2537 *
2538 * In all cases, this function determines the immediate overridden
2539 * method, rather than all of the overridden methods. For example, if
2540 * a method is originally declared in a class A, then overridden in B
2541 * (which in inherits from A) and also in C (which inherited from B),
2542 * then the only overridden method returned from this function when
2543 * invoked on C's method will be B's method. The client may then
2544 * invoke this function again, given the previously-found overridden
2545 * methods, to map out the complete method-override set.
2546 *
2547 * \param cursor A cursor representing an Objective-C or C++
2548 * method. This routine will compute the set of methods that this
2549 * method overrides.
2550 *
2551 * \param overridden A pointer whose pointee will be replaced with a
2552 * pointer to an array of cursors, representing the set of overridden
2553 * methods. If there are no overridden methods, the pointee will be
2554 * set to NULL. The pointee must be freed via a call to
2555 * \c clang_disposeOverriddenCursors().
2556 *
2557 * \param num_overridden A pointer to the number of overridden
2558 * functions, will be set to the number of overridden functions in the
2559 * array pointed to by \p overridden.
2560 */
2561CINDEX_LINKAGE void clang_getOverriddenCursors(CXCursor cursor,
2562 CXCursor **overridden,
2563 unsigned *num_overridden);
2564
2565/**
2566 * \brief Free the set of overridden cursors returned by \c
2567 * clang_getOverriddenCursors().
2568 */
2569CINDEX_LINKAGE void clang_disposeOverriddenCursors(CXCursor *overridden);
2570
Ted Kremenek4ed29252010-04-12 21:22:16 +00002571/**
Douglas Gregor796d76a2010-10-20 22:00:55 +00002572 * \brief Retrieve the file that is included by the given inclusion directive
2573 * cursor.
2574 */
2575CINDEX_LINKAGE CXFile clang_getIncludedFile(CXCursor cursor);
2576
2577/**
Douglas Gregor6007cf22010-01-22 22:29:16 +00002578 * @}
2579 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002580
Douglas Gregor6007cf22010-01-22 22:29:16 +00002581/**
2582 * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code
2583 *
2584 * Cursors represent a location within the Abstract Syntax Tree (AST). These
2585 * routines help map between cursors and the physical locations where the
2586 * described entities occur in the source code. The mapping is provided in
2587 * both directions, so one can map from source code to the AST and back.
2588 *
2589 * @{
Steve Naroffa1c72842009-08-28 15:28:48 +00002590 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002591
Steve Naroff20bad0b2009-10-21 13:56:23 +00002592/**
Douglas Gregor816fd362010-01-22 21:44:22 +00002593 * \brief Map a source location to the cursor that describes the entity at that
2594 * location in the source code.
2595 *
2596 * clang_getCursor() maps an arbitrary source location within a translation
2597 * unit down to the most specific cursor that describes the entity at that
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002598 * location. For example, given an expression \c x + y, invoking
Douglas Gregor816fd362010-01-22 21:44:22 +00002599 * clang_getCursor() with a source location pointing to "x" will return the
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002600 * cursor for "x"; similarly for "y". If the cursor points anywhere between
Douglas Gregor816fd362010-01-22 21:44:22 +00002601 * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor()
2602 * will return a cursor referring to the "+" expression.
2603 *
2604 * \returns a cursor representing the entity at the given source location, or
2605 * a NULL cursor if no such entity can be found.
Steve Naroff20bad0b2009-10-21 13:56:23 +00002606 */
Douglas Gregor816fd362010-01-22 21:44:22 +00002607CINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, CXSourceLocation);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002608
Douglas Gregor66a58812010-01-18 22:46:11 +00002609/**
2610 * \brief Retrieve the physical location of the source constructor referenced
2611 * by the given cursor.
2612 *
2613 * The location of a declaration is typically the location of the name of that
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002614 * declaration, where the name of that declaration would occur if it is
2615 * unnamed, or some keyword that introduces that particular declaration.
2616 * The location of a reference is where that reference occurs within the
Douglas Gregor66a58812010-01-18 22:46:11 +00002617 * source code.
2618 */
2619CINDEX_LINKAGE CXSourceLocation clang_getCursorLocation(CXCursor);
Douglas Gregor6007cf22010-01-22 22:29:16 +00002620
Douglas Gregor6b8232f2010-01-19 19:34:47 +00002621/**
2622 * \brief Retrieve the physical extent of the source construct referenced by
Douglas Gregor33c34ac2010-01-19 00:34:46 +00002623 * the given cursor.
2624 *
2625 * The extent of a cursor starts with the file/line/column pointing at the
2626 * first character within the source construct that the cursor refers to and
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002627 * ends with the last character withinin that source construct. For a
Douglas Gregor33c34ac2010-01-19 00:34:46 +00002628 * declaration, the extent covers the declaration itself. For a reference,
2629 * the extent covers the location of the reference (e.g., where the referenced
2630 * entity was actually used).
2631 */
2632CINDEX_LINKAGE CXSourceRange clang_getCursorExtent(CXCursor);
Douglas Gregorad27e8b2010-01-19 01:20:04 +00002633
Douglas Gregor6007cf22010-01-22 22:29:16 +00002634/**
2635 * @}
2636 */
Ted Kremeneka5940822010-08-26 01:42:22 +00002637
Douglas Gregor6007cf22010-01-22 22:29:16 +00002638/**
Ted Kremenek6bca9842010-05-14 21:29:26 +00002639 * \defgroup CINDEX_TYPES Type information for CXCursors
2640 *
2641 * @{
2642 */
2643
2644/**
2645 * \brief Describes the kind of type
2646 */
2647enum CXTypeKind {
2648 /**
2649 * \brief Reprents an invalid type (e.g., where no type is available).
2650 */
2651 CXType_Invalid = 0,
2652
2653 /**
2654 * \brief A type whose specific kind is not exposed via this
2655 * interface.
2656 */
2657 CXType_Unexposed = 1,
2658
2659 /* Builtin types */
2660 CXType_Void = 2,
2661 CXType_Bool = 3,
2662 CXType_Char_U = 4,
2663 CXType_UChar = 5,
2664 CXType_Char16 = 6,
2665 CXType_Char32 = 7,
2666 CXType_UShort = 8,
2667 CXType_UInt = 9,
2668 CXType_ULong = 10,
2669 CXType_ULongLong = 11,
2670 CXType_UInt128 = 12,
2671 CXType_Char_S = 13,
2672 CXType_SChar = 14,
2673 CXType_WChar = 15,
2674 CXType_Short = 16,
2675 CXType_Int = 17,
2676 CXType_Long = 18,
2677 CXType_LongLong = 19,
2678 CXType_Int128 = 20,
2679 CXType_Float = 21,
2680 CXType_Double = 22,
2681 CXType_LongDouble = 23,
2682 CXType_NullPtr = 24,
2683 CXType_Overload = 25,
2684 CXType_Dependent = 26,
2685 CXType_ObjCId = 27,
2686 CXType_ObjCClass = 28,
2687 CXType_ObjCSel = 29,
2688 CXType_FirstBuiltin = CXType_Void,
2689 CXType_LastBuiltin = CXType_ObjCSel,
2690
2691 CXType_Complex = 100,
2692 CXType_Pointer = 101,
2693 CXType_BlockPointer = 102,
2694 CXType_LValueReference = 103,
2695 CXType_RValueReference = 104,
2696 CXType_Record = 105,
2697 CXType_Enum = 106,
2698 CXType_Typedef = 107,
2699 CXType_ObjCInterface = 108,
Ted Kremenekc1508872010-06-21 20:15:39 +00002700 CXType_ObjCObjectPointer = 109,
2701 CXType_FunctionNoProto = 110,
Argyrios Kyrtzidis2b0cf602011-09-27 17:44:34 +00002702 CXType_FunctionProto = 111,
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00002703 CXType_ConstantArray = 112,
Argyrios Kyrtzidis0661a712013-07-23 17:36:21 +00002704 CXType_Vector = 113,
2705 CXType_IncompleteArray = 114,
2706 CXType_VariableArray = 115,
Argyrios Kyrtzidis7a4253b2013-10-03 16:19:23 +00002707 CXType_DependentSizedArray = 116,
2708 CXType_MemberPointer = 117
Ted Kremenek6bca9842010-05-14 21:29:26 +00002709};
2710
2711/**
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00002712 * \brief Describes the calling convention of a function type
2713 */
2714enum CXCallingConv {
2715 CXCallingConv_Default = 0,
2716 CXCallingConv_C = 1,
2717 CXCallingConv_X86StdCall = 2,
2718 CXCallingConv_X86FastCall = 3,
2719 CXCallingConv_X86ThisCall = 4,
2720 CXCallingConv_X86Pascal = 5,
2721 CXCallingConv_AAPCS = 6,
2722 CXCallingConv_AAPCS_VFP = 7,
Derek Schuffa2020962012-10-16 22:30:41 +00002723 CXCallingConv_PnaclCall = 8,
Guy Benyeif0a014b2012-12-25 08:53:55 +00002724 CXCallingConv_IntelOclBicc = 9,
Charles Davisb5a214e2013-08-30 04:39:01 +00002725 CXCallingConv_X86_64Win64 = 10,
2726 CXCallingConv_X86_64SysV = 11,
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00002727
2728 CXCallingConv_Invalid = 100,
2729 CXCallingConv_Unexposed = 200
2730};
2731
2732
2733/**
Ted Kremenek6bca9842010-05-14 21:29:26 +00002734 * \brief The type of an element in the abstract syntax tree.
2735 *
2736 */
2737typedef struct {
2738 enum CXTypeKind kind;
2739 void *data[2];
2740} CXType;
2741
2742/**
2743 * \brief Retrieve the type of a CXCursor (if any).
2744 */
2745CINDEX_LINKAGE CXType clang_getCursorType(CXCursor C);
2746
2747/**
Dmitri Gribenko00353722013-02-15 21:15:49 +00002748 * \brief Pretty-print the underlying type using the rules of the
2749 * language of the translation unit from which it came.
2750 *
2751 * If the type is invalid, an empty string is returned.
2752 */
2753CINDEX_LINKAGE CXString clang_getTypeSpelling(CXType CT);
2754
2755/**
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00002756 * \brief Retrieve the underlying type of a typedef declaration.
2757 *
2758 * If the cursor does not reference a typedef declaration, an invalid type is
2759 * returned.
2760 */
2761CINDEX_LINKAGE CXType clang_getTypedefDeclUnderlyingType(CXCursor C);
2762
2763/**
2764 * \brief Retrieve the integer type of an enum declaration.
2765 *
2766 * If the cursor does not reference an enum declaration, an invalid type is
2767 * returned.
2768 */
2769CINDEX_LINKAGE CXType clang_getEnumDeclIntegerType(CXCursor C);
2770
2771/**
2772 * \brief Retrieve the integer value of an enum constant declaration as a signed
2773 * long long.
2774 *
2775 * If the cursor does not reference an enum constant declaration, LLONG_MIN is returned.
2776 * Since this is also potentially a valid constant value, the kind of the cursor
2777 * must be verified before calling this function.
2778 */
2779CINDEX_LINKAGE long long clang_getEnumConstantDeclValue(CXCursor C);
2780
2781/**
2782 * \brief Retrieve the integer value of an enum constant declaration as an unsigned
2783 * long long.
2784 *
2785 * If the cursor does not reference an enum constant declaration, ULLONG_MAX is returned.
2786 * Since this is also potentially a valid constant value, the kind of the cursor
2787 * must be verified before calling this function.
2788 */
2789CINDEX_LINKAGE unsigned long long clang_getEnumConstantDeclUnsignedValue(CXCursor C);
2790
2791/**
Dmitri Gribenkob506ba12012-12-04 15:13:46 +00002792 * \brief Retrieve the bit width of a bit field declaration as an integer.
2793 *
2794 * If a cursor that is not a bit field declaration is passed in, -1 is returned.
2795 */
2796CINDEX_LINKAGE int clang_getFieldDeclBitWidth(CXCursor C);
2797
2798/**
Argyrios Kyrtzidis0c27e4b2012-04-11 19:32:19 +00002799 * \brief Retrieve the number of non-variadic arguments associated with a given
2800 * cursor.
2801 *
Argyrios Kyrtzidisb2792972013-04-01 17:38:59 +00002802 * The number of arguments can be determined for calls as well as for
2803 * declarations of functions or methods. For other cursors -1 is returned.
Argyrios Kyrtzidis0c27e4b2012-04-11 19:32:19 +00002804 */
2805CINDEX_LINKAGE int clang_Cursor_getNumArguments(CXCursor C);
2806
2807/**
2808 * \brief Retrieve the argument cursor of a function or method.
2809 *
Argyrios Kyrtzidisb2792972013-04-01 17:38:59 +00002810 * The argument cursor can be determined for calls as well as for declarations
2811 * of functions or methods. For other cursors and for invalid indices, an
2812 * invalid cursor is returned.
Argyrios Kyrtzidis0c27e4b2012-04-11 19:32:19 +00002813 */
2814CINDEX_LINKAGE CXCursor clang_Cursor_getArgument(CXCursor C, unsigned i);
2815
2816/**
James Dennett574cb4c2012-06-15 05:41:51 +00002817 * \brief Determine whether two CXTypes represent the same type.
Ted Kremenek6bca9842010-05-14 21:29:26 +00002818 *
James Dennett574cb4c2012-06-15 05:41:51 +00002819 * \returns non-zero if the CXTypes represent the same type and
2820 * zero otherwise.
Ted Kremenek6bca9842010-05-14 21:29:26 +00002821 */
2822CINDEX_LINKAGE unsigned clang_equalTypes(CXType A, CXType B);
2823
2824/**
2825 * \brief Return the canonical type for a CXType.
2826 *
2827 * Clang's type system explicitly models typedefs and all the ways
2828 * a specific type can be represented. The canonical type is the underlying
2829 * type with all the "sugar" removed. For example, if 'T' is a typedef
2830 * for 'int', the canonical type for 'T' would be 'int'.
2831 */
2832CINDEX_LINKAGE CXType clang_getCanonicalType(CXType T);
2833
2834/**
James Dennett574cb4c2012-06-15 05:41:51 +00002835 * \brief Determine whether a CXType has the "const" qualifier set,
2836 * without looking through typedefs that may have added "const" at a
2837 * different level.
Douglas Gregor56a63802011-01-27 16:27:11 +00002838 */
2839CINDEX_LINKAGE unsigned clang_isConstQualifiedType(CXType T);
2840
2841/**
James Dennett574cb4c2012-06-15 05:41:51 +00002842 * \brief Determine whether a CXType has the "volatile" qualifier set,
2843 * without looking through typedefs that may have added "volatile" at
2844 * a different level.
Douglas Gregor56a63802011-01-27 16:27:11 +00002845 */
2846CINDEX_LINKAGE unsigned clang_isVolatileQualifiedType(CXType T);
2847
2848/**
James Dennett574cb4c2012-06-15 05:41:51 +00002849 * \brief Determine whether a CXType has the "restrict" qualifier set,
2850 * without looking through typedefs that may have added "restrict" at a
2851 * different level.
Douglas Gregor56a63802011-01-27 16:27:11 +00002852 */
2853CINDEX_LINKAGE unsigned clang_isRestrictQualifiedType(CXType T);
2854
2855/**
Ted Kremenek6bca9842010-05-14 21:29:26 +00002856 * \brief For pointer types, returns the type of the pointee.
Ted Kremenek6bca9842010-05-14 21:29:26 +00002857 */
2858CINDEX_LINKAGE CXType clang_getPointeeType(CXType T);
2859
2860/**
2861 * \brief Return the cursor for the declaration of the given type.
2862 */
2863CINDEX_LINKAGE CXCursor clang_getTypeDeclaration(CXType T);
2864
David Chisnall50e4eba2010-12-30 14:05:53 +00002865/**
2866 * Returns the Objective-C type encoding for the specified declaration.
2867 */
2868CINDEX_LINKAGE CXString clang_getDeclObjCTypeEncoding(CXCursor C);
Ted Kremenek6bca9842010-05-14 21:29:26 +00002869
2870/**
2871 * \brief Retrieve the spelling of a given CXTypeKind.
2872 */
2873CINDEX_LINKAGE CXString clang_getTypeKindSpelling(enum CXTypeKind K);
2874
2875/**
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00002876 * \brief Retrieve the calling convention associated with a function type.
2877 *
2878 * If a non-function type is passed in, CXCallingConv_Invalid is returned.
2879 */
2880CINDEX_LINKAGE enum CXCallingConv clang_getFunctionTypeCallingConv(CXType T);
2881
2882/**
Ted Kremenekc62ab8d2010-06-21 20:48:56 +00002883 * \brief Retrieve the result type associated with a function type.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00002884 *
2885 * If a non-function type is passed in, an invalid type is returned.
Ted Kremenekc1508872010-06-21 20:15:39 +00002886 */
2887CINDEX_LINKAGE CXType clang_getResultType(CXType T);
2888
2889/**
Alp Toker601b22c2014-01-21 23:35:24 +00002890 * \brief Retrieve the number of non-variadic parameters associated with a
James Dennett574cb4c2012-06-15 05:41:51 +00002891 * function type.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00002892 *
Argyrios Kyrtzidis0c27e4b2012-04-11 19:32:19 +00002893 * If a non-function type is passed in, -1 is returned.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00002894 */
Argyrios Kyrtzidis0c27e4b2012-04-11 19:32:19 +00002895CINDEX_LINKAGE int clang_getNumArgTypes(CXType T);
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00002896
2897/**
Alp Toker601b22c2014-01-21 23:35:24 +00002898 * \brief Retrieve the type of a parameter of a function type.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00002899 *
James Dennett574cb4c2012-06-15 05:41:51 +00002900 * If a non-function type is passed in or the function does not have enough
2901 * parameters, an invalid type is returned.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00002902 */
2903CINDEX_LINKAGE CXType clang_getArgType(CXType T, unsigned i);
2904
2905/**
2906 * \brief Return 1 if the CXType is a variadic function type, and 0 otherwise.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00002907 */
2908CINDEX_LINKAGE unsigned clang_isFunctionTypeVariadic(CXType T);
2909
2910/**
2911 * \brief Retrieve the result type associated with a given cursor.
2912 *
2913 * This only returns a valid type if the cursor refers to a function or method.
Ted Kremenekc62ab8d2010-06-21 20:48:56 +00002914 */
2915CINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C);
2916
2917/**
Ted Kremenek0c7476a2010-07-30 00:14:11 +00002918 * \brief Return 1 if the CXType is a POD (plain old data) type, and 0
2919 * otherwise.
2920 */
2921CINDEX_LINKAGE unsigned clang_isPODType(CXType T);
2922
2923/**
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00002924 * \brief Return the element type of an array, complex, or vector type.
2925 *
2926 * If a type is passed in that is not an array, complex, or vector type,
2927 * an invalid type is returned.
2928 */
2929CINDEX_LINKAGE CXType clang_getElementType(CXType T);
2930
2931/**
2932 * \brief Return the number of elements of an array or vector type.
2933 *
2934 * If a type is passed in that is not an array or vector type,
2935 * -1 is returned.
2936 */
2937CINDEX_LINKAGE long long clang_getNumElements(CXType T);
2938
2939/**
Argyrios Kyrtzidis2b0cf602011-09-27 17:44:34 +00002940 * \brief Return the element type of an array type.
2941 *
2942 * If a non-array type is passed in, an invalid type is returned.
2943 */
2944CINDEX_LINKAGE CXType clang_getArrayElementType(CXType T);
2945
2946/**
Sylvestre Ledru830885c2012-07-23 08:59:39 +00002947 * \brief Return the array size of a constant array.
Argyrios Kyrtzidis2b0cf602011-09-27 17:44:34 +00002948 *
2949 * If a non-array type is passed in, -1 is returned.
2950 */
2951CINDEX_LINKAGE long long clang_getArraySize(CXType T);
2952
2953/**
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00002954 * \brief List the possible error codes for \c clang_Type_getSizeOf,
2955 * \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf and
2956 * \c clang_Cursor_getOffsetOf.
2957 *
2958 * A value of this enumeration type can be returned if the target type is not
2959 * a valid argument to sizeof, alignof or offsetof.
2960 */
2961enum CXTypeLayoutError {
2962 /**
2963 * \brief Type is of kind CXType_Invalid.
2964 */
2965 CXTypeLayoutError_Invalid = -1,
2966 /**
2967 * \brief The type is an incomplete Type.
2968 */
2969 CXTypeLayoutError_Incomplete = -2,
2970 /**
2971 * \brief The type is a dependent Type.
2972 */
2973 CXTypeLayoutError_Dependent = -3,
2974 /**
2975 * \brief The type is not a constant size type.
2976 */
2977 CXTypeLayoutError_NotConstantSize = -4,
2978 /**
2979 * \brief The Field name is not valid for this record.
2980 */
2981 CXTypeLayoutError_InvalidFieldName = -5
2982};
2983
2984/**
2985 * \brief Return the alignment of a type in bytes as per C++[expr.alignof]
2986 * standard.
2987 *
2988 * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
2989 * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
2990 * is returned.
2991 * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
2992 * returned.
2993 * If the type declaration is not a constant size type,
2994 * CXTypeLayoutError_NotConstantSize is returned.
2995 */
2996CINDEX_LINKAGE long long clang_Type_getAlignOf(CXType T);
2997
2998/**
Argyrios Kyrtzidis7a4253b2013-10-03 16:19:23 +00002999 * \brief Return the class type of an member pointer type.
3000 *
3001 * If a non-member-pointer type is passed in, an invalid type is returned.
3002 */
3003CINDEX_LINKAGE CXType clang_Type_getClassType(CXType T);
3004
3005/**
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003006 * \brief Return the size of a type in bytes as per C++[expr.sizeof] standard.
3007 *
3008 * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
3009 * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
3010 * is returned.
3011 * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
3012 * returned.
3013 */
3014CINDEX_LINKAGE long long clang_Type_getSizeOf(CXType T);
3015
3016/**
3017 * \brief Return the offset of a field named S in a record of type T in bits
3018 * as it would be returned by __offsetof__ as per C++11[18.2p4]
3019 *
3020 * If the cursor is not a record field declaration, CXTypeLayoutError_Invalid
3021 * is returned.
3022 * If the field's type declaration is an incomplete type,
3023 * CXTypeLayoutError_Incomplete is returned.
3024 * If the field's type declaration is a dependent type,
3025 * CXTypeLayoutError_Dependent is returned.
3026 * If the field's name S is not found,
3027 * CXTypeLayoutError_InvalidFieldName is returned.
3028 */
3029CINDEX_LINKAGE long long clang_Type_getOffsetOf(CXType T, const char *S);
3030
Argyrios Kyrtzidisadff3ae2013-10-11 19:58:38 +00003031enum CXRefQualifierKind {
3032 /** \brief No ref-qualifier was provided. */
3033 CXRefQualifier_None = 0,
3034 /** \brief An lvalue ref-qualifier was provided (\c &). */
3035 CXRefQualifier_LValue,
3036 /** \brief An rvalue ref-qualifier was provided (\c &&). */
3037 CXRefQualifier_RValue
3038};
3039
3040/**
3041 * \brief Retrieve the ref-qualifier kind of a function or method.
3042 *
3043 * The ref-qualifier is returned for C++ functions or methods. For other types
3044 * or non-C++ declarations, CXRefQualifier_None is returned.
3045 */
3046CINDEX_LINKAGE enum CXRefQualifierKind clang_Type_getCXXRefQualifier(CXType T);
3047
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003048/**
3049 * \brief Returns non-zero if the cursor specifies a Record member that is a
3050 * bitfield.
3051 */
3052CINDEX_LINKAGE unsigned clang_Cursor_isBitField(CXCursor C);
3053
3054/**
Ted Kremenekae9e2212010-08-27 21:34:58 +00003055 * \brief Returns 1 if the base class specified by the cursor with kind
3056 * CX_CXXBaseSpecifier is virtual.
3057 */
3058CINDEX_LINKAGE unsigned clang_isVirtualBase(CXCursor);
3059
3060/**
3061 * \brief Represents the C++ access control level to a base class for a
3062 * cursor with kind CX_CXXBaseSpecifier.
3063 */
3064enum CX_CXXAccessSpecifier {
3065 CX_CXXInvalidAccessSpecifier,
3066 CX_CXXPublic,
3067 CX_CXXProtected,
3068 CX_CXXPrivate
3069};
3070
3071/**
Argyrios Kyrtzidis1ab09cc2013-04-11 17:02:10 +00003072 * \brief Returns the access control level for the referenced object.
Argyrios Kyrtzidisf6464082013-04-11 17:31:13 +00003073 *
Argyrios Kyrtzidis1ab09cc2013-04-11 17:02:10 +00003074 * If the cursor refers to a C++ declaration, its access control level within its
3075 * parent scope is returned. Otherwise, if the cursor refers to a base specifier or
3076 * access specifier, the specifier itself is returned.
Ted Kremenekae9e2212010-08-27 21:34:58 +00003077 */
3078CINDEX_LINKAGE enum CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor);
3079
3080/**
Douglas Gregor16a2bdd2010-09-13 22:52:57 +00003081 * \brief Determine the number of overloaded declarations referenced by a
3082 * \c CXCursor_OverloadedDeclRef cursor.
3083 *
3084 * \param cursor The cursor whose overloaded declarations are being queried.
3085 *
3086 * \returns The number of overloaded declarations referenced by \c cursor. If it
3087 * is not a \c CXCursor_OverloadedDeclRef cursor, returns 0.
3088 */
3089CINDEX_LINKAGE unsigned clang_getNumOverloadedDecls(CXCursor cursor);
3090
3091/**
3092 * \brief Retrieve a cursor for one of the overloaded declarations referenced
3093 * by a \c CXCursor_OverloadedDeclRef cursor.
3094 *
3095 * \param cursor The cursor whose overloaded declarations are being queried.
3096 *
3097 * \param index The zero-based index into the set of overloaded declarations in
3098 * the cursor.
3099 *
3100 * \returns A cursor representing the declaration referenced by the given
3101 * \c cursor at the specified \c index. If the cursor does not have an
3102 * associated set of overloaded declarations, or if the index is out of bounds,
3103 * returns \c clang_getNullCursor();
3104 */
3105CINDEX_LINKAGE CXCursor clang_getOverloadedDecl(CXCursor cursor,
3106 unsigned index);
3107
3108/**
Ted Kremenek6bca9842010-05-14 21:29:26 +00003109 * @}
3110 */
Ted Kremeneka5940822010-08-26 01:42:22 +00003111
3112/**
Ted Kremenek2c2c5f32010-08-27 21:34:51 +00003113 * \defgroup CINDEX_ATTRIBUTES Information for attributes
Ted Kremeneka5940822010-08-26 01:42:22 +00003114 *
3115 * @{
3116 */
3117
3118
3119/**
3120 * \brief For cursors representing an iboutletcollection attribute,
3121 * this function returns the collection element type.
3122 *
3123 */
3124CINDEX_LINKAGE CXType clang_getIBOutletCollectionType(CXCursor);
3125
3126/**
3127 * @}
3128 */
Ted Kremenek6bca9842010-05-14 21:29:26 +00003129
3130/**
Douglas Gregor6007cf22010-01-22 22:29:16 +00003131 * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors
3132 *
3133 * These routines provide the ability to traverse the abstract syntax tree
3134 * using cursors.
3135 *
3136 * @{
3137 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003138
Douglas Gregor6007cf22010-01-22 22:29:16 +00003139/**
3140 * \brief Describes how the traversal of the children of a particular
3141 * cursor should proceed after visiting a particular child cursor.
3142 *
3143 * A value of this enumeration type should be returned by each
3144 * \c CXCursorVisitor to indicate how clang_visitChildren() proceed.
3145 */
3146enum CXChildVisitResult {
3147 /**
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003148 * \brief Terminates the cursor traversal.
Douglas Gregor6007cf22010-01-22 22:29:16 +00003149 */
3150 CXChildVisit_Break,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003151 /**
Douglas Gregor6007cf22010-01-22 22:29:16 +00003152 * \brief Continues the cursor traversal with the next sibling of
3153 * the cursor just visited, without visiting its children.
3154 */
3155 CXChildVisit_Continue,
3156 /**
3157 * \brief Recursively traverse the children of this cursor, using
3158 * the same visitor and client data.
3159 */
3160 CXChildVisit_Recurse
3161};
3162
3163/**
3164 * \brief Visitor invoked for each cursor found by a traversal.
3165 *
3166 * This visitor function will be invoked for each cursor found by
3167 * clang_visitCursorChildren(). Its first argument is the cursor being
3168 * visited, its second argument is the parent visitor for that cursor,
3169 * and its third argument is the client data provided to
3170 * clang_visitCursorChildren().
3171 *
3172 * The visitor should return one of the \c CXChildVisitResult values
3173 * to direct clang_visitCursorChildren().
3174 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003175typedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor,
3176 CXCursor parent,
Douglas Gregor6007cf22010-01-22 22:29:16 +00003177 CXClientData client_data);
3178
3179/**
3180 * \brief Visit the children of a particular cursor.
3181 *
3182 * This function visits all the direct children of the given cursor,
3183 * invoking the given \p visitor function with the cursors of each
3184 * visited child. The traversal may be recursive, if the visitor returns
3185 * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if
3186 * the visitor returns \c CXChildVisit_Break.
3187 *
Douglas Gregor6007cf22010-01-22 22:29:16 +00003188 * \param parent the cursor whose child may be visited. All kinds of
Daniel Dunbarb9999fd2010-01-24 04:10:31 +00003189 * cursors can be visited, including invalid cursors (which, by
Douglas Gregor6007cf22010-01-22 22:29:16 +00003190 * definition, have no children).
3191 *
3192 * \param visitor the visitor function that will be invoked for each
3193 * child of \p parent.
3194 *
3195 * \param client_data pointer data supplied by the client, which will
3196 * be passed to the visitor each time it is invoked.
3197 *
3198 * \returns a non-zero value if the traversal was terminated
3199 * prematurely by the visitor returning \c CXChildVisit_Break.
3200 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003201CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent,
Douglas Gregor6007cf22010-01-22 22:29:16 +00003202 CXCursorVisitor visitor,
3203 CXClientData client_data);
David Chisnallb2aa0ef2010-11-03 14:12:26 +00003204#ifdef __has_feature
3205# if __has_feature(blocks)
3206/**
3207 * \brief Visitor invoked for each cursor found by a traversal.
3208 *
3209 * This visitor block will be invoked for each cursor found by
3210 * clang_visitChildrenWithBlock(). Its first argument is the cursor being
3211 * visited, its second argument is the parent visitor for that cursor.
3212 *
3213 * The visitor should return one of the \c CXChildVisitResult values
3214 * to direct clang_visitChildrenWithBlock().
3215 */
3216typedef enum CXChildVisitResult
3217 (^CXCursorVisitorBlock)(CXCursor cursor, CXCursor parent);
3218
3219/**
3220 * Visits the children of a cursor using the specified block. Behaves
3221 * identically to clang_visitChildren() in all other respects.
3222 */
3223unsigned clang_visitChildrenWithBlock(CXCursor parent,
3224 CXCursorVisitorBlock block);
3225# endif
3226#endif
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003227
Douglas Gregor6007cf22010-01-22 22:29:16 +00003228/**
3229 * @}
3230 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003231
Douglas Gregor6007cf22010-01-22 22:29:16 +00003232/**
3233 * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST
3234 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003235 * These routines provide the ability to determine references within and
Douglas Gregor6007cf22010-01-22 22:29:16 +00003236 * across translation units, by providing the names of the entities referenced
3237 * by cursors, follow reference cursors to the declarations they reference,
3238 * and associate declarations with their definitions.
3239 *
3240 * @{
3241 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003242
Douglas Gregor6007cf22010-01-22 22:29:16 +00003243/**
3244 * \brief Retrieve a Unified Symbol Resolution (USR) for the entity referenced
3245 * by the given cursor.
3246 *
3247 * A Unified Symbol Resolution (USR) is a string that identifies a particular
3248 * entity (function, class, variable, etc.) within a program. USRs can be
3249 * compared across translation units to determine, e.g., when references in
3250 * one translation refer to an entity defined in another translation unit.
3251 */
3252CINDEX_LINKAGE CXString clang_getCursorUSR(CXCursor);
3253
3254/**
Ted Kremenekd071c602010-03-13 02:50:34 +00003255 * \brief Construct a USR for a specified Objective-C class.
3256 */
3257CINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name);
3258
3259/**
3260 * \brief Construct a USR for a specified Objective-C category.
3261 */
3262CINDEX_LINKAGE CXString
Ted Kremenekbc1a67b2010-03-15 17:38:58 +00003263 clang_constructUSR_ObjCCategory(const char *class_name,
Ted Kremenekd071c602010-03-13 02:50:34 +00003264 const char *category_name);
3265
3266/**
3267 * \brief Construct a USR for a specified Objective-C protocol.
3268 */
3269CINDEX_LINKAGE CXString
3270 clang_constructUSR_ObjCProtocol(const char *protocol_name);
3271
3272
3273/**
3274 * \brief Construct a USR for a specified Objective-C instance variable and
3275 * the USR for its containing class.
3276 */
3277CINDEX_LINKAGE CXString clang_constructUSR_ObjCIvar(const char *name,
3278 CXString classUSR);
3279
3280/**
3281 * \brief Construct a USR for a specified Objective-C method and
3282 * the USR for its containing class.
3283 */
3284CINDEX_LINKAGE CXString clang_constructUSR_ObjCMethod(const char *name,
3285 unsigned isInstanceMethod,
3286 CXString classUSR);
3287
3288/**
3289 * \brief Construct a USR for a specified Objective-C property and the USR
3290 * for its containing class.
3291 */
3292CINDEX_LINKAGE CXString clang_constructUSR_ObjCProperty(const char *property,
3293 CXString classUSR);
3294
3295/**
Douglas Gregor6007cf22010-01-22 22:29:16 +00003296 * \brief Retrieve a name for the entity referenced by this cursor.
3297 */
3298CINDEX_LINKAGE CXString clang_getCursorSpelling(CXCursor);
3299
Douglas Gregor97c75712010-10-02 22:49:11 +00003300/**
Argyrios Kyrtzidis191a6a82012-03-30 20:58:35 +00003301 * \brief Retrieve a range for a piece that forms the cursors spelling name.
3302 * Most of the times there is only one range for the complete spelling but for
3303 * objc methods and objc message expressions, there are multiple pieces for each
3304 * selector identifier.
3305 *
3306 * \param pieceIndex the index of the spelling name piece. If this is greater
3307 * than the actual number of pieces, it will return a NULL (invalid) range.
3308 *
3309 * \param options Reserved.
3310 */
3311CINDEX_LINKAGE CXSourceRange clang_Cursor_getSpellingNameRange(CXCursor,
3312 unsigned pieceIndex,
3313 unsigned options);
3314
3315/**
Douglas Gregor97c75712010-10-02 22:49:11 +00003316 * \brief Retrieve the display name for the entity referenced by this cursor.
3317 *
3318 * The display name contains extra information that helps identify the cursor,
3319 * such as the parameters of a function or template or the arguments of a
3320 * class template specialization.
3321 */
3322CINDEX_LINKAGE CXString clang_getCursorDisplayName(CXCursor);
3323
Douglas Gregorad27e8b2010-01-19 01:20:04 +00003324/** \brief For a cursor that is a reference, retrieve a cursor representing the
3325 * entity that it references.
3326 *
3327 * Reference cursors refer to other entities in the AST. For example, an
3328 * Objective-C superclass reference cursor refers to an Objective-C class.
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003329 * This function produces the cursor for the Objective-C class from the
Douglas Gregorad27e8b2010-01-19 01:20:04 +00003330 * cursor for the superclass reference. If the input cursor is a declaration or
3331 * definition, it returns that declaration or definition unchanged.
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003332 * Otherwise, returns the NULL cursor.
Douglas Gregorad27e8b2010-01-19 01:20:04 +00003333 */
3334CINDEX_LINKAGE CXCursor clang_getCursorReferenced(CXCursor);
Douglas Gregor6b8232f2010-01-19 19:34:47 +00003335
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003336/**
Douglas Gregor6b8232f2010-01-19 19:34:47 +00003337 * \brief For a cursor that is either a reference to or a declaration
3338 * of some entity, retrieve a cursor that describes the definition of
3339 * that entity.
3340 *
3341 * Some entities can be declared multiple times within a translation
3342 * unit, but only one of those declarations can also be a
3343 * definition. For example, given:
3344 *
3345 * \code
3346 * int f(int, int);
3347 * int g(int x, int y) { return f(x, y); }
3348 * int f(int a, int b) { return a + b; }
3349 * int f(int, int);
3350 * \endcode
3351 *
3352 * there are three declarations of the function "f", but only the
3353 * second one is a definition. The clang_getCursorDefinition()
3354 * function will take any cursor pointing to a declaration of "f"
3355 * (the first or fourth lines of the example) or a cursor referenced
3356 * that uses "f" (the call to "f' inside "g") and will return a
3357 * declaration cursor pointing to the definition (the second "f"
3358 * declaration).
3359 *
3360 * If given a cursor for which there is no corresponding definition,
3361 * e.g., because there is no definition of that entity within this
3362 * translation unit, returns a NULL cursor.
3363 */
3364CINDEX_LINKAGE CXCursor clang_getCursorDefinition(CXCursor);
3365
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003366/**
Douglas Gregor6b8232f2010-01-19 19:34:47 +00003367 * \brief Determine whether the declaration pointed to by this cursor
3368 * is also a definition of that entity.
3369 */
3370CINDEX_LINKAGE unsigned clang_isCursorDefinition(CXCursor);
3371
Douglas Gregor6007cf22010-01-22 22:29:16 +00003372/**
Douglas Gregorfec4dc92010-11-19 23:44:15 +00003373 * \brief Retrieve the canonical cursor corresponding to the given cursor.
3374 *
3375 * In the C family of languages, many kinds of entities can be declared several
3376 * times within a single translation unit. For example, a structure type can
3377 * be forward-declared (possibly multiple times) and later defined:
3378 *
3379 * \code
3380 * struct X;
3381 * struct X;
3382 * struct X {
3383 * int member;
3384 * };
3385 * \endcode
3386 *
3387 * The declarations and the definition of \c X are represented by three
3388 * different cursors, all of which are declarations of the same underlying
3389 * entity. One of these cursor is considered the "canonical" cursor, which
3390 * is effectively the representative for the underlying entity. One can
3391 * determine if two cursors are declarations of the same underlying entity by
3392 * comparing their canonical cursors.
3393 *
3394 * \returns The canonical cursor for the entity referred to by the given cursor.
3395 */
3396CINDEX_LINKAGE CXCursor clang_getCanonicalCursor(CXCursor);
3397
Argyrios Kyrtzidis210f29f2012-03-30 22:15:48 +00003398
3399/**
3400 * \brief If the cursor points to a selector identifier in a objc method or
3401 * message expression, this returns the selector index.
3402 *
James Dennett574cb4c2012-06-15 05:41:51 +00003403 * After getting a cursor with #clang_getCursor, this can be called to
Argyrios Kyrtzidis210f29f2012-03-30 22:15:48 +00003404 * determine if the location points to a selector identifier.
3405 *
3406 * \returns The selector index if the cursor is an objc method or message
3407 * expression and the cursor is pointing to a selector identifier, or -1
3408 * otherwise.
3409 */
3410CINDEX_LINKAGE int clang_Cursor_getObjCSelectorIndex(CXCursor);
3411
Douglas Gregorfec4dc92010-11-19 23:44:15 +00003412/**
Argyrios Kyrtzidisb6df68212012-07-02 23:54:36 +00003413 * \brief Given a cursor pointing to a C++ method call or an ObjC message,
3414 * returns non-zero if the method/message is "dynamic", meaning:
3415 *
3416 * For a C++ method: the call is virtual.
3417 * For an ObjC message: the receiver is an object instance, not 'super' or a
3418 * specific class.
3419 *
3420 * If the method/message is "static" or the cursor does not point to a
3421 * method/message, it will return zero.
3422 */
3423CINDEX_LINKAGE int clang_Cursor_isDynamicCall(CXCursor C);
3424
3425/**
Argyrios Kyrtzidisb26a24c2012-11-01 02:01:34 +00003426 * \brief Given a cursor pointing to an ObjC message, returns the CXType of the
3427 * receiver.
3428 */
3429CINDEX_LINKAGE CXType clang_Cursor_getReceiverType(CXCursor C);
3430
3431/**
Argyrios Kyrtzidis9adfd8a2013-04-18 22:15:49 +00003432 * \brief Property attributes for a \c CXCursor_ObjCPropertyDecl.
3433 */
3434typedef enum {
3435 CXObjCPropertyAttr_noattr = 0x00,
3436 CXObjCPropertyAttr_readonly = 0x01,
3437 CXObjCPropertyAttr_getter = 0x02,
3438 CXObjCPropertyAttr_assign = 0x04,
3439 CXObjCPropertyAttr_readwrite = 0x08,
3440 CXObjCPropertyAttr_retain = 0x10,
3441 CXObjCPropertyAttr_copy = 0x20,
3442 CXObjCPropertyAttr_nonatomic = 0x40,
3443 CXObjCPropertyAttr_setter = 0x80,
3444 CXObjCPropertyAttr_atomic = 0x100,
3445 CXObjCPropertyAttr_weak = 0x200,
3446 CXObjCPropertyAttr_strong = 0x400,
3447 CXObjCPropertyAttr_unsafe_unretained = 0x800
3448} CXObjCPropertyAttrKind;
3449
3450/**
3451 * \brief Given a cursor that represents a property declaration, return the
3452 * associated property attributes. The bits are formed from
3453 * \c CXObjCPropertyAttrKind.
3454 *
3455 * \param reserved Reserved for future use, pass 0.
3456 */
3457CINDEX_LINKAGE unsigned clang_Cursor_getObjCPropertyAttributes(CXCursor C,
3458 unsigned reserved);
3459
3460/**
Argyrios Kyrtzidis9d9bc012013-04-18 23:29:12 +00003461 * \brief 'Qualifiers' written next to the return and parameter types in
3462 * ObjC method declarations.
3463 */
3464typedef enum {
3465 CXObjCDeclQualifier_None = 0x0,
3466 CXObjCDeclQualifier_In = 0x1,
3467 CXObjCDeclQualifier_Inout = 0x2,
3468 CXObjCDeclQualifier_Out = 0x4,
3469 CXObjCDeclQualifier_Bycopy = 0x8,
3470 CXObjCDeclQualifier_Byref = 0x10,
3471 CXObjCDeclQualifier_Oneway = 0x20
3472} CXObjCDeclQualifierKind;
3473
3474/**
3475 * \brief Given a cursor that represents an ObjC method or parameter
3476 * declaration, return the associated ObjC qualifiers for the return type or the
Argyrios Kyrtzidis982934e2013-04-19 00:51:52 +00003477 * parameter respectively. The bits are formed from CXObjCDeclQualifierKind.
Argyrios Kyrtzidis9d9bc012013-04-18 23:29:12 +00003478 */
3479CINDEX_LINKAGE unsigned clang_Cursor_getObjCDeclQualifiers(CXCursor C);
3480
3481/**
Argyrios Kyrtzidis7b50fc52013-07-05 20:44:37 +00003482 * \brief Given a cursor that represents an ObjC method or property declaration,
3483 * return non-zero if the declaration was affected by "@optional".
3484 * Returns zero if the cursor is not such a declaration or it is "@required".
3485 */
3486CINDEX_LINKAGE unsigned clang_Cursor_isObjCOptional(CXCursor C);
3487
3488/**
Argyrios Kyrtzidis23814e42013-04-18 23:53:05 +00003489 * \brief Returns non-zero if the given cursor is a variadic function or method.
3490 */
3491CINDEX_LINKAGE unsigned clang_Cursor_isVariadic(CXCursor C);
3492
3493/**
Dmitri Gribenkoaab83832012-06-20 00:34:58 +00003494 * \brief Given a cursor that represents a declaration, return the associated
3495 * comment's source range. The range may include multiple consecutive comments
3496 * with whitespace in between.
3497 */
3498CINDEX_LINKAGE CXSourceRange clang_Cursor_getCommentRange(CXCursor C);
3499
3500/**
3501 * \brief Given a cursor that represents a declaration, return the associated
3502 * comment text, including comment markers.
3503 */
3504CINDEX_LINKAGE CXString clang_Cursor_getRawCommentText(CXCursor C);
3505
3506/**
Dmitri Gribenko5e4fe002012-07-20 21:34:34 +00003507 * \brief Given a cursor that represents a documentable entity (e.g.,
3508 * declaration), return the associated \\brief paragraph; otherwise return the
3509 * first paragraph.
Dmitri Gribenko5188c4b2012-06-26 20:39:18 +00003510 */
3511CINDEX_LINKAGE CXString clang_Cursor_getBriefCommentText(CXCursor C);
3512
3513/**
Dmitri Gribenko5e4fe002012-07-20 21:34:34 +00003514 * \brief Given a cursor that represents a documentable entity (e.g.,
3515 * declaration), return the associated parsed comment as a
3516 * \c CXComment_FullComment AST node.
3517 */
3518CINDEX_LINKAGE CXComment clang_Cursor_getParsedComment(CXCursor C);
3519
3520/**
3521 * @}
3522 */
3523
3524/**
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00003525 * \defgroup CINDEX_MODULE Module introspection
3526 *
3527 * The functions in this group provide access to information about modules.
3528 *
3529 * @{
3530 */
3531
3532typedef void *CXModule;
3533
3534/**
3535 * \brief Given a CXCursor_ModuleImportDecl cursor, return the associated module.
3536 */
3537CINDEX_LINKAGE CXModule clang_Cursor_getModule(CXCursor C);
3538
3539/**
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00003540 * \param Module a module object.
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00003541 *
Argyrios Kyrtzidis12fdb9e2013-04-26 22:47:49 +00003542 * \returns the module file where the provided module object came from.
3543 */
3544CINDEX_LINKAGE CXFile clang_Module_getASTFile(CXModule Module);
3545
3546/**
3547 * \param Module a module object.
3548 *
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00003549 * \returns the parent of a sub-module or NULL if the given module is top-level,
3550 * e.g. for 'std.vector' it will return the 'std' module.
3551 */
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00003552CINDEX_LINKAGE CXModule clang_Module_getParent(CXModule Module);
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00003553
3554/**
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00003555 * \param Module a module object.
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00003556 *
3557 * \returns the name of the module, e.g. for the 'std.vector' sub-module it
3558 * will return "vector".
3559 */
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00003560CINDEX_LINKAGE CXString clang_Module_getName(CXModule Module);
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00003561
3562/**
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00003563 * \param Module a module object.
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00003564 *
3565 * \returns the full name of the module, e.g. "std.vector".
3566 */
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00003567CINDEX_LINKAGE CXString clang_Module_getFullName(CXModule Module);
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00003568
3569/**
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00003570 * \param Module a module object.
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00003571 *
3572 * \returns the number of top level headers associated with this module.
3573 */
Argyrios Kyrtzidis3c5305c2013-03-13 21:13:43 +00003574CINDEX_LINKAGE unsigned clang_Module_getNumTopLevelHeaders(CXTranslationUnit,
3575 CXModule Module);
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00003576
3577/**
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00003578 * \param Module a module object.
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00003579 *
3580 * \param Index top level header index (zero-based).
3581 *
3582 * \returns the specified top level header associated with the module.
3583 */
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00003584CINDEX_LINKAGE
Argyrios Kyrtzidis3c5305c2013-03-13 21:13:43 +00003585CXFile clang_Module_getTopLevelHeader(CXTranslationUnit,
3586 CXModule Module, unsigned Index);
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00003587
3588/**
3589 * @}
3590 */
3591
3592/**
Dmitri Gribenko5e4fe002012-07-20 21:34:34 +00003593 * \defgroup CINDEX_COMMENT Comment AST introspection
3594 *
3595 * The routines in this group provide access to information in the
3596 * documentation comment ASTs.
3597 *
3598 * @{
3599 */
3600
3601/**
3602 * \brief Describes the type of the comment AST node (\c CXComment). A comment
3603 * node can be considered block content (e. g., paragraph), inline content
3604 * (plain text) or neither (the root AST node).
3605 */
3606enum CXCommentKind {
3607 /**
3608 * \brief Null comment. No AST node is constructed at the requested location
3609 * because there is no text or a syntax error.
3610 */
3611 CXComment_Null = 0,
3612
3613 /**
3614 * \brief Plain text. Inline content.
3615 */
3616 CXComment_Text = 1,
3617
3618 /**
3619 * \brief A command with word-like arguments that is considered inline content.
3620 *
3621 * For example: \\c command.
3622 */
3623 CXComment_InlineCommand = 2,
3624
3625 /**
3626 * \brief HTML start tag with attributes (name-value pairs). Considered
3627 * inline content.
3628 *
3629 * For example:
3630 * \verbatim
3631 * <br> <br /> <a href="http://example.org/">
3632 * \endverbatim
3633 */
3634 CXComment_HTMLStartTag = 3,
3635
3636 /**
3637 * \brief HTML end tag. Considered inline content.
3638 *
3639 * For example:
3640 * \verbatim
3641 * </a>
3642 * \endverbatim
3643 */
3644 CXComment_HTMLEndTag = 4,
3645
3646 /**
3647 * \brief A paragraph, contains inline comment. The paragraph itself is
3648 * block content.
3649 */
3650 CXComment_Paragraph = 5,
3651
3652 /**
3653 * \brief A command that has zero or more word-like arguments (number of
3654 * word-like arguments depends on command name) and a paragraph as an
3655 * argument. Block command is block content.
3656 *
3657 * Paragraph argument is also a child of the block command.
3658 *
3659 * For example: \\brief has 0 word-like arguments and a paragraph argument.
3660 *
3661 * AST nodes of special kinds that parser knows about (e. g., \\param
3662 * command) have their own node kinds.
3663 */
3664 CXComment_BlockCommand = 6,
3665
3666 /**
3667 * \brief A \\param or \\arg command that describes the function parameter
3668 * (name, passing direction, description).
3669 *
Dmitri Gribenkoadba9be2012-08-23 17:58:28 +00003670 * For example: \\param [in] ParamName description.
Dmitri Gribenko5e4fe002012-07-20 21:34:34 +00003671 */
3672 CXComment_ParamCommand = 7,
3673
3674 /**
Dmitri Gribenko34df2202012-07-31 22:37:06 +00003675 * \brief A \\tparam command that describes a template parameter (name and
3676 * description).
3677 *
Dmitri Gribenkoadba9be2012-08-23 17:58:28 +00003678 * For example: \\tparam T description.
Dmitri Gribenko34df2202012-07-31 22:37:06 +00003679 */
3680 CXComment_TParamCommand = 8,
3681
3682 /**
Dmitri Gribenko5e4fe002012-07-20 21:34:34 +00003683 * \brief A verbatim block command (e. g., preformatted code). Verbatim
3684 * block has an opening and a closing command and contains multiple lines of
3685 * text (\c CXComment_VerbatimBlockLine child nodes).
3686 *
3687 * For example:
3688 * \\verbatim
3689 * aaa
3690 * \\endverbatim
3691 */
Dmitri Gribenko34df2202012-07-31 22:37:06 +00003692 CXComment_VerbatimBlockCommand = 9,
Dmitri Gribenko5e4fe002012-07-20 21:34:34 +00003693
3694 /**
3695 * \brief A line of text that is contained within a
3696 * CXComment_VerbatimBlockCommand node.
3697 */
Dmitri Gribenko34df2202012-07-31 22:37:06 +00003698 CXComment_VerbatimBlockLine = 10,
Dmitri Gribenko5e4fe002012-07-20 21:34:34 +00003699
3700 /**
3701 * \brief A verbatim line command. Verbatim line has an opening command,
3702 * a single line of text (up to the newline after the opening command) and
3703 * has no closing command.
3704 */
Dmitri Gribenko34df2202012-07-31 22:37:06 +00003705 CXComment_VerbatimLine = 11,
Dmitri Gribenko5e4fe002012-07-20 21:34:34 +00003706
3707 /**
3708 * \brief A full comment attached to a declaration, contains block content.
3709 */
Dmitri Gribenko34df2202012-07-31 22:37:06 +00003710 CXComment_FullComment = 12
Dmitri Gribenko5e4fe002012-07-20 21:34:34 +00003711};
3712
3713/**
Dmitri Gribenkod73e4ce2012-07-23 16:43:01 +00003714 * \brief The most appropriate rendering mode for an inline command, chosen on
3715 * command semantics in Doxygen.
3716 */
3717enum CXCommentInlineCommandRenderKind {
3718 /**
3719 * \brief Command argument should be rendered in a normal font.
3720 */
3721 CXCommentInlineCommandRenderKind_Normal,
3722
3723 /**
3724 * \brief Command argument should be rendered in a bold font.
3725 */
3726 CXCommentInlineCommandRenderKind_Bold,
3727
3728 /**
3729 * \brief Command argument should be rendered in a monospaced font.
3730 */
3731 CXCommentInlineCommandRenderKind_Monospaced,
3732
3733 /**
3734 * \brief Command argument should be rendered emphasized (typically italic
3735 * font).
3736 */
3737 CXCommentInlineCommandRenderKind_Emphasized
3738};
3739
3740/**
Dmitri Gribenko5e4fe002012-07-20 21:34:34 +00003741 * \brief Describes parameter passing direction for \\param or \\arg command.
3742 */
3743enum CXCommentParamPassDirection {
3744 /**
3745 * \brief The parameter is an input parameter.
3746 */
3747 CXCommentParamPassDirection_In,
3748
3749 /**
3750 * \brief The parameter is an output parameter.
3751 */
3752 CXCommentParamPassDirection_Out,
3753
3754 /**
3755 * \brief The parameter is an input and output parameter.
3756 */
3757 CXCommentParamPassDirection_InOut
3758};
3759
3760/**
3761 * \param Comment AST node of any kind.
3762 *
3763 * \returns the type of the AST node.
3764 */
3765CINDEX_LINKAGE enum CXCommentKind clang_Comment_getKind(CXComment Comment);
3766
3767/**
3768 * \param Comment AST node of any kind.
3769 *
3770 * \returns number of children of the AST node.
3771 */
3772CINDEX_LINKAGE unsigned clang_Comment_getNumChildren(CXComment Comment);
3773
3774/**
3775 * \param Comment AST node of any kind.
3776 *
Dmitri Gribenkoadba9be2012-08-23 17:58:28 +00003777 * \param ChildIdx child index (zero-based).
Dmitri Gribenko5e4fe002012-07-20 21:34:34 +00003778 *
3779 * \returns the specified child of the AST node.
3780 */
3781CINDEX_LINKAGE
3782CXComment clang_Comment_getChild(CXComment Comment, unsigned ChildIdx);
3783
3784/**
3785 * \brief A \c CXComment_Paragraph node is considered whitespace if it contains
3786 * only \c CXComment_Text nodes that are empty or whitespace.
3787 *
3788 * Other AST nodes (except \c CXComment_Paragraph and \c CXComment_Text) are
3789 * never considered whitespace.
3790 *
3791 * \returns non-zero if \c Comment is whitespace.
3792 */
3793CINDEX_LINKAGE unsigned clang_Comment_isWhitespace(CXComment Comment);
3794
3795/**
3796 * \returns non-zero if \c Comment is inline content and has a newline
3797 * immediately following it in the comment text. Newlines between paragraphs
3798 * do not count.
3799 */
3800CINDEX_LINKAGE
3801unsigned clang_InlineContentComment_hasTrailingNewline(CXComment Comment);
3802
3803/**
3804 * \param Comment a \c CXComment_Text AST node.
3805 *
3806 * \returns text contained in the AST node.
3807 */
3808CINDEX_LINKAGE CXString clang_TextComment_getText(CXComment Comment);
3809
3810/**
3811 * \param Comment a \c CXComment_InlineCommand AST node.
3812 *
3813 * \returns name of the inline command.
3814 */
3815CINDEX_LINKAGE
3816CXString clang_InlineCommandComment_getCommandName(CXComment Comment);
3817
3818/**
3819 * \param Comment a \c CXComment_InlineCommand AST node.
3820 *
Dmitri Gribenkod73e4ce2012-07-23 16:43:01 +00003821 * \returns the most appropriate rendering mode, chosen on command
3822 * semantics in Doxygen.
3823 */
3824CINDEX_LINKAGE enum CXCommentInlineCommandRenderKind
3825clang_InlineCommandComment_getRenderKind(CXComment Comment);
3826
3827/**
3828 * \param Comment a \c CXComment_InlineCommand AST node.
3829 *
Dmitri Gribenko5e4fe002012-07-20 21:34:34 +00003830 * \returns number of command arguments.
3831 */
3832CINDEX_LINKAGE
3833unsigned clang_InlineCommandComment_getNumArgs(CXComment Comment);
3834
3835/**
3836 * \param Comment a \c CXComment_InlineCommand AST node.
3837 *
3838 * \param ArgIdx argument index (zero-based).
3839 *
3840 * \returns text of the specified argument.
3841 */
3842CINDEX_LINKAGE
3843CXString clang_InlineCommandComment_getArgText(CXComment Comment,
3844 unsigned ArgIdx);
3845
3846/**
3847 * \param Comment a \c CXComment_HTMLStartTag or \c CXComment_HTMLEndTag AST
3848 * node.
3849 *
3850 * \returns HTML tag name.
3851 */
3852CINDEX_LINKAGE CXString clang_HTMLTagComment_getTagName(CXComment Comment);
3853
3854/**
3855 * \param Comment a \c CXComment_HTMLStartTag AST node.
3856 *
3857 * \returns non-zero if tag is self-closing (for example, &lt;br /&gt;).
3858 */
3859CINDEX_LINKAGE
3860unsigned clang_HTMLStartTagComment_isSelfClosing(CXComment Comment);
3861
3862/**
3863 * \param Comment a \c CXComment_HTMLStartTag AST node.
3864 *
3865 * \returns number of attributes (name-value pairs) attached to the start tag.
3866 */
3867CINDEX_LINKAGE unsigned clang_HTMLStartTag_getNumAttrs(CXComment Comment);
3868
3869/**
3870 * \param Comment a \c CXComment_HTMLStartTag AST node.
3871 *
3872 * \param AttrIdx attribute index (zero-based).
3873 *
3874 * \returns name of the specified attribute.
3875 */
3876CINDEX_LINKAGE
3877CXString clang_HTMLStartTag_getAttrName(CXComment Comment, unsigned AttrIdx);
3878
3879/**
3880 * \param Comment a \c CXComment_HTMLStartTag AST node.
3881 *
3882 * \param AttrIdx attribute index (zero-based).
3883 *
3884 * \returns value of the specified attribute.
3885 */
3886CINDEX_LINKAGE
3887CXString clang_HTMLStartTag_getAttrValue(CXComment Comment, unsigned AttrIdx);
3888
3889/**
3890 * \param Comment a \c CXComment_BlockCommand AST node.
3891 *
3892 * \returns name of the block command.
3893 */
3894CINDEX_LINKAGE
3895CXString clang_BlockCommandComment_getCommandName(CXComment Comment);
3896
3897/**
3898 * \param Comment a \c CXComment_BlockCommand AST node.
3899 *
3900 * \returns number of word-like arguments.
3901 */
3902CINDEX_LINKAGE
3903unsigned clang_BlockCommandComment_getNumArgs(CXComment Comment);
3904
3905/**
3906 * \param Comment a \c CXComment_BlockCommand AST node.
3907 *
3908 * \param ArgIdx argument index (zero-based).
3909 *
3910 * \returns text of the specified word-like argument.
3911 */
3912CINDEX_LINKAGE
3913CXString clang_BlockCommandComment_getArgText(CXComment Comment,
3914 unsigned ArgIdx);
3915
3916/**
3917 * \param Comment a \c CXComment_BlockCommand or
3918 * \c CXComment_VerbatimBlockCommand AST node.
3919 *
3920 * \returns paragraph argument of the block command.
3921 */
3922CINDEX_LINKAGE
3923CXComment clang_BlockCommandComment_getParagraph(CXComment Comment);
3924
3925/**
3926 * \param Comment a \c CXComment_ParamCommand AST node.
3927 *
3928 * \returns parameter name.
3929 */
3930CINDEX_LINKAGE
3931CXString clang_ParamCommandComment_getParamName(CXComment Comment);
3932
3933/**
3934 * \param Comment a \c CXComment_ParamCommand AST node.
3935 *
3936 * \returns non-zero if the parameter that this AST node represents was found
3937 * in the function prototype and \c clang_ParamCommandComment_getParamIndex
3938 * function will return a meaningful value.
3939 */
3940CINDEX_LINKAGE
3941unsigned clang_ParamCommandComment_isParamIndexValid(CXComment Comment);
3942
3943/**
3944 * \param Comment a \c CXComment_ParamCommand AST node.
3945 *
3946 * \returns zero-based parameter index in function prototype.
3947 */
3948CINDEX_LINKAGE
3949unsigned clang_ParamCommandComment_getParamIndex(CXComment Comment);
3950
3951/**
3952 * \param Comment a \c CXComment_ParamCommand AST node.
3953 *
3954 * \returns non-zero if parameter passing direction was specified explicitly in
3955 * the comment.
3956 */
3957CINDEX_LINKAGE
3958unsigned clang_ParamCommandComment_isDirectionExplicit(CXComment Comment);
3959
3960/**
3961 * \param Comment a \c CXComment_ParamCommand AST node.
3962 *
3963 * \returns parameter passing direction.
3964 */
3965CINDEX_LINKAGE
3966enum CXCommentParamPassDirection clang_ParamCommandComment_getDirection(
3967 CXComment Comment);
3968
3969/**
Dmitri Gribenko34df2202012-07-31 22:37:06 +00003970 * \param Comment a \c CXComment_TParamCommand AST node.
3971 *
3972 * \returns template parameter name.
3973 */
3974CINDEX_LINKAGE
3975CXString clang_TParamCommandComment_getParamName(CXComment Comment);
3976
3977/**
3978 * \param Comment a \c CXComment_TParamCommand AST node.
3979 *
3980 * \returns non-zero if the parameter that this AST node represents was found
3981 * in the template parameter list and
3982 * \c clang_TParamCommandComment_getDepth and
3983 * \c clang_TParamCommandComment_getIndex functions will return a meaningful
3984 * value.
3985 */
3986CINDEX_LINKAGE
3987unsigned clang_TParamCommandComment_isParamPositionValid(CXComment Comment);
3988
3989/**
3990 * \param Comment a \c CXComment_TParamCommand AST node.
3991 *
3992 * \returns zero-based nesting depth of this parameter in the template parameter list.
3993 *
3994 * For example,
3995 * \verbatim
3996 * template<typename C, template<typename T> class TT>
3997 * void test(TT<int> aaa);
3998 * \endverbatim
3999 * for C and TT nesting depth is 0,
4000 * for T nesting depth is 1.
4001 */
4002CINDEX_LINKAGE
4003unsigned clang_TParamCommandComment_getDepth(CXComment Comment);
4004
4005/**
4006 * \param Comment a \c CXComment_TParamCommand AST node.
4007 *
4008 * \returns zero-based parameter index in the template parameter list at a
4009 * given nesting depth.
4010 *
4011 * For example,
4012 * \verbatim
4013 * template<typename C, template<typename T> class TT>
4014 * void test(TT<int> aaa);
4015 * \endverbatim
4016 * for C and TT nesting depth is 0, so we can ask for index at depth 0:
4017 * at depth 0 C's index is 0, TT's index is 1.
4018 *
4019 * For T nesting depth is 1, so we can ask for index at depth 0 and 1:
4020 * at depth 0 T's index is 1 (same as TT's),
4021 * at depth 1 T's index is 0.
4022 */
4023CINDEX_LINKAGE
4024unsigned clang_TParamCommandComment_getIndex(CXComment Comment, unsigned Depth);
4025
4026/**
Dmitri Gribenko5e4fe002012-07-20 21:34:34 +00004027 * \param Comment a \c CXComment_VerbatimBlockLine AST node.
4028 *
4029 * \returns text contained in the AST node.
4030 */
4031CINDEX_LINKAGE
4032CXString clang_VerbatimBlockLineComment_getText(CXComment Comment);
4033
4034/**
4035 * \param Comment a \c CXComment_VerbatimLine AST node.
4036 *
4037 * \returns text contained in the AST node.
4038 */
4039CINDEX_LINKAGE CXString clang_VerbatimLineComment_getText(CXComment Comment);
4040
4041/**
4042 * \brief Convert an HTML tag AST node to string.
4043 *
4044 * \param Comment a \c CXComment_HTMLStartTag or \c CXComment_HTMLEndTag AST
4045 * node.
4046 *
4047 * \returns string containing an HTML tag.
4048 */
4049CINDEX_LINKAGE CXString clang_HTMLTagComment_getAsString(CXComment Comment);
4050
4051/**
4052 * \brief Convert a given full parsed comment to an HTML fragment.
4053 *
4054 * Specific details of HTML layout are subject to change. Don't try to parse
4055 * this HTML back into an AST, use other APIs instead.
4056 *
4057 * Currently the following CSS classes are used:
4058 * \li "para-brief" for \\brief paragraph and equivalent commands;
4059 * \li "para-returns" for \\returns paragraph and equivalent commands;
4060 * \li "word-returns" for the "Returns" word in \\returns paragraph.
4061 *
Dmitri Gribenko4c6d7a22012-07-21 01:47:43 +00004062 * Function argument documentation is rendered as a \<dl\> list with arguments
4063 * sorted in function prototype order. CSS classes used:
4064 * \li "param-name-index-NUMBER" for parameter name (\<dt\>);
4065 * \li "param-descr-index-NUMBER" for parameter description (\<dd\>);
4066 * \li "param-name-index-invalid" and "param-descr-index-invalid" are used if
4067 * parameter index is invalid.
Dmitri Gribenko5e4fe002012-07-20 21:34:34 +00004068 *
Dmitri Gribenko34df2202012-07-31 22:37:06 +00004069 * Template parameter documentation is rendered as a \<dl\> list with
4070 * parameters sorted in template parameter list order. CSS classes used:
4071 * \li "tparam-name-index-NUMBER" for parameter name (\<dt\>);
4072 * \li "tparam-descr-index-NUMBER" for parameter description (\<dd\>);
Dmitri Gribenko58e41312012-08-01 23:47:30 +00004073 * \li "tparam-name-index-other" and "tparam-descr-index-other" are used for
Dmitri Gribenko34df2202012-07-31 22:37:06 +00004074 * names inside template template parameters;
4075 * \li "tparam-name-index-invalid" and "tparam-descr-index-invalid" are used if
4076 * parameter position is invalid.
4077 *
Dmitri Gribenko5e4fe002012-07-20 21:34:34 +00004078 * \param Comment a \c CXComment_FullComment AST node.
4079 *
4080 * \returns string containing an HTML fragment.
4081 */
4082CINDEX_LINKAGE CXString clang_FullComment_getAsHTML(CXComment Comment);
4083
4084/**
Dmitri Gribenko740c0fb2012-08-07 17:54:38 +00004085 * \brief Convert a given full parsed comment to an XML document.
4086 *
4087 * A Relax NG schema for the XML can be found in comment-xml-schema.rng file
4088 * inside clang source tree.
4089 *
Dmitri Gribenko740c0fb2012-08-07 17:54:38 +00004090 * \param Comment a \c CXComment_FullComment AST node.
4091 *
4092 * \returns string containing an XML document.
4093 */
Dmitri Gribenko7acbf002012-09-10 20:32:42 +00004094CINDEX_LINKAGE CXString clang_FullComment_getAsXML(CXComment Comment);
Dmitri Gribenko740c0fb2012-08-07 17:54:38 +00004095
4096/**
Douglas Gregor6007cf22010-01-22 22:29:16 +00004097 * @}
4098 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004099
Douglas Gregor6007cf22010-01-22 22:29:16 +00004100/**
Ted Kremenek9cfe9e62010-05-17 20:06:56 +00004101 * \defgroup CINDEX_CPP C++ AST introspection
4102 *
4103 * The routines in this group provide access information in the ASTs specific
4104 * to C++ language features.
4105 *
4106 * @{
4107 */
4108
4109/**
Dmitri Gribenko62770be2013-05-17 18:38:35 +00004110 * \brief Determine if a C++ member function or member function template is
4111 * pure virtual.
4112 */
4113CINDEX_LINKAGE unsigned clang_CXXMethod_isPureVirtual(CXCursor C);
4114
4115/**
Douglas Gregorf11309e2010-08-31 22:12:17 +00004116 * \brief Determine if a C++ member function or member function template is
4117 * declared 'static'.
Ted Kremenek9cfe9e62010-05-17 20:06:56 +00004118 */
4119CINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C);
4120
4121/**
Douglas Gregor9519d922011-05-12 15:17:24 +00004122 * \brief Determine if a C++ member function or member function template is
4123 * explicitly declared 'virtual' or if it overrides a virtual method from
4124 * one of the base classes.
4125 */
4126CINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual(CXCursor C);
4127
4128/**
Douglas Gregorf11309e2010-08-31 22:12:17 +00004129 * \brief Given a cursor that represents a template, determine
4130 * the cursor kind of the specializations would be generated by instantiating
4131 * the template.
4132 *
4133 * This routine can be used to determine what flavor of function template,
4134 * class template, or class template partial specialization is stored in the
4135 * cursor. For example, it can describe whether a class template cursor is
4136 * declared with "struct", "class" or "union".
4137 *
4138 * \param C The cursor to query. This cursor should represent a template
4139 * declaration.
4140 *
4141 * \returns The cursor kind of the specializations that would be generated
4142 * by instantiating the template \p C. If \p C is not a template, returns
4143 * \c CXCursor_NoDeclFound.
4144 */
4145CINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind(CXCursor C);
4146
4147/**
Douglas Gregord3f48bd2010-09-02 00:07:54 +00004148 * \brief Given a cursor that may represent a specialization or instantiation
4149 * of a template, retrieve the cursor that represents the template that it
4150 * specializes or from which it was instantiated.
4151 *
4152 * This routine determines the template involved both for explicit
4153 * specializations of templates and for implicit instantiations of the template,
4154 * both of which are referred to as "specializations". For a class template
4155 * specialization (e.g., \c std::vector<bool>), this routine will return
4156 * either the primary template (\c std::vector) or, if the specialization was
4157 * instantiated from a class template partial specialization, the class template
4158 * partial specialization. For a class template partial specialization and a
4159 * function template specialization (including instantiations), this
4160 * this routine will return the specialized template.
4161 *
4162 * For members of a class template (e.g., member functions, member classes, or
4163 * static data members), returns the specialized or instantiated member.
4164 * Although not strictly "templates" in the C++ language, members of class
4165 * templates have the same notions of specializations and instantiations that
4166 * templates do, so this routine treats them similarly.
4167 *
4168 * \param C A cursor that may be a specialization of a template or a member
4169 * of a template.
4170 *
4171 * \returns If the given cursor is a specialization or instantiation of a
4172 * template or a member thereof, the template or member that it specializes or
4173 * from which it was instantiated. Otherwise, returns a NULL cursor.
4174 */
4175CINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate(CXCursor C);
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004176
4177/**
4178 * \brief Given a cursor that references something else, return the source range
4179 * covering that reference.
4180 *
4181 * \param C A cursor pointing to a member reference, a declaration reference, or
4182 * an operator call.
4183 * \param NameFlags A bitset with three independent flags:
4184 * CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and
4185 * CXNameRange_WantSinglePiece.
4186 * \param PieceIndex For contiguous names or when passing the flag
4187 * CXNameRange_WantSinglePiece, only one piece with index 0 is
4188 * available. When the CXNameRange_WantSinglePiece flag is not passed for a
Benjamin Kramer474261a2012-06-02 10:20:41 +00004189 * non-contiguous names, this index can be used to retrieve the individual
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004190 * pieces of the name. See also CXNameRange_WantSinglePiece.
4191 *
4192 * \returns The piece of the name pointed to by the given cursor. If there is no
4193 * name, or if the PieceIndex is out-of-range, a null-cursor will be returned.
4194 */
Francois Pichetece689f2011-07-25 22:00:44 +00004195CINDEX_LINKAGE CXSourceRange clang_getCursorReferenceNameRange(CXCursor C,
4196 unsigned NameFlags,
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004197 unsigned PieceIndex);
4198
4199enum CXNameRefFlags {
4200 /**
4201 * \brief Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the
4202 * range.
4203 */
4204 CXNameRange_WantQualifier = 0x1,
4205
4206 /**
James Dennett574cb4c2012-06-15 05:41:51 +00004207 * \brief Include the explicit template arguments, e.g. \<int> in x.f<int>,
4208 * in the range.
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004209 */
4210 CXNameRange_WantTemplateArgs = 0x2,
4211
4212 /**
4213 * \brief If the name is non-contiguous, return the full spanning range.
4214 *
4215 * Non-contiguous names occur in Objective-C when a selector with two or more
4216 * parameters is used, or in C++ when using an operator:
4217 * \code
4218 * [object doSomething:here withValue:there]; // ObjC
4219 * return some_vector[1]; // C++
4220 * \endcode
4221 */
4222 CXNameRange_WantSinglePiece = 0x4
4223};
Douglas Gregord3f48bd2010-09-02 00:07:54 +00004224
4225/**
Ted Kremenek9cfe9e62010-05-17 20:06:56 +00004226 * @}
4227 */
4228
4229/**
Douglas Gregor61656112010-01-26 18:31:56 +00004230 * \defgroup CINDEX_LEX Token extraction and manipulation
4231 *
4232 * The routines in this group provide access to the tokens within a
4233 * translation unit, along with a semantic mapping of those tokens to
4234 * their corresponding cursors.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004235 *
4236 * @{
4237 */
4238
4239/**
4240 * \brief Describes a kind of token.
4241 */
4242typedef enum CXTokenKind {
4243 /**
4244 * \brief A token that contains some kind of punctuation.
4245 */
4246 CXToken_Punctuation,
Ted Kremenekd071c602010-03-13 02:50:34 +00004247
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004248 /**
Douglas Gregor61656112010-01-26 18:31:56 +00004249 * \brief A language keyword.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004250 */
4251 CXToken_Keyword,
Ted Kremenekd071c602010-03-13 02:50:34 +00004252
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004253 /**
4254 * \brief An identifier (that is not a keyword).
4255 */
4256 CXToken_Identifier,
Ted Kremenekd071c602010-03-13 02:50:34 +00004257
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004258 /**
4259 * \brief A numeric, string, or character literal.
4260 */
4261 CXToken_Literal,
Ted Kremenekd071c602010-03-13 02:50:34 +00004262
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004263 /**
4264 * \brief A comment.
4265 */
4266 CXToken_Comment
4267} CXTokenKind;
4268
4269/**
4270 * \brief Describes a single preprocessing token.
4271 */
4272typedef struct {
4273 unsigned int_data[4];
4274 void *ptr_data;
4275} CXToken;
4276
4277/**
4278 * \brief Determine the kind of the given token.
4279 */
4280CINDEX_LINKAGE CXTokenKind clang_getTokenKind(CXToken);
Ted Kremenekd071c602010-03-13 02:50:34 +00004281
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004282/**
4283 * \brief Determine the spelling of the given token.
4284 *
4285 * The spelling of a token is the textual representation of that token, e.g.,
4286 * the text of an identifier or keyword.
4287 */
4288CINDEX_LINKAGE CXString clang_getTokenSpelling(CXTranslationUnit, CXToken);
Ted Kremenekd071c602010-03-13 02:50:34 +00004289
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004290/**
4291 * \brief Retrieve the source location of the given token.
4292 */
Ted Kremenekd071c602010-03-13 02:50:34 +00004293CINDEX_LINKAGE CXSourceLocation clang_getTokenLocation(CXTranslationUnit,
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004294 CXToken);
Ted Kremenekd071c602010-03-13 02:50:34 +00004295
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004296/**
4297 * \brief Retrieve a source range that covers the given token.
4298 */
4299CINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken);
4300
4301/**
4302 * \brief Tokenize the source code described by the given range into raw
4303 * lexical tokens.
4304 *
4305 * \param TU the translation unit whose text is being tokenized.
4306 *
4307 * \param Range the source range in which text should be tokenized. All of the
4308 * tokens produced by tokenization will fall within this source range,
4309 *
4310 * \param Tokens this pointer will be set to point to the array of tokens
4311 * that occur within the given source range. The returned pointer must be
4312 * freed with clang_disposeTokens() before the translation unit is destroyed.
4313 *
4314 * \param NumTokens will be set to the number of tokens in the \c *Tokens
4315 * array.
4316 *
4317 */
4318CINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
4319 CXToken **Tokens, unsigned *NumTokens);
Ted Kremenekd071c602010-03-13 02:50:34 +00004320
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004321/**
4322 * \brief Annotate the given set of tokens by providing cursors for each token
4323 * that can be mapped to a specific entity within the abstract syntax tree.
4324 *
Douglas Gregor61656112010-01-26 18:31:56 +00004325 * This token-annotation routine is equivalent to invoking
4326 * clang_getCursor() for the source locations of each of the
4327 * tokens. The cursors provided are filtered, so that only those
4328 * cursors that have a direct correspondence to the token are
4329 * accepted. For example, given a function call \c f(x),
4330 * clang_getCursor() would provide the following cursors:
4331 *
4332 * * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'.
4333 * * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'.
4334 * * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'.
4335 *
4336 * Only the first and last of these cursors will occur within the
4337 * annotate, since the tokens "f" and "x' directly refer to a function
4338 * and a variable, respectively, but the parentheses are just a small
4339 * part of the full syntax of the function call expression, which is
4340 * not provided as an annotation.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004341 *
4342 * \param TU the translation unit that owns the given tokens.
4343 *
4344 * \param Tokens the set of tokens to annotate.
4345 *
4346 * \param NumTokens the number of tokens in \p Tokens.
4347 *
4348 * \param Cursors an array of \p NumTokens cursors, whose contents will be
4349 * replaced with the cursors corresponding to each token.
4350 */
4351CINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU,
4352 CXToken *Tokens, unsigned NumTokens,
4353 CXCursor *Cursors);
Ted Kremenekd071c602010-03-13 02:50:34 +00004354
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004355/**
4356 * \brief Free the given set of tokens.
4357 */
Ted Kremenekd071c602010-03-13 02:50:34 +00004358CINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU,
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004359 CXToken *Tokens, unsigned NumTokens);
Ted Kremenekd071c602010-03-13 02:50:34 +00004360
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004361/**
4362 * @}
4363 */
Ted Kremenekd071c602010-03-13 02:50:34 +00004364
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004365/**
Douglas Gregor6007cf22010-01-22 22:29:16 +00004366 * \defgroup CINDEX_DEBUG Debugging facilities
4367 *
4368 * These routines are used for testing and debugging, only, and should not
4369 * be relied upon.
4370 *
4371 * @{
4372 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004373
Steve Naroff76b8f132009-09-23 17:52:52 +00004374/* for debug/testing */
Ted Kremenek29004672010-02-17 00:41:32 +00004375CINDEX_LINKAGE CXString clang_getCursorKindSpelling(enum CXCursorKind Kind);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004376CINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(CXCursor,
4377 const char **startBuf,
Steve Naroff76b8f132009-09-23 17:52:52 +00004378 const char **endBuf,
4379 unsigned *startLine,
4380 unsigned *startColumn,
4381 unsigned *endLine,
4382 unsigned *endColumn);
Douglas Gregor1e21cc72010-02-18 23:07:20 +00004383CINDEX_LINKAGE void clang_enableStackTraces(void);
Daniel Dunbar23420652010-11-04 01:26:29 +00004384CINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void*), void *user_data,
4385 unsigned stack_size);
4386
Douglas Gregor9eb77012009-11-07 00:00:49 +00004387/**
Douglas Gregor6007cf22010-01-22 22:29:16 +00004388 * @}
4389 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004390
Douglas Gregor6007cf22010-01-22 22:29:16 +00004391/**
4392 * \defgroup CINDEX_CODE_COMPLET Code completion
4393 *
4394 * Code completion involves taking an (incomplete) source file, along with
4395 * knowledge of where the user is actively editing that file, and suggesting
4396 * syntactically- and semantically-valid constructs that the user might want to
4397 * use at that particular point in the source code. These data structures and
4398 * routines provide support for code completion.
4399 *
4400 * @{
4401 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004402
Douglas Gregor6007cf22010-01-22 22:29:16 +00004403/**
Douglas Gregor9eb77012009-11-07 00:00:49 +00004404 * \brief A semantic string that describes a code-completion result.
4405 *
4406 * A semantic string that describes the formatting of a code-completion
4407 * result as a single "template" of text that should be inserted into the
4408 * source buffer when a particular code-completion result is selected.
4409 * Each semantic string is made up of some number of "chunks", each of which
4410 * contains some text along with a description of what that text means, e.g.,
4411 * the name of the entity being referenced, whether the text chunk is part of
4412 * the template, or whether it is a "placeholder" that the user should replace
4413 * with actual code,of a specific kind. See \c CXCompletionChunkKind for a
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004414 * description of the different kinds of chunks.
Douglas Gregor9eb77012009-11-07 00:00:49 +00004415 */
4416typedef void *CXCompletionString;
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004417
Douglas Gregor9eb77012009-11-07 00:00:49 +00004418/**
4419 * \brief A single result of code completion.
4420 */
4421typedef struct {
4422 /**
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004423 * \brief The kind of entity that this completion refers to.
Douglas Gregor9eb77012009-11-07 00:00:49 +00004424 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004425 * The cursor kind will be a macro, keyword, or a declaration (one of the
Douglas Gregor9eb77012009-11-07 00:00:49 +00004426 * *Decl cursor kinds), describing the entity that the completion is
4427 * referring to.
4428 *
4429 * \todo In the future, we would like to provide a full cursor, to allow
4430 * the client to extract additional information from declaration.
4431 */
4432 enum CXCursorKind CursorKind;
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004433
4434 /**
Douglas Gregor9eb77012009-11-07 00:00:49 +00004435 * \brief The code-completion string that describes how to insert this
4436 * code-completion result into the editing buffer.
4437 */
4438 CXCompletionString CompletionString;
4439} CXCompletionResult;
4440
4441/**
4442 * \brief Describes a single piece of text within a code-completion string.
4443 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004444 * Each "chunk" within a code-completion string (\c CXCompletionString) is
4445 * either a piece of text with a specific "kind" that describes how that text
Douglas Gregor9eb77012009-11-07 00:00:49 +00004446 * should be interpreted by the client or is another completion string.
4447 */
4448enum CXCompletionChunkKind {
4449 /**
4450 * \brief A code-completion string that describes "optional" text that
4451 * could be a part of the template (but is not required).
4452 *
4453 * The Optional chunk is the only kind of chunk that has a code-completion
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004454 * string for its representation, which is accessible via
Douglas Gregor9eb77012009-11-07 00:00:49 +00004455 * \c clang_getCompletionChunkCompletionString(). The code-completion string
4456 * describes an additional part of the template that is completely optional.
4457 * For example, optional chunks can be used to describe the placeholders for
4458 * arguments that match up with defaulted function parameters, e.g. given:
4459 *
4460 * \code
4461 * void f(int x, float y = 3.14, double z = 2.71828);
4462 * \endcode
4463 *
4464 * The code-completion string for this function would contain:
4465 * - a TypedText chunk for "f".
4466 * - a LeftParen chunk for "(".
4467 * - a Placeholder chunk for "int x"
4468 * - an Optional chunk containing the remaining defaulted arguments, e.g.,
4469 * - a Comma chunk for ","
Daniel Dunbar4053fae2010-02-17 08:07:44 +00004470 * - a Placeholder chunk for "float y"
Douglas Gregor9eb77012009-11-07 00:00:49 +00004471 * - an Optional chunk containing the last defaulted argument:
4472 * - a Comma chunk for ","
4473 * - a Placeholder chunk for "double z"
4474 * - a RightParen chunk for ")"
4475 *
Daniel Dunbar4053fae2010-02-17 08:07:44 +00004476 * There are many ways to handle Optional chunks. Two simple approaches are:
Douglas Gregor9eb77012009-11-07 00:00:49 +00004477 * - Completely ignore optional chunks, in which case the template for the
4478 * function "f" would only include the first parameter ("int x").
4479 * - Fully expand all optional chunks, in which case the template for the
4480 * function "f" would have all of the parameters.
4481 */
4482 CXCompletionChunk_Optional,
4483 /**
4484 * \brief Text that a user would be expected to type to get this
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004485 * code-completion result.
Douglas Gregor9eb77012009-11-07 00:00:49 +00004486 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004487 * There will be exactly one "typed text" chunk in a semantic string, which
4488 * will typically provide the spelling of a keyword or the name of a
Douglas Gregor9eb77012009-11-07 00:00:49 +00004489 * declaration that could be used at the current code point. Clients are
4490 * expected to filter the code-completion results based on the text in this
4491 * chunk.
4492 */
4493 CXCompletionChunk_TypedText,
4494 /**
4495 * \brief Text that should be inserted as part of a code-completion result.
4496 *
4497 * A "text" chunk represents text that is part of the template to be
4498 * inserted into user code should this particular code-completion result
4499 * be selected.
4500 */
4501 CXCompletionChunk_Text,
4502 /**
4503 * \brief Placeholder text that should be replaced by the user.
4504 *
4505 * A "placeholder" chunk marks a place where the user should insert text
4506 * into the code-completion template. For example, placeholders might mark
4507 * the function parameters for a function declaration, to indicate that the
4508 * user should provide arguments for each of those parameters. The actual
4509 * text in a placeholder is a suggestion for the text to display before
4510 * the user replaces the placeholder with real code.
4511 */
4512 CXCompletionChunk_Placeholder,
4513 /**
4514 * \brief Informative text that should be displayed but never inserted as
4515 * part of the template.
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004516 *
Douglas Gregor9eb77012009-11-07 00:00:49 +00004517 * An "informative" chunk contains annotations that can be displayed to
4518 * help the user decide whether a particular code-completion result is the
4519 * right option, but which is not part of the actual template to be inserted
4520 * by code completion.
4521 */
4522 CXCompletionChunk_Informative,
4523 /**
4524 * \brief Text that describes the current parameter when code-completion is
4525 * referring to function call, message send, or template specialization.
4526 *
4527 * A "current parameter" chunk occurs when code-completion is providing
4528 * information about a parameter corresponding to the argument at the
4529 * code-completion point. For example, given a function
4530 *
4531 * \code
4532 * int add(int x, int y);
4533 * \endcode
4534 *
4535 * and the source code \c add(, where the code-completion point is after the
4536 * "(", the code-completion string will contain a "current parameter" chunk
4537 * for "int x", indicating that the current argument will initialize that
4538 * parameter. After typing further, to \c add(17, (where the code-completion
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004539 * point is after the ","), the code-completion string will contain a
Douglas Gregor9eb77012009-11-07 00:00:49 +00004540 * "current paremeter" chunk to "int y".
4541 */
4542 CXCompletionChunk_CurrentParameter,
4543 /**
4544 * \brief A left parenthesis ('('), used to initiate a function call or
4545 * signal the beginning of a function parameter list.
4546 */
4547 CXCompletionChunk_LeftParen,
4548 /**
4549 * \brief A right parenthesis (')'), used to finish a function call or
4550 * signal the end of a function parameter list.
4551 */
4552 CXCompletionChunk_RightParen,
4553 /**
4554 * \brief A left bracket ('[').
4555 */
4556 CXCompletionChunk_LeftBracket,
4557 /**
4558 * \brief A right bracket (']').
4559 */
4560 CXCompletionChunk_RightBracket,
4561 /**
4562 * \brief A left brace ('{').
4563 */
4564 CXCompletionChunk_LeftBrace,
4565 /**
4566 * \brief A right brace ('}').
4567 */
4568 CXCompletionChunk_RightBrace,
4569 /**
4570 * \brief A left angle bracket ('<').
4571 */
4572 CXCompletionChunk_LeftAngle,
4573 /**
4574 * \brief A right angle bracket ('>').
4575 */
4576 CXCompletionChunk_RightAngle,
4577 /**
4578 * \brief A comma separator (',').
4579 */
Douglas Gregorb3fa9192009-12-18 18:53:37 +00004580 CXCompletionChunk_Comma,
4581 /**
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004582 * \brief Text that specifies the result type of a given result.
Douglas Gregorb3fa9192009-12-18 18:53:37 +00004583 *
4584 * This special kind of informative chunk is not meant to be inserted into
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004585 * the text buffer. Rather, it is meant to illustrate the type that an
Douglas Gregorb3fa9192009-12-18 18:53:37 +00004586 * expression using the given completion string would have.
4587 */
Douglas Gregor504a6ae2010-01-10 23:08:15 +00004588 CXCompletionChunk_ResultType,
4589 /**
4590 * \brief A colon (':').
4591 */
4592 CXCompletionChunk_Colon,
4593 /**
4594 * \brief A semicolon (';').
4595 */
4596 CXCompletionChunk_SemiColon,
4597 /**
4598 * \brief An '=' sign.
4599 */
4600 CXCompletionChunk_Equal,
4601 /**
4602 * Horizontal space (' ').
4603 */
4604 CXCompletionChunk_HorizontalSpace,
4605 /**
4606 * Vertical space ('\n'), after which it is generally a good idea to
4607 * perform indentation.
4608 */
4609 CXCompletionChunk_VerticalSpace
Douglas Gregor9eb77012009-11-07 00:00:49 +00004610};
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004611
Douglas Gregor9eb77012009-11-07 00:00:49 +00004612/**
4613 * \brief Determine the kind of a particular chunk within a completion string.
4614 *
4615 * \param completion_string the completion string to query.
4616 *
4617 * \param chunk_number the 0-based index of the chunk in the completion string.
4618 *
4619 * \returns the kind of the chunk at the index \c chunk_number.
4620 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004621CINDEX_LINKAGE enum CXCompletionChunkKind
Douglas Gregor9eb77012009-11-07 00:00:49 +00004622clang_getCompletionChunkKind(CXCompletionString completion_string,
4623 unsigned chunk_number);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004624
Douglas Gregor9eb77012009-11-07 00:00:49 +00004625/**
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004626 * \brief Retrieve the text associated with a particular chunk within a
Douglas Gregor9eb77012009-11-07 00:00:49 +00004627 * completion string.
4628 *
4629 * \param completion_string the completion string to query.
4630 *
4631 * \param chunk_number the 0-based index of the chunk in the completion string.
4632 *
4633 * \returns the text associated with the chunk at index \c chunk_number.
4634 */
Ted Kremenekf602f962010-02-17 01:42:24 +00004635CINDEX_LINKAGE CXString
Douglas Gregor9eb77012009-11-07 00:00:49 +00004636clang_getCompletionChunkText(CXCompletionString completion_string,
4637 unsigned chunk_number);
4638
4639/**
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004640 * \brief Retrieve the completion string associated with a particular chunk
Douglas Gregor9eb77012009-11-07 00:00:49 +00004641 * within a completion string.
4642 *
4643 * \param completion_string the completion string to query.
4644 *
4645 * \param chunk_number the 0-based index of the chunk in the completion string.
4646 *
4647 * \returns the completion string associated with the chunk at index
Erik Verbruggen98ea7f62011-10-14 15:31:08 +00004648 * \c chunk_number.
Douglas Gregor9eb77012009-11-07 00:00:49 +00004649 */
4650CINDEX_LINKAGE CXCompletionString
4651clang_getCompletionChunkCompletionString(CXCompletionString completion_string,
4652 unsigned chunk_number);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004653
Douglas Gregor9eb77012009-11-07 00:00:49 +00004654/**
4655 * \brief Retrieve the number of chunks in the given code-completion string.
4656 */
4657CINDEX_LINKAGE unsigned
4658clang_getNumCompletionChunks(CXCompletionString completion_string);
4659
4660/**
Douglas Gregora2db7932010-05-26 22:00:08 +00004661 * \brief Determine the priority of this code completion.
4662 *
4663 * The priority of a code completion indicates how likely it is that this
4664 * particular completion is the completion that the user will select. The
4665 * priority is selected by various internal heuristics.
4666 *
4667 * \param completion_string The completion string to query.
4668 *
4669 * \returns The priority of this completion string. Smaller values indicate
4670 * higher-priority (more likely) completions.
4671 */
4672CINDEX_LINKAGE unsigned
4673clang_getCompletionPriority(CXCompletionString completion_string);
4674
4675/**
Douglas Gregorf757a122010-08-23 23:00:57 +00004676 * \brief Determine the availability of the entity that this code-completion
4677 * string refers to.
4678 *
4679 * \param completion_string The completion string to query.
4680 *
4681 * \returns The availability of the completion string.
4682 */
4683CINDEX_LINKAGE enum CXAvailabilityKind
4684clang_getCompletionAvailability(CXCompletionString completion_string);
4685
4686/**
Erik Verbruggen98ea7f62011-10-14 15:31:08 +00004687 * \brief Retrieve the number of annotations associated with the given
4688 * completion string.
4689 *
4690 * \param completion_string the completion string to query.
4691 *
4692 * \returns the number of annotations associated with the given completion
4693 * string.
4694 */
4695CINDEX_LINKAGE unsigned
4696clang_getCompletionNumAnnotations(CXCompletionString completion_string);
4697
4698/**
4699 * \brief Retrieve the annotation associated with the given completion string.
4700 *
4701 * \param completion_string the completion string to query.
4702 *
4703 * \param annotation_number the 0-based index of the annotation of the
4704 * completion string.
4705 *
4706 * \returns annotation string associated with the completion at index
4707 * \c annotation_number, or a NULL string if that annotation is not available.
4708 */
4709CINDEX_LINKAGE CXString
4710clang_getCompletionAnnotation(CXCompletionString completion_string,
4711 unsigned annotation_number);
4712
4713/**
Douglas Gregor78254c82012-03-27 23:34:16 +00004714 * \brief Retrieve the parent context of the given completion string.
4715 *
4716 * The parent context of a completion string is the semantic parent of
4717 * the declaration (if any) that the code completion represents. For example,
4718 * a code completion for an Objective-C method would have the method's class
4719 * or protocol as its context.
4720 *
4721 * \param completion_string The code completion string whose parent is
4722 * being queried.
4723 *
Argyrios Kyrtzidis9ae39562012-09-26 16:39:56 +00004724 * \param kind DEPRECATED: always set to CXCursor_NotImplemented if non-NULL.
Douglas Gregor78254c82012-03-27 23:34:16 +00004725 *
James Dennett574cb4c2012-06-15 05:41:51 +00004726 * \returns The name of the completion parent, e.g., "NSObject" if
Douglas Gregor78254c82012-03-27 23:34:16 +00004727 * the completion string represents a method in the NSObject class.
4728 */
4729CINDEX_LINKAGE CXString
4730clang_getCompletionParent(CXCompletionString completion_string,
4731 enum CXCursorKind *kind);
Dmitri Gribenko3292d062012-07-02 17:35:10 +00004732
4733/**
4734 * \brief Retrieve the brief documentation comment attached to the declaration
4735 * that corresponds to the given completion string.
4736 */
4737CINDEX_LINKAGE CXString
4738clang_getCompletionBriefComment(CXCompletionString completion_string);
4739
Douglas Gregor78254c82012-03-27 23:34:16 +00004740/**
Douglas Gregor3f35bb22011-08-04 20:04:59 +00004741 * \brief Retrieve a completion string for an arbitrary declaration or macro
4742 * definition cursor.
4743 *
4744 * \param cursor The cursor to query.
4745 *
4746 * \returns A non-context-sensitive completion string for declaration and macro
4747 * definition cursors, or NULL for other kinds of cursors.
4748 */
4749CINDEX_LINKAGE CXCompletionString
4750clang_getCursorCompletionString(CXCursor cursor);
4751
4752/**
Douglas Gregorf72b6ac2009-12-18 16:20:58 +00004753 * \brief Contains the results of code-completion.
4754 *
4755 * This data structure contains the results of code completion, as
Douglas Gregor6a9580282010-10-11 21:51:20 +00004756 * produced by \c clang_codeCompleteAt(). Its contents must be freed by
Douglas Gregorf72b6ac2009-12-18 16:20:58 +00004757 * \c clang_disposeCodeCompleteResults.
4758 */
4759typedef struct {
4760 /**
4761 * \brief The code-completion results.
4762 */
4763 CXCompletionResult *Results;
4764
4765 /**
4766 * \brief The number of code-completion results stored in the
4767 * \c Results array.
4768 */
4769 unsigned NumResults;
4770} CXCodeCompleteResults;
4771
4772/**
Douglas Gregorb68bc592010-08-05 09:09:23 +00004773 * \brief Flags that can be passed to \c clang_codeCompleteAt() to
4774 * modify its behavior.
4775 *
4776 * The enumerators in this enumeration can be bitwise-OR'd together to
4777 * provide multiple options to \c clang_codeCompleteAt().
4778 */
4779enum CXCodeComplete_Flags {
4780 /**
4781 * \brief Whether to include macros within the set of code
4782 * completions returned.
4783 */
4784 CXCodeComplete_IncludeMacros = 0x01,
4785
4786 /**
4787 * \brief Whether to include code patterns for language constructs
4788 * within the set of code completions, e.g., for loops.
4789 */
Dmitri Gribenko3292d062012-07-02 17:35:10 +00004790 CXCodeComplete_IncludeCodePatterns = 0x02,
4791
4792 /**
4793 * \brief Whether to include brief documentation within the set of code
4794 * completions returned.
4795 */
4796 CXCodeComplete_IncludeBriefComments = 0x04
Douglas Gregorb68bc592010-08-05 09:09:23 +00004797};
4798
4799/**
Douglas Gregor21325842011-07-07 16:03:39 +00004800 * \brief Bits that represent the context under which completion is occurring.
4801 *
4802 * The enumerators in this enumeration may be bitwise-OR'd together if multiple
4803 * contexts are occurring simultaneously.
4804 */
4805enum CXCompletionContext {
4806 /**
4807 * \brief The context for completions is unexposed, as only Clang results
4808 * should be included. (This is equivalent to having no context bits set.)
4809 */
4810 CXCompletionContext_Unexposed = 0,
4811
4812 /**
4813 * \brief Completions for any possible type should be included in the results.
4814 */
4815 CXCompletionContext_AnyType = 1 << 0,
4816
4817 /**
4818 * \brief Completions for any possible value (variables, function calls, etc.)
4819 * should be included in the results.
4820 */
4821 CXCompletionContext_AnyValue = 1 << 1,
4822 /**
4823 * \brief Completions for values that resolve to an Objective-C object should
4824 * be included in the results.
4825 */
4826 CXCompletionContext_ObjCObjectValue = 1 << 2,
4827 /**
4828 * \brief Completions for values that resolve to an Objective-C selector
4829 * should be included in the results.
4830 */
4831 CXCompletionContext_ObjCSelectorValue = 1 << 3,
4832 /**
4833 * \brief Completions for values that resolve to a C++ class type should be
4834 * included in the results.
4835 */
4836 CXCompletionContext_CXXClassTypeValue = 1 << 4,
4837
4838 /**
4839 * \brief Completions for fields of the member being accessed using the dot
4840 * operator should be included in the results.
4841 */
4842 CXCompletionContext_DotMemberAccess = 1 << 5,
4843 /**
4844 * \brief Completions for fields of the member being accessed using the arrow
4845 * operator should be included in the results.
4846 */
4847 CXCompletionContext_ArrowMemberAccess = 1 << 6,
4848 /**
4849 * \brief Completions for properties of the Objective-C object being accessed
4850 * using the dot operator should be included in the results.
4851 */
4852 CXCompletionContext_ObjCPropertyAccess = 1 << 7,
4853
4854 /**
4855 * \brief Completions for enum tags should be included in the results.
4856 */
4857 CXCompletionContext_EnumTag = 1 << 8,
4858 /**
4859 * \brief Completions for union tags should be included in the results.
4860 */
4861 CXCompletionContext_UnionTag = 1 << 9,
4862 /**
4863 * \brief Completions for struct tags should be included in the results.
4864 */
4865 CXCompletionContext_StructTag = 1 << 10,
4866
4867 /**
4868 * \brief Completions for C++ class names should be included in the results.
4869 */
4870 CXCompletionContext_ClassTag = 1 << 11,
4871 /**
4872 * \brief Completions for C++ namespaces and namespace aliases should be
4873 * included in the results.
4874 */
4875 CXCompletionContext_Namespace = 1 << 12,
4876 /**
4877 * \brief Completions for C++ nested name specifiers should be included in
4878 * the results.
4879 */
4880 CXCompletionContext_NestedNameSpecifier = 1 << 13,
4881
4882 /**
4883 * \brief Completions for Objective-C interfaces (classes) should be included
4884 * in the results.
4885 */
4886 CXCompletionContext_ObjCInterface = 1 << 14,
4887 /**
4888 * \brief Completions for Objective-C protocols should be included in
4889 * the results.
4890 */
4891 CXCompletionContext_ObjCProtocol = 1 << 15,
4892 /**
4893 * \brief Completions for Objective-C categories should be included in
4894 * the results.
4895 */
4896 CXCompletionContext_ObjCCategory = 1 << 16,
4897 /**
4898 * \brief Completions for Objective-C instance messages should be included
4899 * in the results.
4900 */
4901 CXCompletionContext_ObjCInstanceMessage = 1 << 17,
4902 /**
4903 * \brief Completions for Objective-C class messages should be included in
4904 * the results.
4905 */
4906 CXCompletionContext_ObjCClassMessage = 1 << 18,
4907 /**
4908 * \brief Completions for Objective-C selector names should be included in
4909 * the results.
4910 */
4911 CXCompletionContext_ObjCSelectorName = 1 << 19,
4912
4913 /**
4914 * \brief Completions for preprocessor macro names should be included in
4915 * the results.
4916 */
4917 CXCompletionContext_MacroName = 1 << 20,
4918
4919 /**
4920 * \brief Natural language completions should be included in the results.
4921 */
4922 CXCompletionContext_NaturalLanguage = 1 << 21,
4923
4924 /**
4925 * \brief The current context is unknown, so set all contexts.
4926 */
4927 CXCompletionContext_Unknown = ((1 << 22) - 1)
4928};
4929
4930/**
Douglas Gregorb68bc592010-08-05 09:09:23 +00004931 * \brief Returns a default set of code-completion options that can be
4932 * passed to\c clang_codeCompleteAt().
4933 */
4934CINDEX_LINKAGE unsigned clang_defaultCodeCompleteOptions(void);
4935
4936/**
Douglas Gregor8e984da2010-08-04 16:47:14 +00004937 * \brief Perform code completion at a given location in a translation unit.
4938 *
4939 * This function performs code completion at a particular file, line, and
4940 * column within source code, providing results that suggest potential
4941 * code snippets based on the context of the completion. The basic model
4942 * for code completion is that Clang will parse a complete source file,
4943 * performing syntax checking up to the location where code-completion has
4944 * been requested. At that point, a special code-completion token is passed
4945 * to the parser, which recognizes this token and determines, based on the
4946 * current location in the C/Objective-C/C++ grammar and the state of
4947 * semantic analysis, what completions to provide. These completions are
4948 * returned via a new \c CXCodeCompleteResults structure.
4949 *
4950 * Code completion itself is meant to be triggered by the client when the
4951 * user types punctuation characters or whitespace, at which point the
4952 * code-completion location will coincide with the cursor. For example, if \c p
4953 * is a pointer, code-completion might be triggered after the "-" and then
4954 * after the ">" in \c p->. When the code-completion location is afer the ">",
4955 * the completion results will provide, e.g., the members of the struct that
4956 * "p" points to. The client is responsible for placing the cursor at the
4957 * beginning of the token currently being typed, then filtering the results
4958 * based on the contents of the token. For example, when code-completing for
4959 * the expression \c p->get, the client should provide the location just after
4960 * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the
4961 * client can filter the results based on the current token text ("get"), only
4962 * showing those results that start with "get". The intent of this interface
4963 * is to separate the relatively high-latency acquisition of code-completion
4964 * results from the filtering of results on a per-character basis, which must
4965 * have a lower latency.
4966 *
4967 * \param TU The translation unit in which code-completion should
4968 * occur. The source files for this translation unit need not be
4969 * completely up-to-date (and the contents of those source files may
4970 * be overridden via \p unsaved_files). Cursors referring into the
4971 * translation unit may be invalidated by this invocation.
4972 *
4973 * \param complete_filename The name of the source file where code
4974 * completion should be performed. This filename may be any file
4975 * included in the translation unit.
4976 *
4977 * \param complete_line The line at which code-completion should occur.
4978 *
4979 * \param complete_column The column at which code-completion should occur.
4980 * Note that the column should point just after the syntactic construct that
4981 * initiated code completion, and not in the middle of a lexical token.
4982 *
4983 * \param unsaved_files the Tiles that have not yet been saved to disk
4984 * but may be required for parsing or code completion, including the
4985 * contents of those files. The contents and name of these files (as
4986 * specified by CXUnsavedFile) are copied when necessary, so the
4987 * client only needs to guarantee their validity until the call to
4988 * this function returns.
4989 *
4990 * \param num_unsaved_files The number of unsaved file entries in \p
4991 * unsaved_files.
4992 *
Douglas Gregorb68bc592010-08-05 09:09:23 +00004993 * \param options Extra options that control the behavior of code
4994 * completion, expressed as a bitwise OR of the enumerators of the
4995 * CXCodeComplete_Flags enumeration. The
4996 * \c clang_defaultCodeCompleteOptions() function returns a default set
4997 * of code-completion options.
4998 *
Douglas Gregor8e984da2010-08-04 16:47:14 +00004999 * \returns If successful, a new \c CXCodeCompleteResults structure
5000 * containing code-completion results, which should eventually be
5001 * freed with \c clang_disposeCodeCompleteResults(). If code
5002 * completion fails, returns NULL.
5003 */
5004CINDEX_LINKAGE
5005CXCodeCompleteResults *clang_codeCompleteAt(CXTranslationUnit TU,
5006 const char *complete_filename,
5007 unsigned complete_line,
5008 unsigned complete_column,
5009 struct CXUnsavedFile *unsaved_files,
Douglas Gregorb68bc592010-08-05 09:09:23 +00005010 unsigned num_unsaved_files,
5011 unsigned options);
Douglas Gregor8e984da2010-08-04 16:47:14 +00005012
5013/**
Douglas Gregor49f67ce2010-08-26 13:48:20 +00005014 * \brief Sort the code-completion results in case-insensitive alphabetical
5015 * order.
5016 *
5017 * \param Results The set of results to sort.
5018 * \param NumResults The number of results in \p Results.
5019 */
5020CINDEX_LINKAGE
5021void clang_sortCodeCompletionResults(CXCompletionResult *Results,
5022 unsigned NumResults);
5023
5024/**
Douglas Gregorf72b6ac2009-12-18 16:20:58 +00005025 * \brief Free the given set of code-completion results.
5026 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005027CINDEX_LINKAGE
Douglas Gregorf72b6ac2009-12-18 16:20:58 +00005028void clang_disposeCodeCompleteResults(CXCodeCompleteResults *Results);
Douglas Gregorf757a122010-08-23 23:00:57 +00005029
Douglas Gregor52606ff2010-01-20 01:10:47 +00005030/**
Douglas Gregor33cdd812010-02-18 18:08:43 +00005031 * \brief Determine the number of diagnostics produced prior to the
5032 * location where code completion was performed.
5033 */
Ted Kremenekd071c602010-03-13 02:50:34 +00005034CINDEX_LINKAGE
Douglas Gregor33cdd812010-02-18 18:08:43 +00005035unsigned clang_codeCompleteGetNumDiagnostics(CXCodeCompleteResults *Results);
5036
5037/**
5038 * \brief Retrieve a diagnostic associated with the given code completion.
5039 *
James Dennett574cb4c2012-06-15 05:41:51 +00005040 * \param Results the code completion results to query.
Douglas Gregor33cdd812010-02-18 18:08:43 +00005041 * \param Index the zero-based diagnostic number to retrieve.
5042 *
5043 * \returns the requested diagnostic. This diagnostic must be freed
5044 * via a call to \c clang_disposeDiagnostic().
5045 */
Ted Kremenekd071c602010-03-13 02:50:34 +00005046CINDEX_LINKAGE
Douglas Gregor33cdd812010-02-18 18:08:43 +00005047CXDiagnostic clang_codeCompleteGetDiagnostic(CXCodeCompleteResults *Results,
5048 unsigned Index);
5049
5050/**
Douglas Gregor21325842011-07-07 16:03:39 +00005051 * \brief Determines what compeltions are appropriate for the context
5052 * the given code completion.
5053 *
5054 * \param Results the code completion results to query
5055 *
5056 * \returns the kinds of completions that are appropriate for use
5057 * along with the given code completion results.
5058 */
5059CINDEX_LINKAGE
5060unsigned long long clang_codeCompleteGetContexts(
5061 CXCodeCompleteResults *Results);
Douglas Gregor63745d52011-07-21 01:05:26 +00005062
5063/**
5064 * \brief Returns the cursor kind for the container for the current code
5065 * completion context. The container is only guaranteed to be set for
5066 * contexts where a container exists (i.e. member accesses or Objective-C
5067 * message sends); if there is not a container, this function will return
5068 * CXCursor_InvalidCode.
5069 *
5070 * \param Results the code completion results to query
5071 *
5072 * \param IsIncomplete on return, this value will be false if Clang has complete
5073 * information about the container. If Clang does not have complete
5074 * information, this value will be true.
5075 *
5076 * \returns the container kind, or CXCursor_InvalidCode if there is not a
5077 * container
5078 */
5079CINDEX_LINKAGE
5080enum CXCursorKind clang_codeCompleteGetContainerKind(
5081 CXCodeCompleteResults *Results,
5082 unsigned *IsIncomplete);
5083
5084/**
5085 * \brief Returns the USR for the container for the current code completion
5086 * context. If there is not a container for the current context, this
5087 * function will return the empty string.
5088 *
5089 * \param Results the code completion results to query
5090 *
5091 * \returns the USR for the container
5092 */
5093CINDEX_LINKAGE
5094CXString clang_codeCompleteGetContainerUSR(CXCodeCompleteResults *Results);
Douglas Gregor21325842011-07-07 16:03:39 +00005095
Douglas Gregorea777402011-07-26 15:24:30 +00005096
5097/**
5098 * \brief Returns the currently-entered selector for an Objective-C message
5099 * send, formatted like "initWithFoo:bar:". Only guaranteed to return a
5100 * non-empty string for CXCompletionContext_ObjCInstanceMessage and
5101 * CXCompletionContext_ObjCClassMessage.
5102 *
5103 * \param Results the code completion results to query
5104 *
5105 * \returns the selector (or partial selector) that has been entered thus far
5106 * for an Objective-C message send.
5107 */
5108CINDEX_LINKAGE
5109CXString clang_codeCompleteGetObjCSelector(CXCodeCompleteResults *Results);
5110
Douglas Gregor21325842011-07-07 16:03:39 +00005111/**
Douglas Gregor52606ff2010-01-20 01:10:47 +00005112 * @}
5113 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005114
5115
Ted Kremenekc0f3f722010-01-22 22:44:15 +00005116/**
5117 * \defgroup CINDEX_MISC Miscellaneous utility functions
5118 *
5119 * @{
5120 */
Ted Kremenek3e315a22010-01-23 17:51:23 +00005121
5122/**
5123 * \brief Return a version string, suitable for showing to a user, but not
5124 * intended to be parsed (the format is not guaranteed to be stable).
5125 */
NAKAMURA Takumieacd6672013-01-10 02:12:38 +00005126CINDEX_LINKAGE CXString clang_getClangVersion(void);
Ted Kremenekc0f3f722010-01-22 22:44:15 +00005127
Ted Kremenek1ec7b332011-03-18 23:05:39 +00005128
5129/**
5130 * \brief Enable/disable crash recovery.
5131 *
James Dennett574cb4c2012-06-15 05:41:51 +00005132 * \param isEnabled Flag to indicate if crash recovery is enabled. A non-zero
5133 * value enables crash recovery, while 0 disables it.
Ted Kremenek1ec7b332011-03-18 23:05:39 +00005134 */
5135CINDEX_LINKAGE void clang_toggleCrashRecovery(unsigned isEnabled);
5136
Ted Kremenek0b86e3a2010-01-26 19:31:51 +00005137 /**
Ted Kremenekd071c602010-03-13 02:50:34 +00005138 * \brief Visitor invoked for each file in a translation unit
Ted Kremenek0b86e3a2010-01-26 19:31:51 +00005139 * (used with clang_getInclusions()).
5140 *
5141 * This visitor function will be invoked by clang_getInclusions() for each
James Dennett574cb4c2012-06-15 05:41:51 +00005142 * file included (either at the top-level or by \#include directives) within
Ted Kremenek0b86e3a2010-01-26 19:31:51 +00005143 * a translation unit. The first argument is the file being included, and
5144 * the second and third arguments provide the inclusion stack. The
5145 * array is sorted in order of immediate inclusion. For example,
5146 * the first element refers to the location that included 'included_file'.
5147 */
5148typedef void (*CXInclusionVisitor)(CXFile included_file,
5149 CXSourceLocation* inclusion_stack,
5150 unsigned include_len,
5151 CXClientData client_data);
5152
5153/**
5154 * \brief Visit the set of preprocessor inclusions in a translation unit.
5155 * The visitor function is called with the provided data for every included
5156 * file. This does not include headers included by the PCH file (unless one
5157 * is inspecting the inclusions in the PCH file itself).
5158 */
5159CINDEX_LINKAGE void clang_getInclusions(CXTranslationUnit tu,
5160 CXInclusionVisitor visitor,
5161 CXClientData client_data);
5162
5163/**
Ted Kremenekc0f3f722010-01-22 22:44:15 +00005164 * @}
5165 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005166
Argyrios Kyrtzidisf89cc692011-07-11 20:15:00 +00005167/** \defgroup CINDEX_REMAPPING Remapping functions
5168 *
5169 * @{
5170 */
5171
5172/**
5173 * \brief A remapping of original source files and their translated files.
5174 */
5175typedef void *CXRemapping;
5176
5177/**
5178 * \brief Retrieve a remapping.
5179 *
5180 * \param path the path that contains metadata about remappings.
5181 *
5182 * \returns the requested remapping. This remapping must be freed
5183 * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
5184 */
5185CINDEX_LINKAGE CXRemapping clang_getRemappings(const char *path);
5186
5187/**
Ted Kremenekf7639e12012-03-06 20:06:33 +00005188 * \brief Retrieve a remapping.
5189 *
5190 * \param filePaths pointer to an array of file paths containing remapping info.
5191 *
5192 * \param numFiles number of file paths.
5193 *
5194 * \returns the requested remapping. This remapping must be freed
5195 * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
5196 */
5197CINDEX_LINKAGE
5198CXRemapping clang_getRemappingsFromFileList(const char **filePaths,
5199 unsigned numFiles);
5200
5201/**
Argyrios Kyrtzidisf89cc692011-07-11 20:15:00 +00005202 * \brief Determine the number of remappings.
5203 */
5204CINDEX_LINKAGE unsigned clang_remap_getNumFiles(CXRemapping);
5205
5206/**
5207 * \brief Get the original and the associated filename from the remapping.
5208 *
5209 * \param original If non-NULL, will be set to the original filename.
5210 *
5211 * \param transformed If non-NULL, will be set to the filename that the original
5212 * is associated with.
5213 */
5214CINDEX_LINKAGE void clang_remap_getFilenames(CXRemapping, unsigned index,
5215 CXString *original, CXString *transformed);
5216
5217/**
5218 * \brief Dispose the remapping.
5219 */
5220CINDEX_LINKAGE void clang_remap_dispose(CXRemapping);
5221
5222/**
5223 * @}
5224 */
5225
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00005226/** \defgroup CINDEX_HIGH Higher level API functions
5227 *
5228 * @{
5229 */
5230
5231enum CXVisitorResult {
5232 CXVisit_Break,
5233 CXVisit_Continue
5234};
5235
5236typedef struct {
5237 void *context;
5238 enum CXVisitorResult (*visit)(void *context, CXCursor, CXSourceRange);
5239} CXCursorAndRangeVisitor;
5240
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00005241typedef enum {
5242 /**
5243 * \brief Function returned successfully.
5244 */
5245 CXResult_Success = 0,
5246 /**
5247 * \brief One of the parameters was invalid for the function.
5248 */
5249 CXResult_Invalid = 1,
5250 /**
5251 * \brief The function was terminated by a callback (e.g. it returned
5252 * CXVisit_Break)
5253 */
5254 CXResult_VisitBreak = 2
5255
5256} CXResult;
5257
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00005258/**
5259 * \brief Find references of a declaration in a specific file.
5260 *
5261 * \param cursor pointing to a declaration or a reference of one.
5262 *
5263 * \param file to search for references.
5264 *
5265 * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
5266 * each reference found.
5267 * The CXSourceRange will point inside the file; if the reference is inside
5268 * a macro (and not a macro argument) the CXSourceRange will be invalid.
Argyrios Kyrtzidis951f61f2013-03-08 20:42:33 +00005269 *
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00005270 * \returns one of the CXResult enumerators.
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00005271 */
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00005272CINDEX_LINKAGE CXResult clang_findReferencesInFile(CXCursor cursor, CXFile file,
5273 CXCursorAndRangeVisitor visitor);
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00005274
Argyrios Kyrtzidis503c83a2013-03-08 02:32:34 +00005275/**
5276 * \brief Find #import/#include directives in a specific file.
5277 *
5278 * \param TU translation unit containing the file to query.
5279 *
5280 * \param file to search for #import/#include directives.
5281 *
5282 * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
5283 * each directive found.
Argyrios Kyrtzidis951f61f2013-03-08 20:42:33 +00005284 *
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00005285 * \returns one of the CXResult enumerators.
Argyrios Kyrtzidis503c83a2013-03-08 02:32:34 +00005286 */
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00005287CINDEX_LINKAGE CXResult clang_findIncludesInFile(CXTranslationUnit TU,
5288 CXFile file,
5289 CXCursorAndRangeVisitor visitor);
Argyrios Kyrtzidis503c83a2013-03-08 02:32:34 +00005290
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00005291#ifdef __has_feature
5292# if __has_feature(blocks)
5293
5294typedef enum CXVisitorResult
5295 (^CXCursorAndRangeVisitorBlock)(CXCursor, CXSourceRange);
5296
5297CINDEX_LINKAGE
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00005298CXResult clang_findReferencesInFileWithBlock(CXCursor, CXFile,
5299 CXCursorAndRangeVisitorBlock);
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00005300
Argyrios Kyrtzidis503c83a2013-03-08 02:32:34 +00005301CINDEX_LINKAGE
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00005302CXResult clang_findIncludesInFileWithBlock(CXTranslationUnit, CXFile,
5303 CXCursorAndRangeVisitorBlock);
Argyrios Kyrtzidis503c83a2013-03-08 02:32:34 +00005304
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00005305# endif
5306#endif
5307
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005308/**
5309 * \brief The client's data object that is associated with a CXFile.
5310 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005311typedef void *CXIdxClientFile;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005312
5313/**
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00005314 * \brief The client's data object that is associated with a semantic entity.
5315 */
5316typedef void *CXIdxClientEntity;
5317
5318/**
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005319 * \brief The client's data object that is associated with a semantic container
5320 * of entities.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005321 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005322typedef void *CXIdxClientContainer;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005323
5324/**
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005325 * \brief The client's data object that is associated with an AST file (PCH
5326 * or module).
5327 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005328typedef void *CXIdxClientASTFile;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005329
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005330/**
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005331 * \brief Source location passed to index callbacks.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005332 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005333typedef struct {
5334 void *ptr_data[2];
5335 unsigned int_data;
5336} CXIdxLoc;
5337
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005338/**
James Dennett574cb4c2012-06-15 05:41:51 +00005339 * \brief Data for ppIncludedFile callback.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005340 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005341typedef struct {
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005342 /**
James Dennett574cb4c2012-06-15 05:41:51 +00005343 * \brief Location of '#' in the \#include/\#import directive.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005344 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005345 CXIdxLoc hashLoc;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005346 /**
James Dennett574cb4c2012-06-15 05:41:51 +00005347 * \brief Filename as written in the \#include/\#import directive.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005348 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005349 const char *filename;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005350 /**
James Dennett574cb4c2012-06-15 05:41:51 +00005351 * \brief The actual file that the \#include/\#import directive resolved to.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005352 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005353 CXFile file;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005354 int isImport;
5355 int isAngled;
Argyrios Kyrtzidis5e2ec482012-10-18 00:17:05 +00005356 /**
5357 * \brief Non-zero if the directive was automatically turned into a module
5358 * import.
5359 */
5360 int isModuleImport;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005361} CXIdxIncludedFileInfo;
5362
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005363/**
James Dennett574cb4c2012-06-15 05:41:51 +00005364 * \brief Data for IndexerCallbacks#importedASTFile.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005365 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005366typedef struct {
Argyrios Kyrtzidis472eda02012-10-02 16:10:38 +00005367 /**
5368 * \brief Top level AST file containing the imported PCH, module or submodule.
5369 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005370 CXFile file;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005371 /**
Argyrios Kyrtzidisdc78f3e2012-10-05 00:22:40 +00005372 * \brief The imported module or NULL if the AST file is a PCH.
5373 */
5374 CXModule module;
5375 /**
Argyrios Kyrtzidis472eda02012-10-02 16:10:38 +00005376 * \brief Location where the file is imported. Applicable only for modules.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005377 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005378 CXIdxLoc loc;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005379 /**
Argyrios Kyrtzidis472eda02012-10-02 16:10:38 +00005380 * \brief Non-zero if an inclusion directive was automatically turned into
Argyrios Kyrtzidisdc78f3e2012-10-05 00:22:40 +00005381 * a module import. Applicable only for modules.
Argyrios Kyrtzidis472eda02012-10-02 16:10:38 +00005382 */
Argyrios Kyrtzidis184b1442012-10-03 21:05:44 +00005383 int isImplicit;
Argyrios Kyrtzidis472eda02012-10-02 16:10:38 +00005384
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005385} CXIdxImportedASTFileInfo;
5386
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005387typedef enum {
5388 CXIdxEntity_Unexposed = 0,
5389 CXIdxEntity_Typedef = 1,
5390 CXIdxEntity_Function = 2,
5391 CXIdxEntity_Variable = 3,
5392 CXIdxEntity_Field = 4,
5393 CXIdxEntity_EnumConstant = 5,
5394
5395 CXIdxEntity_ObjCClass = 6,
5396 CXIdxEntity_ObjCProtocol = 7,
5397 CXIdxEntity_ObjCCategory = 8,
5398
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00005399 CXIdxEntity_ObjCInstanceMethod = 9,
5400 CXIdxEntity_ObjCClassMethod = 10,
5401 CXIdxEntity_ObjCProperty = 11,
5402 CXIdxEntity_ObjCIvar = 12,
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005403
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00005404 CXIdxEntity_Enum = 13,
5405 CXIdxEntity_Struct = 14,
5406 CXIdxEntity_Union = 15,
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00005407
5408 CXIdxEntity_CXXClass = 16,
5409 CXIdxEntity_CXXNamespace = 17,
5410 CXIdxEntity_CXXNamespaceAlias = 18,
5411 CXIdxEntity_CXXStaticVariable = 19,
5412 CXIdxEntity_CXXStaticMethod = 20,
5413 CXIdxEntity_CXXInstanceMethod = 21,
Joao Matose9a3ed42012-08-31 22:18:20 +00005414 CXIdxEntity_CXXConstructor = 22,
5415 CXIdxEntity_CXXDestructor = 23,
5416 CXIdxEntity_CXXConversionFunction = 24,
5417 CXIdxEntity_CXXTypeAlias = 25,
5418 CXIdxEntity_CXXInterface = 26
5419
5420} CXIdxEntityKind;
5421
Argyrios Kyrtzidis52002882011-12-07 20:44:12 +00005422typedef enum {
5423 CXIdxEntityLang_None = 0,
5424 CXIdxEntityLang_C = 1,
5425 CXIdxEntityLang_ObjC = 2,
5426 CXIdxEntityLang_CXX = 3
5427} CXIdxEntityLanguage;
5428
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00005429/**
5430 * \brief Extra C++ template information for an entity. This can apply to:
5431 * CXIdxEntity_Function
5432 * CXIdxEntity_CXXClass
5433 * CXIdxEntity_CXXStaticMethod
5434 * CXIdxEntity_CXXInstanceMethod
5435 * CXIdxEntity_CXXConstructor
5436 * CXIdxEntity_CXXConversionFunction
5437 * CXIdxEntity_CXXTypeAlias
5438 */
5439typedef enum {
5440 CXIdxEntity_NonTemplate = 0,
5441 CXIdxEntity_Template = 1,
5442 CXIdxEntity_TemplatePartialSpecialization = 2,
5443 CXIdxEntity_TemplateSpecialization = 3
5444} CXIdxEntityCXXTemplateKind;
5445
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00005446typedef enum {
5447 CXIdxAttr_Unexposed = 0,
5448 CXIdxAttr_IBAction = 1,
5449 CXIdxAttr_IBOutlet = 2,
5450 CXIdxAttr_IBOutletCollection = 3
5451} CXIdxAttrKind;
5452
5453typedef struct {
5454 CXIdxAttrKind kind;
5455 CXCursor cursor;
5456 CXIdxLoc loc;
5457} CXIdxAttrInfo;
5458
5459typedef struct {
Argyrios Kyrtzidis4d873b72011-12-15 00:05:00 +00005460 CXIdxEntityKind kind;
5461 CXIdxEntityCXXTemplateKind templateKind;
5462 CXIdxEntityLanguage lang;
5463 const char *name;
5464 const char *USR;
5465 CXCursor cursor;
5466 const CXIdxAttrInfo *const *attributes;
5467 unsigned numAttributes;
5468} CXIdxEntityInfo;
5469
5470typedef struct {
5471 CXCursor cursor;
5472} CXIdxContainerInfo;
5473
5474typedef struct {
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00005475 const CXIdxAttrInfo *attrInfo;
5476 const CXIdxEntityInfo *objcClass;
5477 CXCursor classCursor;
5478 CXIdxLoc classLoc;
5479} CXIdxIBOutletCollectionAttrInfo;
5480
Argyrios Kyrtzidis8b71bc72012-12-06 19:41:16 +00005481typedef enum {
5482 CXIdxDeclFlag_Skipped = 0x1
5483} CXIdxDeclInfoFlags;
5484
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005485typedef struct {
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00005486 const CXIdxEntityInfo *entityInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005487 CXCursor cursor;
5488 CXIdxLoc loc;
Argyrios Kyrtzidis663c8ec2011-12-07 20:44:19 +00005489 const CXIdxContainerInfo *semanticContainer;
5490 /**
James Dennett574cb4c2012-06-15 05:41:51 +00005491 * \brief Generally same as #semanticContainer but can be different in
Argyrios Kyrtzidis663c8ec2011-12-07 20:44:19 +00005492 * cases like out-of-line C++ member functions.
5493 */
5494 const CXIdxContainerInfo *lexicalContainer;
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005495 int isRedeclaration;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005496 int isDefinition;
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00005497 int isContainer;
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00005498 const CXIdxContainerInfo *declAsContainer;
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00005499 /**
5500 * \brief Whether the declaration exists in code or was created implicitly
5501 * by the compiler, e.g. implicit objc methods for properties.
5502 */
5503 int isImplicit;
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00005504 const CXIdxAttrInfo *const *attributes;
5505 unsigned numAttributes;
Argyrios Kyrtzidis8b71bc72012-12-06 19:41:16 +00005506
5507 unsigned flags;
5508
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005509} CXIdxDeclInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005510
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005511typedef enum {
5512 CXIdxObjCContainer_ForwardRef = 0,
5513 CXIdxObjCContainer_Interface = 1,
5514 CXIdxObjCContainer_Implementation = 2
5515} CXIdxObjCContainerKind;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005516
5517typedef struct {
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00005518 const CXIdxDeclInfo *declInfo;
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005519 CXIdxObjCContainerKind kind;
5520} CXIdxObjCContainerDeclInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005521
5522typedef struct {
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00005523 const CXIdxEntityInfo *base;
5524 CXCursor cursor;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005525 CXIdxLoc loc;
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00005526} CXIdxBaseClassInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005527
5528typedef struct {
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00005529 const CXIdxEntityInfo *protocol;
5530 CXCursor cursor;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005531 CXIdxLoc loc;
5532} CXIdxObjCProtocolRefInfo;
5533
5534typedef struct {
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00005535 const CXIdxObjCProtocolRefInfo *const *protocols;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005536 unsigned numProtocols;
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00005537} CXIdxObjCProtocolRefListInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005538
5539typedef struct {
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00005540 const CXIdxObjCContainerDeclInfo *containerInfo;
5541 const CXIdxBaseClassInfo *superInfo;
5542 const CXIdxObjCProtocolRefListInfo *protocols;
5543} CXIdxObjCInterfaceDeclInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005544
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00005545typedef struct {
Argyrios Kyrtzidis9b9f7a92011-12-13 18:47:45 +00005546 const CXIdxObjCContainerDeclInfo *containerInfo;
5547 const CXIdxEntityInfo *objcClass;
5548 CXCursor classCursor;
5549 CXIdxLoc classLoc;
5550 const CXIdxObjCProtocolRefListInfo *protocols;
5551} CXIdxObjCCategoryDeclInfo;
5552
5553typedef struct {
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00005554 const CXIdxDeclInfo *declInfo;
Argyrios Kyrtzidis93db2922012-02-28 17:50:33 +00005555 const CXIdxEntityInfo *getter;
5556 const CXIdxEntityInfo *setter;
5557} CXIdxObjCPropertyDeclInfo;
5558
5559typedef struct {
5560 const CXIdxDeclInfo *declInfo;
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00005561 const CXIdxBaseClassInfo *const *bases;
5562 unsigned numBases;
5563} CXIdxCXXClassDeclInfo;
5564
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005565/**
James Dennett574cb4c2012-06-15 05:41:51 +00005566 * \brief Data for IndexerCallbacks#indexEntityReference.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005567 */
Argyrios Kyrtzidis0c7735e52011-10-18 15:50:50 +00005568typedef enum {
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005569 /**
5570 * \brief The entity is referenced directly in user's code.
5571 */
Argyrios Kyrtzidis0c7735e52011-10-18 15:50:50 +00005572 CXIdxEntityRef_Direct = 1,
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005573 /**
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00005574 * \brief An implicit reference, e.g. a reference of an ObjC method via the
5575 * dot syntax.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005576 */
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00005577 CXIdxEntityRef_Implicit = 2
Argyrios Kyrtzidis0c7735e52011-10-18 15:50:50 +00005578} CXIdxEntityRefKind;
5579
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005580/**
James Dennett574cb4c2012-06-15 05:41:51 +00005581 * \brief Data for IndexerCallbacks#indexEntityReference.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005582 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005583typedef struct {
Argyrios Kyrtzidis663c8ec2011-12-07 20:44:19 +00005584 CXIdxEntityRefKind kind;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005585 /**
5586 * \brief Reference cursor.
5587 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005588 CXCursor cursor;
5589 CXIdxLoc loc;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005590 /**
5591 * \brief The entity that gets referenced.
5592 */
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00005593 const CXIdxEntityInfo *referencedEntity;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005594 /**
5595 * \brief Immediate "parent" of the reference. For example:
5596 *
5597 * \code
5598 * Foo *var;
5599 * \endcode
5600 *
5601 * The parent of reference of type 'Foo' is the variable 'var'.
Argyrios Kyrtzidis25cb0ff2011-12-13 18:47:41 +00005602 * For references inside statement bodies of functions/methods,
5603 * the parentEntity will be the function/method.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005604 */
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00005605 const CXIdxEntityInfo *parentEntity;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005606 /**
Argyrios Kyrtzidis25cb0ff2011-12-13 18:47:41 +00005607 * \brief Lexical container context of the reference.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005608 */
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00005609 const CXIdxContainerInfo *container;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005610} CXIdxEntityRefInfo;
5611
James Dennett574cb4c2012-06-15 05:41:51 +00005612/**
5613 * \brief A group of callbacks used by #clang_indexSourceFile and
5614 * #clang_indexTranslationUnit.
5615 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005616typedef struct {
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005617 /**
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00005618 * \brief Called periodically to check whether indexing should be aborted.
5619 * Should return 0 to continue, and non-zero to abort.
5620 */
5621 int (*abortQuery)(CXClientData client_data, void *reserved);
5622
5623 /**
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00005624 * \brief Called at the end of indexing; passes the complete diagnostic set.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005625 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005626 void (*diagnostic)(CXClientData client_data,
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00005627 CXDiagnosticSet, void *reserved);
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005628
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005629 CXIdxClientFile (*enteredMainFile)(CXClientData client_data,
James Dennett574cb4c2012-06-15 05:41:51 +00005630 CXFile mainFile, void *reserved);
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005631
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005632 /**
James Dennett574cb4c2012-06-15 05:41:51 +00005633 * \brief Called when a file gets \#included/\#imported.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005634 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005635 CXIdxClientFile (*ppIncludedFile)(CXClientData client_data,
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00005636 const CXIdxIncludedFileInfo *);
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005637
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005638 /**
5639 * \brief Called when a AST file (PCH or module) gets imported.
5640 *
5641 * AST files will not get indexed (there will not be callbacks to index all
5642 * the entities in an AST file). The recommended action is that, if the AST
Argyrios Kyrtzidis472eda02012-10-02 16:10:38 +00005643 * file is not already indexed, to initiate a new indexing job specific to
5644 * the AST file.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005645 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005646 CXIdxClientASTFile (*importedASTFile)(CXClientData client_data,
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00005647 const CXIdxImportedASTFileInfo *);
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005648
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005649 /**
5650 * \brief Called at the beginning of indexing a translation unit.
5651 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005652 CXIdxClientContainer (*startedTranslationUnit)(CXClientData client_data,
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00005653 void *reserved);
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005654
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00005655 void (*indexDeclaration)(CXClientData client_data,
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00005656 const CXIdxDeclInfo *);
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005657
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005658 /**
5659 * \brief Called to index a reference of an entity.
5660 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005661 void (*indexEntityReference)(CXClientData client_data,
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00005662 const CXIdxEntityRefInfo *);
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005663
5664} IndexerCallbacks;
5665
NAKAMURA Takumiaacef7e2011-11-11 02:51:09 +00005666CINDEX_LINKAGE int clang_index_isEntityObjCContainerKind(CXIdxEntityKind);
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00005667CINDEX_LINKAGE const CXIdxObjCContainerDeclInfo *
5668clang_index_getObjCContainerDeclInfo(const CXIdxDeclInfo *);
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005669
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00005670CINDEX_LINKAGE const CXIdxObjCInterfaceDeclInfo *
5671clang_index_getObjCInterfaceDeclInfo(const CXIdxDeclInfo *);
5672
NAKAMURA Takumiaacef7e2011-11-11 02:51:09 +00005673CINDEX_LINKAGE
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00005674const CXIdxObjCCategoryDeclInfo *
5675clang_index_getObjCCategoryDeclInfo(const CXIdxDeclInfo *);
5676
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00005677CINDEX_LINKAGE const CXIdxObjCProtocolRefListInfo *
5678clang_index_getObjCProtocolRefListInfo(const CXIdxDeclInfo *);
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005679
Argyrios Kyrtzidis93db2922012-02-28 17:50:33 +00005680CINDEX_LINKAGE const CXIdxObjCPropertyDeclInfo *
5681clang_index_getObjCPropertyDeclInfo(const CXIdxDeclInfo *);
5682
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00005683CINDEX_LINKAGE const CXIdxIBOutletCollectionAttrInfo *
5684clang_index_getIBOutletCollectionAttrInfo(const CXIdxAttrInfo *);
5685
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00005686CINDEX_LINKAGE const CXIdxCXXClassDeclInfo *
5687clang_index_getCXXClassDeclInfo(const CXIdxDeclInfo *);
5688
5689/**
5690 * \brief For retrieving a custom CXIdxClientContainer attached to a
5691 * container.
5692 */
5693CINDEX_LINKAGE CXIdxClientContainer
5694clang_index_getClientContainer(const CXIdxContainerInfo *);
5695
5696/**
5697 * \brief For setting a custom CXIdxClientContainer attached to a
5698 * container.
5699 */
5700CINDEX_LINKAGE void
5701clang_index_setClientContainer(const CXIdxContainerInfo *,CXIdxClientContainer);
5702
5703/**
5704 * \brief For retrieving a custom CXIdxClientEntity attached to an entity.
5705 */
5706CINDEX_LINKAGE CXIdxClientEntity
5707clang_index_getClientEntity(const CXIdxEntityInfo *);
5708
5709/**
5710 * \brief For setting a custom CXIdxClientEntity attached to an entity.
5711 */
5712CINDEX_LINKAGE void
5713clang_index_setClientEntity(const CXIdxEntityInfo *, CXIdxClientEntity);
5714
5715/**
Argyrios Kyrtzidis8b71bc72012-12-06 19:41:16 +00005716 * \brief An indexing action/session, to be applied to one or multiple
5717 * translation units.
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00005718 */
5719typedef void *CXIndexAction;
5720
5721/**
Argyrios Kyrtzidis8b71bc72012-12-06 19:41:16 +00005722 * \brief An indexing action/session, to be applied to one or multiple
5723 * translation units.
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00005724 *
5725 * \param CIdx The index object with which the index action will be associated.
5726 */
5727CINDEX_LINKAGE CXIndexAction clang_IndexAction_create(CXIndex CIdx);
5728
5729/**
5730 * \brief Destroy the given index action.
5731 *
5732 * The index action must not be destroyed until all of the translation units
5733 * created within that index action have been destroyed.
5734 */
5735CINDEX_LINKAGE void clang_IndexAction_dispose(CXIndexAction);
5736
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00005737typedef enum {
5738 /**
5739 * \brief Used to indicate that no special indexing options are needed.
5740 */
5741 CXIndexOpt_None = 0x0,
5742
5743 /**
James Dennett574cb4c2012-06-15 05:41:51 +00005744 * \brief Used to indicate that IndexerCallbacks#indexEntityReference should
5745 * be invoked for only one reference of an entity per source file that does
5746 * not also include a declaration/definition of the entity.
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00005747 */
Argyrios Kyrtzidisfb7d1452012-01-14 00:11:49 +00005748 CXIndexOpt_SuppressRedundantRefs = 0x1,
5749
5750 /**
5751 * \brief Function-local symbols should be indexed. If this is not set
5752 * function-local symbols will be ignored.
5753 */
Argyrios Kyrtzidis7e747952012-02-14 22:23:11 +00005754 CXIndexOpt_IndexFunctionLocalSymbols = 0x2,
5755
5756 /**
5757 * \brief Implicit function/class template instantiations should be indexed.
5758 * If this is not set, implicit instantiations will be ignored.
5759 */
Argyrios Kyrtzidis6c9ed7d2012-03-27 21:38:03 +00005760 CXIndexOpt_IndexImplicitTemplateInstantiations = 0x4,
5761
5762 /**
5763 * \brief Suppress all compiler warnings when parsing for indexing.
5764 */
Argyrios Kyrtzidis8b71bc72012-12-06 19:41:16 +00005765 CXIndexOpt_SuppressWarnings = 0x8,
5766
5767 /**
5768 * \brief Skip a function/method body that was already parsed during an
5769 * indexing session assosiated with a \c CXIndexAction object.
5770 * Bodies in system headers are always skipped.
5771 */
5772 CXIndexOpt_SkipParsedBodiesInSession = 0x10
5773
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00005774} CXIndexOptFlags;
5775
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005776/**
5777 * \brief Index the given source file and the translation unit corresponding
James Dennett574cb4c2012-06-15 05:41:51 +00005778 * to that file via callbacks implemented through #IndexerCallbacks.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005779 *
5780 * \param client_data pointer data supplied by the client, which will
5781 * be passed to the invoked callbacks.
5782 *
5783 * \param index_callbacks Pointer to indexing callbacks that the client
5784 * implements.
5785 *
James Dennett574cb4c2012-06-15 05:41:51 +00005786 * \param index_callbacks_size Size of #IndexerCallbacks structure that gets
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005787 * passed in index_callbacks.
5788 *
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00005789 * \param index_options A bitmask of options that affects how indexing is
5790 * performed. This should be a bitwise OR of the CXIndexOpt_XXX flags.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005791 *
5792 * \param out_TU [out] pointer to store a CXTranslationUnit that can be reused
5793 * after indexing is finished. Set to NULL if you do not require it.
5794 *
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00005795 * \returns If there is a failure from which the there is no recovery, returns
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005796 * non-zero, otherwise returns 0.
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00005797 *
James Dennett574cb4c2012-06-15 05:41:51 +00005798 * The rest of the parameters are the same as #clang_parseTranslationUnit.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005799 */
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00005800CINDEX_LINKAGE int clang_indexSourceFile(CXIndexAction,
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005801 CXClientData client_data,
5802 IndexerCallbacks *index_callbacks,
5803 unsigned index_callbacks_size,
5804 unsigned index_options,
5805 const char *source_filename,
5806 const char * const *command_line_args,
5807 int num_command_line_args,
5808 struct CXUnsavedFile *unsaved_files,
5809 unsigned num_unsaved_files,
5810 CXTranslationUnit *out_TU,
5811 unsigned TU_options);
5812
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005813/**
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00005814 * \brief Index the given translation unit via callbacks implemented through
James Dennett574cb4c2012-06-15 05:41:51 +00005815 * #IndexerCallbacks.
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00005816 *
5817 * The order of callback invocations is not guaranteed to be the same as
5818 * when indexing a source file. The high level order will be:
5819 *
5820 * -Preprocessor callbacks invocations
5821 * -Declaration/reference callbacks invocations
5822 * -Diagnostic callback invocations
5823 *
James Dennett574cb4c2012-06-15 05:41:51 +00005824 * The parameters are the same as #clang_indexSourceFile.
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00005825 *
5826 * \returns If there is a failure from which the there is no recovery, returns
5827 * non-zero, otherwise returns 0.
5828 */
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00005829CINDEX_LINKAGE int clang_indexTranslationUnit(CXIndexAction,
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00005830 CXClientData client_data,
5831 IndexerCallbacks *index_callbacks,
5832 unsigned index_callbacks_size,
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00005833 unsigned index_options,
5834 CXTranslationUnit);
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00005835
5836/**
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005837 * \brief Retrieve the CXIdxFile, file, line, column, and offset represented by
5838 * the given CXIdxLoc.
5839 *
5840 * If the location refers into a macro expansion, retrieves the
5841 * location of the macro expansion and if it refers into a macro argument
5842 * retrieves the location of the argument.
5843 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005844CINDEX_LINKAGE void clang_indexLoc_getFileLocation(CXIdxLoc loc,
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005845 CXIdxClientFile *indexFile,
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005846 CXFile *file,
5847 unsigned *line,
5848 unsigned *column,
5849 unsigned *offset);
5850
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005851/**
5852 * \brief Retrieve the CXSourceLocation represented by the given CXIdxLoc.
5853 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005854CINDEX_LINKAGE
5855CXSourceLocation clang_indexLoc_getCXSourceLocation(CXIdxLoc loc);
5856
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00005857/**
5858 * @}
5859 */
5860
Douglas Gregor6007cf22010-01-22 22:29:16 +00005861/**
5862 * @}
5863 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005864
Ted Kremenekb60d87c2009-08-26 22:36:44 +00005865#ifdef __cplusplus
5866}
5867#endif
5868#endif
5869