blob: 91b3d11a549a04ab78205c54d3e3dc7494ea541f [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
Benjamin Kramer2f5db8b2014-08-13 16:25:19 +000016#ifndef LLVM_CLANG_C_INDEX_H
17#define LLVM_CLANG_C_INDEX_H
Ted Kremenekb60d87c2009-08-26 22:36:44 +000018
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"
Argyrios Kyrtzidis0b9682e2014-02-25 03:59:23 +000022#include "clang-c/CXErrorCode.h"
Arnaud A. de Grandmaison0271b322012-06-28 22:01:06 +000023#include "clang-c/CXString.h"
Argyrios Kyrtzidis09a439d2014-02-25 03:59:16 +000024#include "clang-c/BuildSystem.h"
Arnaud A. de Grandmaison0271b322012-06-28 22:01:06 +000025
Argyrios Kyrtzidis1c4db8d2012-11-06 21:21:49 +000026/**
27 * \brief The version constants for the libclang API.
28 * CINDEX_VERSION_MINOR should increase when there are API additions.
29 * CINDEX_VERSION_MAJOR is intended for "major" source/ABI breaking changes.
30 *
31 * The policy about the libclang API was always to keep it source and ABI
32 * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
33 */
Argyrios Kyrtzidis5b216ed2012-10-29 23:24:44 +000034#define CINDEX_VERSION_MAJOR 0
Erik Verbruggen346066b2017-05-30 14:25:54 +000035#define CINDEX_VERSION_MINOR 41
Argyrios Kyrtzidis5b216ed2012-10-29 23:24:44 +000036
37#define CINDEX_VERSION_ENCODE(major, minor) ( \
38 ((major) * 10000) \
39 + ((minor) * 1))
40
41#define CINDEX_VERSION CINDEX_VERSION_ENCODE( \
42 CINDEX_VERSION_MAJOR, \
43 CINDEX_VERSION_MINOR )
44
45#define CINDEX_VERSION_STRINGIZE_(major, minor) \
46 #major"."#minor
47#define CINDEX_VERSION_STRINGIZE(major, minor) \
48 CINDEX_VERSION_STRINGIZE_(major, minor)
49
50#define CINDEX_VERSION_STRING CINDEX_VERSION_STRINGIZE( \
51 CINDEX_VERSION_MAJOR, \
52 CINDEX_VERSION_MINOR)
53
Ted Kremenekb60d87c2009-08-26 22:36:44 +000054#ifdef __cplusplus
55extern "C" {
56#endif
57
Douglas Gregor4a4e0eb2011-02-23 17:45:25 +000058/** \defgroup CINDEX libclang: C Interface to Clang
Douglas Gregor52606ff2010-01-20 01:10:47 +000059 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +000060 * The C Interface to Clang provides a relatively small API that exposes
Douglas Gregorc8e390c2010-01-20 22:45:41 +000061 * facilities for parsing source code into an abstract syntax tree (AST),
62 * loading already-parsed ASTs, traversing the AST, associating
63 * physical source locations with elements within the AST, and other
64 * facilities that support Clang-based development tools.
Douglas Gregor52606ff2010-01-20 01:10:47 +000065 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +000066 * This C interface to Clang will never provide all of the information
Douglas Gregorc8e390c2010-01-20 22:45:41 +000067 * representation stored in Clang's C++ AST, nor should it: the intent is to
68 * maintain an API that is relatively stable from one release to the next,
69 * providing only the basic functionality needed to support development tools.
Daniel Dunbar62ebf252010-01-24 02:54:26 +000070 *
71 * To avoid namespace pollution, data types are prefixed with "CX" and
Douglas Gregorc8e390c2010-01-20 22:45:41 +000072 * functions are prefixed with "clang_".
Douglas Gregor52606ff2010-01-20 01:10:47 +000073 *
74 * @{
75 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +000076
Douglas Gregor802f12f2010-01-20 22:28:27 +000077/**
78 * \brief An "index" that consists of a set of translation units that would
79 * typically be linked together into an executable or library.
80 */
81typedef void *CXIndex;
Steve Naroffd5e8e862009-08-27 19:51:58 +000082
Douglas Gregor802f12f2010-01-20 22:28:27 +000083/**
Emilio Cobos Alvarez485ad422017-04-28 15:56:39 +000084 * \brief An opaque type representing target information for a given translation
85 * unit.
86 */
87typedef struct CXTargetInfoImpl *CXTargetInfo;
88
89/**
Douglas Gregor802f12f2010-01-20 22:28:27 +000090 * \brief A single translation unit, which resides in an index.
91 */
Ted Kremenek7df92ae2010-11-17 23:24:11 +000092typedef struct CXTranslationUnitImpl *CXTranslationUnit;
Steve Naroffd5e8e862009-08-27 19:51:58 +000093
Douglas Gregor802f12f2010-01-20 22:28:27 +000094/**
Douglas Gregor6007cf22010-01-22 22:29:16 +000095 * \brief Opaque pointer representing client data that will be passed through
96 * to various callbacks and visitors.
Douglas Gregor802f12f2010-01-20 22:28:27 +000097 */
Douglas Gregor6007cf22010-01-22 22:29:16 +000098typedef void *CXClientData;
Daniel Dunbar62ebf252010-01-24 02:54:26 +000099
Douglas Gregor9485bf92009-12-02 09:21:34 +0000100/**
101 * \brief Provides the contents of a file that has not yet been saved to disk.
102 *
103 * Each CXUnsavedFile instance provides the name of a file on the
104 * system along with the current contents of that file that have not
105 * yet been saved to disk.
106 */
107struct CXUnsavedFile {
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000108 /**
109 * \brief The file whose contents have not yet been saved.
Douglas Gregor9485bf92009-12-02 09:21:34 +0000110 *
111 * This file must already exist in the file system.
112 */
113 const char *Filename;
114
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000115 /**
Douglas Gregor89a56c52010-02-27 01:32:48 +0000116 * \brief A buffer containing the unsaved contents of this file.
Douglas Gregor9485bf92009-12-02 09:21:34 +0000117 */
118 const char *Contents;
119
120 /**
Douglas Gregor89a56c52010-02-27 01:32:48 +0000121 * \brief The length of the unsaved contents of this buffer.
Douglas Gregor9485bf92009-12-02 09:21:34 +0000122 */
123 unsigned long Length;
124};
125
Peter Collingbourne5caf5af2010-08-24 00:31:37 +0000126/**
127 * \brief Describes the availability of a particular entity, which indicates
128 * whether the use of this entity will result in a warning or error due to
129 * it being deprecated or unavailable.
130 */
Douglas Gregorf757a122010-08-23 23:00:57 +0000131enum CXAvailabilityKind {
Peter Collingbourne5caf5af2010-08-24 00:31:37 +0000132 /**
133 * \brief The entity is available.
134 */
Douglas Gregorf757a122010-08-23 23:00:57 +0000135 CXAvailability_Available,
Peter Collingbourne5caf5af2010-08-24 00:31:37 +0000136 /**
137 * \brief The entity is available, but has been deprecated (and its use is
138 * not recommended).
139 */
Douglas Gregorf757a122010-08-23 23:00:57 +0000140 CXAvailability_Deprecated,
Peter Collingbourne5caf5af2010-08-24 00:31:37 +0000141 /**
142 * \brief The entity is not available; any use of it will be an error.
143 */
Erik Verbruggen2e657ff2011-10-06 07:27:49 +0000144 CXAvailability_NotAvailable,
145 /**
146 * \brief The entity is available, but not accessible; any use of it will be
147 * an error.
148 */
149 CXAvailability_NotAccessible
Douglas Gregorf757a122010-08-23 23:00:57 +0000150};
Douglas Gregord6225d32012-05-08 00:14:45 +0000151
152/**
153 * \brief Describes a version number of the form major.minor.subminor.
154 */
155typedef struct CXVersion {
156 /**
157 * \brief The major version number, e.g., the '10' in '10.7.3'. A negative
158 * value indicates that there is no version number at all.
159 */
160 int Major;
161 /**
162 * \brief The minor version number, e.g., the '7' in '10.7.3'. This value
163 * will be negative if no minor version number was provided, e.g., for
164 * version '10'.
165 */
166 int Minor;
167 /**
168 * \brief The subminor version number, e.g., the '3' in '10.7.3'. This value
169 * will be negative if no minor or subminor version number was provided,
170 * e.g., in version '10' or '10.7'.
171 */
172 int Subminor;
173} CXVersion;
Douglas Gregorf757a122010-08-23 23:00:57 +0000174
Douglas Gregor802f12f2010-01-20 22:28:27 +0000175/**
James Dennett574cb4c2012-06-15 05:41:51 +0000176 * \brief Provides a shared context for creating translation units.
177 *
178 * It provides two options:
Steve Naroff531e2842009-10-20 14:46:24 +0000179 *
180 * - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local"
181 * declarations (when loading any new translation units). A "local" declaration
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000182 * is one that belongs in the translation unit itself and not in a precompiled
Steve Naroff531e2842009-10-20 14:46:24 +0000183 * header that was used by the translation unit. If zero, all declarations
184 * will be enumerated.
185 *
Steve Naroffbb4568a2009-10-20 16:36:34 +0000186 * Here is an example:
187 *
James Dennett574cb4c2012-06-15 05:41:51 +0000188 * \code
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000189 * // excludeDeclsFromPCH = 1, displayDiagnostics=1
190 * Idx = clang_createIndex(1, 1);
Steve Naroffbb4568a2009-10-20 16:36:34 +0000191 *
192 * // IndexTest.pch was produced with the following command:
193 * // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch"
194 * TU = clang_createTranslationUnit(Idx, "IndexTest.pch");
195 *
196 * // This will load all the symbols from 'IndexTest.pch'
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000197 * clang_visitChildren(clang_getTranslationUnitCursor(TU),
Douglas Gregor990b5762010-01-20 21:37:00 +0000198 * TranslationUnitVisitor, 0);
Steve Naroffbb4568a2009-10-20 16:36:34 +0000199 * clang_disposeTranslationUnit(TU);
200 *
201 * // This will load all the symbols from 'IndexTest.c', excluding symbols
202 * // from 'IndexTest.pch'.
Daniel Dunbard0159262010-01-25 00:43:14 +0000203 * char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" };
204 * TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args,
205 * 0, 0);
Douglas Gregorfed36b12010-01-20 23:57:43 +0000206 * clang_visitChildren(clang_getTranslationUnitCursor(TU),
207 * TranslationUnitVisitor, 0);
Steve Naroffbb4568a2009-10-20 16:36:34 +0000208 * clang_disposeTranslationUnit(TU);
James Dennett574cb4c2012-06-15 05:41:51 +0000209 * \endcode
Steve Naroffbb4568a2009-10-20 16:36:34 +0000210 *
211 * This process of creating the 'pch', loading it separately, and using it (via
212 * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks
213 * (which gives the indexer the same performance benefit as the compiler).
Steve Naroff531e2842009-10-20 14:46:24 +0000214 */
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000215CINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH,
216 int displayDiagnostics);
Ted Kremenekd071c602010-03-13 02:50:34 +0000217
Douglas Gregor408bb742010-02-08 23:03:06 +0000218/**
219 * \brief Destroy the given index.
220 *
221 * The index must not be destroyed until all of the translation units created
222 * within that index have been destroyed.
223 */
Daniel Dunbar11089662009-12-03 01:54:28 +0000224CINDEX_LINKAGE void clang_disposeIndex(CXIndex index);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000225
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000226typedef enum {
227 /**
228 * \brief Used to indicate that no special CXIndex options are needed.
229 */
230 CXGlobalOpt_None = 0x0,
231
232 /**
233 * \brief Used to indicate that threads that libclang creates for indexing
234 * purposes should use background priority.
James Dennett574cb4c2012-06-15 05:41:51 +0000235 *
236 * Affects #clang_indexSourceFile, #clang_indexTranslationUnit,
237 * #clang_parseTranslationUnit, #clang_saveTranslationUnit.
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000238 */
239 CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1,
240
241 /**
242 * \brief Used to indicate that threads that libclang creates for editing
243 * purposes should use background priority.
James Dennett574cb4c2012-06-15 05:41:51 +0000244 *
245 * Affects #clang_reparseTranslationUnit, #clang_codeCompleteAt,
246 * #clang_annotateTokens
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000247 */
248 CXGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2,
249
250 /**
251 * \brief Used to indicate that all threads that libclang creates should use
252 * background priority.
253 */
254 CXGlobalOpt_ThreadBackgroundPriorityForAll =
255 CXGlobalOpt_ThreadBackgroundPriorityForIndexing |
256 CXGlobalOpt_ThreadBackgroundPriorityForEditing
257
258} CXGlobalOptFlags;
259
260/**
James Dennett574cb4c2012-06-15 05:41:51 +0000261 * \brief Sets general options associated with a CXIndex.
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000262 *
263 * For example:
264 * \code
265 * CXIndex idx = ...;
266 * clang_CXIndex_setGlobalOptions(idx,
267 * clang_CXIndex_getGlobalOptions(idx) |
268 * CXGlobalOpt_ThreadBackgroundPriorityForIndexing);
269 * \endcode
270 *
271 * \param options A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags.
272 */
273CINDEX_LINKAGE void clang_CXIndex_setGlobalOptions(CXIndex, unsigned options);
274
275/**
276 * \brief Gets the general options associated with a CXIndex.
277 *
278 * \returns A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags that
279 * are associated with the given CXIndex object.
280 */
281CINDEX_LINKAGE unsigned clang_CXIndex_getGlobalOptions(CXIndex);
282
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000283/**
Douglas Gregor6007cf22010-01-22 22:29:16 +0000284 * \defgroup CINDEX_FILES File manipulation routines
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000285 *
286 * @{
287 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000288
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000289/**
290 * \brief A particular source file that is part of a translation unit.
291 */
292typedef void *CXFile;
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000293
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000294/**
295 * \brief Retrieve the complete file and path name of the given file.
Steve Naroff6231f182009-10-27 14:35:18 +0000296 */
Ted Kremenekc560b682010-02-17 00:41:20 +0000297CINDEX_LINKAGE CXString clang_getFileName(CXFile SFile);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000298
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000299/**
300 * \brief Retrieve the last modification time of the given file.
301 */
Douglas Gregor249c1212009-10-31 15:48:08 +0000302CINDEX_LINKAGE time_t clang_getFileTime(CXFile SFile);
Steve Naroff6231f182009-10-27 14:35:18 +0000303
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000304/**
Argyrios Kyrtzidisac08b262013-01-26 04:52:52 +0000305 * \brief Uniquely identifies a CXFile, that refers to the same underlying file,
306 * across an indexing session.
307 */
308typedef struct {
309 unsigned long long data[3];
310} CXFileUniqueID;
311
312/**
313 * \brief Retrieve the unique ID for the given \c file.
314 *
315 * \param file the file to get the ID for.
316 * \param outID stores the returned CXFileUniqueID.
317 * \returns If there was a failure getting the unique ID, returns non-zero,
318 * otherwise returns 0.
319*/
320CINDEX_LINKAGE int clang_getFileUniqueID(CXFile file, CXFileUniqueID *outID);
321
322/**
Douglas Gregor37aa4932011-05-04 00:14:37 +0000323 * \brief Determine whether the given header is guarded against
324 * multiple inclusions, either with the conventional
James Dennett574cb4c2012-06-15 05:41:51 +0000325 * \#ifndef/\#define/\#endif macro guards or with \#pragma once.
Douglas Gregor37aa4932011-05-04 00:14:37 +0000326 */
327CINDEX_LINKAGE unsigned
328clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu, CXFile file);
329
330/**
Douglas Gregor816fd362010-01-22 21:44:22 +0000331 * \brief Retrieve a file handle within the given translation unit.
332 *
333 * \param tu the translation unit
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000334 *
Samuel Antao4c8035b2016-12-12 18:00:20 +0000335 * \param file_name the name of the file.
Douglas Gregor816fd362010-01-22 21:44:22 +0000336 *
337 * \returns the file handle for the named file in the translation unit \p tu,
338 * or a NULL file handle if the file was not a part of this translation unit.
339 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000340CINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu,
Douglas Gregor816fd362010-01-22 21:44:22 +0000341 const char *file_name);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000342
Douglas Gregor816fd362010-01-22 21:44:22 +0000343/**
Argyrios Kyrtzidisac3997e2014-08-16 00:26:19 +0000344 * \brief Returns non-zero if the \c file1 and \c file2 point to the same file,
345 * or they are both NULL.
346 */
347CINDEX_LINKAGE int clang_File_isEqual(CXFile file1, CXFile file2);
348
349/**
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000350 * @}
351 */
352
353/**
354 * \defgroup CINDEX_LOCATIONS Physical source locations
355 *
356 * Clang represents physical source locations in its abstract syntax tree in
357 * great detail, with file, line, and column information for the majority of
358 * the tokens parsed in the source code. These data types and functions are
359 * used to represent source location information, either for a particular
360 * point in the program or for a range of points in the program, and extract
361 * specific location information from those data types.
362 *
363 * @{
364 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000365
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000366/**
Douglas Gregor4f46e782010-01-19 21:36:55 +0000367 * \brief Identifies a specific source location within a translation
368 * unit.
369 *
Chandler Carruth4aa01ef2011-08-31 16:53:37 +0000370 * Use clang_getExpansionLocation() or clang_getSpellingLocation()
Douglas Gregor229bebd2010-11-09 06:24:54 +0000371 * to map a source location to a particular file, line, and column.
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000372 */
373typedef struct {
Argyrios Kyrtzidis49d9d0292013-01-11 22:29:47 +0000374 const void *ptr_data[2];
Douglas Gregor4f46e782010-01-19 21:36:55 +0000375 unsigned int_data;
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000376} CXSourceLocation;
Ted Kremeneka44d99c2010-01-05 23:18:49 +0000377
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000378/**
Daniel Dunbar02968e52010-02-14 10:02:57 +0000379 * \brief Identifies a half-open character range in the source code.
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000380 *
Douglas Gregor4f46e782010-01-19 21:36:55 +0000381 * Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the
382 * starting and end locations from a source range, respectively.
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000383 */
384typedef struct {
Argyrios Kyrtzidis49d9d0292013-01-11 22:29:47 +0000385 const void *ptr_data[2];
Douglas Gregor4f46e782010-01-19 21:36:55 +0000386 unsigned begin_int_data;
387 unsigned end_int_data;
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000388} CXSourceRange;
Ted Kremeneka44d99c2010-01-05 23:18:49 +0000389
Douglas Gregor4f46e782010-01-19 21:36:55 +0000390/**
Douglas Gregor816fd362010-01-22 21:44:22 +0000391 * \brief Retrieve a NULL (invalid) source location.
392 */
NAKAMURA Takumieacd6672013-01-10 02:12:38 +0000393CINDEX_LINKAGE CXSourceLocation clang_getNullLocation(void);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000394
Douglas Gregor816fd362010-01-22 21:44:22 +0000395/**
James Dennett574cb4c2012-06-15 05:41:51 +0000396 * \brief Determine whether two source locations, which must refer into
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000397 * the same translation unit, refer to exactly the same point in the source
Douglas Gregor816fd362010-01-22 21:44:22 +0000398 * code.
399 *
400 * \returns non-zero if the source locations refer to the same location, zero
401 * if they refer to different locations.
402 */
403CINDEX_LINKAGE unsigned clang_equalLocations(CXSourceLocation loc1,
404 CXSourceLocation loc2);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000405
Douglas Gregor816fd362010-01-22 21:44:22 +0000406/**
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000407 * \brief Retrieves the source location associated with a given file/line/column
408 * in a particular translation unit.
Douglas Gregor816fd362010-01-22 21:44:22 +0000409 */
410CINDEX_LINKAGE CXSourceLocation clang_getLocation(CXTranslationUnit tu,
411 CXFile file,
412 unsigned line,
413 unsigned column);
David Chisnall2e16ac52010-10-15 17:07:39 +0000414/**
415 * \brief Retrieves the source location associated with a given character offset
416 * in a particular translation unit.
417 */
418CINDEX_LINKAGE CXSourceLocation clang_getLocationForOffset(CXTranslationUnit tu,
419 CXFile file,
420 unsigned offset);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000421
Douglas Gregor816fd362010-01-22 21:44:22 +0000422/**
Argyrios Kyrtzidis25f7af12013-04-12 17:06:51 +0000423 * \brief Returns non-zero if the given source location is in a system header.
424 */
425CINDEX_LINKAGE int clang_Location_isInSystemHeader(CXSourceLocation location);
426
427/**
Stefanus Du Toitdb51c632013-08-08 17:48:14 +0000428 * \brief Returns non-zero if the given source location is in the main file of
429 * the corresponding translation unit.
430 */
431CINDEX_LINKAGE int clang_Location_isFromMainFile(CXSourceLocation location);
432
433/**
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000434 * \brief Retrieve a NULL (invalid) source range.
435 */
NAKAMURA Takumieacd6672013-01-10 02:12:38 +0000436CINDEX_LINKAGE CXSourceRange clang_getNullRange(void);
Ted Kremenekd071c602010-03-13 02:50:34 +0000437
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000438/**
Douglas Gregor816fd362010-01-22 21:44:22 +0000439 * \brief Retrieve a source range given the beginning and ending source
440 * locations.
441 */
442CINDEX_LINKAGE CXSourceRange clang_getRange(CXSourceLocation begin,
443 CXSourceLocation end);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000444
Douglas Gregor816fd362010-01-22 21:44:22 +0000445/**
Douglas Gregor757e38b2011-07-23 19:35:14 +0000446 * \brief Determine whether two ranges are equivalent.
447 *
448 * \returns non-zero if the ranges are the same, zero if they differ.
449 */
450CINDEX_LINKAGE unsigned clang_equalRanges(CXSourceRange range1,
451 CXSourceRange range2);
452
453/**
Dmitri Gribenko8994e0c2012-09-13 13:11:20 +0000454 * \brief Returns non-zero if \p range is null.
Argyrios Kyrtzidise7e42912011-09-28 18:14:21 +0000455 */
Erik Verbruggend610b0f2011-10-06 12:11:57 +0000456CINDEX_LINKAGE int clang_Range_isNull(CXSourceRange range);
Argyrios Kyrtzidise7e42912011-09-28 18:14:21 +0000457
458/**
Douglas Gregor9bd6db52010-01-26 19:19:08 +0000459 * \brief Retrieve the file, line, column, and offset represented by
460 * the given source location.
Douglas Gregor4f46e782010-01-19 21:36:55 +0000461 *
Chandler Carruth4aa01ef2011-08-31 16:53:37 +0000462 * If the location refers into a macro expansion, retrieves the
463 * location of the macro expansion.
Douglas Gregor229bebd2010-11-09 06:24:54 +0000464 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000465 * \param location the location within a source file that will be decomposed
466 * into its parts.
Douglas Gregor4f46e782010-01-19 21:36:55 +0000467 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000468 * \param file [out] if non-NULL, will be set to the file to which the given
Douglas Gregor4f46e782010-01-19 21:36:55 +0000469 * source location points.
470 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000471 * \param line [out] if non-NULL, will be set to the line to which the given
Douglas Gregor4f46e782010-01-19 21:36:55 +0000472 * source location points.
473 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000474 * \param column [out] if non-NULL, will be set to the column to which the given
475 * source location points.
Douglas Gregor9bd6db52010-01-26 19:19:08 +0000476 *
477 * \param offset [out] if non-NULL, will be set to the offset into the
478 * buffer to which the given source location points.
Douglas Gregor4f46e782010-01-19 21:36:55 +0000479 */
Chandler Carruth4aa01ef2011-08-31 16:53:37 +0000480CINDEX_LINKAGE void clang_getExpansionLocation(CXSourceLocation location,
481 CXFile *file,
482 unsigned *line,
483 unsigned *column,
484 unsigned *offset);
485
486/**
Vassil Vassilev4b8e29d2017-04-06 10:05:46 +0000487 * \brief Retrieve the file, line and column represented by the given source
488 * location, as specified in a # line directive.
Argyrios Kyrtzidis91672b32011-09-13 21:49:08 +0000489 *
490 * Example: given the following source code in a file somefile.c
491 *
James Dennett574cb4c2012-06-15 05:41:51 +0000492 * \code
Argyrios Kyrtzidis91672b32011-09-13 21:49:08 +0000493 * #123 "dummy.c" 1
494 *
495 * static int func(void)
496 * {
497 * return 0;
498 * }
James Dennett574cb4c2012-06-15 05:41:51 +0000499 * \endcode
Argyrios Kyrtzidis91672b32011-09-13 21:49:08 +0000500 *
501 * the location information returned by this function would be
502 *
503 * File: dummy.c Line: 124 Column: 12
504 *
505 * whereas clang_getExpansionLocation would have returned
506 *
507 * File: somefile.c Line: 3 Column: 12
508 *
509 * \param location the location within a source file that will be decomposed
510 * into its parts.
511 *
512 * \param filename [out] if non-NULL, will be set to the filename of the
513 * source location. Note that filenames returned will be for "virtual" files,
514 * which don't necessarily exist on the machine running clang - e.g. when
515 * parsing preprocessed output obtained from a different environment. If
516 * a non-NULL value is passed in, remember to dispose of the returned value
517 * using \c clang_disposeString() once you've finished with it. For an invalid
518 * source location, an empty string is returned.
519 *
520 * \param line [out] if non-NULL, will be set to the line number of the
521 * source location. For an invalid source location, zero is returned.
522 *
523 * \param column [out] if non-NULL, will be set to the column number of the
524 * source location. For an invalid source location, zero is returned.
525 */
526CINDEX_LINKAGE void clang_getPresumedLocation(CXSourceLocation location,
527 CXString *filename,
528 unsigned *line,
529 unsigned *column);
530
531/**
Chandler Carruth4aa01ef2011-08-31 16:53:37 +0000532 * \brief Legacy API to retrieve the file, line, column, and offset represented
533 * by the given source location.
534 *
535 * This interface has been replaced by the newer interface
James Dennett574cb4c2012-06-15 05:41:51 +0000536 * #clang_getExpansionLocation(). See that interface's documentation for
Chandler Carruth4aa01ef2011-08-31 16:53:37 +0000537 * details.
538 */
Douglas Gregor4f46e782010-01-19 21:36:55 +0000539CINDEX_LINKAGE void clang_getInstantiationLocation(CXSourceLocation location,
540 CXFile *file,
541 unsigned *line,
Douglas Gregor9bd6db52010-01-26 19:19:08 +0000542 unsigned *column,
543 unsigned *offset);
Douglas Gregor47751d62010-01-26 03:07:15 +0000544
545/**
Douglas Gregor229bebd2010-11-09 06:24:54 +0000546 * \brief Retrieve the file, line, column, and offset represented by
547 * the given source location.
548 *
549 * If the location refers into a macro instantiation, return where the
550 * location was originally spelled in the source file.
551 *
552 * \param location the location within a source file that will be decomposed
553 * into its parts.
554 *
555 * \param file [out] if non-NULL, will be set to the file to which the given
556 * source location points.
557 *
558 * \param line [out] if non-NULL, will be set to the line to which the given
559 * source location points.
560 *
561 * \param column [out] if non-NULL, will be set to the column to which the given
562 * source location points.
563 *
564 * \param offset [out] if non-NULL, will be set to the offset into the
565 * buffer to which the given source location points.
566 */
567CINDEX_LINKAGE void clang_getSpellingLocation(CXSourceLocation location,
568 CXFile *file,
569 unsigned *line,
570 unsigned *column,
571 unsigned *offset);
572
573/**
Argyrios Kyrtzidis56be7162013-01-04 18:30:13 +0000574 * \brief Retrieve the file, line, column, and offset represented by
575 * the given source location.
576 *
577 * If the location refers into a macro expansion, return where the macro was
578 * expanded or where the macro argument was written, if the location points at
579 * a macro argument.
580 *
581 * \param location the location within a source file that will be decomposed
582 * into its parts.
583 *
584 * \param file [out] if non-NULL, will be set to the file to which the given
585 * source location points.
586 *
587 * \param line [out] if non-NULL, will be set to the line to which the given
588 * source location points.
589 *
590 * \param column [out] if non-NULL, will be set to the column to which the given
591 * source location points.
592 *
593 * \param offset [out] if non-NULL, will be set to the offset into the
594 * buffer to which the given source location points.
595 */
596CINDEX_LINKAGE void clang_getFileLocation(CXSourceLocation location,
597 CXFile *file,
598 unsigned *line,
599 unsigned *column,
600 unsigned *offset);
601
602/**
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000603 * \brief Retrieve a source location representing the first character within a
604 * source range.
Douglas Gregor4f46e782010-01-19 21:36:55 +0000605 */
606CINDEX_LINKAGE CXSourceLocation clang_getRangeStart(CXSourceRange range);
607
608/**
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000609 * \brief Retrieve a source location representing the last character within a
610 * source range.
Douglas Gregor4f46e782010-01-19 21:36:55 +0000611 */
612CINDEX_LINKAGE CXSourceLocation clang_getRangeEnd(CXSourceRange range);
613
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000614/**
Argyrios Kyrtzidis0e282ef2013-12-06 18:55:45 +0000615 * \brief Identifies an array of ranges.
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000616 */
617typedef struct {
618 /** \brief The number of ranges in the \c ranges array. */
619 unsigned count;
620 /**
Argyrios Kyrtzidis0e282ef2013-12-06 18:55:45 +0000621 * \brief An array of \c CXSourceRanges.
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000622 */
623 CXSourceRange *ranges;
Argyrios Kyrtzidis0e282ef2013-12-06 18:55:45 +0000624} CXSourceRangeList;
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000625
626/**
627 * \brief Retrieve all ranges that were skipped by the preprocessor.
Argyrios Kyrtzidis0e282ef2013-12-06 18:55:45 +0000628 *
629 * The preprocessor will skip lines when they are surrounded by an
630 * if/ifdef/ifndef directive whose condition does not evaluate to true.
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000631 */
Argyrios Kyrtzidis0e282ef2013-12-06 18:55:45 +0000632CINDEX_LINKAGE CXSourceRangeList *clang_getSkippedRanges(CXTranslationUnit tu,
633 CXFile file);
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000634
635/**
Cameron Desrochersd8091282016-08-18 15:43:55 +0000636 * \brief Retrieve all ranges from all files that were skipped by the
637 * preprocessor.
638 *
639 * The preprocessor will skip lines when they are surrounded by an
640 * if/ifdef/ifndef directive whose condition does not evaluate to true.
641 */
642CINDEX_LINKAGE CXSourceRangeList *clang_getAllSkippedRanges(CXTranslationUnit tu);
643
644/**
Argyrios Kyrtzidis0e282ef2013-12-06 18:55:45 +0000645 * \brief Destroy the given \c CXSourceRangeList.
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000646 */
Argyrios Kyrtzidis0e282ef2013-12-06 18:55:45 +0000647CINDEX_LINKAGE void clang_disposeSourceRangeList(CXSourceRangeList *ranges);
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000648
649/**
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000650 * @}
651 */
Douglas Gregor6007cf22010-01-22 22:29:16 +0000652
653/**
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000654 * \defgroup CINDEX_DIAG Diagnostic reporting
655 *
656 * @{
657 */
658
659/**
660 * \brief Describes the severity of a particular diagnostic.
661 */
662enum CXDiagnosticSeverity {
663 /**
Ted Kremenekd071c602010-03-13 02:50:34 +0000664 * \brief A diagnostic that has been suppressed, e.g., by a command-line
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000665 * option.
666 */
667 CXDiagnostic_Ignored = 0,
Ted Kremenekd071c602010-03-13 02:50:34 +0000668
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000669 /**
670 * \brief This diagnostic is a note that should be attached to the
671 * previous (non-note) diagnostic.
672 */
673 CXDiagnostic_Note = 1,
674
675 /**
676 * \brief This diagnostic indicates suspicious code that may not be
677 * wrong.
678 */
679 CXDiagnostic_Warning = 2,
680
681 /**
682 * \brief This diagnostic indicates that the code is ill-formed.
683 */
684 CXDiagnostic_Error = 3,
685
686 /**
687 * \brief This diagnostic indicates that the code is ill-formed such
688 * that future parser recovery is unlikely to produce useful
689 * results.
690 */
691 CXDiagnostic_Fatal = 4
692};
693
694/**
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000695 * \brief A single diagnostic, containing the diagnostic's severity,
696 * location, text, source ranges, and fix-it hints.
697 */
698typedef void *CXDiagnostic;
699
700/**
Ted Kremenekd010ba42011-11-10 08:43:12 +0000701 * \brief A group of CXDiagnostics.
702 */
703typedef void *CXDiagnosticSet;
704
705/**
706 * \brief Determine the number of diagnostics in a CXDiagnosticSet.
707 */
708CINDEX_LINKAGE unsigned clang_getNumDiagnosticsInSet(CXDiagnosticSet Diags);
709
710/**
711 * \brief Retrieve a diagnostic associated with the given CXDiagnosticSet.
712 *
James Dennett574cb4c2012-06-15 05:41:51 +0000713 * \param Diags the CXDiagnosticSet to query.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000714 * \param Index the zero-based diagnostic number to retrieve.
715 *
716 * \returns the requested diagnostic. This diagnostic must be freed
717 * via a call to \c clang_disposeDiagnostic().
718 */
719CINDEX_LINKAGE CXDiagnostic clang_getDiagnosticInSet(CXDiagnosticSet Diags,
720 unsigned Index);
721
Ted Kremenekd010ba42011-11-10 08:43:12 +0000722/**
723 * \brief Describes the kind of error that occurred (if any) in a call to
724 * \c clang_loadDiagnostics.
725 */
726enum CXLoadDiag_Error {
727 /**
728 * \brief Indicates that no error occurred.
729 */
730 CXLoadDiag_None = 0,
731
732 /**
733 * \brief Indicates that an unknown error occurred while attempting to
734 * deserialize diagnostics.
735 */
736 CXLoadDiag_Unknown = 1,
737
738 /**
739 * \brief Indicates that the file containing the serialized diagnostics
740 * could not be opened.
741 */
742 CXLoadDiag_CannotLoad = 2,
743
744 /**
745 * \brief Indicates that the serialized diagnostics file is invalid or
James Dennett574cb4c2012-06-15 05:41:51 +0000746 * corrupt.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000747 */
748 CXLoadDiag_InvalidFile = 3
749};
750
751/**
752 * \brief Deserialize a set of diagnostics from a Clang diagnostics bitcode
James Dennett574cb4c2012-06-15 05:41:51 +0000753 * file.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000754 *
James Dennett574cb4c2012-06-15 05:41:51 +0000755 * \param file The name of the file to deserialize.
756 * \param error A pointer to a enum value recording if there was a problem
Ted Kremenekd010ba42011-11-10 08:43:12 +0000757 * deserializing the diagnostics.
James Dennett574cb4c2012-06-15 05:41:51 +0000758 * \param errorString A pointer to a CXString for recording the error string
Ted Kremenekd010ba42011-11-10 08:43:12 +0000759 * if the file was not successfully loaded.
760 *
761 * \returns A loaded CXDiagnosticSet if successful, and NULL otherwise. These
James Dennett574cb4c2012-06-15 05:41:51 +0000762 * diagnostics should be released using clang_disposeDiagnosticSet().
Ted Kremenekd010ba42011-11-10 08:43:12 +0000763 */
764CINDEX_LINKAGE CXDiagnosticSet clang_loadDiagnostics(const char *file,
765 enum CXLoadDiag_Error *error,
766 CXString *errorString);
767
768/**
769 * \brief Release a CXDiagnosticSet and all of its contained diagnostics.
770 */
771CINDEX_LINKAGE void clang_disposeDiagnosticSet(CXDiagnosticSet Diags);
772
773/**
James Dennett574cb4c2012-06-15 05:41:51 +0000774 * \brief Retrieve the child diagnostics of a CXDiagnostic.
775 *
776 * This CXDiagnosticSet does not need to be released by
Sylvestre Ledrud29d97c2013-11-17 09:46:45 +0000777 * clang_disposeDiagnosticSet.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000778 */
779CINDEX_LINKAGE CXDiagnosticSet clang_getChildDiagnostics(CXDiagnostic D);
780
781/**
Douglas Gregor33cdd812010-02-18 18:08:43 +0000782 * \brief Determine the number of diagnostics produced for the given
783 * translation unit.
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000784 */
Douglas Gregor33cdd812010-02-18 18:08:43 +0000785CINDEX_LINKAGE unsigned clang_getNumDiagnostics(CXTranslationUnit Unit);
786
787/**
788 * \brief Retrieve a diagnostic associated with the given translation unit.
789 *
790 * \param Unit the translation unit to query.
791 * \param Index the zero-based diagnostic number to retrieve.
792 *
793 * \returns the requested diagnostic. This diagnostic must be freed
794 * via a call to \c clang_disposeDiagnostic().
795 */
796CINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit,
797 unsigned Index);
798
799/**
Ted Kremenekb4a8b052011-12-09 22:28:32 +0000800 * \brief Retrieve the complete set of diagnostics associated with a
801 * translation unit.
802 *
803 * \param Unit the translation unit to query.
804 */
805CINDEX_LINKAGE CXDiagnosticSet
806 clang_getDiagnosticSetFromTU(CXTranslationUnit Unit);
807
808/**
Douglas Gregor33cdd812010-02-18 18:08:43 +0000809 * \brief Destroy a diagnostic.
810 */
811CINDEX_LINKAGE void clang_disposeDiagnostic(CXDiagnostic Diagnostic);
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000812
813/**
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000814 * \brief Options to control the display of diagnostics.
815 *
816 * The values in this enum are meant to be combined to customize the
Sylvestre Ledrud29d97c2013-11-17 09:46:45 +0000817 * behavior of \c clang_formatDiagnostic().
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000818 */
819enum CXDiagnosticDisplayOptions {
820 /**
821 * \brief Display the source-location information where the
822 * diagnostic was located.
823 *
824 * When set, diagnostics will be prefixed by the file, line, and
825 * (optionally) column to which the diagnostic refers. For example,
826 *
827 * \code
828 * test.c:28: warning: extra tokens at end of #endif directive
829 * \endcode
830 *
831 * This option corresponds to the clang flag \c -fshow-source-location.
832 */
833 CXDiagnostic_DisplaySourceLocation = 0x01,
834
835 /**
836 * \brief If displaying the source-location information of the
837 * diagnostic, also include the column number.
838 *
839 * This option corresponds to the clang flag \c -fshow-column.
840 */
841 CXDiagnostic_DisplayColumn = 0x02,
842
843 /**
844 * \brief If displaying the source-location information of the
845 * diagnostic, also include information about source ranges in a
846 * machine-parsable format.
847 *
Ted Kremenekd071c602010-03-13 02:50:34 +0000848 * This option corresponds to the clang flag
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000849 * \c -fdiagnostics-print-source-range-info.
850 */
Douglas Gregora750e8e2010-11-19 16:18:16 +0000851 CXDiagnostic_DisplaySourceRanges = 0x04,
852
853 /**
854 * \brief Display the option name associated with this diagnostic, if any.
855 *
856 * The option name displayed (e.g., -Wconversion) will be placed in brackets
857 * after the diagnostic text. This option corresponds to the clang flag
858 * \c -fdiagnostics-show-option.
859 */
860 CXDiagnostic_DisplayOption = 0x08,
861
862 /**
863 * \brief Display the category number associated with this diagnostic, if any.
864 *
865 * The category number is displayed within brackets after the diagnostic text.
866 * This option corresponds to the clang flag
867 * \c -fdiagnostics-show-category=id.
868 */
869 CXDiagnostic_DisplayCategoryId = 0x10,
870
871 /**
872 * \brief Display the category name associated with this diagnostic, if any.
873 *
874 * The category name is displayed within brackets after the diagnostic text.
875 * This option corresponds to the clang flag
876 * \c -fdiagnostics-show-category=name.
877 */
878 CXDiagnostic_DisplayCategoryName = 0x20
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000879};
880
881/**
Douglas Gregord770f732010-02-22 23:17:23 +0000882 * \brief Format the given diagnostic in a manner that is suitable for display.
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000883 *
Douglas Gregord770f732010-02-22 23:17:23 +0000884 * This routine will format the given diagnostic to a string, rendering
Ted Kremenekd071c602010-03-13 02:50:34 +0000885 * the diagnostic according to the various options given. The
886 * \c clang_defaultDiagnosticDisplayOptions() function returns the set of
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000887 * options that most closely mimics the behavior of the clang compiler.
888 *
889 * \param Diagnostic The diagnostic to print.
890 *
Ted Kremenekd071c602010-03-13 02:50:34 +0000891 * \param Options A set of options that control the diagnostic display,
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000892 * created by combining \c CXDiagnosticDisplayOptions values.
Douglas Gregord770f732010-02-22 23:17:23 +0000893 *
894 * \returns A new string containing for formatted diagnostic.
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000895 */
Douglas Gregord770f732010-02-22 23:17:23 +0000896CINDEX_LINKAGE CXString clang_formatDiagnostic(CXDiagnostic Diagnostic,
897 unsigned Options);
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000898
899/**
900 * \brief Retrieve the set of display options most similar to the
901 * default behavior of the clang compiler.
902 *
903 * \returns A set of display options suitable for use with \c
Sylvestre Ledrud29d97c2013-11-17 09:46:45 +0000904 * clang_formatDiagnostic().
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000905 */
906CINDEX_LINKAGE unsigned clang_defaultDiagnosticDisplayOptions(void);
907
908/**
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000909 * \brief Determine the severity of the given diagnostic.
910 */
Ted Kremenekd071c602010-03-13 02:50:34 +0000911CINDEX_LINKAGE enum CXDiagnosticSeverity
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000912clang_getDiagnosticSeverity(CXDiagnostic);
913
914/**
915 * \brief Retrieve the source location of the given diagnostic.
916 *
917 * This location is where Clang would print the caret ('^') when
918 * displaying the diagnostic on the command line.
919 */
920CINDEX_LINKAGE CXSourceLocation clang_getDiagnosticLocation(CXDiagnostic);
921
922/**
923 * \brief Retrieve the text of the given diagnostic.
924 */
925CINDEX_LINKAGE CXString clang_getDiagnosticSpelling(CXDiagnostic);
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +0000926
927/**
Douglas Gregora750e8e2010-11-19 16:18:16 +0000928 * \brief Retrieve the name of the command-line option that enabled this
929 * diagnostic.
930 *
931 * \param Diag The diagnostic to be queried.
932 *
933 * \param Disable If non-NULL, will be set to the option that disables this
934 * diagnostic (if any).
935 *
936 * \returns A string that contains the command-line option used to enable this
937 * warning, such as "-Wconversion" or "-pedantic".
938 */
939CINDEX_LINKAGE CXString clang_getDiagnosticOption(CXDiagnostic Diag,
940 CXString *Disable);
941
942/**
943 * \brief Retrieve the category number for this diagnostic.
944 *
945 * Diagnostics can be categorized into groups along with other, related
946 * diagnostics (e.g., diagnostics under the same warning flag). This routine
947 * retrieves the category number for the given diagnostic.
948 *
949 * \returns The number of the category that contains this diagnostic, or zero
950 * if this diagnostic is uncategorized.
951 */
952CINDEX_LINKAGE unsigned clang_getDiagnosticCategory(CXDiagnostic);
953
954/**
Ted Kremenek26a6d492012-04-12 00:03:31 +0000955 * \brief Retrieve the name of a particular diagnostic category. This
956 * is now deprecated. Use clang_getDiagnosticCategoryText()
957 * instead.
Douglas Gregora750e8e2010-11-19 16:18:16 +0000958 *
959 * \param Category A diagnostic category number, as returned by
960 * \c clang_getDiagnosticCategory().
961 *
962 * \returns The name of the given diagnostic category.
963 */
Ted Kremenek26a6d492012-04-12 00:03:31 +0000964CINDEX_DEPRECATED CINDEX_LINKAGE
965CXString clang_getDiagnosticCategoryName(unsigned Category);
966
967/**
968 * \brief Retrieve the diagnostic category text for a given diagnostic.
969 *
Ted Kremenek26a6d492012-04-12 00:03:31 +0000970 * \returns The text of the given diagnostic category.
971 */
972CINDEX_LINKAGE CXString clang_getDiagnosticCategoryText(CXDiagnostic);
Douglas Gregora750e8e2010-11-19 16:18:16 +0000973
974/**
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +0000975 * \brief Determine the number of source ranges associated with the given
976 * diagnostic.
977 */
978CINDEX_LINKAGE unsigned clang_getDiagnosticNumRanges(CXDiagnostic);
Ted Kremenekd071c602010-03-13 02:50:34 +0000979
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000980/**
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +0000981 * \brief Retrieve a source range associated with the diagnostic.
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000982 *
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +0000983 * A diagnostic's source ranges highlight important elements in the source
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000984 * code. On the command line, Clang displays source ranges by
Ted Kremenekd071c602010-03-13 02:50:34 +0000985 * underlining them with '~' characters.
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000986 *
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +0000987 * \param Diagnostic the diagnostic whose range is being extracted.
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000988 *
Ted Kremenekd071c602010-03-13 02:50:34 +0000989 * \param Range the zero-based index specifying which range to
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000990 *
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +0000991 * \returns the requested source range.
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000992 */
Ted Kremenekd071c602010-03-13 02:50:34 +0000993CINDEX_LINKAGE CXSourceRange clang_getDiagnosticRange(CXDiagnostic Diagnostic,
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +0000994 unsigned Range);
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000995
996/**
997 * \brief Determine the number of fix-it hints associated with the
998 * given diagnostic.
999 */
1000CINDEX_LINKAGE unsigned clang_getDiagnosticNumFixIts(CXDiagnostic Diagnostic);
1001
1002/**
Douglas Gregor836ec942010-02-19 18:16:06 +00001003 * \brief Retrieve the replacement information for a given fix-it.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001004 *
Douglas Gregor836ec942010-02-19 18:16:06 +00001005 * Fix-its are described in terms of a source range whose contents
1006 * should be replaced by a string. This approach generalizes over
1007 * three kinds of operations: removal of source code (the range covers
1008 * the code to be removed and the replacement string is empty),
1009 * replacement of source code (the range covers the code to be
1010 * replaced and the replacement string provides the new code), and
1011 * insertion (both the start and end of the range point at the
1012 * insertion location, and the replacement string provides the text to
1013 * insert).
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001014 *
Douglas Gregor836ec942010-02-19 18:16:06 +00001015 * \param Diagnostic The diagnostic whose fix-its are being queried.
1016 *
1017 * \param FixIt The zero-based index of the fix-it.
1018 *
1019 * \param ReplacementRange The source range whose contents will be
1020 * replaced with the returned replacement string. Note that source
1021 * ranges are half-open ranges [a, b), so the source code should be
1022 * replaced from a and up to (but not including) b.
1023 *
1024 * \returns A string containing text that should be replace the source
1025 * code indicated by the \c ReplacementRange.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001026 */
Ted Kremenekd071c602010-03-13 02:50:34 +00001027CINDEX_LINKAGE CXString clang_getDiagnosticFixIt(CXDiagnostic Diagnostic,
Douglas Gregor836ec942010-02-19 18:16:06 +00001028 unsigned FixIt,
1029 CXSourceRange *ReplacementRange);
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001030
1031/**
1032 * @}
1033 */
1034
1035/**
1036 * \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation
1037 *
1038 * The routines in this group provide the ability to create and destroy
1039 * translation units from files, either by parsing the contents of the files or
1040 * by reading in a serialized representation of a translation unit.
1041 *
1042 * @{
1043 */
Ted Kremenekd071c602010-03-13 02:50:34 +00001044
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001045/**
1046 * \brief Get the original translation unit source file name.
1047 */
1048CINDEX_LINKAGE CXString
1049clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit);
1050
1051/**
1052 * \brief Return the CXTranslationUnit for a given source file and the provided
1053 * command line arguments one would pass to the compiler.
1054 *
1055 * Note: The 'source_filename' argument is optional. If the caller provides a
1056 * NULL pointer, the name of the source file is expected to reside in the
1057 * specified command line arguments.
1058 *
1059 * Note: When encountered in 'clang_command_line_args', the following options
1060 * are ignored:
1061 *
1062 * '-c'
1063 * '-emit-ast'
1064 * '-fsyntax-only'
James Dennett574cb4c2012-06-15 05:41:51 +00001065 * '-o \<output file>' (both '-o' and '\<output file>' are ignored)
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001066 *
Ted Kremenekbd4972442010-11-08 04:28:51 +00001067 * \param CIdx The index object with which the translation unit will be
1068 * associated.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001069 *
James Dennett574cb4c2012-06-15 05:41:51 +00001070 * \param source_filename The name of the source file to load, or NULL if the
Ted Kremenekbd4972442010-11-08 04:28:51 +00001071 * source file is included in \p clang_command_line_args.
1072 *
1073 * \param num_clang_command_line_args The number of command-line arguments in
1074 * \p clang_command_line_args.
1075 *
1076 * \param clang_command_line_args The command-line arguments that would be
1077 * passed to the \c clang executable if it were being invoked out-of-process.
1078 * These command-line options will be parsed and will affect how the translation
1079 * unit is parsed. Note that the following options are ignored: '-c',
James Dennett574cb4c2012-06-15 05:41:51 +00001080 * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001081 *
1082 * \param num_unsaved_files the number of unsaved file entries in \p
1083 * unsaved_files.
1084 *
1085 * \param unsaved_files the files that have not yet been saved to disk
1086 * but may be required for code completion, including the contents of
Ted Kremenekde24a942010-04-12 18:47:26 +00001087 * those files. The contents and name of these files (as specified by
1088 * CXUnsavedFile) are copied when necessary, so the client only needs to
1089 * guarantee their validity until the call to this function returns.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001090 */
1091CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnitFromSourceFile(
1092 CXIndex CIdx,
1093 const char *source_filename,
1094 int num_clang_command_line_args,
Douglas Gregor57879fa2010-09-01 16:43:19 +00001095 const char * const *clang_command_line_args,
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001096 unsigned num_unsaved_files,
Douglas Gregor33cdd812010-02-18 18:08:43 +00001097 struct CXUnsavedFile *unsaved_files);
Ted Kremenekd071c602010-03-13 02:50:34 +00001098
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001099/**
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001100 * \brief Same as \c clang_createTranslationUnit2, but returns
1101 * the \c CXTranslationUnit instead of an error code. In case of an error this
1102 * routine returns a \c NULL \c CXTranslationUnit, without further detailed
1103 * error codes.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001104 */
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001105CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnit(
1106 CXIndex CIdx,
1107 const char *ast_filename);
1108
1109/**
1110 * \brief Create a translation unit from an AST file (\c -emit-ast).
1111 *
1112 * \param[out] out_TU A non-NULL pointer to store the created
1113 * \c CXTranslationUnit.
1114 *
1115 * \returns Zero on success, otherwise returns an error code.
1116 */
1117CINDEX_LINKAGE enum CXErrorCode clang_createTranslationUnit2(
1118 CXIndex CIdx,
1119 const char *ast_filename,
1120 CXTranslationUnit *out_TU);
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001121
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001122/**
1123 * \brief Flags that control the creation of translation units.
1124 *
1125 * The enumerators in this enumeration type are meant to be bitwise
1126 * ORed together to specify which options should be used when
1127 * constructing the translation unit.
1128 */
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001129enum CXTranslationUnit_Flags {
1130 /**
1131 * \brief Used to indicate that no special translation-unit options are
1132 * needed.
1133 */
1134 CXTranslationUnit_None = 0x0,
1135
1136 /**
1137 * \brief Used to indicate that the parser should construct a "detailed"
1138 * preprocessing record, including all macro definitions and instantiations.
1139 *
1140 * Constructing a detailed preprocessing record requires more memory
1141 * and time to parse, since the information contained in the record
1142 * is usually not retained. However, it can be useful for
1143 * applications that require more detailed information about the
1144 * behavior of the preprocessor.
1145 */
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001146 CXTranslationUnit_DetailedPreprocessingRecord = 0x01,
1147
1148 /**
Douglas Gregor4a47bca2010-08-09 22:28:58 +00001149 * \brief Used to indicate that the translation unit is incomplete.
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001150 *
Douglas Gregor4a47bca2010-08-09 22:28:58 +00001151 * When a translation unit is considered "incomplete", semantic
1152 * analysis that is typically performed at the end of the
1153 * translation unit will be suppressed. For example, this suppresses
1154 * the completion of tentative declarations in C and of
1155 * instantiation of implicitly-instantiation function templates in
1156 * C++. This option is typically used when parsing a header with the
1157 * intent of producing a precompiled header.
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001158 */
Douglas Gregor4a47bca2010-08-09 22:28:58 +00001159 CXTranslationUnit_Incomplete = 0x02,
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001160
1161 /**
1162 * \brief Used to indicate that the translation unit should be built with an
1163 * implicit precompiled header for the preamble.
1164 *
1165 * An implicit precompiled header is used as an optimization when a
1166 * particular translation unit is likely to be reparsed many times
1167 * when the sources aren't changing that often. In this case, an
1168 * implicit precompiled header will be built containing all of the
1169 * initial includes at the top of the main file (what we refer to as
1170 * the "preamble" of the file). In subsequent parses, if the
1171 * preamble or the files in it have not changed, \c
1172 * clang_reparseTranslationUnit() will re-use the implicit
1173 * precompiled header to improve parsing performance.
1174 */
Douglas Gregorde051182010-08-11 15:58:42 +00001175 CXTranslationUnit_PrecompiledPreamble = 0x04,
1176
1177 /**
1178 * \brief Used to indicate that the translation unit should cache some
1179 * code-completion results with each reparse of the source file.
1180 *
1181 * Caching of code-completion results is a performance optimization that
1182 * introduces some overhead to reparsing but improves the performance of
1183 * code-completion operations.
1184 */
Douglas Gregorf5a18542010-10-27 17:24:53 +00001185 CXTranslationUnit_CacheCompletionResults = 0x08,
Argyrios Kyrtzidis0db720f2012-10-11 16:05:00 +00001186
Douglas Gregorf5a18542010-10-27 17:24:53 +00001187 /**
Argyrios Kyrtzidis0db720f2012-10-11 16:05:00 +00001188 * \brief Used to indicate that the translation unit will be serialized with
1189 * \c clang_saveTranslationUnit.
Douglas Gregorf5a18542010-10-27 17:24:53 +00001190 *
Argyrios Kyrtzidis0db720f2012-10-11 16:05:00 +00001191 * This option is typically used when parsing a header with the intent of
1192 * producing a precompiled header.
Douglas Gregorf5a18542010-10-27 17:24:53 +00001193 */
Argyrios Kyrtzidis0db720f2012-10-11 16:05:00 +00001194 CXTranslationUnit_ForSerialization = 0x10,
Douglas Gregorf5a18542010-10-27 17:24:53 +00001195
1196 /**
Douglas Gregor2ed0ee12011-08-25 22:54:01 +00001197 * \brief DEPRECATED: Enabled chained precompiled preambles in C++.
Douglas Gregorf5a18542010-10-27 17:24:53 +00001198 *
1199 * Note: this is a *temporary* option that is available only while
Douglas Gregor2ed0ee12011-08-25 22:54:01 +00001200 * we are testing C++ precompiled preamble support. It is deprecated.
Douglas Gregorf5a18542010-10-27 17:24:53 +00001201 */
Erik Verbruggen6e922512012-04-12 10:11:59 +00001202 CXTranslationUnit_CXXChainedPCH = 0x20,
1203
1204 /**
1205 * \brief Used to indicate that function/method bodies should be skipped while
1206 * parsing.
1207 *
1208 * This option can be used to search for declarations/definitions while
1209 * ignoring the usages.
1210 */
Dmitri Gribenko3292d062012-07-02 17:35:10 +00001211 CXTranslationUnit_SkipFunctionBodies = 0x40,
1212
1213 /**
1214 * \brief Used to indicate that brief documentation comments should be
1215 * included into the set of code completions returned from this translation
1216 * unit.
1217 */
Benjamin Kramer5c248d82015-12-15 09:30:31 +00001218 CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 0x80,
1219
1220 /**
1221 * \brief Used to indicate that the precompiled preamble should be created on
1222 * the first parse. Otherwise it will be created on the first reparse. This
1223 * trades runtime on the first parse (serializing the preamble takes time) for
1224 * reduced runtime on the second parse (can now reuse the preamble).
1225 */
Manuel Klimek016c0242016-03-01 10:56:19 +00001226 CXTranslationUnit_CreatePreambleOnFirstParse = 0x100,
1227
1228 /**
1229 * \brief Do not stop processing when fatal errors are encountered.
1230 *
1231 * When fatal errors are encountered while parsing a translation unit,
1232 * semantic analysis is typically stopped early when compiling code. A common
1233 * source for fatal errors are unresolvable include files. For the
1234 * purposes of an IDE, this is undesirable behavior and as much information
1235 * as possible should be reported. Use this flag to enable this behavior.
1236 */
1237 CXTranslationUnit_KeepGoing = 0x200
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001238};
1239
1240/**
Douglas Gregor4a47bca2010-08-09 22:28:58 +00001241 * \brief Returns the set of flags that is suitable for parsing a translation
1242 * unit that is being edited.
1243 *
1244 * The set of flags returned provide options for \c clang_parseTranslationUnit()
1245 * to indicate that the translation unit is likely to be reparsed many times,
1246 * either explicitly (via \c clang_reparseTranslationUnit()) or implicitly
1247 * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag
1248 * set contains an unspecified set of optimizations (e.g., the precompiled
1249 * preamble) geared toward improving the performance of these routines. The
1250 * set of optimizations enabled may change from one version to the next.
1251 */
Douglas Gregorde051182010-08-11 15:58:42 +00001252CINDEX_LINKAGE unsigned clang_defaultEditingTranslationUnitOptions(void);
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001253
1254/**
1255 * \brief Same as \c clang_parseTranslationUnit2, but returns
1256 * the \c CXTranslationUnit instead of an error code. In case of an error this
1257 * routine returns a \c NULL \c CXTranslationUnit, without further detailed
1258 * error codes.
1259 */
1260CINDEX_LINKAGE CXTranslationUnit
1261clang_parseTranslationUnit(CXIndex CIdx,
1262 const char *source_filename,
1263 const char *const *command_line_args,
1264 int num_command_line_args,
1265 struct CXUnsavedFile *unsaved_files,
1266 unsigned num_unsaved_files,
1267 unsigned options);
1268
Douglas Gregor4a47bca2010-08-09 22:28:58 +00001269/**
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001270 * \brief Parse the given source file and the translation unit corresponding
1271 * to that file.
1272 *
1273 * This routine is the main entry point for the Clang C API, providing the
1274 * ability to parse a source file into a translation unit that can then be
1275 * queried by other functions in the API. This routine accepts a set of
1276 * command-line arguments so that the compilation can be configured in the same
1277 * way that the compiler is configured on the command line.
1278 *
1279 * \param CIdx The index object with which the translation unit will be
1280 * associated.
1281 *
1282 * \param source_filename The name of the source file to load, or NULL if the
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001283 * source file is included in \c command_line_args.
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001284 *
1285 * \param command_line_args The command-line arguments that would be
1286 * passed to the \c clang executable if it were being invoked out-of-process.
1287 * These command-line options will be parsed and will affect how the translation
1288 * unit is parsed. Note that the following options are ignored: '-c',
James Dennett574cb4c2012-06-15 05:41:51 +00001289 * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001290 *
1291 * \param num_command_line_args The number of command-line arguments in
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001292 * \c command_line_args.
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001293 *
1294 * \param unsaved_files the files that have not yet been saved to disk
Douglas Gregor8e984da2010-08-04 16:47:14 +00001295 * but may be required for parsing, including the contents of
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001296 * those files. The contents and name of these files (as specified by
1297 * CXUnsavedFile) are copied when necessary, so the client only needs to
1298 * guarantee their validity until the call to this function returns.
1299 *
1300 * \param num_unsaved_files the number of unsaved file entries in \p
1301 * unsaved_files.
1302 *
1303 * \param options A bitmask of options that affects how the translation unit
1304 * is managed but not its compilation. This should be a bitwise OR of the
1305 * CXTranslationUnit_XXX flags.
1306 *
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001307 * \param[out] out_TU A non-NULL pointer to store the created
1308 * \c CXTranslationUnit, describing the parsed code and containing any
1309 * diagnostics produced by the compiler.
1310 *
1311 * \returns Zero on success, otherwise returns an error code.
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001312 */
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001313CINDEX_LINKAGE enum CXErrorCode
1314clang_parseTranslationUnit2(CXIndex CIdx,
1315 const char *source_filename,
1316 const char *const *command_line_args,
1317 int num_command_line_args,
1318 struct CXUnsavedFile *unsaved_files,
1319 unsigned num_unsaved_files,
1320 unsigned options,
1321 CXTranslationUnit *out_TU);
1322
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001323/**
Benjamin Kramerc02670e2015-11-18 16:14:27 +00001324 * \brief Same as clang_parseTranslationUnit2 but requires a full command line
1325 * for \c command_line_args including argv[0]. This is useful if the standard
1326 * library paths are relative to the binary.
1327 */
1328CINDEX_LINKAGE enum CXErrorCode clang_parseTranslationUnit2FullArgv(
1329 CXIndex CIdx, const char *source_filename,
1330 const char *const *command_line_args, int num_command_line_args,
1331 struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files,
1332 unsigned options, CXTranslationUnit *out_TU);
1333
1334/**
Douglas Gregor6bb92ec2010-08-13 15:35:05 +00001335 * \brief Flags that control how translation units are saved.
1336 *
1337 * The enumerators in this enumeration type are meant to be bitwise
1338 * ORed together to specify which options should be used when
1339 * saving the translation unit.
1340 */
1341enum CXSaveTranslationUnit_Flags {
1342 /**
1343 * \brief Used to indicate that no special saving options are needed.
1344 */
1345 CXSaveTranslationUnit_None = 0x0
1346};
1347
1348/**
1349 * \brief Returns the set of flags that is suitable for saving a translation
1350 * unit.
1351 *
1352 * The set of flags returned provide options for
1353 * \c clang_saveTranslationUnit() by default. The returned flag
1354 * set contains an unspecified set of options that save translation units with
1355 * the most commonly-requested data.
1356 */
1357CINDEX_LINKAGE unsigned clang_defaultSaveOptions(CXTranslationUnit TU);
1358
1359/**
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001360 * \brief Describes the kind of error that occurred (if any) in a call to
1361 * \c clang_saveTranslationUnit().
1362 */
1363enum CXSaveError {
1364 /**
1365 * \brief Indicates that no error occurred while saving a translation unit.
1366 */
1367 CXSaveError_None = 0,
1368
1369 /**
1370 * \brief Indicates that an unknown error occurred while attempting to save
1371 * the file.
1372 *
1373 * This error typically indicates that file I/O failed when attempting to
1374 * write the file.
1375 */
1376 CXSaveError_Unknown = 1,
1377
1378 /**
1379 * \brief Indicates that errors during translation prevented this attempt
1380 * to save the translation unit.
1381 *
1382 * Errors that prevent the translation unit from being saved can be
1383 * extracted using \c clang_getNumDiagnostics() and \c clang_getDiagnostic().
1384 */
1385 CXSaveError_TranslationErrors = 2,
1386
1387 /**
1388 * \brief Indicates that the translation unit to be saved was somehow
1389 * invalid (e.g., NULL).
1390 */
1391 CXSaveError_InvalidTU = 3
1392};
1393
1394/**
Douglas Gregore9386682010-08-13 05:36:37 +00001395 * \brief Saves a translation unit into a serialized representation of
1396 * that translation unit on disk.
1397 *
1398 * Any translation unit that was parsed without error can be saved
1399 * into a file. The translation unit can then be deserialized into a
1400 * new \c CXTranslationUnit with \c clang_createTranslationUnit() or,
1401 * if it is an incomplete translation unit that corresponds to a
1402 * header, used as a precompiled header when parsing other translation
1403 * units.
1404 *
1405 * \param TU The translation unit to save.
Douglas Gregor6bb92ec2010-08-13 15:35:05 +00001406 *
Douglas Gregore9386682010-08-13 05:36:37 +00001407 * \param FileName The file to which the translation unit will be saved.
1408 *
Douglas Gregor6bb92ec2010-08-13 15:35:05 +00001409 * \param options A bitmask of options that affects how the translation unit
1410 * is saved. This should be a bitwise OR of the
1411 * CXSaveTranslationUnit_XXX flags.
1412 *
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001413 * \returns A value that will match one of the enumerators of the CXSaveError
1414 * enumeration. Zero (CXSaveError_None) indicates that the translation unit was
1415 * saved successfully, while a non-zero value indicates that a problem occurred.
Douglas Gregore9386682010-08-13 05:36:37 +00001416 */
1417CINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU,
Douglas Gregor6bb92ec2010-08-13 15:35:05 +00001418 const char *FileName,
1419 unsigned options);
Douglas Gregore9386682010-08-13 05:36:37 +00001420
1421/**
Erik Verbruggen346066b2017-05-30 14:25:54 +00001422 * \brief Suspend a translation unit in order to free memory associated with it.
1423 *
1424 * A suspended translation unit uses significantly less memory but on the other
1425 * side does not support any other calls than \c clang_reparseTranslationUnit
1426 * to resume it or \c clang_disposeTranslationUnit to dispose it completely.
1427 */
1428CINDEX_LINKAGE unsigned clang_suspendTranslationUnit(CXTranslationUnit);
1429
1430/**
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001431 * \brief Destroy the specified CXTranslationUnit object.
1432 */
1433CINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit);
Ted Kremenekd071c602010-03-13 02:50:34 +00001434
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001435/**
Douglas Gregorde051182010-08-11 15:58:42 +00001436 * \brief Flags that control the reparsing of translation units.
1437 *
1438 * The enumerators in this enumeration type are meant to be bitwise
1439 * ORed together to specify which options should be used when
1440 * reparsing the translation unit.
1441 */
1442enum CXReparse_Flags {
1443 /**
1444 * \brief Used to indicate that no special reparsing options are needed.
1445 */
1446 CXReparse_None = 0x0
1447};
1448
1449/**
1450 * \brief Returns the set of flags that is suitable for reparsing a translation
1451 * unit.
1452 *
1453 * The set of flags returned provide options for
1454 * \c clang_reparseTranslationUnit() by default. The returned flag
1455 * set contains an unspecified set of optimizations geared toward common uses
1456 * of reparsing. The set of optimizations enabled may change from one version
1457 * to the next.
1458 */
1459CINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU);
1460
1461/**
Douglas Gregoraa21cc42010-07-19 21:46:24 +00001462 * \brief Reparse the source files that produced this translation unit.
1463 *
1464 * This routine can be used to re-parse the source files that originally
1465 * created the given translation unit, for example because those source files
1466 * have changed (either on disk or as passed via \p unsaved_files). The
1467 * source code will be reparsed with the same command-line options as it
1468 * was originally parsed.
1469 *
1470 * Reparsing a translation unit invalidates all cursors and source locations
1471 * that refer into that translation unit. This makes reparsing a translation
1472 * unit semantically equivalent to destroying the translation unit and then
1473 * creating a new translation unit with the same command-line arguments.
1474 * However, it may be more efficient to reparse a translation
1475 * unit using this routine.
1476 *
1477 * \param TU The translation unit whose contents will be re-parsed. The
1478 * translation unit must originally have been built with
1479 * \c clang_createTranslationUnitFromSourceFile().
1480 *
1481 * \param num_unsaved_files The number of unsaved file entries in \p
1482 * unsaved_files.
1483 *
1484 * \param unsaved_files The files that have not yet been saved to disk
1485 * but may be required for parsing, including the contents of
1486 * those files. The contents and name of these files (as specified by
1487 * CXUnsavedFile) are copied when necessary, so the client only needs to
1488 * guarantee their validity until the call to this function returns.
1489 *
Douglas Gregorde051182010-08-11 15:58:42 +00001490 * \param options A bitset of options composed of the flags in CXReparse_Flags.
1491 * The function \c clang_defaultReparseOptions() produces a default set of
1492 * options recommended for most uses, based on the translation unit.
1493 *
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001494 * \returns 0 if the sources could be reparsed. A non-zero error code will be
Douglas Gregoraa21cc42010-07-19 21:46:24 +00001495 * returned if reparsing was impossible, such that the translation unit is
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001496 * invalid. In such cases, the only valid call for \c TU is
1497 * \c clang_disposeTranslationUnit(TU). The error codes returned by this
1498 * routine are described by the \c CXErrorCode enum.
Douglas Gregoraa21cc42010-07-19 21:46:24 +00001499 */
1500CINDEX_LINKAGE int clang_reparseTranslationUnit(CXTranslationUnit TU,
1501 unsigned num_unsaved_files,
Douglas Gregorde051182010-08-11 15:58:42 +00001502 struct CXUnsavedFile *unsaved_files,
1503 unsigned options);
Ted Kremenek83f642e2011-04-18 22:47:10 +00001504
1505/**
1506 * \brief Categorizes how memory is being used by a translation unit.
1507 */
Ted Kremenek23324122011-04-20 16:41:07 +00001508enum CXTUResourceUsageKind {
1509 CXTUResourceUsage_AST = 1,
1510 CXTUResourceUsage_Identifiers = 2,
1511 CXTUResourceUsage_Selectors = 3,
1512 CXTUResourceUsage_GlobalCompletionResults = 4,
Ted Kremenek21735e62011-04-28 04:10:31 +00001513 CXTUResourceUsage_SourceManagerContentCache = 5,
Ted Kremenekf5df0ce2011-04-28 04:53:38 +00001514 CXTUResourceUsage_AST_SideTables = 6,
Ted Kremenek8d587902011-04-28 20:36:42 +00001515 CXTUResourceUsage_SourceManager_Membuffer_Malloc = 7,
Ted Kremenek5e1ed7b2011-04-28 23:46:20 +00001516 CXTUResourceUsage_SourceManager_Membuffer_MMap = 8,
1517 CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc = 9,
1518 CXTUResourceUsage_ExternalASTSource_Membuffer_MMap = 10,
Ted Kremenek2160a0d2011-05-04 01:38:46 +00001519 CXTUResourceUsage_Preprocessor = 11,
1520 CXTUResourceUsage_PreprocessingRecord = 12,
Ted Kremenek120992a2011-07-26 23:46:06 +00001521 CXTUResourceUsage_SourceManager_DataStructures = 13,
Ted Kremenekfbcce6f2011-07-26 23:46:11 +00001522 CXTUResourceUsage_Preprocessor_HeaderSearch = 14,
Ted Kremenek23324122011-04-20 16:41:07 +00001523 CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST,
1524 CXTUResourceUsage_MEMORY_IN_BYTES_END =
Ted Kremenekfbcce6f2011-07-26 23:46:11 +00001525 CXTUResourceUsage_Preprocessor_HeaderSearch,
Ted Kremenek23324122011-04-20 16:41:07 +00001526
1527 CXTUResourceUsage_First = CXTUResourceUsage_AST,
Ted Kremenekfbcce6f2011-07-26 23:46:11 +00001528 CXTUResourceUsage_Last = CXTUResourceUsage_Preprocessor_HeaderSearch
Ted Kremenek83f642e2011-04-18 22:47:10 +00001529};
1530
1531/**
1532 * \brief Returns the human-readable null-terminated C string that represents
Ted Kremenek23324122011-04-20 16:41:07 +00001533 * the name of the memory category. This string should never be freed.
Ted Kremenek83f642e2011-04-18 22:47:10 +00001534 */
1535CINDEX_LINKAGE
Ted Kremenek23324122011-04-20 16:41:07 +00001536const char *clang_getTUResourceUsageName(enum CXTUResourceUsageKind kind);
Ted Kremenek83f642e2011-04-18 22:47:10 +00001537
Ted Kremenek23324122011-04-20 16:41:07 +00001538typedef struct CXTUResourceUsageEntry {
Ted Kremenek83f642e2011-04-18 22:47:10 +00001539 /* \brief The memory usage category. */
Ted Kremenek23324122011-04-20 16:41:07 +00001540 enum CXTUResourceUsageKind kind;
1541 /* \brief Amount of resources used.
1542 The units will depend on the resource kind. */
Ted Kremenek83f642e2011-04-18 22:47:10 +00001543 unsigned long amount;
Ted Kremenek23324122011-04-20 16:41:07 +00001544} CXTUResourceUsageEntry;
Ted Kremenek83f642e2011-04-18 22:47:10 +00001545
1546/**
1547 * \brief The memory usage of a CXTranslationUnit, broken into categories.
1548 */
Ted Kremenek23324122011-04-20 16:41:07 +00001549typedef struct CXTUResourceUsage {
Ted Kremenek83f642e2011-04-18 22:47:10 +00001550 /* \brief Private data member, used for queries. */
1551 void *data;
1552
1553 /* \brief The number of entries in the 'entries' array. */
1554 unsigned numEntries;
1555
1556 /* \brief An array of key-value pairs, representing the breakdown of memory
1557 usage. */
Ted Kremenek23324122011-04-20 16:41:07 +00001558 CXTUResourceUsageEntry *entries;
Ted Kremenek83f642e2011-04-18 22:47:10 +00001559
Ted Kremenek23324122011-04-20 16:41:07 +00001560} CXTUResourceUsage;
Ted Kremenek83f642e2011-04-18 22:47:10 +00001561
1562/**
1563 * \brief Return the memory usage of a translation unit. This object
Ted Kremenek23324122011-04-20 16:41:07 +00001564 * should be released with clang_disposeCXTUResourceUsage().
Ted Kremenek83f642e2011-04-18 22:47:10 +00001565 */
Ted Kremenek23324122011-04-20 16:41:07 +00001566CINDEX_LINKAGE CXTUResourceUsage clang_getCXTUResourceUsage(CXTranslationUnit TU);
Ted Kremenek83f642e2011-04-18 22:47:10 +00001567
Ted Kremenek23324122011-04-20 16:41:07 +00001568CINDEX_LINKAGE void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage);
Ted Kremenek83f642e2011-04-18 22:47:10 +00001569
Douglas Gregoraa21cc42010-07-19 21:46:24 +00001570/**
Emilio Cobos Alvarez485ad422017-04-28 15:56:39 +00001571 * \brief Get target information for this translation unit.
1572 *
1573 * The CXTargetInfo object cannot outlive the CXTranslationUnit object.
1574 */
1575CINDEX_LINKAGE CXTargetInfo
1576clang_getTranslationUnitTargetInfo(CXTranslationUnit CTUnit);
1577
1578/**
1579 * \brief Destroy the CXTargetInfo object.
1580 */
1581CINDEX_LINKAGE void
1582clang_TargetInfo_dispose(CXTargetInfo Info);
1583
1584/**
1585 * \brief Get the normalized target triple as a string.
1586 *
1587 * Returns the empty string in case of any error.
1588 */
1589CINDEX_LINKAGE CXString
1590clang_TargetInfo_getTriple(CXTargetInfo Info);
1591
1592/**
1593 * \brief Get the pointer width of the target in bits.
1594 *
1595 * Returns -1 in case of error.
1596 */
1597CINDEX_LINKAGE int
1598clang_TargetInfo_getPointerWidth(CXTargetInfo Info);
1599
1600/**
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001601 * @}
1602 */
Ted Kremenekd071c602010-03-13 02:50:34 +00001603
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001604/**
Douglas Gregor6007cf22010-01-22 22:29:16 +00001605 * \brief Describes the kind of entity that a cursor refers to.
1606 */
1607enum CXCursorKind {
1608 /* Declarations */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001609 /**
Douglas Gregor6007cf22010-01-22 22:29:16 +00001610 * \brief A declaration whose specific kind is not exposed via this
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001611 * interface.
Douglas Gregor6007cf22010-01-22 22:29:16 +00001612 *
1613 * Unexposed declarations have the same operations as any other kind
1614 * of declaration; one can extract their location information,
1615 * spelling, find their definitions, etc. However, the specific kind
1616 * of the declaration is not reported.
1617 */
1618 CXCursor_UnexposedDecl = 1,
1619 /** \brief A C or C++ struct. */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001620 CXCursor_StructDecl = 2,
Douglas Gregor6007cf22010-01-22 22:29:16 +00001621 /** \brief A C or C++ union. */
1622 CXCursor_UnionDecl = 3,
1623 /** \brief A C++ class. */
1624 CXCursor_ClassDecl = 4,
1625 /** \brief An enumeration. */
1626 CXCursor_EnumDecl = 5,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001627 /**
Douglas Gregor6007cf22010-01-22 22:29:16 +00001628 * \brief A field (in C) or non-static data member (in C++) in a
1629 * struct, union, or C++ class.
1630 */
1631 CXCursor_FieldDecl = 6,
1632 /** \brief An enumerator constant. */
1633 CXCursor_EnumConstantDecl = 7,
1634 /** \brief A function. */
1635 CXCursor_FunctionDecl = 8,
1636 /** \brief A variable. */
1637 CXCursor_VarDecl = 9,
1638 /** \brief A function or method parameter. */
1639 CXCursor_ParmDecl = 10,
James Dennett1355bd12012-06-11 06:19:40 +00001640 /** \brief An Objective-C \@interface. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001641 CXCursor_ObjCInterfaceDecl = 11,
James Dennett1355bd12012-06-11 06:19:40 +00001642 /** \brief An Objective-C \@interface for a category. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001643 CXCursor_ObjCCategoryDecl = 12,
James Dennett1355bd12012-06-11 06:19:40 +00001644 /** \brief An Objective-C \@protocol declaration. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001645 CXCursor_ObjCProtocolDecl = 13,
James Dennett1355bd12012-06-11 06:19:40 +00001646 /** \brief An Objective-C \@property declaration. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001647 CXCursor_ObjCPropertyDecl = 14,
1648 /** \brief An Objective-C instance variable. */
1649 CXCursor_ObjCIvarDecl = 15,
1650 /** \brief An Objective-C instance method. */
1651 CXCursor_ObjCInstanceMethodDecl = 16,
1652 /** \brief An Objective-C class method. */
1653 CXCursor_ObjCClassMethodDecl = 17,
James Dennett1355bd12012-06-11 06:19:40 +00001654 /** \brief An Objective-C \@implementation. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001655 CXCursor_ObjCImplementationDecl = 18,
James Dennett1355bd12012-06-11 06:19:40 +00001656 /** \brief An Objective-C \@implementation for a category. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001657 CXCursor_ObjCCategoryImplDecl = 19,
Saleem Abdulrasool993b2862015-08-12 03:21:44 +00001658 /** \brief A typedef. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001659 CXCursor_TypedefDecl = 20,
Ted Kremenek225b8e32010-04-13 23:39:06 +00001660 /** \brief A C++ class method. */
1661 CXCursor_CXXMethod = 21,
Ted Kremenekbd67fb22010-05-06 23:38:21 +00001662 /** \brief A C++ namespace. */
1663 CXCursor_Namespace = 22,
Ted Kremenekb80cba52010-05-07 01:04:29 +00001664 /** \brief A linkage specification, e.g. 'extern "C"'. */
1665 CXCursor_LinkageSpec = 23,
Douglas Gregor12bca222010-08-31 14:41:23 +00001666 /** \brief A C++ constructor. */
1667 CXCursor_Constructor = 24,
1668 /** \brief A C++ destructor. */
1669 CXCursor_Destructor = 25,
1670 /** \brief A C++ conversion function. */
1671 CXCursor_ConversionFunction = 26,
Douglas Gregor713602b2010-08-31 17:01:39 +00001672 /** \brief A C++ template type parameter. */
1673 CXCursor_TemplateTypeParameter = 27,
1674 /** \brief A C++ non-type template parameter. */
1675 CXCursor_NonTypeTemplateParameter = 28,
1676 /** \brief A C++ template template parameter. */
1677 CXCursor_TemplateTemplateParameter = 29,
1678 /** \brief A C++ function template. */
1679 CXCursor_FunctionTemplate = 30,
Douglas Gregor1fbaeb12010-08-31 19:02:00 +00001680 /** \brief A C++ class template. */
1681 CXCursor_ClassTemplate = 31,
Douglas Gregorf96abb22010-08-31 19:31:58 +00001682 /** \brief A C++ class template partial specialization. */
1683 CXCursor_ClassTemplatePartialSpecialization = 32,
Douglas Gregora89314e2010-08-31 23:48:11 +00001684 /** \brief A C++ namespace alias declaration. */
1685 CXCursor_NamespaceAlias = 33,
Douglas Gregor01a430132010-09-01 03:07:18 +00001686 /** \brief A C++ using directive. */
1687 CXCursor_UsingDirective = 34,
Richard Smithdda56e42011-04-15 14:24:37 +00001688 /** \brief A C++ using declaration. */
Douglas Gregora9aa29c2010-09-01 19:52:22 +00001689 CXCursor_UsingDeclaration = 35,
Richard Smithdda56e42011-04-15 14:24:37 +00001690 /** \brief A C++ alias declaration */
1691 CXCursor_TypeAliasDecl = 36,
James Dennett574cb4c2012-06-15 05:41:51 +00001692 /** \brief An Objective-C \@synthesize definition. */
Douglas Gregor4cd65962011-06-03 23:08:58 +00001693 CXCursor_ObjCSynthesizeDecl = 37,
James Dennett574cb4c2012-06-15 05:41:51 +00001694 /** \brief An Objective-C \@dynamic definition. */
Douglas Gregor4cd65962011-06-03 23:08:58 +00001695 CXCursor_ObjCDynamicDecl = 38,
Argyrios Kyrtzidis12afd702011-09-30 17:58:23 +00001696 /** \brief An access specifier. */
1697 CXCursor_CXXAccessSpecifier = 39,
Douglas Gregor4c362d52011-10-05 19:00:14 +00001698
Ted Kremenek08de5c12010-05-19 21:51:10 +00001699 CXCursor_FirstDecl = CXCursor_UnexposedDecl,
Argyrios Kyrtzidis12afd702011-09-30 17:58:23 +00001700 CXCursor_LastDecl = CXCursor_CXXAccessSpecifier,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001701
Douglas Gregor6007cf22010-01-22 22:29:16 +00001702 /* References */
1703 CXCursor_FirstRef = 40, /* Decl references */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001704 CXCursor_ObjCSuperClassRef = 40,
Douglas Gregor6007cf22010-01-22 22:29:16 +00001705 CXCursor_ObjCProtocolRef = 41,
1706 CXCursor_ObjCClassRef = 42,
1707 /**
1708 * \brief A reference to a type declaration.
1709 *
1710 * A type reference occurs anywhere where a type is named but not
1711 * declared. For example, given:
1712 *
1713 * \code
1714 * typedef unsigned size_type;
1715 * size_type size;
1716 * \endcode
1717 *
1718 * The typedef is a declaration of size_type (CXCursor_TypedefDecl),
1719 * while the type of the variable "size" is referenced. The cursor
1720 * referenced by the type of size is the typedef for size_type.
1721 */
1722 CXCursor_TypeRef = 43,
Ted Kremenekae9e2212010-08-27 21:34:58 +00001723 CXCursor_CXXBaseSpecifier = 44,
Douglas Gregora23e8f72010-08-31 20:37:03 +00001724 /**
Douglas Gregorf3af3112010-09-09 21:42:20 +00001725 * \brief A reference to a class template, function template, template
1726 * template parameter, or class template partial specialization.
Douglas Gregora23e8f72010-08-31 20:37:03 +00001727 */
1728 CXCursor_TemplateRef = 45,
Douglas Gregora89314e2010-08-31 23:48:11 +00001729 /**
1730 * \brief A reference to a namespace or namespace alias.
1731 */
1732 CXCursor_NamespaceRef = 46,
Douglas Gregorf3af3112010-09-09 21:42:20 +00001733 /**
Douglas Gregora93ab662010-09-10 00:22:18 +00001734 * \brief A reference to a member of a struct, union, or class that occurs in
1735 * some non-expression context, e.g., a designated initializer.
Douglas Gregorf3af3112010-09-09 21:42:20 +00001736 */
1737 CXCursor_MemberRef = 47,
Douglas Gregora93ab662010-09-10 00:22:18 +00001738 /**
1739 * \brief A reference to a labeled statement.
1740 *
1741 * This cursor kind is used to describe the jump to "start_over" in the
1742 * goto statement in the following example:
1743 *
1744 * \code
1745 * start_over:
1746 * ++counter;
1747 *
1748 * goto start_over;
1749 * \endcode
1750 *
1751 * A label reference cursor refers to a label statement.
1752 */
1753 CXCursor_LabelRef = 48,
1754
Douglas Gregor16a2bdd2010-09-13 22:52:57 +00001755 /**
1756 * \brief A reference to a set of overloaded functions or function templates
1757 * that has not yet been resolved to a specific function or function template.
1758 *
1759 * An overloaded declaration reference cursor occurs in C++ templates where
1760 * a dependent name refers to a function. For example:
1761 *
1762 * \code
1763 * template<typename T> void swap(T&, T&);
1764 *
1765 * struct X { ... };
1766 * void swap(X&, X&);
1767 *
1768 * template<typename T>
1769 * void reverse(T* first, T* last) {
1770 * while (first < last - 1) {
1771 * swap(*first, *--last);
1772 * ++first;
1773 * }
1774 * }
1775 *
1776 * struct Y { };
1777 * void swap(Y&, Y&);
1778 * \endcode
1779 *
1780 * Here, the identifier "swap" is associated with an overloaded declaration
1781 * reference. In the template definition, "swap" refers to either of the two
1782 * "swap" functions declared above, so both results will be available. At
1783 * instantiation time, "swap" may also refer to other functions found via
1784 * argument-dependent lookup (e.g., the "swap" function at the end of the
1785 * example).
1786 *
1787 * The functions \c clang_getNumOverloadedDecls() and
1788 * \c clang_getOverloadedDecl() can be used to retrieve the definitions
1789 * referenced by this cursor.
1790 */
1791 CXCursor_OverloadedDeclRef = 49,
1792
Douglas Gregor30093832012-02-15 00:54:55 +00001793 /**
1794 * \brief A reference to a variable that occurs in some non-expression
1795 * context, e.g., a C++ lambda capture list.
1796 */
1797 CXCursor_VariableRef = 50,
1798
1799 CXCursor_LastRef = CXCursor_VariableRef,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001800
Douglas Gregor6007cf22010-01-22 22:29:16 +00001801 /* Error conditions */
1802 CXCursor_FirstInvalid = 70,
1803 CXCursor_InvalidFile = 70,
1804 CXCursor_NoDeclFound = 71,
1805 CXCursor_NotImplemented = 72,
Ted Kremeneke184ac52010-03-19 20:39:03 +00001806 CXCursor_InvalidCode = 73,
1807 CXCursor_LastInvalid = CXCursor_InvalidCode,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001808
Douglas Gregor6007cf22010-01-22 22:29:16 +00001809 /* Expressions */
1810 CXCursor_FirstExpr = 100,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001811
Douglas Gregor6007cf22010-01-22 22:29:16 +00001812 /**
1813 * \brief An expression whose specific kind is not exposed via this
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001814 * interface.
Douglas Gregor6007cf22010-01-22 22:29:16 +00001815 *
1816 * Unexposed expressions have the same operations as any other kind
1817 * of expression; one can extract their location information,
1818 * spelling, children, etc. However, the specific kind of the
1819 * expression is not reported.
1820 */
1821 CXCursor_UnexposedExpr = 100,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001822
Douglas Gregor6007cf22010-01-22 22:29:16 +00001823 /**
1824 * \brief An expression that refers to some value declaration, such
Nico Weber7deebef2014-04-24 03:17:47 +00001825 * as a function, variable, or enumerator.
Douglas Gregor6007cf22010-01-22 22:29:16 +00001826 */
1827 CXCursor_DeclRefExpr = 101,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001828
Douglas Gregor6007cf22010-01-22 22:29:16 +00001829 /**
1830 * \brief An expression that refers to a member of a struct, union,
1831 * class, Objective-C class, etc.
1832 */
1833 CXCursor_MemberRefExpr = 102,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001834
Douglas Gregor6007cf22010-01-22 22:29:16 +00001835 /** \brief An expression that calls a function. */
1836 CXCursor_CallExpr = 103,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001837
Douglas Gregor6007cf22010-01-22 22:29:16 +00001838 /** \brief An expression that sends a message to an Objective-C
1839 object or class. */
1840 CXCursor_ObjCMessageExpr = 104,
Ted Kremenek33b9a422010-04-11 21:47:37 +00001841
1842 /** \brief An expression that represents a block literal. */
1843 CXCursor_BlockExpr = 105,
1844
Douglas Gregor4c362d52011-10-05 19:00:14 +00001845 /** \brief An integer literal.
1846 */
1847 CXCursor_IntegerLiteral = 106,
1848
1849 /** \brief A floating point number literal.
1850 */
1851 CXCursor_FloatingLiteral = 107,
1852
1853 /** \brief An imaginary number literal.
1854 */
1855 CXCursor_ImaginaryLiteral = 108,
1856
1857 /** \brief A string literal.
1858 */
1859 CXCursor_StringLiteral = 109,
1860
1861 /** \brief A character literal.
1862 */
1863 CXCursor_CharacterLiteral = 110,
1864
1865 /** \brief A parenthesized expression, e.g. "(1)".
1866 *
1867 * This AST node is only formed if full location information is requested.
1868 */
1869 CXCursor_ParenExpr = 111,
1870
1871 /** \brief This represents the unary-expression's (except sizeof and
1872 * alignof).
1873 */
1874 CXCursor_UnaryOperator = 112,
1875
1876 /** \brief [C99 6.5.2.1] Array Subscripting.
1877 */
1878 CXCursor_ArraySubscriptExpr = 113,
1879
1880 /** \brief A builtin binary operation expression such as "x + y" or
1881 * "x <= y".
1882 */
1883 CXCursor_BinaryOperator = 114,
1884
1885 /** \brief Compound assignment such as "+=".
1886 */
1887 CXCursor_CompoundAssignOperator = 115,
1888
1889 /** \brief The ?: ternary operator.
1890 */
1891 CXCursor_ConditionalOperator = 116,
1892
1893 /** \brief An explicit cast in C (C99 6.5.4) or a C-style cast in C++
1894 * (C++ [expr.cast]), which uses the syntax (Type)expr.
1895 *
1896 * For example: (int)f.
1897 */
1898 CXCursor_CStyleCastExpr = 117,
1899
1900 /** \brief [C99 6.5.2.5]
1901 */
1902 CXCursor_CompoundLiteralExpr = 118,
1903
1904 /** \brief Describes an C or C++ initializer list.
1905 */
1906 CXCursor_InitListExpr = 119,
1907
1908 /** \brief The GNU address of label extension, representing &&label.
1909 */
1910 CXCursor_AddrLabelExpr = 120,
1911
1912 /** \brief This is the GNU Statement Expression extension: ({int X=4; X;})
1913 */
1914 CXCursor_StmtExpr = 121,
1915
Benjamin Kramere56f3932011-12-23 17:00:35 +00001916 /** \brief Represents a C11 generic selection.
Douglas Gregor4c362d52011-10-05 19:00:14 +00001917 */
1918 CXCursor_GenericSelectionExpr = 122,
1919
1920 /** \brief Implements the GNU __null extension, which is a name for a null
1921 * pointer constant that has integral type (e.g., int or long) and is the same
1922 * size and alignment as a pointer.
1923 *
1924 * The __null extension is typically only used by system headers, which define
1925 * NULL as __null in C++ rather than using 0 (which is an integer that may not
1926 * match the size of a pointer).
1927 */
1928 CXCursor_GNUNullExpr = 123,
1929
1930 /** \brief C++'s static_cast<> expression.
1931 */
1932 CXCursor_CXXStaticCastExpr = 124,
1933
1934 /** \brief C++'s dynamic_cast<> expression.
1935 */
1936 CXCursor_CXXDynamicCastExpr = 125,
1937
1938 /** \brief C++'s reinterpret_cast<> expression.
1939 */
1940 CXCursor_CXXReinterpretCastExpr = 126,
1941
1942 /** \brief C++'s const_cast<> expression.
1943 */
1944 CXCursor_CXXConstCastExpr = 127,
1945
1946 /** \brief Represents an explicit C++ type conversion that uses "functional"
1947 * notion (C++ [expr.type.conv]).
1948 *
1949 * Example:
1950 * \code
1951 * x = int(0.5);
1952 * \endcode
1953 */
1954 CXCursor_CXXFunctionalCastExpr = 128,
1955
1956 /** \brief A C++ typeid expression (C++ [expr.typeid]).
1957 */
1958 CXCursor_CXXTypeidExpr = 129,
1959
1960 /** \brief [C++ 2.13.5] C++ Boolean Literal.
1961 */
1962 CXCursor_CXXBoolLiteralExpr = 130,
1963
1964 /** \brief [C++0x 2.14.7] C++ Pointer Literal.
1965 */
1966 CXCursor_CXXNullPtrLiteralExpr = 131,
1967
1968 /** \brief Represents the "this" expression in C++
1969 */
1970 CXCursor_CXXThisExpr = 132,
1971
1972 /** \brief [C++ 15] C++ Throw Expression.
1973 *
1974 * This handles 'throw' and 'throw' assignment-expression. When
1975 * assignment-expression isn't present, Op will be null.
1976 */
1977 CXCursor_CXXThrowExpr = 133,
1978
1979 /** \brief A new expression for memory allocation and constructor calls, e.g:
1980 * "new CXXNewExpr(foo)".
1981 */
1982 CXCursor_CXXNewExpr = 134,
1983
1984 /** \brief A delete expression for memory deallocation and destructor calls,
1985 * e.g. "delete[] pArray".
1986 */
1987 CXCursor_CXXDeleteExpr = 135,
1988
Olivier Goffart692d5332016-06-09 16:16:06 +00001989 /** \brief A unary expression. (noexcept, sizeof, or other traits)
Douglas Gregor4c362d52011-10-05 19:00:14 +00001990 */
1991 CXCursor_UnaryExpr = 136,
1992
Douglas Gregor910c37c2011-11-11 22:35:18 +00001993 /** \brief An Objective-C string literal i.e. @"foo".
Douglas Gregor4c362d52011-10-05 19:00:14 +00001994 */
1995 CXCursor_ObjCStringLiteral = 137,
1996
James Dennett574cb4c2012-06-15 05:41:51 +00001997 /** \brief An Objective-C \@encode expression.
Douglas Gregor4c362d52011-10-05 19:00:14 +00001998 */
1999 CXCursor_ObjCEncodeExpr = 138,
2000
James Dennett574cb4c2012-06-15 05:41:51 +00002001 /** \brief An Objective-C \@selector expression.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002002 */
2003 CXCursor_ObjCSelectorExpr = 139,
2004
James Dennett1355bd12012-06-11 06:19:40 +00002005 /** \brief An Objective-C \@protocol expression.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002006 */
2007 CXCursor_ObjCProtocolExpr = 140,
2008
2009 /** \brief An Objective-C "bridged" cast expression, which casts between
2010 * Objective-C pointers and C pointers, transferring ownership in the process.
2011 *
2012 * \code
2013 * NSString *str = (__bridge_transfer NSString *)CFCreateString();
2014 * \endcode
2015 */
2016 CXCursor_ObjCBridgedCastExpr = 141,
2017
2018 /** \brief Represents a C++0x pack expansion that produces a sequence of
2019 * expressions.
2020 *
2021 * A pack expansion expression contains a pattern (which itself is an
2022 * expression) followed by an ellipsis. For example:
2023 *
2024 * \code
2025 * template<typename F, typename ...Types>
2026 * void forward(F f, Types &&...args) {
2027 * f(static_cast<Types&&>(args)...);
2028 * }
2029 * \endcode
2030 */
2031 CXCursor_PackExpansionExpr = 142,
2032
2033 /** \brief Represents an expression that computes the length of a parameter
2034 * pack.
2035 *
2036 * \code
2037 * template<typename ...Types>
2038 * struct count {
2039 * static const unsigned value = sizeof...(Types);
2040 * };
2041 * \endcode
2042 */
2043 CXCursor_SizeOfPackExpr = 143,
2044
Douglas Gregor30093832012-02-15 00:54:55 +00002045 /* \brief Represents a C++ lambda expression that produces a local function
2046 * object.
2047 *
2048 * \code
2049 * void abssort(float *x, unsigned N) {
2050 * std::sort(x, x + N,
2051 * [](float a, float b) {
2052 * return std::abs(a) < std::abs(b);
2053 * });
2054 * }
2055 * \endcode
2056 */
2057 CXCursor_LambdaExpr = 144,
2058
Ted Kremenek77006f62012-03-06 20:06:06 +00002059 /** \brief Objective-c Boolean Literal.
2060 */
2061 CXCursor_ObjCBoolLiteralExpr = 145,
2062
Nico Weber7deebef2014-04-24 03:17:47 +00002063 /** \brief Represents the "self" expression in an Objective-C method.
Argyrios Kyrtzidisc2233be2013-04-23 17:57:17 +00002064 */
2065 CXCursor_ObjCSelfExpr = 146,
2066
Alexey Bataev1a3320e2015-08-25 14:24:04 +00002067 /** \brief OpenMP 4.0 [2.4, Array Section].
2068 */
2069 CXCursor_OMPArraySectionExpr = 147,
2070
Erik Pilkington29099de2016-07-16 00:35:23 +00002071 /** \brief Represents an @available(...) check.
2072 */
2073 CXCursor_ObjCAvailabilityCheckExpr = 148,
2074
2075 CXCursor_LastExpr = CXCursor_ObjCAvailabilityCheckExpr,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002076
Douglas Gregor6007cf22010-01-22 22:29:16 +00002077 /* Statements */
2078 CXCursor_FirstStmt = 200,
2079 /**
2080 * \brief A statement whose specific kind is not exposed via this
2081 * interface.
2082 *
2083 * Unexposed statements have the same operations as any other kind of
2084 * statement; one can extract their location information, spelling,
2085 * children, etc. However, the specific kind of the statement is not
2086 * reported.
2087 */
2088 CXCursor_UnexposedStmt = 200,
Douglas Gregora93ab662010-09-10 00:22:18 +00002089
2090 /** \brief A labelled statement in a function.
2091 *
2092 * This cursor kind is used to describe the "start_over:" label statement in
2093 * the following example:
2094 *
2095 * \code
2096 * start_over:
2097 * ++counter;
2098 * \endcode
2099 *
2100 */
2101 CXCursor_LabelStmt = 201,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002102
2103 /** \brief A group of statements like { stmt stmt }.
2104 *
2105 * This cursor kind is used to describe compound statements, e.g. function
2106 * bodies.
2107 */
2108 CXCursor_CompoundStmt = 202,
2109
Benjamin Kramer2501f142013-10-20 11:47:15 +00002110 /** \brief A case statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002111 */
2112 CXCursor_CaseStmt = 203,
2113
2114 /** \brief A default statement.
2115 */
2116 CXCursor_DefaultStmt = 204,
2117
2118 /** \brief An if statement
2119 */
2120 CXCursor_IfStmt = 205,
2121
2122 /** \brief A switch statement.
2123 */
2124 CXCursor_SwitchStmt = 206,
2125
2126 /** \brief A while statement.
2127 */
2128 CXCursor_WhileStmt = 207,
2129
2130 /** \brief A do statement.
2131 */
2132 CXCursor_DoStmt = 208,
2133
2134 /** \brief A for statement.
2135 */
2136 CXCursor_ForStmt = 209,
2137
2138 /** \brief A goto statement.
2139 */
2140 CXCursor_GotoStmt = 210,
2141
2142 /** \brief An indirect goto statement.
2143 */
2144 CXCursor_IndirectGotoStmt = 211,
2145
2146 /** \brief A continue statement.
2147 */
2148 CXCursor_ContinueStmt = 212,
2149
2150 /** \brief A break statement.
2151 */
2152 CXCursor_BreakStmt = 213,
2153
2154 /** \brief A return statement.
2155 */
2156 CXCursor_ReturnStmt = 214,
2157
Chad Rosierde70e0e2012-08-25 00:11:56 +00002158 /** \brief A GCC inline assembly statement extension.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002159 */
Chad Rosierde70e0e2012-08-25 00:11:56 +00002160 CXCursor_GCCAsmStmt = 215,
Argyrios Kyrtzidis5eae0732012-09-24 19:27:20 +00002161 CXCursor_AsmStmt = CXCursor_GCCAsmStmt,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002162
James Dennett574cb4c2012-06-15 05:41:51 +00002163 /** \brief Objective-C's overall \@try-\@catch-\@finally statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002164 */
2165 CXCursor_ObjCAtTryStmt = 216,
2166
James Dennett574cb4c2012-06-15 05:41:51 +00002167 /** \brief Objective-C's \@catch statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002168 */
2169 CXCursor_ObjCAtCatchStmt = 217,
2170
James Dennett574cb4c2012-06-15 05:41:51 +00002171 /** \brief Objective-C's \@finally statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002172 */
2173 CXCursor_ObjCAtFinallyStmt = 218,
2174
James Dennett574cb4c2012-06-15 05:41:51 +00002175 /** \brief Objective-C's \@throw statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002176 */
2177 CXCursor_ObjCAtThrowStmt = 219,
2178
James Dennett574cb4c2012-06-15 05:41:51 +00002179 /** \brief Objective-C's \@synchronized statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002180 */
2181 CXCursor_ObjCAtSynchronizedStmt = 220,
2182
2183 /** \brief Objective-C's autorelease pool statement.
2184 */
2185 CXCursor_ObjCAutoreleasePoolStmt = 221,
2186
2187 /** \brief Objective-C's collection statement.
2188 */
2189 CXCursor_ObjCForCollectionStmt = 222,
2190
2191 /** \brief C++'s catch statement.
2192 */
2193 CXCursor_CXXCatchStmt = 223,
2194
2195 /** \brief C++'s try statement.
2196 */
2197 CXCursor_CXXTryStmt = 224,
2198
2199 /** \brief C++'s for (* : *) statement.
2200 */
2201 CXCursor_CXXForRangeStmt = 225,
2202
2203 /** \brief Windows Structured Exception Handling's try statement.
2204 */
2205 CXCursor_SEHTryStmt = 226,
2206
2207 /** \brief Windows Structured Exception Handling's except statement.
2208 */
2209 CXCursor_SEHExceptStmt = 227,
2210
2211 /** \brief Windows Structured Exception Handling's finally statement.
2212 */
2213 CXCursor_SEHFinallyStmt = 228,
2214
Chad Rosier32503022012-06-11 20:47:18 +00002215 /** \brief A MS inline assembly statement extension.
2216 */
2217 CXCursor_MSAsmStmt = 229,
2218
Chad Rosierdb1cc7f2014-12-05 15:50:44 +00002219 /** \brief The null statement ";": C99 6.8.3p3.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002220 *
2221 * This cursor kind is used to describe the null statement.
2222 */
2223 CXCursor_NullStmt = 230,
2224
2225 /** \brief Adaptor class for mixing declarations with statements and
2226 * expressions.
2227 */
2228 CXCursor_DeclStmt = 231,
2229
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002230 /** \brief OpenMP parallel directive.
2231 */
2232 CXCursor_OMPParallelDirective = 232,
2233
Chad Rosierdb1cc7f2014-12-05 15:50:44 +00002234 /** \brief OpenMP SIMD directive.
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002235 */
2236 CXCursor_OMPSimdDirective = 233,
2237
Alexey Bataevf29276e2014-06-18 04:14:57 +00002238 /** \brief OpenMP for directive.
2239 */
2240 CXCursor_OMPForDirective = 234,
2241
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002242 /** \brief OpenMP sections directive.
2243 */
2244 CXCursor_OMPSectionsDirective = 235,
2245
Alexey Bataev1e0498a2014-06-26 08:21:58 +00002246 /** \brief OpenMP section directive.
2247 */
2248 CXCursor_OMPSectionDirective = 236,
2249
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00002250 /** \brief OpenMP single directive.
2251 */
2252 CXCursor_OMPSingleDirective = 237,
2253
Alexey Bataev4acb8592014-07-07 13:01:15 +00002254 /** \brief OpenMP parallel for directive.
2255 */
2256 CXCursor_OMPParallelForDirective = 238,
2257
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002258 /** \brief OpenMP parallel sections directive.
2259 */
2260 CXCursor_OMPParallelSectionsDirective = 239,
2261
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002262 /** \brief OpenMP task directive.
2263 */
2264 CXCursor_OMPTaskDirective = 240,
2265
Alexander Musman80c22892014-07-17 08:54:58 +00002266 /** \brief OpenMP master directive.
2267 */
2268 CXCursor_OMPMasterDirective = 241,
2269
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002270 /** \brief OpenMP critical directive.
2271 */
2272 CXCursor_OMPCriticalDirective = 242,
2273
Alexey Bataev68446b72014-07-18 07:47:19 +00002274 /** \brief OpenMP taskyield directive.
2275 */
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002276 CXCursor_OMPTaskyieldDirective = 243,
Alexey Bataev68446b72014-07-18 07:47:19 +00002277
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00002278 /** \brief OpenMP barrier directive.
2279 */
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002280 CXCursor_OMPBarrierDirective = 244,
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00002281
Alexey Bataev2df347a2014-07-18 10:17:07 +00002282 /** \brief OpenMP taskwait directive.
2283 */
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002284 CXCursor_OMPTaskwaitDirective = 245,
Alexey Bataev2df347a2014-07-18 10:17:07 +00002285
Alexey Bataev6125da92014-07-21 11:26:11 +00002286 /** \brief OpenMP flush directive.
2287 */
2288 CXCursor_OMPFlushDirective = 246,
Alexey Bataev0162e452014-07-22 10:10:35 +00002289
Reid Klecknerba764482014-07-24 18:22:15 +00002290 /** \brief Windows Structured Exception Handling's leave statement.
2291 */
2292 CXCursor_SEHLeaveStmt = 247,
2293
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002294 /** \brief OpenMP ordered directive.
2295 */
Reid Klecknerba764482014-07-24 18:22:15 +00002296 CXCursor_OMPOrderedDirective = 248,
Alexey Bataev6125da92014-07-21 11:26:11 +00002297
Alexey Bataev0162e452014-07-22 10:10:35 +00002298 /** \brief OpenMP atomic directive.
2299 */
Reid Klecknerba764482014-07-24 18:22:15 +00002300 CXCursor_OMPAtomicDirective = 249,
Alexey Bataev0162e452014-07-22 10:10:35 +00002301
Chad Rosierdb1cc7f2014-12-05 15:50:44 +00002302 /** \brief OpenMP for SIMD directive.
Alexander Musmanf82886e2014-09-18 05:12:34 +00002303 */
2304 CXCursor_OMPForSimdDirective = 250,
2305
Chad Rosierdb1cc7f2014-12-05 15:50:44 +00002306 /** \brief OpenMP parallel for SIMD directive.
Alexander Musmane4e893b2014-09-23 09:33:00 +00002307 */
2308 CXCursor_OMPParallelForSimdDirective = 251,
2309
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002310 /** \brief OpenMP target directive.
2311 */
Alexander Musmane4e893b2014-09-23 09:33:00 +00002312 CXCursor_OMPTargetDirective = 252,
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002313
Alexey Bataev13314bf2014-10-09 04:18:56 +00002314 /** \brief OpenMP teams directive.
2315 */
2316 CXCursor_OMPTeamsDirective = 253,
2317
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002318 /** \brief OpenMP taskgroup directive.
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002319 */
Michael Wong65f367f2015-07-21 13:44:28 +00002320 CXCursor_OMPTaskgroupDirective = 254,
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002321
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002322 /** \brief OpenMP cancellation point directive.
2323 */
Michael Wong65f367f2015-07-21 13:44:28 +00002324 CXCursor_OMPCancellationPointDirective = 255,
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002325
Alexey Bataev80909872015-07-02 11:25:17 +00002326 /** \brief OpenMP cancel directive.
2327 */
Michael Wong65f367f2015-07-21 13:44:28 +00002328 CXCursor_OMPCancelDirective = 256,
Alexey Bataev80909872015-07-02 11:25:17 +00002329
Michael Wong65f367f2015-07-21 13:44:28 +00002330 /** \brief OpenMP target data directive.
2331 */
2332 CXCursor_OMPTargetDataDirective = 257,
2333
Alexey Bataev49f6e782015-12-01 04:18:41 +00002334 /** \brief OpenMP taskloop directive.
2335 */
2336 CXCursor_OMPTaskLoopDirective = 258,
2337
Alexey Bataev0a6ed842015-12-03 09:40:15 +00002338 /** \brief OpenMP taskloop simd directive.
2339 */
2340 CXCursor_OMPTaskLoopSimdDirective = 259,
2341
Samuel Antao686c70c2016-05-26 17:30:50 +00002342 /** \brief OpenMP distribute directive.
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00002343 */
2344 CXCursor_OMPDistributeDirective = 260,
2345
Samuel Antaodf67fc42016-01-19 19:15:56 +00002346 /** \brief OpenMP target enter data directive.
2347 */
2348 CXCursor_OMPTargetEnterDataDirective = 261,
2349
Samuel Antao72590762016-01-19 20:04:50 +00002350 /** \brief OpenMP target exit data directive.
2351 */
2352 CXCursor_OMPTargetExitDataDirective = 262,
2353
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002354 /** \brief OpenMP target parallel directive.
2355 */
2356 CXCursor_OMPTargetParallelDirective = 263,
2357
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00002358 /** \brief OpenMP target parallel for directive.
2359 */
2360 CXCursor_OMPTargetParallelForDirective = 264,
2361
Samuel Antao686c70c2016-05-26 17:30:50 +00002362 /** \brief OpenMP target update directive.
2363 */
2364 CXCursor_OMPTargetUpdateDirective = 265,
2365
Carlo Bertolli9925f152016-06-27 14:55:37 +00002366 /** \brief OpenMP distribute parallel for directive.
2367 */
2368 CXCursor_OMPDistributeParallelForDirective = 266,
2369
Kelvin Li4a39add2016-07-05 05:00:15 +00002370 /** \brief OpenMP distribute parallel for simd directive.
2371 */
2372 CXCursor_OMPDistributeParallelForSimdDirective = 267,
2373
Kelvin Li787f3fc2016-07-06 04:45:38 +00002374 /** \brief OpenMP distribute simd directive.
2375 */
2376 CXCursor_OMPDistributeSimdDirective = 268,
2377
Kelvin Lia579b912016-07-14 02:54:56 +00002378 /** \brief OpenMP target parallel for simd directive.
2379 */
2380 CXCursor_OMPTargetParallelForSimdDirective = 269,
2381
Kelvin Li986330c2016-07-20 22:57:10 +00002382 /** \brief OpenMP target simd directive.
2383 */
2384 CXCursor_OMPTargetSimdDirective = 270,
2385
Kelvin Li02532872016-08-05 14:37:37 +00002386 /** \brief OpenMP teams distribute directive.
2387 */
2388 CXCursor_OMPTeamsDistributeDirective = 271,
2389
Kelvin Li4e325f72016-10-25 12:50:55 +00002390 /** \brief OpenMP teams distribute simd directive.
2391 */
2392 CXCursor_OMPTeamsDistributeSimdDirective = 272,
2393
Kelvin Li579e41c2016-11-30 23:51:03 +00002394 /** \brief OpenMP teams distribute parallel for simd directive.
2395 */
2396 CXCursor_OMPTeamsDistributeParallelForSimdDirective = 273,
2397
Kelvin Li7ade93f2016-12-09 03:24:30 +00002398 /** \brief OpenMP teams distribute parallel for directive.
2399 */
2400 CXCursor_OMPTeamsDistributeParallelForDirective = 274,
2401
Kelvin Libf594a52016-12-17 05:48:59 +00002402 /** \brief OpenMP target teams directive.
2403 */
2404 CXCursor_OMPTargetTeamsDirective = 275,
2405
Kelvin Li83c451e2016-12-25 04:52:54 +00002406 /** \brief OpenMP target teams distribute directive.
2407 */
2408 CXCursor_OMPTargetTeamsDistributeDirective = 276,
2409
Kelvin Li80e8f562016-12-29 22:16:30 +00002410 /** \brief OpenMP target teams distribute parallel for directive.
2411 */
2412 CXCursor_OMPTargetTeamsDistributeParallelForDirective = 277,
2413
Kelvin Li1851df52017-01-03 05:23:48 +00002414 /** \brief OpenMP target teams distribute parallel for simd directive.
2415 */
2416 CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective = 278,
2417
Kelvin Lida681182017-01-10 18:08:18 +00002418 /** \brief OpenMP target teams distribute simd directive.
2419 */
2420 CXCursor_OMPTargetTeamsDistributeSimdDirective = 279,
2421
2422 CXCursor_LastStmt = CXCursor_OMPTargetTeamsDistributeSimdDirective,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002423
Douglas Gregor6007cf22010-01-22 22:29:16 +00002424 /**
2425 * \brief Cursor that represents the translation unit itself.
2426 *
2427 * The translation unit cursor exists primarily to act as the root
2428 * cursor for traversing the contents of a translation unit.
2429 */
Ted Kremenekbff31432010-02-18 03:09:07 +00002430 CXCursor_TranslationUnit = 300,
2431
Bill Wendling44426052012-12-20 19:22:21 +00002432 /* Attributes */
Ted Kremenekbff31432010-02-18 03:09:07 +00002433 CXCursor_FirstAttr = 400,
2434 /**
2435 * \brief An attribute whose specific kind is not exposed via this
2436 * interface.
2437 */
2438 CXCursor_UnexposedAttr = 400,
2439
2440 CXCursor_IBActionAttr = 401,
2441 CXCursor_IBOutletAttr = 402,
Ted Kremenek26bde772010-05-19 17:38:06 +00002442 CXCursor_IBOutletCollectionAttr = 403,
Argyrios Kyrtzidis2cb4e3c2011-09-13 17:39:31 +00002443 CXCursor_CXXFinalAttr = 404,
2444 CXCursor_CXXOverrideAttr = 405,
Erik Verbruggenca98f2a2011-10-13 09:41:32 +00002445 CXCursor_AnnotateAttr = 406,
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00002446 CXCursor_AsmLabelAttr = 407,
Argyrios Kyrtzidis16834f12013-09-25 00:14:38 +00002447 CXCursor_PackedAttr = 408,
Joey Gouly81228382014-05-01 15:41:58 +00002448 CXCursor_PureAttr = 409,
2449 CXCursor_ConstAttr = 410,
2450 CXCursor_NoDuplicateAttr = 411,
Eli Bendersky2581e662014-05-28 19:29:58 +00002451 CXCursor_CUDAConstantAttr = 412,
2452 CXCursor_CUDADeviceAttr = 413,
2453 CXCursor_CUDAGlobalAttr = 414,
2454 CXCursor_CUDAHostAttr = 415,
Eli Bendersky9b071472014-08-08 14:59:00 +00002455 CXCursor_CUDASharedAttr = 416,
Saleem Abdulrasool79c69712015-09-05 18:53:43 +00002456 CXCursor_VisibilityAttr = 417,
Saleem Abdulrasool8aa0b802015-12-10 18:45:18 +00002457 CXCursor_DLLExport = 418,
2458 CXCursor_DLLImport = 419,
2459 CXCursor_LastAttr = CXCursor_DLLImport,
Eli Bendersky2581e662014-05-28 19:29:58 +00002460
Douglas Gregor92a524f2010-03-18 00:42:48 +00002461 /* Preprocessing */
2462 CXCursor_PreprocessingDirective = 500,
Douglas Gregor06d6d322010-03-18 18:04:21 +00002463 CXCursor_MacroDefinition = 501,
Chandler Carruth9e4704a2011-07-14 08:41:15 +00002464 CXCursor_MacroExpansion = 502,
2465 CXCursor_MacroInstantiation = CXCursor_MacroExpansion,
Douglas Gregor796d76a2010-10-20 22:00:55 +00002466 CXCursor_InclusionDirective = 503,
Douglas Gregor92a524f2010-03-18 00:42:48 +00002467 CXCursor_FirstPreprocessing = CXCursor_PreprocessingDirective,
Argyrios Kyrtzidis50e5b1d2012-10-05 00:22:24 +00002468 CXCursor_LastPreprocessing = CXCursor_InclusionDirective,
2469
2470 /* Extra Declarations */
2471 /**
2472 * \brief A module import declaration.
2473 */
2474 CXCursor_ModuleImportDecl = 600,
Sergey Kalinichev8f3b1872015-11-15 13:48:32 +00002475 CXCursor_TypeAliasTemplateDecl = 601,
Olivier Goffart81978012016-06-09 16:15:55 +00002476 /**
2477 * \brief A static_assert or _Static_assert node
2478 */
2479 CXCursor_StaticAssert = 602,
Olivier Goffartd211c642016-11-04 06:29:27 +00002480 /**
2481 * \brief a friend declaration.
2482 */
2483 CXCursor_FriendDecl = 603,
Argyrios Kyrtzidis50e5b1d2012-10-05 00:22:24 +00002484 CXCursor_FirstExtraDecl = CXCursor_ModuleImportDecl,
Olivier Goffartd211c642016-11-04 06:29:27 +00002485 CXCursor_LastExtraDecl = CXCursor_FriendDecl,
Francisco Lopes da Silva975a9f62015-01-21 16:24:11 +00002486
2487 /**
2488 * \brief A code completion overload candidate.
2489 */
2490 CXCursor_OverloadCandidate = 700
Douglas Gregor6007cf22010-01-22 22:29:16 +00002491};
2492
2493/**
2494 * \brief A cursor representing some element in the abstract syntax tree for
2495 * a translation unit.
2496 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002497 * The cursor abstraction unifies the different kinds of entities in a
Douglas Gregor6007cf22010-01-22 22:29:16 +00002498 * program--declaration, statements, expressions, references to declarations,
2499 * etc.--under a single "cursor" abstraction with a common set of operations.
2500 * Common operation for a cursor include: getting the physical location in
2501 * a source file where the cursor points, getting the name associated with a
2502 * cursor, and retrieving cursors for any child nodes of a particular cursor.
2503 *
2504 * Cursors can be produced in two specific ways.
2505 * clang_getTranslationUnitCursor() produces a cursor for a translation unit,
2506 * from which one can use clang_visitChildren() to explore the rest of the
2507 * translation unit. clang_getCursor() maps from a physical source location
2508 * to the entity that resides at that location, allowing one to map from the
2509 * source code into the AST.
2510 */
2511typedef struct {
2512 enum CXCursorKind kind;
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00002513 int xdata;
Dmitri Gribenkoba2f7462013-01-11 21:01:49 +00002514 const void *data[3];
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002515} CXCursor;
Douglas Gregor6007cf22010-01-22 22:29:16 +00002516
2517/**
2518 * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations
2519 *
2520 * @{
2521 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002522
Douglas Gregor6007cf22010-01-22 22:29:16 +00002523/**
2524 * \brief Retrieve the NULL cursor, which represents no entity.
2525 */
2526CINDEX_LINKAGE CXCursor clang_getNullCursor(void);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002527
Douglas Gregor6007cf22010-01-22 22:29:16 +00002528/**
2529 * \brief Retrieve the cursor that represents the given translation unit.
2530 *
2531 * The translation unit cursor can be used to start traversing the
2532 * various declarations within the given translation unit.
2533 */
2534CINDEX_LINKAGE CXCursor clang_getTranslationUnitCursor(CXTranslationUnit);
2535
2536/**
2537 * \brief Determine whether two cursors are equivalent.
2538 */
2539CINDEX_LINKAGE unsigned clang_equalCursors(CXCursor, CXCursor);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002540
Douglas Gregor6007cf22010-01-22 22:29:16 +00002541/**
Dmitri Gribenko8994e0c2012-09-13 13:11:20 +00002542 * \brief Returns non-zero if \p cursor is null.
Argyrios Kyrtzidisd6e9fa52011-09-27 00:30:30 +00002543 */
Dmitri Gribenko8994e0c2012-09-13 13:11:20 +00002544CINDEX_LINKAGE int clang_Cursor_isNull(CXCursor cursor);
Argyrios Kyrtzidisd6e9fa52011-09-27 00:30:30 +00002545
2546/**
Douglas Gregor06a3f302010-11-20 00:09:34 +00002547 * \brief Compute a hash value for the given cursor.
2548 */
2549CINDEX_LINKAGE unsigned clang_hashCursor(CXCursor);
2550
2551/**
Douglas Gregor6007cf22010-01-22 22:29:16 +00002552 * \brief Retrieve the kind of the given cursor.
2553 */
2554CINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor);
2555
2556/**
2557 * \brief Determine whether the given cursor kind represents a declaration.
2558 */
2559CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind);
2560
2561/**
2562 * \brief Determine whether the given cursor kind represents a simple
2563 * reference.
2564 *
2565 * Note that other kinds of cursors (such as expressions) can also refer to
2566 * other cursors. Use clang_getCursorReferenced() to determine whether a
2567 * particular cursor refers to another entity.
2568 */
2569CINDEX_LINKAGE unsigned clang_isReference(enum CXCursorKind);
2570
2571/**
2572 * \brief Determine whether the given cursor kind represents an expression.
2573 */
2574CINDEX_LINKAGE unsigned clang_isExpression(enum CXCursorKind);
2575
2576/**
2577 * \brief Determine whether the given cursor kind represents a statement.
2578 */
2579CINDEX_LINKAGE unsigned clang_isStatement(enum CXCursorKind);
2580
2581/**
Douglas Gregora98034a2011-07-06 03:00:34 +00002582 * \brief Determine whether the given cursor kind represents an attribute.
2583 */
2584CINDEX_LINKAGE unsigned clang_isAttribute(enum CXCursorKind);
2585
2586/**
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00002587 * \brief Determine whether the given cursor has any attributes.
2588 */
2589CINDEX_LINKAGE unsigned clang_Cursor_hasAttrs(CXCursor C);
2590
2591/**
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002592 * \brief Determine whether the given cursor kind represents an invalid
Douglas Gregor6007cf22010-01-22 22:29:16 +00002593 * cursor.
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002594 */
Douglas Gregor6007cf22010-01-22 22:29:16 +00002595CINDEX_LINKAGE unsigned clang_isInvalid(enum CXCursorKind);
2596
2597/**
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002598 * \brief Determine whether the given cursor kind represents a translation
2599 * unit.
Douglas Gregor6007cf22010-01-22 22:29:16 +00002600 */
2601CINDEX_LINKAGE unsigned clang_isTranslationUnit(enum CXCursorKind);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002602
Ted Kremenekff9021b2010-03-08 21:17:29 +00002603/***
Douglas Gregor92a524f2010-03-18 00:42:48 +00002604 * \brief Determine whether the given cursor represents a preprocessing
2605 * element, such as a preprocessor directive or macro instantiation.
2606 */
2607CINDEX_LINKAGE unsigned clang_isPreprocessing(enum CXCursorKind);
2608
2609/***
Ted Kremenekff9021b2010-03-08 21:17:29 +00002610 * \brief Determine whether the given cursor represents a currently
2611 * unexposed piece of the AST (e.g., CXCursor_UnexposedStmt).
2612 */
2613CINDEX_LINKAGE unsigned clang_isUnexposed(enum CXCursorKind);
2614
Douglas Gregor6007cf22010-01-22 22:29:16 +00002615/**
Ted Kremenekfb4961d2010-03-03 06:36:57 +00002616 * \brief Describe the linkage of the entity referred to by a cursor.
2617 */
2618enum CXLinkageKind {
2619 /** \brief This value indicates that no linkage information is available
2620 * for a provided CXCursor. */
2621 CXLinkage_Invalid,
2622 /**
2623 * \brief This is the linkage for variables, parameters, and so on that
2624 * have automatic storage. This covers normal (non-extern) local variables.
2625 */
2626 CXLinkage_NoLinkage,
2627 /** \brief This is the linkage for static variables and static functions. */
2628 CXLinkage_Internal,
2629 /** \brief This is the linkage for entities with external linkage that live
2630 * in C++ anonymous namespaces.*/
2631 CXLinkage_UniqueExternal,
2632 /** \brief This is the linkage for entities with true, external linkage. */
2633 CXLinkage_External
2634};
2635
2636/**
Ted Kremenek4ed29252010-04-12 21:22:16 +00002637 * \brief Determine the linkage of the entity referred to by a given cursor.
Ted Kremenekfb4961d2010-03-03 06:36:57 +00002638 */
2639CINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor);
2640
Ehsan Akhgarib743de72016-05-31 15:55:51 +00002641enum CXVisibilityKind {
2642 /** \brief This value indicates that no visibility information is available
2643 * for a provided CXCursor. */
2644 CXVisibility_Invalid,
2645
2646 /** \brief Symbol not seen by the linker. */
2647 CXVisibility_Hidden,
2648 /** \brief Symbol seen by the linker but resolves to a symbol inside this object. */
2649 CXVisibility_Protected,
2650 /** \brief Symbol seen by the linker and acts like a normal symbol. */
2651 CXVisibility_Default
2652};
2653
2654/**
2655 * \brief Describe the visibility of the entity referred to by a cursor.
2656 *
2657 * This returns the default visibility if not explicitly specified by
2658 * a visibility attribute. The default visibility may be changed by
2659 * commandline arguments.
2660 *
2661 * \param cursor The cursor to query.
2662 *
2663 * \returns The visibility of the cursor.
2664 */
2665CINDEX_LINKAGE enum CXVisibilityKind clang_getCursorVisibility(CXCursor cursor);
2666
Ehsan Akhgari93697fa2015-11-23 19:56:46 +00002667/**
Douglas Gregord6225d32012-05-08 00:14:45 +00002668 * \brief Determine the availability of the entity that this cursor refers to,
2669 * taking the current target platform into account.
Douglas Gregorf757a122010-08-23 23:00:57 +00002670 *
2671 * \param cursor The cursor to query.
2672 *
2673 * \returns The availability of the cursor.
2674 */
2675CINDEX_LINKAGE enum CXAvailabilityKind
2676clang_getCursorAvailability(CXCursor cursor);
2677
2678/**
Douglas Gregord6225d32012-05-08 00:14:45 +00002679 * Describes the availability of a given entity on a particular platform, e.g.,
2680 * a particular class might only be available on Mac OS 10.7 or newer.
2681 */
2682typedef struct CXPlatformAvailability {
2683 /**
2684 * \brief A string that describes the platform for which this structure
2685 * provides availability information.
2686 *
Manman Renccf25bb2016-06-28 20:55:30 +00002687 * Possible values are "ios" or "macos".
Douglas Gregord6225d32012-05-08 00:14:45 +00002688 */
2689 CXString Platform;
2690 /**
2691 * \brief The version number in which this entity was introduced.
2692 */
2693 CXVersion Introduced;
2694 /**
2695 * \brief The version number in which this entity was deprecated (but is
2696 * still available).
2697 */
2698 CXVersion Deprecated;
2699 /**
2700 * \brief The version number in which this entity was obsoleted, and therefore
2701 * is no longer available.
2702 */
2703 CXVersion Obsoleted;
2704 /**
2705 * \brief Whether the entity is unconditionally unavailable on this platform.
2706 */
2707 int Unavailable;
2708 /**
2709 * \brief An optional message to provide to a user of this API, e.g., to
2710 * suggest replacement APIs.
2711 */
2712 CXString Message;
2713} CXPlatformAvailability;
2714
2715/**
2716 * \brief Determine the availability of the entity that this cursor refers to
2717 * on any platforms for which availability information is known.
2718 *
2719 * \param cursor The cursor to query.
2720 *
2721 * \param always_deprecated If non-NULL, will be set to indicate whether the
2722 * entity is deprecated on all platforms.
2723 *
2724 * \param deprecated_message If non-NULL, will be set to the message text
2725 * provided along with the unconditional deprecation of this entity. The client
2726 * is responsible for deallocating this string.
2727 *
James Dennett574cb4c2012-06-15 05:41:51 +00002728 * \param always_unavailable If non-NULL, will be set to indicate whether the
Douglas Gregord6225d32012-05-08 00:14:45 +00002729 * entity is unavailable on all platforms.
2730 *
2731 * \param unavailable_message If non-NULL, will be set to the message text
2732 * provided along with the unconditional unavailability of this entity. The
2733 * client is responsible for deallocating this string.
2734 *
2735 * \param availability If non-NULL, an array of CXPlatformAvailability instances
2736 * that will be populated with platform availability information, up to either
2737 * the number of platforms for which availability information is available (as
2738 * returned by this function) or \c availability_size, whichever is smaller.
2739 *
2740 * \param availability_size The number of elements available in the
2741 * \c availability array.
2742 *
2743 * \returns The number of platforms (N) for which availability information is
2744 * available (which is unrelated to \c availability_size).
2745 *
2746 * Note that the client is responsible for calling
2747 * \c clang_disposeCXPlatformAvailability to free each of the
2748 * platform-availability structures returned. There are
2749 * \c min(N, availability_size) such structures.
2750 */
2751CINDEX_LINKAGE int
2752clang_getCursorPlatformAvailability(CXCursor cursor,
2753 int *always_deprecated,
2754 CXString *deprecated_message,
2755 int *always_unavailable,
2756 CXString *unavailable_message,
2757 CXPlatformAvailability *availability,
2758 int availability_size);
2759
2760/**
2761 * \brief Free the memory associated with a \c CXPlatformAvailability structure.
2762 */
2763CINDEX_LINKAGE void
2764clang_disposeCXPlatformAvailability(CXPlatformAvailability *availability);
2765
2766/**
Ted Kremenek4ed29252010-04-12 21:22:16 +00002767 * \brief Describe the "language" of the entity referred to by a cursor.
2768 */
Reid Kleckner9e3bc722013-12-30 17:48:49 +00002769enum CXLanguageKind {
Ted Kremenekee457512010-04-14 20:58:32 +00002770 CXLanguage_Invalid = 0,
Ted Kremenek4ed29252010-04-12 21:22:16 +00002771 CXLanguage_C,
2772 CXLanguage_ObjC,
Ted Kremenekee457512010-04-14 20:58:32 +00002773 CXLanguage_CPlusPlus
Ted Kremenek4ed29252010-04-12 21:22:16 +00002774};
2775
2776/**
2777 * \brief Determine the "language" of the entity referred to by a given cursor.
2778 */
2779CINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor);
2780
Argyrios Kyrtzidisd6e9fa52011-09-27 00:30:30 +00002781/**
2782 * \brief Returns the translation unit that a cursor originated from.
2783 */
2784CINDEX_LINKAGE CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor);
2785
Ted Kremenekc0b98662013-04-24 07:17:12 +00002786/**
2787 * \brief A fast container representing a set of CXCursors.
2788 */
2789typedef struct CXCursorSetImpl *CXCursorSet;
2790
2791/**
2792 * \brief Creates an empty CXCursorSet.
2793 */
2794CINDEX_LINKAGE CXCursorSet clang_createCXCursorSet(void);
2795
2796/**
2797 * \brief Disposes a CXCursorSet and releases its associated memory.
2798 */
2799CINDEX_LINKAGE void clang_disposeCXCursorSet(CXCursorSet cset);
2800
2801/**
2802 * \brief Queries a CXCursorSet to see if it contains a specific CXCursor.
2803 *
2804 * \returns non-zero if the set contains the specified cursor.
2805*/
2806CINDEX_LINKAGE unsigned clang_CXCursorSet_contains(CXCursorSet cset,
2807 CXCursor cursor);
2808
2809/**
2810 * \brief Inserts a CXCursor into a CXCursorSet.
2811 *
2812 * \returns zero if the CXCursor was already in the set, and non-zero otherwise.
2813*/
2814CINDEX_LINKAGE unsigned clang_CXCursorSet_insert(CXCursorSet cset,
2815 CXCursor cursor);
2816
Douglas Gregor0576ce72010-09-22 21:22:29 +00002817/**
2818 * \brief Determine the semantic parent of the given cursor.
2819 *
2820 * The semantic parent of a cursor is the cursor that semantically contains
2821 * the given \p cursor. For many declarations, the lexical and semantic parents
2822 * are equivalent (the lexical parent is returned by
2823 * \c clang_getCursorLexicalParent()). They diverge when declarations or
2824 * definitions are provided out-of-line. For example:
2825 *
2826 * \code
2827 * class C {
2828 * void f();
2829 * };
2830 *
2831 * void C::f() { }
2832 * \endcode
2833 *
Nico Weber7deebef2014-04-24 03:17:47 +00002834 * In the out-of-line definition of \c C::f, the semantic parent is
Douglas Gregor0576ce72010-09-22 21:22:29 +00002835 * the class \c C, of which this function is a member. The lexical parent is
2836 * the place where the declaration actually occurs in the source code; in this
Nico Weber7deebef2014-04-24 03:17:47 +00002837 * case, the definition occurs in the translation unit. In general, the
Douglas Gregor0576ce72010-09-22 21:22:29 +00002838 * lexical parent for a given entity can change without affecting the semantics
2839 * of the program, and the lexical parent of different declarations of the
2840 * same entity may be different. Changing the semantic parent of a declaration,
2841 * on the other hand, can have a major impact on semantics, and redeclarations
2842 * of a particular entity should all have the same semantic context.
2843 *
2844 * In the example above, both declarations of \c C::f have \c C as their
2845 * semantic context, while the lexical context of the first \c C::f is \c C
2846 * and the lexical context of the second \c C::f is the translation unit.
Douglas Gregor7ecd19e2010-12-21 07:55:45 +00002847 *
2848 * For global declarations, the semantic parent is the translation unit.
Douglas Gregor0576ce72010-09-22 21:22:29 +00002849 */
2850CINDEX_LINKAGE CXCursor clang_getCursorSemanticParent(CXCursor cursor);
2851
2852/**
2853 * \brief Determine the lexical parent of the given cursor.
2854 *
2855 * The lexical parent of a cursor is the cursor in which the given \p cursor
2856 * was actually written. For many declarations, the lexical and semantic parents
2857 * are equivalent (the semantic parent is returned by
2858 * \c clang_getCursorSemanticParent()). They diverge when declarations or
2859 * definitions are provided out-of-line. For example:
2860 *
2861 * \code
2862 * class C {
2863 * void f();
2864 * };
2865 *
2866 * void C::f() { }
2867 * \endcode
2868 *
Nico Weber7deebef2014-04-24 03:17:47 +00002869 * In the out-of-line definition of \c C::f, the semantic parent is
Douglas Gregor0576ce72010-09-22 21:22:29 +00002870 * the class \c C, of which this function is a member. The lexical parent is
2871 * the place where the declaration actually occurs in the source code; in this
Nico Weber7deebef2014-04-24 03:17:47 +00002872 * case, the definition occurs in the translation unit. In general, the
Douglas Gregor0576ce72010-09-22 21:22:29 +00002873 * lexical parent for a given entity can change without affecting the semantics
2874 * of the program, and the lexical parent of different declarations of the
2875 * same entity may be different. Changing the semantic parent of a declaration,
2876 * on the other hand, can have a major impact on semantics, and redeclarations
2877 * of a particular entity should all have the same semantic context.
2878 *
2879 * In the example above, both declarations of \c C::f have \c C as their
2880 * semantic context, while the lexical context of the first \c C::f is \c C
2881 * and the lexical context of the second \c C::f is the translation unit.
Douglas Gregor7ecd19e2010-12-21 07:55:45 +00002882 *
2883 * For declarations written in the global scope, the lexical parent is
2884 * the translation unit.
Douglas Gregor0576ce72010-09-22 21:22:29 +00002885 */
2886CINDEX_LINKAGE CXCursor clang_getCursorLexicalParent(CXCursor cursor);
Douglas Gregor99a26af2010-10-01 20:25:15 +00002887
2888/**
2889 * \brief Determine the set of methods that are overridden by the given
2890 * method.
2891 *
2892 * In both Objective-C and C++, a method (aka virtual member function,
2893 * in C++) can override a virtual method in a base class. For
2894 * Objective-C, a method is said to override any method in the class's
Argyrios Kyrtzidisbfb24252012-03-08 00:20:03 +00002895 * base class, its protocols, or its categories' protocols, that has the same
2896 * selector and is of the same kind (class or instance).
2897 * If no such method exists, the search continues to the class's superclass,
2898 * its protocols, and its categories, and so on. A method from an Objective-C
2899 * implementation is considered to override the same methods as its
2900 * corresponding method in the interface.
Douglas Gregor99a26af2010-10-01 20:25:15 +00002901 *
2902 * For C++, a virtual member function overrides any virtual member
2903 * function with the same signature that occurs in its base
2904 * classes. With multiple inheritance, a virtual member function can
2905 * override several virtual member functions coming from different
2906 * base classes.
2907 *
2908 * In all cases, this function determines the immediate overridden
2909 * method, rather than all of the overridden methods. For example, if
2910 * a method is originally declared in a class A, then overridden in B
2911 * (which in inherits from A) and also in C (which inherited from B),
2912 * then the only overridden method returned from this function when
2913 * invoked on C's method will be B's method. The client may then
2914 * invoke this function again, given the previously-found overridden
2915 * methods, to map out the complete method-override set.
2916 *
2917 * \param cursor A cursor representing an Objective-C or C++
2918 * method. This routine will compute the set of methods that this
2919 * method overrides.
2920 *
2921 * \param overridden A pointer whose pointee will be replaced with a
2922 * pointer to an array of cursors, representing the set of overridden
2923 * methods. If there are no overridden methods, the pointee will be
2924 * set to NULL. The pointee must be freed via a call to
2925 * \c clang_disposeOverriddenCursors().
2926 *
2927 * \param num_overridden A pointer to the number of overridden
2928 * functions, will be set to the number of overridden functions in the
2929 * array pointed to by \p overridden.
2930 */
2931CINDEX_LINKAGE void clang_getOverriddenCursors(CXCursor cursor,
2932 CXCursor **overridden,
2933 unsigned *num_overridden);
2934
2935/**
2936 * \brief Free the set of overridden cursors returned by \c
2937 * clang_getOverriddenCursors().
2938 */
2939CINDEX_LINKAGE void clang_disposeOverriddenCursors(CXCursor *overridden);
2940
Ted Kremenek4ed29252010-04-12 21:22:16 +00002941/**
Douglas Gregor796d76a2010-10-20 22:00:55 +00002942 * \brief Retrieve the file that is included by the given inclusion directive
2943 * cursor.
2944 */
2945CINDEX_LINKAGE CXFile clang_getIncludedFile(CXCursor cursor);
2946
2947/**
Douglas Gregor6007cf22010-01-22 22:29:16 +00002948 * @}
2949 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002950
Douglas Gregor6007cf22010-01-22 22:29:16 +00002951/**
2952 * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code
2953 *
2954 * Cursors represent a location within the Abstract Syntax Tree (AST). These
2955 * routines help map between cursors and the physical locations where the
2956 * described entities occur in the source code. The mapping is provided in
2957 * both directions, so one can map from source code to the AST and back.
2958 *
2959 * @{
Steve Naroffa1c72842009-08-28 15:28:48 +00002960 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002961
Steve Naroff20bad0b2009-10-21 13:56:23 +00002962/**
Douglas Gregor816fd362010-01-22 21:44:22 +00002963 * \brief Map a source location to the cursor that describes the entity at that
2964 * location in the source code.
2965 *
2966 * clang_getCursor() maps an arbitrary source location within a translation
2967 * unit down to the most specific cursor that describes the entity at that
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002968 * location. For example, given an expression \c x + y, invoking
Douglas Gregor816fd362010-01-22 21:44:22 +00002969 * clang_getCursor() with a source location pointing to "x" will return the
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002970 * cursor for "x"; similarly for "y". If the cursor points anywhere between
Douglas Gregor816fd362010-01-22 21:44:22 +00002971 * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor()
2972 * will return a cursor referring to the "+" expression.
2973 *
2974 * \returns a cursor representing the entity at the given source location, or
2975 * a NULL cursor if no such entity can be found.
Steve Naroff20bad0b2009-10-21 13:56:23 +00002976 */
Douglas Gregor816fd362010-01-22 21:44:22 +00002977CINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, CXSourceLocation);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002978
Douglas Gregor66a58812010-01-18 22:46:11 +00002979/**
2980 * \brief Retrieve the physical location of the source constructor referenced
2981 * by the given cursor.
2982 *
2983 * The location of a declaration is typically the location of the name of that
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002984 * declaration, where the name of that declaration would occur if it is
2985 * unnamed, or some keyword that introduces that particular declaration.
2986 * The location of a reference is where that reference occurs within the
Douglas Gregor66a58812010-01-18 22:46:11 +00002987 * source code.
2988 */
2989CINDEX_LINKAGE CXSourceLocation clang_getCursorLocation(CXCursor);
Douglas Gregor6007cf22010-01-22 22:29:16 +00002990
Douglas Gregor6b8232f2010-01-19 19:34:47 +00002991/**
2992 * \brief Retrieve the physical extent of the source construct referenced by
Douglas Gregor33c34ac2010-01-19 00:34:46 +00002993 * the given cursor.
2994 *
2995 * The extent of a cursor starts with the file/line/column pointing at the
2996 * first character within the source construct that the cursor refers to and
Nico Weber7deebef2014-04-24 03:17:47 +00002997 * ends with the last character within that source construct. For a
Douglas Gregor33c34ac2010-01-19 00:34:46 +00002998 * declaration, the extent covers the declaration itself. For a reference,
2999 * the extent covers the location of the reference (e.g., where the referenced
3000 * entity was actually used).
3001 */
3002CINDEX_LINKAGE CXSourceRange clang_getCursorExtent(CXCursor);
Douglas Gregorad27e8b2010-01-19 01:20:04 +00003003
Douglas Gregor6007cf22010-01-22 22:29:16 +00003004/**
3005 * @}
3006 */
Ted Kremeneka5940822010-08-26 01:42:22 +00003007
Douglas Gregor6007cf22010-01-22 22:29:16 +00003008/**
Ted Kremenek6bca9842010-05-14 21:29:26 +00003009 * \defgroup CINDEX_TYPES Type information for CXCursors
3010 *
3011 * @{
3012 */
3013
3014/**
3015 * \brief Describes the kind of type
3016 */
3017enum CXTypeKind {
3018 /**
Nico Weber7deebef2014-04-24 03:17:47 +00003019 * \brief Represents an invalid type (e.g., where no type is available).
Ted Kremenek6bca9842010-05-14 21:29:26 +00003020 */
3021 CXType_Invalid = 0,
3022
3023 /**
3024 * \brief A type whose specific kind is not exposed via this
3025 * interface.
3026 */
3027 CXType_Unexposed = 1,
3028
3029 /* Builtin types */
3030 CXType_Void = 2,
3031 CXType_Bool = 3,
3032 CXType_Char_U = 4,
3033 CXType_UChar = 5,
3034 CXType_Char16 = 6,
3035 CXType_Char32 = 7,
3036 CXType_UShort = 8,
3037 CXType_UInt = 9,
3038 CXType_ULong = 10,
3039 CXType_ULongLong = 11,
3040 CXType_UInt128 = 12,
3041 CXType_Char_S = 13,
3042 CXType_SChar = 14,
3043 CXType_WChar = 15,
3044 CXType_Short = 16,
3045 CXType_Int = 17,
3046 CXType_Long = 18,
3047 CXType_LongLong = 19,
3048 CXType_Int128 = 20,
3049 CXType_Float = 21,
3050 CXType_Double = 22,
3051 CXType_LongDouble = 23,
3052 CXType_NullPtr = 24,
3053 CXType_Overload = 25,
3054 CXType_Dependent = 26,
3055 CXType_ObjCId = 27,
3056 CXType_ObjCClass = 28,
3057 CXType_ObjCSel = 29,
Nemanja Ivanovicbb1ea2d2016-05-09 08:52:33 +00003058 CXType_Float128 = 30,
Joey Gouly6ea21852017-02-10 15:51:11 +00003059 CXType_Half = 31,
Ted Kremenek6bca9842010-05-14 21:29:26 +00003060 CXType_FirstBuiltin = CXType_Void,
Joey Gouly6ea21852017-02-10 15:51:11 +00003061 CXType_LastBuiltin = CXType_Half,
Ted Kremenek6bca9842010-05-14 21:29:26 +00003062
3063 CXType_Complex = 100,
3064 CXType_Pointer = 101,
3065 CXType_BlockPointer = 102,
3066 CXType_LValueReference = 103,
3067 CXType_RValueReference = 104,
3068 CXType_Record = 105,
3069 CXType_Enum = 106,
3070 CXType_Typedef = 107,
3071 CXType_ObjCInterface = 108,
Ted Kremenekc1508872010-06-21 20:15:39 +00003072 CXType_ObjCObjectPointer = 109,
3073 CXType_FunctionNoProto = 110,
Argyrios Kyrtzidis2b0cf602011-09-27 17:44:34 +00003074 CXType_FunctionProto = 111,
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003075 CXType_ConstantArray = 112,
Argyrios Kyrtzidis0661a712013-07-23 17:36:21 +00003076 CXType_Vector = 113,
3077 CXType_IncompleteArray = 114,
3078 CXType_VariableArray = 115,
Argyrios Kyrtzidis7a4253b2013-10-03 16:19:23 +00003079 CXType_DependentSizedArray = 116,
Sergey Kalinichevc0151202015-11-15 13:10:10 +00003080 CXType_MemberPointer = 117,
Sergey Kalinichev69770ae2016-05-03 06:58:29 +00003081 CXType_Auto = 118,
3082
3083 /**
3084 * \brief Represents a type that was referred to using an elaborated type keyword.
3085 *
3086 * E.g., struct S, or via a qualified name, e.g., N::M::type, or both.
3087 */
Sven van Haastregtcc4f1e42017-05-23 10:36:43 +00003088 CXType_Elaborated = 119,
3089
3090 /* OpenCL PipeType. */
3091 CXType_Pipe = 120,
3092
3093 /* OpenCL builtin types. */
3094 CXType_OCLImage1dRO = 121,
3095 CXType_OCLImage1dArrayRO = 122,
3096 CXType_OCLImage1dBufferRO = 123,
3097 CXType_OCLImage2dRO = 124,
3098 CXType_OCLImage2dArrayRO = 125,
3099 CXType_OCLImage2dDepthRO = 126,
3100 CXType_OCLImage2dArrayDepthRO = 127,
3101 CXType_OCLImage2dMSAARO = 128,
3102 CXType_OCLImage2dArrayMSAARO = 129,
3103 CXType_OCLImage2dMSAADepthRO = 130,
3104 CXType_OCLImage2dArrayMSAADepthRO = 131,
3105 CXType_OCLImage3dRO = 132,
3106 CXType_OCLImage1dWO = 133,
3107 CXType_OCLImage1dArrayWO = 134,
3108 CXType_OCLImage1dBufferWO = 135,
3109 CXType_OCLImage2dWO = 136,
3110 CXType_OCLImage2dArrayWO = 137,
3111 CXType_OCLImage2dDepthWO = 138,
3112 CXType_OCLImage2dArrayDepthWO = 139,
3113 CXType_OCLImage2dMSAAWO = 140,
3114 CXType_OCLImage2dArrayMSAAWO = 141,
3115 CXType_OCLImage2dMSAADepthWO = 142,
3116 CXType_OCLImage2dArrayMSAADepthWO = 143,
3117 CXType_OCLImage3dWO = 144,
3118 CXType_OCLImage1dRW = 145,
3119 CXType_OCLImage1dArrayRW = 146,
3120 CXType_OCLImage1dBufferRW = 147,
3121 CXType_OCLImage2dRW = 148,
3122 CXType_OCLImage2dArrayRW = 149,
3123 CXType_OCLImage2dDepthRW = 150,
3124 CXType_OCLImage2dArrayDepthRW = 151,
3125 CXType_OCLImage2dMSAARW = 152,
3126 CXType_OCLImage2dArrayMSAARW = 153,
3127 CXType_OCLImage2dMSAADepthRW = 154,
3128 CXType_OCLImage2dArrayMSAADepthRW = 155,
3129 CXType_OCLImage3dRW = 156,
3130 CXType_OCLSampler = 157,
3131 CXType_OCLEvent = 158,
3132 CXType_OCLQueue = 159,
3133 CXType_OCLReserveID = 160
Ted Kremenek6bca9842010-05-14 21:29:26 +00003134};
3135
3136/**
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003137 * \brief Describes the calling convention of a function type
3138 */
3139enum CXCallingConv {
3140 CXCallingConv_Default = 0,
3141 CXCallingConv_C = 1,
3142 CXCallingConv_X86StdCall = 2,
3143 CXCallingConv_X86FastCall = 3,
3144 CXCallingConv_X86ThisCall = 4,
3145 CXCallingConv_X86Pascal = 5,
3146 CXCallingConv_AAPCS = 6,
3147 CXCallingConv_AAPCS_VFP = 7,
Erich Keane757d3172016-11-02 18:29:35 +00003148 CXCallingConv_X86RegCall = 8,
Guy Benyeif0a014b2012-12-25 08:53:55 +00003149 CXCallingConv_IntelOclBicc = 9,
Charles Davisb5a214e2013-08-30 04:39:01 +00003150 CXCallingConv_X86_64Win64 = 10,
3151 CXCallingConv_X86_64SysV = 11,
Reid Klecknerd7857f02014-10-24 17:42:17 +00003152 CXCallingConv_X86VectorCall = 12,
John McCall477f2bb2016-03-03 06:39:32 +00003153 CXCallingConv_Swift = 13,
Roman Levenstein35aa5ce2016-03-16 18:00:46 +00003154 CXCallingConv_PreserveMost = 14,
3155 CXCallingConv_PreserveAll = 15,
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003156
3157 CXCallingConv_Invalid = 100,
3158 CXCallingConv_Unexposed = 200
3159};
3160
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003161/**
Ted Kremenek6bca9842010-05-14 21:29:26 +00003162 * \brief The type of an element in the abstract syntax tree.
3163 *
3164 */
3165typedef struct {
3166 enum CXTypeKind kind;
3167 void *data[2];
3168} CXType;
3169
3170/**
3171 * \brief Retrieve the type of a CXCursor (if any).
3172 */
3173CINDEX_LINKAGE CXType clang_getCursorType(CXCursor C);
3174
3175/**
Dmitri Gribenko00353722013-02-15 21:15:49 +00003176 * \brief Pretty-print the underlying type using the rules of the
3177 * language of the translation unit from which it came.
3178 *
3179 * If the type is invalid, an empty string is returned.
3180 */
3181CINDEX_LINKAGE CXString clang_getTypeSpelling(CXType CT);
3182
3183/**
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003184 * \brief Retrieve the underlying type of a typedef declaration.
3185 *
3186 * If the cursor does not reference a typedef declaration, an invalid type is
3187 * returned.
3188 */
3189CINDEX_LINKAGE CXType clang_getTypedefDeclUnderlyingType(CXCursor C);
3190
3191/**
3192 * \brief Retrieve the integer type of an enum declaration.
3193 *
3194 * If the cursor does not reference an enum declaration, an invalid type is
3195 * returned.
3196 */
3197CINDEX_LINKAGE CXType clang_getEnumDeclIntegerType(CXCursor C);
3198
3199/**
3200 * \brief Retrieve the integer value of an enum constant declaration as a signed
3201 * long long.
3202 *
3203 * If the cursor does not reference an enum constant declaration, LLONG_MIN is returned.
3204 * Since this is also potentially a valid constant value, the kind of the cursor
3205 * must be verified before calling this function.
3206 */
3207CINDEX_LINKAGE long long clang_getEnumConstantDeclValue(CXCursor C);
3208
3209/**
3210 * \brief Retrieve the integer value of an enum constant declaration as an unsigned
3211 * long long.
3212 *
3213 * If the cursor does not reference an enum constant declaration, ULLONG_MAX is returned.
3214 * Since this is also potentially a valid constant value, the kind of the cursor
3215 * must be verified before calling this function.
3216 */
3217CINDEX_LINKAGE unsigned long long clang_getEnumConstantDeclUnsignedValue(CXCursor C);
3218
3219/**
Dmitri Gribenkob506ba12012-12-04 15:13:46 +00003220 * \brief Retrieve the bit width of a bit field declaration as an integer.
3221 *
3222 * If a cursor that is not a bit field declaration is passed in, -1 is returned.
3223 */
3224CINDEX_LINKAGE int clang_getFieldDeclBitWidth(CXCursor C);
3225
3226/**
Argyrios Kyrtzidis0c27e4b2012-04-11 19:32:19 +00003227 * \brief Retrieve the number of non-variadic arguments associated with a given
3228 * cursor.
3229 *
Argyrios Kyrtzidisb2792972013-04-01 17:38:59 +00003230 * The number of arguments can be determined for calls as well as for
3231 * declarations of functions or methods. For other cursors -1 is returned.
Argyrios Kyrtzidis0c27e4b2012-04-11 19:32:19 +00003232 */
3233CINDEX_LINKAGE int clang_Cursor_getNumArguments(CXCursor C);
3234
3235/**
3236 * \brief Retrieve the argument cursor of a function or method.
3237 *
Argyrios Kyrtzidisb2792972013-04-01 17:38:59 +00003238 * The argument cursor can be determined for calls as well as for declarations
3239 * of functions or methods. For other cursors and for invalid indices, an
3240 * invalid cursor is returned.
Argyrios Kyrtzidis0c27e4b2012-04-11 19:32:19 +00003241 */
3242CINDEX_LINKAGE CXCursor clang_Cursor_getArgument(CXCursor C, unsigned i);
3243
3244/**
Eli Benderskyc27a0c42014-10-10 20:01:05 +00003245 * \brief Describes the kind of a template argument.
3246 *
3247 * See the definition of llvm::clang::TemplateArgument::ArgKind for full
3248 * element descriptions.
3249 */
3250enum CXTemplateArgumentKind {
3251 CXTemplateArgumentKind_Null,
3252 CXTemplateArgumentKind_Type,
3253 CXTemplateArgumentKind_Declaration,
3254 CXTemplateArgumentKind_NullPtr,
3255 CXTemplateArgumentKind_Integral,
3256 CXTemplateArgumentKind_Template,
3257 CXTemplateArgumentKind_TemplateExpansion,
3258 CXTemplateArgumentKind_Expression,
3259 CXTemplateArgumentKind_Pack,
3260 /* Indicates an error case, preventing the kind from being deduced. */
3261 CXTemplateArgumentKind_Invalid
3262};
3263
3264/**
3265 *\brief Returns the number of template args of a function decl representing a
3266 * template specialization.
3267 *
3268 * If the argument cursor cannot be converted into a template function
3269 * declaration, -1 is returned.
3270 *
3271 * For example, for the following declaration and specialization:
3272 * template <typename T, int kInt, bool kBool>
3273 * void foo() { ... }
3274 *
3275 * template <>
3276 * void foo<float, -7, true>();
3277 *
3278 * The value 3 would be returned from this call.
3279 */
3280CINDEX_LINKAGE int clang_Cursor_getNumTemplateArguments(CXCursor C);
3281
3282/**
3283 * \brief Retrieve the kind of the I'th template argument of the CXCursor C.
3284 *
3285 * If the argument CXCursor does not represent a FunctionDecl, an invalid
3286 * template argument kind is returned.
3287 *
3288 * For example, for the following declaration and specialization:
3289 * template <typename T, int kInt, bool kBool>
3290 * void foo() { ... }
3291 *
3292 * template <>
3293 * void foo<float, -7, true>();
3294 *
3295 * For I = 0, 1, and 2, Type, Integral, and Integral will be returned,
3296 * respectively.
3297 */
3298CINDEX_LINKAGE enum CXTemplateArgumentKind clang_Cursor_getTemplateArgumentKind(
3299 CXCursor C, unsigned I);
3300
3301/**
3302 * \brief Retrieve a CXType representing the type of a TemplateArgument of a
3303 * function decl representing a template specialization.
3304 *
3305 * If the argument CXCursor does not represent a FunctionDecl whose I'th
3306 * template argument has a kind of CXTemplateArgKind_Integral, an invalid type
3307 * is returned.
3308 *
3309 * For example, for the following declaration and specialization:
3310 * template <typename T, int kInt, bool kBool>
3311 * void foo() { ... }
3312 *
3313 * template <>
3314 * void foo<float, -7, true>();
3315 *
3316 * If called with I = 0, "float", will be returned.
3317 * Invalid types will be returned for I == 1 or 2.
3318 */
3319CINDEX_LINKAGE CXType clang_Cursor_getTemplateArgumentType(CXCursor C,
3320 unsigned I);
3321
3322/**
3323 * \brief Retrieve the value of an Integral TemplateArgument (of a function
3324 * decl representing a template specialization) as a signed long long.
3325 *
3326 * It is undefined to call this function on a CXCursor that does not represent a
3327 * FunctionDecl or whose I'th template argument is not an integral value.
3328 *
3329 * For example, for the following declaration and specialization:
3330 * template <typename T, int kInt, bool kBool>
3331 * void foo() { ... }
3332 *
3333 * template <>
3334 * void foo<float, -7, true>();
3335 *
3336 * If called with I = 1 or 2, -7 or true will be returned, respectively.
3337 * For I == 0, this function's behavior is undefined.
3338 */
3339CINDEX_LINKAGE long long clang_Cursor_getTemplateArgumentValue(CXCursor C,
3340 unsigned I);
3341
3342/**
3343 * \brief Retrieve the value of an Integral TemplateArgument (of a function
3344 * decl representing a template specialization) as an unsigned long long.
3345 *
3346 * It is undefined to call this function on a CXCursor that does not represent a
3347 * FunctionDecl or whose I'th template argument is not an integral value.
3348 *
3349 * For example, for the following declaration and specialization:
3350 * template <typename T, int kInt, bool kBool>
3351 * void foo() { ... }
3352 *
3353 * template <>
3354 * void foo<float, 2147483649, true>();
3355 *
3356 * If called with I = 1 or 2, 2147483649 or true will be returned, respectively.
3357 * For I == 0, this function's behavior is undefined.
3358 */
3359CINDEX_LINKAGE unsigned long long clang_Cursor_getTemplateArgumentUnsignedValue(
3360 CXCursor C, unsigned I);
3361
3362/**
James Dennett574cb4c2012-06-15 05:41:51 +00003363 * \brief Determine whether two CXTypes represent the same type.
Ted Kremenek6bca9842010-05-14 21:29:26 +00003364 *
James Dennett574cb4c2012-06-15 05:41:51 +00003365 * \returns non-zero if the CXTypes represent the same type and
3366 * zero otherwise.
Ted Kremenek6bca9842010-05-14 21:29:26 +00003367 */
3368CINDEX_LINKAGE unsigned clang_equalTypes(CXType A, CXType B);
3369
3370/**
3371 * \brief Return the canonical type for a CXType.
3372 *
3373 * Clang's type system explicitly models typedefs and all the ways
3374 * a specific type can be represented. The canonical type is the underlying
3375 * type with all the "sugar" removed. For example, if 'T' is a typedef
3376 * for 'int', the canonical type for 'T' would be 'int'.
3377 */
3378CINDEX_LINKAGE CXType clang_getCanonicalType(CXType T);
3379
3380/**
James Dennett574cb4c2012-06-15 05:41:51 +00003381 * \brief Determine whether a CXType has the "const" qualifier set,
3382 * without looking through typedefs that may have added "const" at a
3383 * different level.
Douglas Gregor56a63802011-01-27 16:27:11 +00003384 */
3385CINDEX_LINKAGE unsigned clang_isConstQualifiedType(CXType T);
3386
3387/**
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00003388 * \brief Determine whether a CXCursor that is a macro, is
3389 * function like.
3390 */
3391CINDEX_LINKAGE unsigned clang_Cursor_isMacroFunctionLike(CXCursor C);
3392
3393/**
3394 * \brief Determine whether a CXCursor that is a macro, is a
3395 * builtin one.
3396 */
3397CINDEX_LINKAGE unsigned clang_Cursor_isMacroBuiltin(CXCursor C);
3398
3399/**
3400 * \brief Determine whether a CXCursor that is a function declaration, is an
3401 * inline declaration.
3402 */
3403CINDEX_LINKAGE unsigned clang_Cursor_isFunctionInlined(CXCursor C);
3404
3405/**
James Dennett574cb4c2012-06-15 05:41:51 +00003406 * \brief Determine whether a CXType has the "volatile" qualifier set,
3407 * without looking through typedefs that may have added "volatile" at
3408 * a different level.
Douglas Gregor56a63802011-01-27 16:27:11 +00003409 */
3410CINDEX_LINKAGE unsigned clang_isVolatileQualifiedType(CXType T);
3411
3412/**
James Dennett574cb4c2012-06-15 05:41:51 +00003413 * \brief Determine whether a CXType has the "restrict" qualifier set,
3414 * without looking through typedefs that may have added "restrict" at a
3415 * different level.
Douglas Gregor56a63802011-01-27 16:27:11 +00003416 */
3417CINDEX_LINKAGE unsigned clang_isRestrictQualifiedType(CXType T);
3418
3419/**
Ted Kremenek6bca9842010-05-14 21:29:26 +00003420 * \brief For pointer types, returns the type of the pointee.
Ted Kremenek6bca9842010-05-14 21:29:26 +00003421 */
3422CINDEX_LINKAGE CXType clang_getPointeeType(CXType T);
3423
3424/**
3425 * \brief Return the cursor for the declaration of the given type.
3426 */
3427CINDEX_LINKAGE CXCursor clang_getTypeDeclaration(CXType T);
3428
David Chisnall50e4eba2010-12-30 14:05:53 +00003429/**
3430 * Returns the Objective-C type encoding for the specified declaration.
3431 */
3432CINDEX_LINKAGE CXString clang_getDeclObjCTypeEncoding(CXCursor C);
Ted Kremenek6bca9842010-05-14 21:29:26 +00003433
3434/**
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00003435 * Returns the Objective-C type encoding for the specified CXType.
3436 */
3437CINDEX_LINKAGE CXString clang_Type_getObjCEncoding(CXType type);
3438
3439/**
Ted Kremenek6bca9842010-05-14 21:29:26 +00003440 * \brief Retrieve the spelling of a given CXTypeKind.
3441 */
3442CINDEX_LINKAGE CXString clang_getTypeKindSpelling(enum CXTypeKind K);
3443
3444/**
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003445 * \brief Retrieve the calling convention associated with a function type.
3446 *
3447 * If a non-function type is passed in, CXCallingConv_Invalid is returned.
3448 */
3449CINDEX_LINKAGE enum CXCallingConv clang_getFunctionTypeCallingConv(CXType T);
3450
3451/**
Alp Toker314cc812014-01-25 16:55:45 +00003452 * \brief Retrieve the return type associated with a function type.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003453 *
3454 * If a non-function type is passed in, an invalid type is returned.
Ted Kremenekc1508872010-06-21 20:15:39 +00003455 */
3456CINDEX_LINKAGE CXType clang_getResultType(CXType T);
3457
3458/**
Alp Toker601b22c2014-01-21 23:35:24 +00003459 * \brief Retrieve the number of non-variadic parameters associated with a
James Dennett574cb4c2012-06-15 05:41:51 +00003460 * function type.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003461 *
Argyrios Kyrtzidis0c27e4b2012-04-11 19:32:19 +00003462 * If a non-function type is passed in, -1 is returned.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003463 */
Argyrios Kyrtzidis0c27e4b2012-04-11 19:32:19 +00003464CINDEX_LINKAGE int clang_getNumArgTypes(CXType T);
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003465
3466/**
Alp Toker601b22c2014-01-21 23:35:24 +00003467 * \brief Retrieve the type of a parameter of a function type.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003468 *
James Dennett574cb4c2012-06-15 05:41:51 +00003469 * If a non-function type is passed in or the function does not have enough
3470 * parameters, an invalid type is returned.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003471 */
3472CINDEX_LINKAGE CXType clang_getArgType(CXType T, unsigned i);
3473
3474/**
3475 * \brief Return 1 if the CXType is a variadic function type, and 0 otherwise.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003476 */
3477CINDEX_LINKAGE unsigned clang_isFunctionTypeVariadic(CXType T);
3478
3479/**
Alp Toker314cc812014-01-25 16:55:45 +00003480 * \brief Retrieve the return type associated with a given cursor.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003481 *
3482 * This only returns a valid type if the cursor refers to a function or method.
Ted Kremenekc62ab8d2010-06-21 20:48:56 +00003483 */
3484CINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C);
3485
3486/**
Ted Kremenek0c7476a2010-07-30 00:14:11 +00003487 * \brief Return 1 if the CXType is a POD (plain old data) type, and 0
3488 * otherwise.
3489 */
3490CINDEX_LINKAGE unsigned clang_isPODType(CXType T);
3491
3492/**
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003493 * \brief Return the element type of an array, complex, or vector type.
3494 *
3495 * If a type is passed in that is not an array, complex, or vector type,
3496 * an invalid type is returned.
3497 */
3498CINDEX_LINKAGE CXType clang_getElementType(CXType T);
3499
3500/**
3501 * \brief Return the number of elements of an array or vector type.
3502 *
3503 * If a type is passed in that is not an array or vector type,
3504 * -1 is returned.
3505 */
3506CINDEX_LINKAGE long long clang_getNumElements(CXType T);
3507
3508/**
Argyrios Kyrtzidis2b0cf602011-09-27 17:44:34 +00003509 * \brief Return the element type of an array type.
3510 *
3511 * If a non-array type is passed in, an invalid type is returned.
3512 */
3513CINDEX_LINKAGE CXType clang_getArrayElementType(CXType T);
3514
3515/**
Sylvestre Ledru830885c2012-07-23 08:59:39 +00003516 * \brief Return the array size of a constant array.
Argyrios Kyrtzidis2b0cf602011-09-27 17:44:34 +00003517 *
3518 * If a non-array type is passed in, -1 is returned.
3519 */
3520CINDEX_LINKAGE long long clang_getArraySize(CXType T);
3521
3522/**
Sergey Kalinichev69770ae2016-05-03 06:58:29 +00003523 * \brief Retrieve the type named by the qualified-id.
3524 *
3525 * If a non-elaborated type is passed in, an invalid type is returned.
3526 */
3527CINDEX_LINKAGE CXType clang_Type_getNamedType(CXType T);
3528
3529/**
Argyrios Kyrtzidis3b25c912017-03-21 16:56:02 +00003530 * \brief Determine if a typedef is 'transparent' tag.
3531 *
3532 * A typedef is considered 'transparent' if it shares a name and spelling
3533 * location with its underlying tag type, as is the case with the NS_ENUM macro.
3534 *
3535 * \returns non-zero if transparent and zero otherwise.
3536 */
3537CINDEX_LINKAGE unsigned clang_Type_isTransparentTagTypedef(CXType T);
3538
3539/**
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003540 * \brief List the possible error codes for \c clang_Type_getSizeOf,
3541 * \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf and
3542 * \c clang_Cursor_getOffsetOf.
3543 *
3544 * A value of this enumeration type can be returned if the target type is not
3545 * a valid argument to sizeof, alignof or offsetof.
3546 */
3547enum CXTypeLayoutError {
3548 /**
3549 * \brief Type is of kind CXType_Invalid.
3550 */
3551 CXTypeLayoutError_Invalid = -1,
3552 /**
3553 * \brief The type is an incomplete Type.
3554 */
3555 CXTypeLayoutError_Incomplete = -2,
3556 /**
3557 * \brief The type is a dependent Type.
3558 */
3559 CXTypeLayoutError_Dependent = -3,
3560 /**
3561 * \brief The type is not a constant size type.
3562 */
3563 CXTypeLayoutError_NotConstantSize = -4,
3564 /**
3565 * \brief The Field name is not valid for this record.
3566 */
3567 CXTypeLayoutError_InvalidFieldName = -5
3568};
3569
3570/**
3571 * \brief Return the alignment of a type in bytes as per C++[expr.alignof]
3572 * standard.
3573 *
3574 * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
3575 * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
3576 * is returned.
3577 * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
3578 * returned.
3579 * If the type declaration is not a constant size type,
3580 * CXTypeLayoutError_NotConstantSize is returned.
3581 */
3582CINDEX_LINKAGE long long clang_Type_getAlignOf(CXType T);
3583
3584/**
Argyrios Kyrtzidis7a4253b2013-10-03 16:19:23 +00003585 * \brief Return the class type of an member pointer type.
3586 *
3587 * If a non-member-pointer type is passed in, an invalid type is returned.
3588 */
3589CINDEX_LINKAGE CXType clang_Type_getClassType(CXType T);
3590
3591/**
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003592 * \brief Return the size of a type in bytes as per C++[expr.sizeof] standard.
3593 *
3594 * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
3595 * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
3596 * is returned.
3597 * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
3598 * returned.
3599 */
3600CINDEX_LINKAGE long long clang_Type_getSizeOf(CXType T);
3601
3602/**
3603 * \brief Return the offset of a field named S in a record of type T in bits
3604 * as it would be returned by __offsetof__ as per C++11[18.2p4]
3605 *
3606 * If the cursor is not a record field declaration, CXTypeLayoutError_Invalid
3607 * is returned.
3608 * If the field's type declaration is an incomplete type,
3609 * CXTypeLayoutError_Incomplete is returned.
3610 * If the field's type declaration is a dependent type,
3611 * CXTypeLayoutError_Dependent is returned.
3612 * If the field's name S is not found,
3613 * CXTypeLayoutError_InvalidFieldName is returned.
3614 */
3615CINDEX_LINKAGE long long clang_Type_getOffsetOf(CXType T, const char *S);
3616
Argyrios Kyrtzidis2bff5162015-04-13 16:55:04 +00003617/**
3618 * \brief Return the offset of the field represented by the Cursor.
3619 *
3620 * If the cursor is not a field declaration, -1 is returned.
3621 * If the cursor semantic parent is not a record field declaration,
3622 * CXTypeLayoutError_Invalid is returned.
3623 * If the field's type declaration is an incomplete type,
3624 * CXTypeLayoutError_Incomplete is returned.
3625 * If the field's type declaration is a dependent type,
3626 * CXTypeLayoutError_Dependent is returned.
3627 * If the field's name S is not found,
3628 * CXTypeLayoutError_InvalidFieldName is returned.
3629 */
3630CINDEX_LINKAGE long long clang_Cursor_getOffsetOfField(CXCursor C);
3631
3632/**
3633 * \brief Determine whether the given cursor represents an anonymous record
3634 * declaration.
3635 */
3636CINDEX_LINKAGE unsigned clang_Cursor_isAnonymous(CXCursor C);
3637
Argyrios Kyrtzidisadff3ae2013-10-11 19:58:38 +00003638enum CXRefQualifierKind {
3639 /** \brief No ref-qualifier was provided. */
3640 CXRefQualifier_None = 0,
3641 /** \brief An lvalue ref-qualifier was provided (\c &). */
3642 CXRefQualifier_LValue,
3643 /** \brief An rvalue ref-qualifier was provided (\c &&). */
3644 CXRefQualifier_RValue
3645};
3646
3647/**
Argyrios Kyrtzidis35f5aab2016-11-15 20:51:46 +00003648 * \brief Returns the number of template arguments for given template
3649 * specialization, or -1 if type \c T is not a template specialization.
Dmitri Gribenko6ede6ab2014-02-27 16:05:05 +00003650 */
3651CINDEX_LINKAGE int clang_Type_getNumTemplateArguments(CXType T);
3652
3653/**
3654 * \brief Returns the type template argument of a template class specialization
3655 * at given index.
3656 *
3657 * This function only returns template type arguments and does not handle
3658 * template template arguments or variadic packs.
3659 */
3660CINDEX_LINKAGE CXType clang_Type_getTemplateArgumentAsType(CXType T, unsigned i);
3661
3662/**
Argyrios Kyrtzidisadff3ae2013-10-11 19:58:38 +00003663 * \brief Retrieve the ref-qualifier kind of a function or method.
3664 *
3665 * The ref-qualifier is returned for C++ functions or methods. For other types
3666 * or non-C++ declarations, CXRefQualifier_None is returned.
3667 */
3668CINDEX_LINKAGE enum CXRefQualifierKind clang_Type_getCXXRefQualifier(CXType T);
3669
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003670/**
3671 * \brief Returns non-zero if the cursor specifies a Record member that is a
3672 * bitfield.
3673 */
3674CINDEX_LINKAGE unsigned clang_Cursor_isBitField(CXCursor C);
3675
3676/**
Ted Kremenekae9e2212010-08-27 21:34:58 +00003677 * \brief Returns 1 if the base class specified by the cursor with kind
3678 * CX_CXXBaseSpecifier is virtual.
3679 */
3680CINDEX_LINKAGE unsigned clang_isVirtualBase(CXCursor);
3681
3682/**
3683 * \brief Represents the C++ access control level to a base class for a
3684 * cursor with kind CX_CXXBaseSpecifier.
3685 */
3686enum CX_CXXAccessSpecifier {
3687 CX_CXXInvalidAccessSpecifier,
3688 CX_CXXPublic,
3689 CX_CXXProtected,
3690 CX_CXXPrivate
3691};
3692
3693/**
Argyrios Kyrtzidis1ab09cc2013-04-11 17:02:10 +00003694 * \brief Returns the access control level for the referenced object.
Argyrios Kyrtzidisf6464082013-04-11 17:31:13 +00003695 *
Argyrios Kyrtzidis1ab09cc2013-04-11 17:02:10 +00003696 * If the cursor refers to a C++ declaration, its access control level within its
3697 * parent scope is returned. Otherwise, if the cursor refers to a base specifier or
3698 * access specifier, the specifier itself is returned.
Ted Kremenekae9e2212010-08-27 21:34:58 +00003699 */
3700CINDEX_LINKAGE enum CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor);
3701
3702/**
Argyrios Kyrtzidis4e0854f2014-10-15 17:05:31 +00003703 * \brief Represents the storage classes as declared in the source. CX_SC_Invalid
Chad Rosierdb1cc7f2014-12-05 15:50:44 +00003704 * was added for the case that the passed cursor in not a declaration.
Argyrios Kyrtzidis4e0854f2014-10-15 17:05:31 +00003705 */
3706enum CX_StorageClass {
3707 CX_SC_Invalid,
3708 CX_SC_None,
3709 CX_SC_Extern,
3710 CX_SC_Static,
3711 CX_SC_PrivateExtern,
3712 CX_SC_OpenCLWorkGroupLocal,
3713 CX_SC_Auto,
3714 CX_SC_Register
3715};
3716
3717/**
3718 * \brief Returns the storage class for a function or variable declaration.
3719 *
3720 * If the passed in Cursor is not a function or variable declaration,
3721 * CX_SC_Invalid is returned else the storage class.
3722 */
3723CINDEX_LINKAGE enum CX_StorageClass clang_Cursor_getStorageClass(CXCursor);
3724
3725/**
Douglas Gregor16a2bdd2010-09-13 22:52:57 +00003726 * \brief Determine the number of overloaded declarations referenced by a
3727 * \c CXCursor_OverloadedDeclRef cursor.
3728 *
3729 * \param cursor The cursor whose overloaded declarations are being queried.
3730 *
3731 * \returns The number of overloaded declarations referenced by \c cursor. If it
3732 * is not a \c CXCursor_OverloadedDeclRef cursor, returns 0.
3733 */
3734CINDEX_LINKAGE unsigned clang_getNumOverloadedDecls(CXCursor cursor);
3735
3736/**
3737 * \brief Retrieve a cursor for one of the overloaded declarations referenced
3738 * by a \c CXCursor_OverloadedDeclRef cursor.
3739 *
3740 * \param cursor The cursor whose overloaded declarations are being queried.
3741 *
3742 * \param index The zero-based index into the set of overloaded declarations in
3743 * the cursor.
3744 *
3745 * \returns A cursor representing the declaration referenced by the given
3746 * \c cursor at the specified \c index. If the cursor does not have an
3747 * associated set of overloaded declarations, or if the index is out of bounds,
3748 * returns \c clang_getNullCursor();
3749 */
3750CINDEX_LINKAGE CXCursor clang_getOverloadedDecl(CXCursor cursor,
3751 unsigned index);
3752
3753/**
Ted Kremenek6bca9842010-05-14 21:29:26 +00003754 * @}
3755 */
Ted Kremeneka5940822010-08-26 01:42:22 +00003756
3757/**
Ted Kremenek2c2c5f32010-08-27 21:34:51 +00003758 * \defgroup CINDEX_ATTRIBUTES Information for attributes
Ted Kremeneka5940822010-08-26 01:42:22 +00003759 *
3760 * @{
3761 */
3762
Ted Kremeneka5940822010-08-26 01:42:22 +00003763/**
3764 * \brief For cursors representing an iboutletcollection attribute,
3765 * this function returns the collection element type.
3766 *
3767 */
3768CINDEX_LINKAGE CXType clang_getIBOutletCollectionType(CXCursor);
3769
3770/**
3771 * @}
3772 */
Ted Kremenek6bca9842010-05-14 21:29:26 +00003773
3774/**
Douglas Gregor6007cf22010-01-22 22:29:16 +00003775 * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors
3776 *
3777 * These routines provide the ability to traverse the abstract syntax tree
3778 * using cursors.
3779 *
3780 * @{
3781 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003782
Douglas Gregor6007cf22010-01-22 22:29:16 +00003783/**
3784 * \brief Describes how the traversal of the children of a particular
3785 * cursor should proceed after visiting a particular child cursor.
3786 *
3787 * A value of this enumeration type should be returned by each
3788 * \c CXCursorVisitor to indicate how clang_visitChildren() proceed.
3789 */
3790enum CXChildVisitResult {
3791 /**
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003792 * \brief Terminates the cursor traversal.
Douglas Gregor6007cf22010-01-22 22:29:16 +00003793 */
3794 CXChildVisit_Break,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003795 /**
Douglas Gregor6007cf22010-01-22 22:29:16 +00003796 * \brief Continues the cursor traversal with the next sibling of
3797 * the cursor just visited, without visiting its children.
3798 */
3799 CXChildVisit_Continue,
3800 /**
3801 * \brief Recursively traverse the children of this cursor, using
3802 * the same visitor and client data.
3803 */
3804 CXChildVisit_Recurse
3805};
3806
3807/**
3808 * \brief Visitor invoked for each cursor found by a traversal.
3809 *
3810 * This visitor function will be invoked for each cursor found by
3811 * clang_visitCursorChildren(). Its first argument is the cursor being
3812 * visited, its second argument is the parent visitor for that cursor,
3813 * and its third argument is the client data provided to
3814 * clang_visitCursorChildren().
3815 *
3816 * The visitor should return one of the \c CXChildVisitResult values
3817 * to direct clang_visitCursorChildren().
3818 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003819typedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor,
3820 CXCursor parent,
Douglas Gregor6007cf22010-01-22 22:29:16 +00003821 CXClientData client_data);
3822
3823/**
3824 * \brief Visit the children of a particular cursor.
3825 *
3826 * This function visits all the direct children of the given cursor,
3827 * invoking the given \p visitor function with the cursors of each
3828 * visited child. The traversal may be recursive, if the visitor returns
3829 * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if
3830 * the visitor returns \c CXChildVisit_Break.
3831 *
Douglas Gregor6007cf22010-01-22 22:29:16 +00003832 * \param parent the cursor whose child may be visited. All kinds of
Daniel Dunbarb9999fd2010-01-24 04:10:31 +00003833 * cursors can be visited, including invalid cursors (which, by
Douglas Gregor6007cf22010-01-22 22:29:16 +00003834 * definition, have no children).
3835 *
3836 * \param visitor the visitor function that will be invoked for each
3837 * child of \p parent.
3838 *
3839 * \param client_data pointer data supplied by the client, which will
3840 * be passed to the visitor each time it is invoked.
3841 *
3842 * \returns a non-zero value if the traversal was terminated
3843 * prematurely by the visitor returning \c CXChildVisit_Break.
3844 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003845CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent,
Douglas Gregor6007cf22010-01-22 22:29:16 +00003846 CXCursorVisitor visitor,
3847 CXClientData client_data);
David Chisnallb2aa0ef2010-11-03 14:12:26 +00003848#ifdef __has_feature
3849# if __has_feature(blocks)
3850/**
3851 * \brief Visitor invoked for each cursor found by a traversal.
3852 *
3853 * This visitor block will be invoked for each cursor found by
3854 * clang_visitChildrenWithBlock(). Its first argument is the cursor being
3855 * visited, its second argument is the parent visitor for that cursor.
3856 *
3857 * The visitor should return one of the \c CXChildVisitResult values
3858 * to direct clang_visitChildrenWithBlock().
3859 */
3860typedef enum CXChildVisitResult
3861 (^CXCursorVisitorBlock)(CXCursor cursor, CXCursor parent);
3862
3863/**
3864 * Visits the children of a cursor using the specified block. Behaves
3865 * identically to clang_visitChildren() in all other respects.
3866 */
Argyrios Kyrtzidisa0a35d72016-02-07 18:21:28 +00003867CINDEX_LINKAGE unsigned clang_visitChildrenWithBlock(CXCursor parent,
3868 CXCursorVisitorBlock block);
David Chisnallb2aa0ef2010-11-03 14:12:26 +00003869# endif
3870#endif
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003871
Douglas Gregor6007cf22010-01-22 22:29:16 +00003872/**
3873 * @}
3874 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003875
Douglas Gregor6007cf22010-01-22 22:29:16 +00003876/**
3877 * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST
3878 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003879 * These routines provide the ability to determine references within and
Douglas Gregor6007cf22010-01-22 22:29:16 +00003880 * across translation units, by providing the names of the entities referenced
3881 * by cursors, follow reference cursors to the declarations they reference,
3882 * and associate declarations with their definitions.
3883 *
3884 * @{
3885 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003886
Douglas Gregor6007cf22010-01-22 22:29:16 +00003887/**
3888 * \brief Retrieve a Unified Symbol Resolution (USR) for the entity referenced
3889 * by the given cursor.
3890 *
3891 * A Unified Symbol Resolution (USR) is a string that identifies a particular
3892 * entity (function, class, variable, etc.) within a program. USRs can be
3893 * compared across translation units to determine, e.g., when references in
3894 * one translation refer to an entity defined in another translation unit.
3895 */
3896CINDEX_LINKAGE CXString clang_getCursorUSR(CXCursor);
3897
3898/**
Ted Kremenekd071c602010-03-13 02:50:34 +00003899 * \brief Construct a USR for a specified Objective-C class.
3900 */
3901CINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name);
3902
3903/**
3904 * \brief Construct a USR for a specified Objective-C category.
3905 */
3906CINDEX_LINKAGE CXString
Ted Kremenekbc1a67b2010-03-15 17:38:58 +00003907 clang_constructUSR_ObjCCategory(const char *class_name,
Ted Kremenekd071c602010-03-13 02:50:34 +00003908 const char *category_name);
3909
3910/**
3911 * \brief Construct a USR for a specified Objective-C protocol.
3912 */
3913CINDEX_LINKAGE CXString
3914 clang_constructUSR_ObjCProtocol(const char *protocol_name);
3915
Ted Kremenekd071c602010-03-13 02:50:34 +00003916/**
3917 * \brief Construct a USR for a specified Objective-C instance variable and
3918 * the USR for its containing class.
3919 */
3920CINDEX_LINKAGE CXString clang_constructUSR_ObjCIvar(const char *name,
3921 CXString classUSR);
3922
3923/**
3924 * \brief Construct a USR for a specified Objective-C method and
3925 * the USR for its containing class.
3926 */
3927CINDEX_LINKAGE CXString clang_constructUSR_ObjCMethod(const char *name,
3928 unsigned isInstanceMethod,
3929 CXString classUSR);
3930
3931/**
3932 * \brief Construct a USR for a specified Objective-C property and the USR
3933 * for its containing class.
3934 */
3935CINDEX_LINKAGE CXString clang_constructUSR_ObjCProperty(const char *property,
3936 CXString classUSR);
3937
3938/**
Douglas Gregor6007cf22010-01-22 22:29:16 +00003939 * \brief Retrieve a name for the entity referenced by this cursor.
3940 */
3941CINDEX_LINKAGE CXString clang_getCursorSpelling(CXCursor);
3942
Douglas Gregor97c75712010-10-02 22:49:11 +00003943/**
Argyrios Kyrtzidis191a6a82012-03-30 20:58:35 +00003944 * \brief Retrieve a range for a piece that forms the cursors spelling name.
3945 * Most of the times there is only one range for the complete spelling but for
Nico Weber7deebef2014-04-24 03:17:47 +00003946 * Objective-C methods and Objective-C message expressions, there are multiple
3947 * pieces for each selector identifier.
Argyrios Kyrtzidis191a6a82012-03-30 20:58:35 +00003948 *
3949 * \param pieceIndex the index of the spelling name piece. If this is greater
3950 * than the actual number of pieces, it will return a NULL (invalid) range.
3951 *
3952 * \param options Reserved.
3953 */
3954CINDEX_LINKAGE CXSourceRange clang_Cursor_getSpellingNameRange(CXCursor,
3955 unsigned pieceIndex,
3956 unsigned options);
3957
3958/**
Douglas Gregor97c75712010-10-02 22:49:11 +00003959 * \brief Retrieve the display name for the entity referenced by this cursor.
3960 *
3961 * The display name contains extra information that helps identify the cursor,
3962 * such as the parameters of a function or template or the arguments of a
3963 * class template specialization.
3964 */
3965CINDEX_LINKAGE CXString clang_getCursorDisplayName(CXCursor);
3966
Douglas Gregorad27e8b2010-01-19 01:20:04 +00003967/** \brief For a cursor that is a reference, retrieve a cursor representing the
3968 * entity that it references.
3969 *
3970 * Reference cursors refer to other entities in the AST. For example, an
3971 * Objective-C superclass reference cursor refers to an Objective-C class.
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003972 * This function produces the cursor for the Objective-C class from the
Douglas Gregorad27e8b2010-01-19 01:20:04 +00003973 * cursor for the superclass reference. If the input cursor is a declaration or
3974 * definition, it returns that declaration or definition unchanged.
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003975 * Otherwise, returns the NULL cursor.
Douglas Gregorad27e8b2010-01-19 01:20:04 +00003976 */
3977CINDEX_LINKAGE CXCursor clang_getCursorReferenced(CXCursor);
Douglas Gregor6b8232f2010-01-19 19:34:47 +00003978
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003979/**
Douglas Gregor6b8232f2010-01-19 19:34:47 +00003980 * \brief For a cursor that is either a reference to or a declaration
3981 * of some entity, retrieve a cursor that describes the definition of
3982 * that entity.
3983 *
3984 * Some entities can be declared multiple times within a translation
3985 * unit, but only one of those declarations can also be a
3986 * definition. For example, given:
3987 *
3988 * \code
3989 * int f(int, int);
3990 * int g(int x, int y) { return f(x, y); }
3991 * int f(int a, int b) { return a + b; }
3992 * int f(int, int);
3993 * \endcode
3994 *
3995 * there are three declarations of the function "f", but only the
3996 * second one is a definition. The clang_getCursorDefinition()
3997 * function will take any cursor pointing to a declaration of "f"
3998 * (the first or fourth lines of the example) or a cursor referenced
3999 * that uses "f" (the call to "f' inside "g") and will return a
4000 * declaration cursor pointing to the definition (the second "f"
4001 * declaration).
4002 *
4003 * If given a cursor for which there is no corresponding definition,
4004 * e.g., because there is no definition of that entity within this
4005 * translation unit, returns a NULL cursor.
4006 */
4007CINDEX_LINKAGE CXCursor clang_getCursorDefinition(CXCursor);
4008
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004009/**
Douglas Gregor6b8232f2010-01-19 19:34:47 +00004010 * \brief Determine whether the declaration pointed to by this cursor
4011 * is also a definition of that entity.
4012 */
4013CINDEX_LINKAGE unsigned clang_isCursorDefinition(CXCursor);
4014
Douglas Gregor6007cf22010-01-22 22:29:16 +00004015/**
Douglas Gregorfec4dc92010-11-19 23:44:15 +00004016 * \brief Retrieve the canonical cursor corresponding to the given cursor.
4017 *
4018 * In the C family of languages, many kinds of entities can be declared several
4019 * times within a single translation unit. For example, a structure type can
4020 * be forward-declared (possibly multiple times) and later defined:
4021 *
4022 * \code
4023 * struct X;
4024 * struct X;
4025 * struct X {
4026 * int member;
4027 * };
4028 * \endcode
4029 *
4030 * The declarations and the definition of \c X are represented by three
4031 * different cursors, all of which are declarations of the same underlying
4032 * entity. One of these cursor is considered the "canonical" cursor, which
4033 * is effectively the representative for the underlying entity. One can
4034 * determine if two cursors are declarations of the same underlying entity by
4035 * comparing their canonical cursors.
4036 *
4037 * \returns The canonical cursor for the entity referred to by the given cursor.
4038 */
4039CINDEX_LINKAGE CXCursor clang_getCanonicalCursor(CXCursor);
4040
Argyrios Kyrtzidis210f29f2012-03-30 22:15:48 +00004041/**
Nico Weber7deebef2014-04-24 03:17:47 +00004042 * \brief If the cursor points to a selector identifier in an Objective-C
4043 * method or message expression, this returns the selector index.
Argyrios Kyrtzidis210f29f2012-03-30 22:15:48 +00004044 *
James Dennett574cb4c2012-06-15 05:41:51 +00004045 * After getting a cursor with #clang_getCursor, this can be called to
Argyrios Kyrtzidis210f29f2012-03-30 22:15:48 +00004046 * determine if the location points to a selector identifier.
4047 *
Nico Weber7deebef2014-04-24 03:17:47 +00004048 * \returns The selector index if the cursor is an Objective-C method or message
Argyrios Kyrtzidis210f29f2012-03-30 22:15:48 +00004049 * expression and the cursor is pointing to a selector identifier, or -1
4050 * otherwise.
4051 */
4052CINDEX_LINKAGE int clang_Cursor_getObjCSelectorIndex(CXCursor);
4053
Douglas Gregorfec4dc92010-11-19 23:44:15 +00004054/**
Nico Weber7deebef2014-04-24 03:17:47 +00004055 * \brief Given a cursor pointing to a C++ method call or an Objective-C
4056 * message, returns non-zero if the method/message is "dynamic", meaning:
Argyrios Kyrtzidisb6df68212012-07-02 23:54:36 +00004057 *
4058 * For a C++ method: the call is virtual.
Nico Weber7deebef2014-04-24 03:17:47 +00004059 * For an Objective-C message: the receiver is an object instance, not 'super'
4060 * or a specific class.
Argyrios Kyrtzidisb6df68212012-07-02 23:54:36 +00004061 *
4062 * If the method/message is "static" or the cursor does not point to a
4063 * method/message, it will return zero.
4064 */
4065CINDEX_LINKAGE int clang_Cursor_isDynamicCall(CXCursor C);
4066
4067/**
Argyrios Kyrtzidis2a684862017-04-27 17:23:04 +00004068 * \brief Given a cursor pointing to an Objective-C message or property
4069 * reference, or C++ method call, returns the CXType of the receiver.
Argyrios Kyrtzidisb26a24c2012-11-01 02:01:34 +00004070 */
4071CINDEX_LINKAGE CXType clang_Cursor_getReceiverType(CXCursor C);
4072
4073/**
Argyrios Kyrtzidis9adfd8a2013-04-18 22:15:49 +00004074 * \brief Property attributes for a \c CXCursor_ObjCPropertyDecl.
4075 */
4076typedef enum {
4077 CXObjCPropertyAttr_noattr = 0x00,
4078 CXObjCPropertyAttr_readonly = 0x01,
4079 CXObjCPropertyAttr_getter = 0x02,
4080 CXObjCPropertyAttr_assign = 0x04,
4081 CXObjCPropertyAttr_readwrite = 0x08,
4082 CXObjCPropertyAttr_retain = 0x10,
4083 CXObjCPropertyAttr_copy = 0x20,
4084 CXObjCPropertyAttr_nonatomic = 0x40,
4085 CXObjCPropertyAttr_setter = 0x80,
4086 CXObjCPropertyAttr_atomic = 0x100,
4087 CXObjCPropertyAttr_weak = 0x200,
4088 CXObjCPropertyAttr_strong = 0x400,
Manman Ren04fd4d82016-05-31 23:22:04 +00004089 CXObjCPropertyAttr_unsafe_unretained = 0x800,
Manman Ren400e4c32016-06-03 23:11:41 +00004090 CXObjCPropertyAttr_class = 0x1000
Argyrios Kyrtzidis9adfd8a2013-04-18 22:15:49 +00004091} CXObjCPropertyAttrKind;
4092
4093/**
4094 * \brief Given a cursor that represents a property declaration, return the
4095 * associated property attributes. The bits are formed from
4096 * \c CXObjCPropertyAttrKind.
4097 *
4098 * \param reserved Reserved for future use, pass 0.
4099 */
4100CINDEX_LINKAGE unsigned clang_Cursor_getObjCPropertyAttributes(CXCursor C,
4101 unsigned reserved);
4102
4103/**
Argyrios Kyrtzidis9d9bc012013-04-18 23:29:12 +00004104 * \brief 'Qualifiers' written next to the return and parameter types in
Nico Weber7deebef2014-04-24 03:17:47 +00004105 * Objective-C method declarations.
Argyrios Kyrtzidis9d9bc012013-04-18 23:29:12 +00004106 */
4107typedef enum {
4108 CXObjCDeclQualifier_None = 0x0,
4109 CXObjCDeclQualifier_In = 0x1,
4110 CXObjCDeclQualifier_Inout = 0x2,
4111 CXObjCDeclQualifier_Out = 0x4,
4112 CXObjCDeclQualifier_Bycopy = 0x8,
4113 CXObjCDeclQualifier_Byref = 0x10,
4114 CXObjCDeclQualifier_Oneway = 0x20
4115} CXObjCDeclQualifierKind;
4116
4117/**
Nico Weber7deebef2014-04-24 03:17:47 +00004118 * \brief Given a cursor that represents an Objective-C method or parameter
4119 * declaration, return the associated Objective-C qualifiers for the return
4120 * type or the parameter respectively. The bits are formed from
4121 * CXObjCDeclQualifierKind.
Argyrios Kyrtzidis9d9bc012013-04-18 23:29:12 +00004122 */
4123CINDEX_LINKAGE unsigned clang_Cursor_getObjCDeclQualifiers(CXCursor C);
4124
4125/**
Nico Weber7deebef2014-04-24 03:17:47 +00004126 * \brief Given a cursor that represents an Objective-C method or property
Alex Lorenz6c2898a2017-04-06 14:03:25 +00004127 * declaration, return non-zero if the declaration was affected by "\@optional".
4128 * Returns zero if the cursor is not such a declaration or it is "\@required".
Argyrios Kyrtzidis7b50fc52013-07-05 20:44:37 +00004129 */
4130CINDEX_LINKAGE unsigned clang_Cursor_isObjCOptional(CXCursor C);
4131
4132/**
Argyrios Kyrtzidis23814e42013-04-18 23:53:05 +00004133 * \brief Returns non-zero if the given cursor is a variadic function or method.
4134 */
4135CINDEX_LINKAGE unsigned clang_Cursor_isVariadic(CXCursor C);
4136
4137/**
Argyrios Kyrtzidis0381cc72017-05-10 15:10:36 +00004138 * \brief Returns non-zero if the given cursor points to a symbol marked with
4139 * external_source_symbol attribute.
4140 *
4141 * \param language If non-NULL, and the attribute is present, will be set to
4142 * the 'language' string from the attribute.
4143 *
4144 * \param definedIn If non-NULL, and the attribute is present, will be set to
4145 * the 'definedIn' string from the attribute.
4146 *
4147 * \param isGenerated If non-NULL, and the attribute is present, will be set to
Argyrios Kyrtzidis8b337c02017-05-10 15:48:16 +00004148 * non-zero if the 'generated_declaration' is set in the attribute.
Argyrios Kyrtzidis0381cc72017-05-10 15:10:36 +00004149 */
4150CINDEX_LINKAGE unsigned clang_Cursor_isExternalSymbol(CXCursor C,
4151 CXString *language, CXString *definedIn,
4152 unsigned *isGenerated);
4153
4154/**
Dmitri Gribenkoaab83832012-06-20 00:34:58 +00004155 * \brief Given a cursor that represents a declaration, return the associated
4156 * comment's source range. The range may include multiple consecutive comments
4157 * with whitespace in between.
4158 */
4159CINDEX_LINKAGE CXSourceRange clang_Cursor_getCommentRange(CXCursor C);
4160
4161/**
4162 * \brief Given a cursor that represents a declaration, return the associated
4163 * comment text, including comment markers.
4164 */
4165CINDEX_LINKAGE CXString clang_Cursor_getRawCommentText(CXCursor C);
4166
4167/**
Dmitri Gribenko5e4fe002012-07-20 21:34:34 +00004168 * \brief Given a cursor that represents a documentable entity (e.g.,
4169 * declaration), return the associated \\brief paragraph; otherwise return the
4170 * first paragraph.
Dmitri Gribenko5188c4b2012-06-26 20:39:18 +00004171 */
4172CINDEX_LINKAGE CXString clang_Cursor_getBriefCommentText(CXCursor C);
4173
4174/**
Dmitri Gribenko5e4fe002012-07-20 21:34:34 +00004175 * @}
4176 */
4177
Eli Bendersky44a206f2014-07-31 18:04:56 +00004178/** \defgroup CINDEX_MANGLE Name Mangling API Functions
4179 *
4180 * @{
4181 */
4182
4183/**
4184 * \brief Retrieve the CXString representing the mangled name of the cursor.
4185 */
4186CINDEX_LINKAGE CXString clang_Cursor_getMangling(CXCursor);
4187
4188/**
Saleem Abdulrasool60034432015-11-12 03:57:22 +00004189 * \brief Retrieve the CXStrings representing the mangled symbols of the C++
4190 * constructor or destructor at the cursor.
4191 */
4192CINDEX_LINKAGE CXStringSet *clang_Cursor_getCXXManglings(CXCursor);
4193
4194/**
Eli Bendersky44a206f2014-07-31 18:04:56 +00004195 * @}
4196 */
4197
Dmitri Gribenko5e4fe002012-07-20 21:34:34 +00004198/**
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004199 * \defgroup CINDEX_MODULE Module introspection
4200 *
4201 * The functions in this group provide access to information about modules.
4202 *
4203 * @{
4204 */
4205
4206typedef void *CXModule;
4207
4208/**
4209 * \brief Given a CXCursor_ModuleImportDecl cursor, return the associated module.
4210 */
4211CINDEX_LINKAGE CXModule clang_Cursor_getModule(CXCursor C);
4212
4213/**
Argyrios Kyrtzidisf6d49c32014-05-14 23:14:37 +00004214 * \brief Given a CXFile header file, return the module that contains it, if one
4215 * exists.
4216 */
4217CINDEX_LINKAGE CXModule clang_getModuleForFile(CXTranslationUnit, CXFile);
4218
4219/**
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004220 * \param Module a module object.
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004221 *
Argyrios Kyrtzidis12fdb9e2013-04-26 22:47:49 +00004222 * \returns the module file where the provided module object came from.
4223 */
4224CINDEX_LINKAGE CXFile clang_Module_getASTFile(CXModule Module);
4225
4226/**
4227 * \param Module a module object.
4228 *
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004229 * \returns the parent of a sub-module or NULL if the given module is top-level,
4230 * e.g. for 'std.vector' it will return the 'std' module.
4231 */
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004232CINDEX_LINKAGE CXModule clang_Module_getParent(CXModule Module);
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004233
4234/**
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004235 * \param Module a module object.
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004236 *
4237 * \returns the name of the module, e.g. for the 'std.vector' sub-module it
4238 * will return "vector".
4239 */
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004240CINDEX_LINKAGE CXString clang_Module_getName(CXModule Module);
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004241
4242/**
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004243 * \param Module a module object.
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004244 *
4245 * \returns the full name of the module, e.g. "std.vector".
4246 */
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004247CINDEX_LINKAGE CXString clang_Module_getFullName(CXModule Module);
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004248
4249/**
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004250 * \param Module a module object.
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004251 *
Argyrios Kyrtzidis884337f2014-05-15 04:44:25 +00004252 * \returns non-zero if the module is a system one.
4253 */
4254CINDEX_LINKAGE int clang_Module_isSystem(CXModule Module);
4255
4256/**
4257 * \param Module a module object.
4258 *
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004259 * \returns the number of top level headers associated with this module.
4260 */
Argyrios Kyrtzidis3c5305c2013-03-13 21:13:43 +00004261CINDEX_LINKAGE unsigned clang_Module_getNumTopLevelHeaders(CXTranslationUnit,
4262 CXModule Module);
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004263
4264/**
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004265 * \param Module a module object.
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004266 *
4267 * \param Index top level header index (zero-based).
4268 *
4269 * \returns the specified top level header associated with the module.
4270 */
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004271CINDEX_LINKAGE
Argyrios Kyrtzidis3c5305c2013-03-13 21:13:43 +00004272CXFile clang_Module_getTopLevelHeader(CXTranslationUnit,
4273 CXModule Module, unsigned Index);
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004274
4275/**
4276 * @}
4277 */
4278
4279/**
Ted Kremenek9cfe9e62010-05-17 20:06:56 +00004280 * \defgroup CINDEX_CPP C++ AST introspection
4281 *
4282 * The routines in this group provide access information in the ASTs specific
4283 * to C++ language features.
4284 *
4285 * @{
4286 */
4287
4288/**
Jonathan Coe29565352016-04-27 12:48:25 +00004289 * \brief Determine if a C++ constructor is a converting constructor.
4290 */
4291CINDEX_LINKAGE unsigned clang_CXXConstructor_isConvertingConstructor(CXCursor C);
4292
4293/**
4294 * \brief Determine if a C++ constructor is a copy constructor.
4295 */
4296CINDEX_LINKAGE unsigned clang_CXXConstructor_isCopyConstructor(CXCursor C);
4297
4298/**
4299 * \brief Determine if a C++ constructor is the default constructor.
4300 */
4301CINDEX_LINKAGE unsigned clang_CXXConstructor_isDefaultConstructor(CXCursor C);
4302
4303/**
4304 * \brief Determine if a C++ constructor is a move constructor.
4305 */
4306CINDEX_LINKAGE unsigned clang_CXXConstructor_isMoveConstructor(CXCursor C);
4307
4308/**
Saleem Abdulrasool6ea75db2015-10-27 15:50:22 +00004309 * \brief Determine if a C++ field is declared 'mutable'.
4310 */
4311CINDEX_LINKAGE unsigned clang_CXXField_isMutable(CXCursor C);
4312
4313/**
Jonathan Coe29565352016-04-27 12:48:25 +00004314 * \brief Determine if a C++ method is declared '= default'.
4315 */
4316CINDEX_LINKAGE unsigned clang_CXXMethod_isDefaulted(CXCursor C);
4317
4318/**
Dmitri Gribenko62770be2013-05-17 18:38:35 +00004319 * \brief Determine if a C++ member function or member function template is
4320 * pure virtual.
4321 */
4322CINDEX_LINKAGE unsigned clang_CXXMethod_isPureVirtual(CXCursor C);
4323
4324/**
Douglas Gregorf11309e2010-08-31 22:12:17 +00004325 * \brief Determine if a C++ member function or member function template is
4326 * declared 'static'.
Ted Kremenek9cfe9e62010-05-17 20:06:56 +00004327 */
4328CINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C);
4329
4330/**
Douglas Gregor9519d922011-05-12 15:17:24 +00004331 * \brief Determine if a C++ member function or member function template is
4332 * explicitly declared 'virtual' or if it overrides a virtual method from
4333 * one of the base classes.
4334 */
4335CINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual(CXCursor C);
4336
4337/**
Dmitri Gribenkoe570ede2014-04-07 14:59:13 +00004338 * \brief Determine if a C++ member function or member function template is
4339 * declared 'const'.
4340 */
4341CINDEX_LINKAGE unsigned clang_CXXMethod_isConst(CXCursor C);
4342
4343/**
Douglas Gregorf11309e2010-08-31 22:12:17 +00004344 * \brief Given a cursor that represents a template, determine
4345 * the cursor kind of the specializations would be generated by instantiating
4346 * the template.
4347 *
4348 * This routine can be used to determine what flavor of function template,
4349 * class template, or class template partial specialization is stored in the
4350 * cursor. For example, it can describe whether a class template cursor is
4351 * declared with "struct", "class" or "union".
4352 *
4353 * \param C The cursor to query. This cursor should represent a template
4354 * declaration.
4355 *
4356 * \returns The cursor kind of the specializations that would be generated
4357 * by instantiating the template \p C. If \p C is not a template, returns
4358 * \c CXCursor_NoDeclFound.
4359 */
4360CINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind(CXCursor C);
4361
4362/**
Douglas Gregord3f48bd2010-09-02 00:07:54 +00004363 * \brief Given a cursor that may represent a specialization or instantiation
4364 * of a template, retrieve the cursor that represents the template that it
4365 * specializes or from which it was instantiated.
4366 *
4367 * This routine determines the template involved both for explicit
4368 * specializations of templates and for implicit instantiations of the template,
4369 * both of which are referred to as "specializations". For a class template
4370 * specialization (e.g., \c std::vector<bool>), this routine will return
4371 * either the primary template (\c std::vector) or, if the specialization was
4372 * instantiated from a class template partial specialization, the class template
4373 * partial specialization. For a class template partial specialization and a
4374 * function template specialization (including instantiations), this
4375 * this routine will return the specialized template.
4376 *
4377 * For members of a class template (e.g., member functions, member classes, or
4378 * static data members), returns the specialized or instantiated member.
4379 * Although not strictly "templates" in the C++ language, members of class
4380 * templates have the same notions of specializations and instantiations that
4381 * templates do, so this routine treats them similarly.
4382 *
4383 * \param C A cursor that may be a specialization of a template or a member
4384 * of a template.
4385 *
4386 * \returns If the given cursor is a specialization or instantiation of a
4387 * template or a member thereof, the template or member that it specializes or
4388 * from which it was instantiated. Otherwise, returns a NULL cursor.
4389 */
4390CINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate(CXCursor C);
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004391
4392/**
4393 * \brief Given a cursor that references something else, return the source range
4394 * covering that reference.
4395 *
4396 * \param C A cursor pointing to a member reference, a declaration reference, or
4397 * an operator call.
4398 * \param NameFlags A bitset with three independent flags:
4399 * CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and
4400 * CXNameRange_WantSinglePiece.
4401 * \param PieceIndex For contiguous names or when passing the flag
4402 * CXNameRange_WantSinglePiece, only one piece with index 0 is
4403 * available. When the CXNameRange_WantSinglePiece flag is not passed for a
Benjamin Kramer474261a2012-06-02 10:20:41 +00004404 * non-contiguous names, this index can be used to retrieve the individual
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004405 * pieces of the name. See also CXNameRange_WantSinglePiece.
4406 *
4407 * \returns The piece of the name pointed to by the given cursor. If there is no
4408 * name, or if the PieceIndex is out-of-range, a null-cursor will be returned.
4409 */
Francois Pichetece689f2011-07-25 22:00:44 +00004410CINDEX_LINKAGE CXSourceRange clang_getCursorReferenceNameRange(CXCursor C,
4411 unsigned NameFlags,
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004412 unsigned PieceIndex);
4413
4414enum CXNameRefFlags {
4415 /**
4416 * \brief Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the
4417 * range.
4418 */
4419 CXNameRange_WantQualifier = 0x1,
4420
4421 /**
James Dennett574cb4c2012-06-15 05:41:51 +00004422 * \brief Include the explicit template arguments, e.g. \<int> in x.f<int>,
4423 * in the range.
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004424 */
4425 CXNameRange_WantTemplateArgs = 0x2,
4426
4427 /**
4428 * \brief If the name is non-contiguous, return the full spanning range.
4429 *
4430 * Non-contiguous names occur in Objective-C when a selector with two or more
4431 * parameters is used, or in C++ when using an operator:
4432 * \code
Nico Weber7deebef2014-04-24 03:17:47 +00004433 * [object doSomething:here withValue:there]; // Objective-C
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004434 * return some_vector[1]; // C++
4435 * \endcode
4436 */
4437 CXNameRange_WantSinglePiece = 0x4
4438};
Douglas Gregord3f48bd2010-09-02 00:07:54 +00004439
4440/**
Ted Kremenek9cfe9e62010-05-17 20:06:56 +00004441 * @}
4442 */
4443
4444/**
Douglas Gregor61656112010-01-26 18:31:56 +00004445 * \defgroup CINDEX_LEX Token extraction and manipulation
4446 *
4447 * The routines in this group provide access to the tokens within a
4448 * translation unit, along with a semantic mapping of those tokens to
4449 * their corresponding cursors.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004450 *
4451 * @{
4452 */
4453
4454/**
4455 * \brief Describes a kind of token.
4456 */
4457typedef enum CXTokenKind {
4458 /**
4459 * \brief A token that contains some kind of punctuation.
4460 */
4461 CXToken_Punctuation,
Ted Kremenekd071c602010-03-13 02:50:34 +00004462
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004463 /**
Douglas Gregor61656112010-01-26 18:31:56 +00004464 * \brief A language keyword.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004465 */
4466 CXToken_Keyword,
Ted Kremenekd071c602010-03-13 02:50:34 +00004467
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004468 /**
4469 * \brief An identifier (that is not a keyword).
4470 */
4471 CXToken_Identifier,
Ted Kremenekd071c602010-03-13 02:50:34 +00004472
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004473 /**
4474 * \brief A numeric, string, or character literal.
4475 */
4476 CXToken_Literal,
Ted Kremenekd071c602010-03-13 02:50:34 +00004477
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004478 /**
4479 * \brief A comment.
4480 */
4481 CXToken_Comment
4482} CXTokenKind;
4483
4484/**
4485 * \brief Describes a single preprocessing token.
4486 */
4487typedef struct {
4488 unsigned int_data[4];
4489 void *ptr_data;
4490} CXToken;
4491
4492/**
4493 * \brief Determine the kind of the given token.
4494 */
4495CINDEX_LINKAGE CXTokenKind clang_getTokenKind(CXToken);
Ted Kremenekd071c602010-03-13 02:50:34 +00004496
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004497/**
4498 * \brief Determine the spelling of the given token.
4499 *
4500 * The spelling of a token is the textual representation of that token, e.g.,
4501 * the text of an identifier or keyword.
4502 */
4503CINDEX_LINKAGE CXString clang_getTokenSpelling(CXTranslationUnit, CXToken);
Ted Kremenekd071c602010-03-13 02:50:34 +00004504
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004505/**
4506 * \brief Retrieve the source location of the given token.
4507 */
Ted Kremenekd071c602010-03-13 02:50:34 +00004508CINDEX_LINKAGE CXSourceLocation clang_getTokenLocation(CXTranslationUnit,
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004509 CXToken);
Ted Kremenekd071c602010-03-13 02:50:34 +00004510
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004511/**
4512 * \brief Retrieve a source range that covers the given token.
4513 */
4514CINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken);
4515
4516/**
4517 * \brief Tokenize the source code described by the given range into raw
4518 * lexical tokens.
4519 *
4520 * \param TU the translation unit whose text is being tokenized.
4521 *
4522 * \param Range the source range in which text should be tokenized. All of the
4523 * tokens produced by tokenization will fall within this source range,
4524 *
4525 * \param Tokens this pointer will be set to point to the array of tokens
4526 * that occur within the given source range. The returned pointer must be
4527 * freed with clang_disposeTokens() before the translation unit is destroyed.
4528 *
4529 * \param NumTokens will be set to the number of tokens in the \c *Tokens
4530 * array.
4531 *
4532 */
4533CINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
4534 CXToken **Tokens, unsigned *NumTokens);
Ted Kremenekd071c602010-03-13 02:50:34 +00004535
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004536/**
4537 * \brief Annotate the given set of tokens by providing cursors for each token
4538 * that can be mapped to a specific entity within the abstract syntax tree.
4539 *
Douglas Gregor61656112010-01-26 18:31:56 +00004540 * This token-annotation routine is equivalent to invoking
4541 * clang_getCursor() for the source locations of each of the
4542 * tokens. The cursors provided are filtered, so that only those
4543 * cursors that have a direct correspondence to the token are
4544 * accepted. For example, given a function call \c f(x),
4545 * clang_getCursor() would provide the following cursors:
4546 *
4547 * * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'.
4548 * * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'.
4549 * * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'.
4550 *
4551 * Only the first and last of these cursors will occur within the
4552 * annotate, since the tokens "f" and "x' directly refer to a function
4553 * and a variable, respectively, but the parentheses are just a small
4554 * part of the full syntax of the function call expression, which is
4555 * not provided as an annotation.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004556 *
4557 * \param TU the translation unit that owns the given tokens.
4558 *
4559 * \param Tokens the set of tokens to annotate.
4560 *
4561 * \param NumTokens the number of tokens in \p Tokens.
4562 *
4563 * \param Cursors an array of \p NumTokens cursors, whose contents will be
4564 * replaced with the cursors corresponding to each token.
4565 */
4566CINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU,
4567 CXToken *Tokens, unsigned NumTokens,
4568 CXCursor *Cursors);
Ted Kremenekd071c602010-03-13 02:50:34 +00004569
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004570/**
4571 * \brief Free the given set of tokens.
4572 */
Ted Kremenekd071c602010-03-13 02:50:34 +00004573CINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU,
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004574 CXToken *Tokens, unsigned NumTokens);
Ted Kremenekd071c602010-03-13 02:50:34 +00004575
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004576/**
4577 * @}
4578 */
Ted Kremenekd071c602010-03-13 02:50:34 +00004579
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004580/**
Douglas Gregor6007cf22010-01-22 22:29:16 +00004581 * \defgroup CINDEX_DEBUG Debugging facilities
4582 *
4583 * These routines are used for testing and debugging, only, and should not
4584 * be relied upon.
4585 *
4586 * @{
4587 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004588
Steve Naroff76b8f132009-09-23 17:52:52 +00004589/* for debug/testing */
Ted Kremenek29004672010-02-17 00:41:32 +00004590CINDEX_LINKAGE CXString clang_getCursorKindSpelling(enum CXCursorKind Kind);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004591CINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(CXCursor,
4592 const char **startBuf,
Steve Naroff76b8f132009-09-23 17:52:52 +00004593 const char **endBuf,
4594 unsigned *startLine,
4595 unsigned *startColumn,
4596 unsigned *endLine,
4597 unsigned *endColumn);
Douglas Gregor1e21cc72010-02-18 23:07:20 +00004598CINDEX_LINKAGE void clang_enableStackTraces(void);
Daniel Dunbar23420652010-11-04 01:26:29 +00004599CINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void*), void *user_data,
4600 unsigned stack_size);
4601
Douglas Gregor9eb77012009-11-07 00:00:49 +00004602/**
Douglas Gregor6007cf22010-01-22 22:29:16 +00004603 * @}
4604 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004605
Douglas Gregor6007cf22010-01-22 22:29:16 +00004606/**
4607 * \defgroup CINDEX_CODE_COMPLET Code completion
4608 *
4609 * Code completion involves taking an (incomplete) source file, along with
4610 * knowledge of where the user is actively editing that file, and suggesting
4611 * syntactically- and semantically-valid constructs that the user might want to
4612 * use at that particular point in the source code. These data structures and
4613 * routines provide support for code completion.
4614 *
4615 * @{
4616 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004617
Douglas Gregor6007cf22010-01-22 22:29:16 +00004618/**
Douglas Gregor9eb77012009-11-07 00:00:49 +00004619 * \brief A semantic string that describes a code-completion result.
4620 *
4621 * A semantic string that describes the formatting of a code-completion
4622 * result as a single "template" of text that should be inserted into the
4623 * source buffer when a particular code-completion result is selected.
4624 * Each semantic string is made up of some number of "chunks", each of which
4625 * contains some text along with a description of what that text means, e.g.,
4626 * the name of the entity being referenced, whether the text chunk is part of
4627 * the template, or whether it is a "placeholder" that the user should replace
4628 * with actual code,of a specific kind. See \c CXCompletionChunkKind for a
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004629 * description of the different kinds of chunks.
Douglas Gregor9eb77012009-11-07 00:00:49 +00004630 */
4631typedef void *CXCompletionString;
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004632
Douglas Gregor9eb77012009-11-07 00:00:49 +00004633/**
4634 * \brief A single result of code completion.
4635 */
4636typedef struct {
4637 /**
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004638 * \brief The kind of entity that this completion refers to.
Douglas Gregor9eb77012009-11-07 00:00:49 +00004639 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004640 * The cursor kind will be a macro, keyword, or a declaration (one of the
Douglas Gregor9eb77012009-11-07 00:00:49 +00004641 * *Decl cursor kinds), describing the entity that the completion is
4642 * referring to.
4643 *
4644 * \todo In the future, we would like to provide a full cursor, to allow
4645 * the client to extract additional information from declaration.
4646 */
4647 enum CXCursorKind CursorKind;
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004648
4649 /**
Douglas Gregor9eb77012009-11-07 00:00:49 +00004650 * \brief The code-completion string that describes how to insert this
4651 * code-completion result into the editing buffer.
4652 */
4653 CXCompletionString CompletionString;
4654} CXCompletionResult;
4655
4656/**
4657 * \brief Describes a single piece of text within a code-completion string.
4658 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004659 * Each "chunk" within a code-completion string (\c CXCompletionString) is
4660 * either a piece of text with a specific "kind" that describes how that text
Douglas Gregor9eb77012009-11-07 00:00:49 +00004661 * should be interpreted by the client or is another completion string.
4662 */
4663enum CXCompletionChunkKind {
4664 /**
4665 * \brief A code-completion string that describes "optional" text that
4666 * could be a part of the template (but is not required).
4667 *
4668 * The Optional chunk is the only kind of chunk that has a code-completion
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004669 * string for its representation, which is accessible via
Douglas Gregor9eb77012009-11-07 00:00:49 +00004670 * \c clang_getCompletionChunkCompletionString(). The code-completion string
4671 * describes an additional part of the template that is completely optional.
4672 * For example, optional chunks can be used to describe the placeholders for
4673 * arguments that match up with defaulted function parameters, e.g. given:
4674 *
4675 * \code
4676 * void f(int x, float y = 3.14, double z = 2.71828);
4677 * \endcode
4678 *
4679 * The code-completion string for this function would contain:
4680 * - a TypedText chunk for "f".
4681 * - a LeftParen chunk for "(".
4682 * - a Placeholder chunk for "int x"
4683 * - an Optional chunk containing the remaining defaulted arguments, e.g.,
4684 * - a Comma chunk for ","
Daniel Dunbar4053fae2010-02-17 08:07:44 +00004685 * - a Placeholder chunk for "float y"
Douglas Gregor9eb77012009-11-07 00:00:49 +00004686 * - an Optional chunk containing the last defaulted argument:
4687 * - a Comma chunk for ","
4688 * - a Placeholder chunk for "double z"
4689 * - a RightParen chunk for ")"
4690 *
Daniel Dunbar4053fae2010-02-17 08:07:44 +00004691 * There are many ways to handle Optional chunks. Two simple approaches are:
Douglas Gregor9eb77012009-11-07 00:00:49 +00004692 * - Completely ignore optional chunks, in which case the template for the
4693 * function "f" would only include the first parameter ("int x").
4694 * - Fully expand all optional chunks, in which case the template for the
4695 * function "f" would have all of the parameters.
4696 */
4697 CXCompletionChunk_Optional,
4698 /**
4699 * \brief Text that a user would be expected to type to get this
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004700 * code-completion result.
Douglas Gregor9eb77012009-11-07 00:00:49 +00004701 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004702 * There will be exactly one "typed text" chunk in a semantic string, which
4703 * will typically provide the spelling of a keyword or the name of a
Douglas Gregor9eb77012009-11-07 00:00:49 +00004704 * declaration that could be used at the current code point. Clients are
4705 * expected to filter the code-completion results based on the text in this
4706 * chunk.
4707 */
4708 CXCompletionChunk_TypedText,
4709 /**
4710 * \brief Text that should be inserted as part of a code-completion result.
4711 *
4712 * A "text" chunk represents text that is part of the template to be
4713 * inserted into user code should this particular code-completion result
4714 * be selected.
4715 */
4716 CXCompletionChunk_Text,
4717 /**
4718 * \brief Placeholder text that should be replaced by the user.
4719 *
4720 * A "placeholder" chunk marks a place where the user should insert text
4721 * into the code-completion template. For example, placeholders might mark
4722 * the function parameters for a function declaration, to indicate that the
4723 * user should provide arguments for each of those parameters. The actual
4724 * text in a placeholder is a suggestion for the text to display before
4725 * the user replaces the placeholder with real code.
4726 */
4727 CXCompletionChunk_Placeholder,
4728 /**
4729 * \brief Informative text that should be displayed but never inserted as
4730 * part of the template.
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004731 *
Douglas Gregor9eb77012009-11-07 00:00:49 +00004732 * An "informative" chunk contains annotations that can be displayed to
4733 * help the user decide whether a particular code-completion result is the
4734 * right option, but which is not part of the actual template to be inserted
4735 * by code completion.
4736 */
4737 CXCompletionChunk_Informative,
4738 /**
4739 * \brief Text that describes the current parameter when code-completion is
4740 * referring to function call, message send, or template specialization.
4741 *
4742 * A "current parameter" chunk occurs when code-completion is providing
4743 * information about a parameter corresponding to the argument at the
4744 * code-completion point. For example, given a function
4745 *
4746 * \code
4747 * int add(int x, int y);
4748 * \endcode
4749 *
4750 * and the source code \c add(, where the code-completion point is after the
4751 * "(", the code-completion string will contain a "current parameter" chunk
4752 * for "int x", indicating that the current argument will initialize that
4753 * parameter. After typing further, to \c add(17, (where the code-completion
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004754 * point is after the ","), the code-completion string will contain a
Douglas Gregor9eb77012009-11-07 00:00:49 +00004755 * "current paremeter" chunk to "int y".
4756 */
4757 CXCompletionChunk_CurrentParameter,
4758 /**
4759 * \brief A left parenthesis ('('), used to initiate a function call or
4760 * signal the beginning of a function parameter list.
4761 */
4762 CXCompletionChunk_LeftParen,
4763 /**
4764 * \brief A right parenthesis (')'), used to finish a function call or
4765 * signal the end of a function parameter list.
4766 */
4767 CXCompletionChunk_RightParen,
4768 /**
4769 * \brief A left bracket ('[').
4770 */
4771 CXCompletionChunk_LeftBracket,
4772 /**
4773 * \brief A right bracket (']').
4774 */
4775 CXCompletionChunk_RightBracket,
4776 /**
4777 * \brief A left brace ('{').
4778 */
4779 CXCompletionChunk_LeftBrace,
4780 /**
4781 * \brief A right brace ('}').
4782 */
4783 CXCompletionChunk_RightBrace,
4784 /**
4785 * \brief A left angle bracket ('<').
4786 */
4787 CXCompletionChunk_LeftAngle,
4788 /**
4789 * \brief A right angle bracket ('>').
4790 */
4791 CXCompletionChunk_RightAngle,
4792 /**
4793 * \brief A comma separator (',').
4794 */
Douglas Gregorb3fa9192009-12-18 18:53:37 +00004795 CXCompletionChunk_Comma,
4796 /**
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004797 * \brief Text that specifies the result type of a given result.
Douglas Gregorb3fa9192009-12-18 18:53:37 +00004798 *
4799 * This special kind of informative chunk is not meant to be inserted into
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004800 * the text buffer. Rather, it is meant to illustrate the type that an
Douglas Gregorb3fa9192009-12-18 18:53:37 +00004801 * expression using the given completion string would have.
4802 */
Douglas Gregor504a6ae2010-01-10 23:08:15 +00004803 CXCompletionChunk_ResultType,
4804 /**
4805 * \brief A colon (':').
4806 */
4807 CXCompletionChunk_Colon,
4808 /**
4809 * \brief A semicolon (';').
4810 */
4811 CXCompletionChunk_SemiColon,
4812 /**
4813 * \brief An '=' sign.
4814 */
4815 CXCompletionChunk_Equal,
4816 /**
4817 * Horizontal space (' ').
4818 */
4819 CXCompletionChunk_HorizontalSpace,
4820 /**
Alex Lorenz6c2898a2017-04-06 14:03:25 +00004821 * Vertical space ('\\n'), after which it is generally a good idea to
Douglas Gregor504a6ae2010-01-10 23:08:15 +00004822 * perform indentation.
4823 */
4824 CXCompletionChunk_VerticalSpace
Douglas Gregor9eb77012009-11-07 00:00:49 +00004825};
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004826
Douglas Gregor9eb77012009-11-07 00:00:49 +00004827/**
4828 * \brief Determine the kind of a particular chunk within a completion string.
4829 *
4830 * \param completion_string the completion string to query.
4831 *
4832 * \param chunk_number the 0-based index of the chunk in the completion string.
4833 *
4834 * \returns the kind of the chunk at the index \c chunk_number.
4835 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004836CINDEX_LINKAGE enum CXCompletionChunkKind
Douglas Gregor9eb77012009-11-07 00:00:49 +00004837clang_getCompletionChunkKind(CXCompletionString completion_string,
4838 unsigned chunk_number);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004839
Douglas Gregor9eb77012009-11-07 00:00:49 +00004840/**
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004841 * \brief Retrieve the text associated with a particular chunk within a
Douglas Gregor9eb77012009-11-07 00:00:49 +00004842 * completion string.
4843 *
4844 * \param completion_string the completion string to query.
4845 *
4846 * \param chunk_number the 0-based index of the chunk in the completion string.
4847 *
4848 * \returns the text associated with the chunk at index \c chunk_number.
4849 */
Ted Kremenekf602f962010-02-17 01:42:24 +00004850CINDEX_LINKAGE CXString
Douglas Gregor9eb77012009-11-07 00:00:49 +00004851clang_getCompletionChunkText(CXCompletionString completion_string,
4852 unsigned chunk_number);
4853
4854/**
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004855 * \brief Retrieve the completion string associated with a particular chunk
Douglas Gregor9eb77012009-11-07 00:00:49 +00004856 * within a completion string.
4857 *
4858 * \param completion_string the completion string to query.
4859 *
4860 * \param chunk_number the 0-based index of the chunk in the completion string.
4861 *
4862 * \returns the completion string associated with the chunk at index
Erik Verbruggen98ea7f62011-10-14 15:31:08 +00004863 * \c chunk_number.
Douglas Gregor9eb77012009-11-07 00:00:49 +00004864 */
4865CINDEX_LINKAGE CXCompletionString
4866clang_getCompletionChunkCompletionString(CXCompletionString completion_string,
4867 unsigned chunk_number);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004868
Douglas Gregor9eb77012009-11-07 00:00:49 +00004869/**
4870 * \brief Retrieve the number of chunks in the given code-completion string.
4871 */
4872CINDEX_LINKAGE unsigned
4873clang_getNumCompletionChunks(CXCompletionString completion_string);
4874
4875/**
Douglas Gregora2db7932010-05-26 22:00:08 +00004876 * \brief Determine the priority of this code completion.
4877 *
4878 * The priority of a code completion indicates how likely it is that this
4879 * particular completion is the completion that the user will select. The
4880 * priority is selected by various internal heuristics.
4881 *
4882 * \param completion_string The completion string to query.
4883 *
4884 * \returns The priority of this completion string. Smaller values indicate
4885 * higher-priority (more likely) completions.
4886 */
4887CINDEX_LINKAGE unsigned
4888clang_getCompletionPriority(CXCompletionString completion_string);
4889
4890/**
Douglas Gregorf757a122010-08-23 23:00:57 +00004891 * \brief Determine the availability of the entity that this code-completion
4892 * string refers to.
4893 *
4894 * \param completion_string The completion string to query.
4895 *
4896 * \returns The availability of the completion string.
4897 */
4898CINDEX_LINKAGE enum CXAvailabilityKind
4899clang_getCompletionAvailability(CXCompletionString completion_string);
4900
4901/**
Erik Verbruggen98ea7f62011-10-14 15:31:08 +00004902 * \brief Retrieve the number of annotations associated with the given
4903 * completion string.
4904 *
4905 * \param completion_string the completion string to query.
4906 *
4907 * \returns the number of annotations associated with the given completion
4908 * string.
4909 */
4910CINDEX_LINKAGE unsigned
4911clang_getCompletionNumAnnotations(CXCompletionString completion_string);
4912
4913/**
4914 * \brief Retrieve the annotation associated with the given completion string.
4915 *
4916 * \param completion_string the completion string to query.
4917 *
4918 * \param annotation_number the 0-based index of the annotation of the
4919 * completion string.
4920 *
4921 * \returns annotation string associated with the completion at index
4922 * \c annotation_number, or a NULL string if that annotation is not available.
4923 */
4924CINDEX_LINKAGE CXString
4925clang_getCompletionAnnotation(CXCompletionString completion_string,
4926 unsigned annotation_number);
4927
4928/**
Douglas Gregor78254c82012-03-27 23:34:16 +00004929 * \brief Retrieve the parent context of the given completion string.
4930 *
4931 * The parent context of a completion string is the semantic parent of
4932 * the declaration (if any) that the code completion represents. For example,
4933 * a code completion for an Objective-C method would have the method's class
4934 * or protocol as its context.
4935 *
4936 * \param completion_string The code completion string whose parent is
4937 * being queried.
4938 *
Argyrios Kyrtzidis9ae39562012-09-26 16:39:56 +00004939 * \param kind DEPRECATED: always set to CXCursor_NotImplemented if non-NULL.
Douglas Gregor78254c82012-03-27 23:34:16 +00004940 *
James Dennett574cb4c2012-06-15 05:41:51 +00004941 * \returns The name of the completion parent, e.g., "NSObject" if
Douglas Gregor78254c82012-03-27 23:34:16 +00004942 * the completion string represents a method in the NSObject class.
4943 */
4944CINDEX_LINKAGE CXString
4945clang_getCompletionParent(CXCompletionString completion_string,
4946 enum CXCursorKind *kind);
Dmitri Gribenko3292d062012-07-02 17:35:10 +00004947
4948/**
4949 * \brief Retrieve the brief documentation comment attached to the declaration
4950 * that corresponds to the given completion string.
4951 */
4952CINDEX_LINKAGE CXString
4953clang_getCompletionBriefComment(CXCompletionString completion_string);
4954
Douglas Gregor78254c82012-03-27 23:34:16 +00004955/**
Douglas Gregor3f35bb22011-08-04 20:04:59 +00004956 * \brief Retrieve a completion string for an arbitrary declaration or macro
4957 * definition cursor.
4958 *
4959 * \param cursor The cursor to query.
4960 *
4961 * \returns A non-context-sensitive completion string for declaration and macro
4962 * definition cursors, or NULL for other kinds of cursors.
4963 */
4964CINDEX_LINKAGE CXCompletionString
4965clang_getCursorCompletionString(CXCursor cursor);
4966
4967/**
Douglas Gregorf72b6ac2009-12-18 16:20:58 +00004968 * \brief Contains the results of code-completion.
4969 *
4970 * This data structure contains the results of code completion, as
Douglas Gregor6a9580282010-10-11 21:51:20 +00004971 * produced by \c clang_codeCompleteAt(). Its contents must be freed by
Douglas Gregorf72b6ac2009-12-18 16:20:58 +00004972 * \c clang_disposeCodeCompleteResults.
4973 */
4974typedef struct {
4975 /**
4976 * \brief The code-completion results.
4977 */
4978 CXCompletionResult *Results;
4979
4980 /**
4981 * \brief The number of code-completion results stored in the
4982 * \c Results array.
4983 */
4984 unsigned NumResults;
4985} CXCodeCompleteResults;
4986
4987/**
Douglas Gregorb68bc592010-08-05 09:09:23 +00004988 * \brief Flags that can be passed to \c clang_codeCompleteAt() to
4989 * modify its behavior.
4990 *
4991 * The enumerators in this enumeration can be bitwise-OR'd together to
4992 * provide multiple options to \c clang_codeCompleteAt().
4993 */
4994enum CXCodeComplete_Flags {
4995 /**
4996 * \brief Whether to include macros within the set of code
4997 * completions returned.
4998 */
4999 CXCodeComplete_IncludeMacros = 0x01,
5000
5001 /**
5002 * \brief Whether to include code patterns for language constructs
5003 * within the set of code completions, e.g., for loops.
5004 */
Dmitri Gribenko3292d062012-07-02 17:35:10 +00005005 CXCodeComplete_IncludeCodePatterns = 0x02,
5006
5007 /**
5008 * \brief Whether to include brief documentation within the set of code
5009 * completions returned.
5010 */
5011 CXCodeComplete_IncludeBriefComments = 0x04
Douglas Gregorb68bc592010-08-05 09:09:23 +00005012};
5013
5014/**
Douglas Gregor21325842011-07-07 16:03:39 +00005015 * \brief Bits that represent the context under which completion is occurring.
5016 *
5017 * The enumerators in this enumeration may be bitwise-OR'd together if multiple
5018 * contexts are occurring simultaneously.
5019 */
5020enum CXCompletionContext {
5021 /**
5022 * \brief The context for completions is unexposed, as only Clang results
5023 * should be included. (This is equivalent to having no context bits set.)
5024 */
5025 CXCompletionContext_Unexposed = 0,
5026
5027 /**
5028 * \brief Completions for any possible type should be included in the results.
5029 */
5030 CXCompletionContext_AnyType = 1 << 0,
5031
5032 /**
5033 * \brief Completions for any possible value (variables, function calls, etc.)
5034 * should be included in the results.
5035 */
5036 CXCompletionContext_AnyValue = 1 << 1,
5037 /**
5038 * \brief Completions for values that resolve to an Objective-C object should
5039 * be included in the results.
5040 */
5041 CXCompletionContext_ObjCObjectValue = 1 << 2,
5042 /**
5043 * \brief Completions for values that resolve to an Objective-C selector
5044 * should be included in the results.
5045 */
5046 CXCompletionContext_ObjCSelectorValue = 1 << 3,
5047 /**
5048 * \brief Completions for values that resolve to a C++ class type should be
5049 * included in the results.
5050 */
5051 CXCompletionContext_CXXClassTypeValue = 1 << 4,
5052
5053 /**
5054 * \brief Completions for fields of the member being accessed using the dot
5055 * operator should be included in the results.
5056 */
5057 CXCompletionContext_DotMemberAccess = 1 << 5,
5058 /**
5059 * \brief Completions for fields of the member being accessed using the arrow
5060 * operator should be included in the results.
5061 */
5062 CXCompletionContext_ArrowMemberAccess = 1 << 6,
5063 /**
5064 * \brief Completions for properties of the Objective-C object being accessed
5065 * using the dot operator should be included in the results.
5066 */
5067 CXCompletionContext_ObjCPropertyAccess = 1 << 7,
5068
5069 /**
5070 * \brief Completions for enum tags should be included in the results.
5071 */
5072 CXCompletionContext_EnumTag = 1 << 8,
5073 /**
5074 * \brief Completions for union tags should be included in the results.
5075 */
5076 CXCompletionContext_UnionTag = 1 << 9,
5077 /**
5078 * \brief Completions for struct tags should be included in the results.
5079 */
5080 CXCompletionContext_StructTag = 1 << 10,
5081
5082 /**
5083 * \brief Completions for C++ class names should be included in the results.
5084 */
5085 CXCompletionContext_ClassTag = 1 << 11,
5086 /**
5087 * \brief Completions for C++ namespaces and namespace aliases should be
5088 * included in the results.
5089 */
5090 CXCompletionContext_Namespace = 1 << 12,
5091 /**
5092 * \brief Completions for C++ nested name specifiers should be included in
5093 * the results.
5094 */
5095 CXCompletionContext_NestedNameSpecifier = 1 << 13,
5096
5097 /**
5098 * \brief Completions for Objective-C interfaces (classes) should be included
5099 * in the results.
5100 */
5101 CXCompletionContext_ObjCInterface = 1 << 14,
5102 /**
5103 * \brief Completions for Objective-C protocols should be included in
5104 * the results.
5105 */
5106 CXCompletionContext_ObjCProtocol = 1 << 15,
5107 /**
5108 * \brief Completions for Objective-C categories should be included in
5109 * the results.
5110 */
5111 CXCompletionContext_ObjCCategory = 1 << 16,
5112 /**
5113 * \brief Completions for Objective-C instance messages should be included
5114 * in the results.
5115 */
5116 CXCompletionContext_ObjCInstanceMessage = 1 << 17,
5117 /**
5118 * \brief Completions for Objective-C class messages should be included in
5119 * the results.
5120 */
5121 CXCompletionContext_ObjCClassMessage = 1 << 18,
5122 /**
5123 * \brief Completions for Objective-C selector names should be included in
5124 * the results.
5125 */
5126 CXCompletionContext_ObjCSelectorName = 1 << 19,
5127
5128 /**
5129 * \brief Completions for preprocessor macro names should be included in
5130 * the results.
5131 */
5132 CXCompletionContext_MacroName = 1 << 20,
5133
5134 /**
5135 * \brief Natural language completions should be included in the results.
5136 */
5137 CXCompletionContext_NaturalLanguage = 1 << 21,
5138
5139 /**
5140 * \brief The current context is unknown, so set all contexts.
5141 */
5142 CXCompletionContext_Unknown = ((1 << 22) - 1)
5143};
5144
5145/**
Douglas Gregorb68bc592010-08-05 09:09:23 +00005146 * \brief Returns a default set of code-completion options that can be
5147 * passed to\c clang_codeCompleteAt().
5148 */
5149CINDEX_LINKAGE unsigned clang_defaultCodeCompleteOptions(void);
5150
5151/**
Douglas Gregor8e984da2010-08-04 16:47:14 +00005152 * \brief Perform code completion at a given location in a translation unit.
5153 *
5154 * This function performs code completion at a particular file, line, and
5155 * column within source code, providing results that suggest potential
5156 * code snippets based on the context of the completion. The basic model
5157 * for code completion is that Clang will parse a complete source file,
5158 * performing syntax checking up to the location where code-completion has
5159 * been requested. At that point, a special code-completion token is passed
5160 * to the parser, which recognizes this token and determines, based on the
5161 * current location in the C/Objective-C/C++ grammar and the state of
5162 * semantic analysis, what completions to provide. These completions are
5163 * returned via a new \c CXCodeCompleteResults structure.
5164 *
5165 * Code completion itself is meant to be triggered by the client when the
5166 * user types punctuation characters or whitespace, at which point the
5167 * code-completion location will coincide with the cursor. For example, if \c p
5168 * is a pointer, code-completion might be triggered after the "-" and then
5169 * after the ">" in \c p->. When the code-completion location is afer the ">",
5170 * the completion results will provide, e.g., the members of the struct that
5171 * "p" points to. The client is responsible for placing the cursor at the
5172 * beginning of the token currently being typed, then filtering the results
5173 * based on the contents of the token. For example, when code-completing for
5174 * the expression \c p->get, the client should provide the location just after
5175 * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the
5176 * client can filter the results based on the current token text ("get"), only
5177 * showing those results that start with "get". The intent of this interface
5178 * is to separate the relatively high-latency acquisition of code-completion
5179 * results from the filtering of results on a per-character basis, which must
5180 * have a lower latency.
5181 *
5182 * \param TU The translation unit in which code-completion should
5183 * occur. The source files for this translation unit need not be
5184 * completely up-to-date (and the contents of those source files may
5185 * be overridden via \p unsaved_files). Cursors referring into the
5186 * translation unit may be invalidated by this invocation.
5187 *
5188 * \param complete_filename The name of the source file where code
5189 * completion should be performed. This filename may be any file
5190 * included in the translation unit.
5191 *
5192 * \param complete_line The line at which code-completion should occur.
5193 *
5194 * \param complete_column The column at which code-completion should occur.
5195 * Note that the column should point just after the syntactic construct that
5196 * initiated code completion, and not in the middle of a lexical token.
5197 *
Vedant Kumarcbfe7bb2016-03-23 23:51:36 +00005198 * \param unsaved_files the Files that have not yet been saved to disk
Douglas Gregor8e984da2010-08-04 16:47:14 +00005199 * but may be required for parsing or code completion, including the
5200 * contents of those files. The contents and name of these files (as
5201 * specified by CXUnsavedFile) are copied when necessary, so the
5202 * client only needs to guarantee their validity until the call to
5203 * this function returns.
5204 *
5205 * \param num_unsaved_files The number of unsaved file entries in \p
5206 * unsaved_files.
5207 *
Douglas Gregorb68bc592010-08-05 09:09:23 +00005208 * \param options Extra options that control the behavior of code
5209 * completion, expressed as a bitwise OR of the enumerators of the
5210 * CXCodeComplete_Flags enumeration. The
5211 * \c clang_defaultCodeCompleteOptions() function returns a default set
5212 * of code-completion options.
5213 *
Douglas Gregor8e984da2010-08-04 16:47:14 +00005214 * \returns If successful, a new \c CXCodeCompleteResults structure
5215 * containing code-completion results, which should eventually be
5216 * freed with \c clang_disposeCodeCompleteResults(). If code
5217 * completion fails, returns NULL.
5218 */
5219CINDEX_LINKAGE
5220CXCodeCompleteResults *clang_codeCompleteAt(CXTranslationUnit TU,
5221 const char *complete_filename,
5222 unsigned complete_line,
5223 unsigned complete_column,
5224 struct CXUnsavedFile *unsaved_files,
Douglas Gregorb68bc592010-08-05 09:09:23 +00005225 unsigned num_unsaved_files,
5226 unsigned options);
Douglas Gregor8e984da2010-08-04 16:47:14 +00005227
5228/**
Douglas Gregor49f67ce2010-08-26 13:48:20 +00005229 * \brief Sort the code-completion results in case-insensitive alphabetical
5230 * order.
5231 *
5232 * \param Results The set of results to sort.
5233 * \param NumResults The number of results in \p Results.
5234 */
5235CINDEX_LINKAGE
5236void clang_sortCodeCompletionResults(CXCompletionResult *Results,
5237 unsigned NumResults);
5238
5239/**
Douglas Gregorf72b6ac2009-12-18 16:20:58 +00005240 * \brief Free the given set of code-completion results.
5241 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005242CINDEX_LINKAGE
Douglas Gregorf72b6ac2009-12-18 16:20:58 +00005243void clang_disposeCodeCompleteResults(CXCodeCompleteResults *Results);
Douglas Gregorf757a122010-08-23 23:00:57 +00005244
Douglas Gregor52606ff2010-01-20 01:10:47 +00005245/**
Douglas Gregor33cdd812010-02-18 18:08:43 +00005246 * \brief Determine the number of diagnostics produced prior to the
5247 * location where code completion was performed.
5248 */
Ted Kremenekd071c602010-03-13 02:50:34 +00005249CINDEX_LINKAGE
Douglas Gregor33cdd812010-02-18 18:08:43 +00005250unsigned clang_codeCompleteGetNumDiagnostics(CXCodeCompleteResults *Results);
5251
5252/**
5253 * \brief Retrieve a diagnostic associated with the given code completion.
5254 *
James Dennett574cb4c2012-06-15 05:41:51 +00005255 * \param Results the code completion results to query.
Douglas Gregor33cdd812010-02-18 18:08:43 +00005256 * \param Index the zero-based diagnostic number to retrieve.
5257 *
5258 * \returns the requested diagnostic. This diagnostic must be freed
5259 * via a call to \c clang_disposeDiagnostic().
5260 */
Ted Kremenekd071c602010-03-13 02:50:34 +00005261CINDEX_LINKAGE
Douglas Gregor33cdd812010-02-18 18:08:43 +00005262CXDiagnostic clang_codeCompleteGetDiagnostic(CXCodeCompleteResults *Results,
5263 unsigned Index);
5264
5265/**
Nico Weberdd9c19f2014-04-24 03:06:18 +00005266 * \brief Determines what completions are appropriate for the context
Douglas Gregor21325842011-07-07 16:03:39 +00005267 * the given code completion.
5268 *
5269 * \param Results the code completion results to query
5270 *
5271 * \returns the kinds of completions that are appropriate for use
5272 * along with the given code completion results.
5273 */
5274CINDEX_LINKAGE
5275unsigned long long clang_codeCompleteGetContexts(
5276 CXCodeCompleteResults *Results);
Douglas Gregor63745d52011-07-21 01:05:26 +00005277
5278/**
5279 * \brief Returns the cursor kind for the container for the current code
5280 * completion context. The container is only guaranteed to be set for
5281 * contexts where a container exists (i.e. member accesses or Objective-C
5282 * message sends); if there is not a container, this function will return
5283 * CXCursor_InvalidCode.
5284 *
5285 * \param Results the code completion results to query
5286 *
5287 * \param IsIncomplete on return, this value will be false if Clang has complete
5288 * information about the container. If Clang does not have complete
5289 * information, this value will be true.
5290 *
5291 * \returns the container kind, or CXCursor_InvalidCode if there is not a
5292 * container
5293 */
5294CINDEX_LINKAGE
5295enum CXCursorKind clang_codeCompleteGetContainerKind(
5296 CXCodeCompleteResults *Results,
5297 unsigned *IsIncomplete);
5298
5299/**
5300 * \brief Returns the USR for the container for the current code completion
5301 * context. If there is not a container for the current context, this
5302 * function will return the empty string.
5303 *
5304 * \param Results the code completion results to query
5305 *
5306 * \returns the USR for the container
5307 */
5308CINDEX_LINKAGE
5309CXString clang_codeCompleteGetContainerUSR(CXCodeCompleteResults *Results);
NAKAMURA Takumiaa13f942015-12-09 07:52:46 +00005310
Douglas Gregorea777402011-07-26 15:24:30 +00005311/**
5312 * \brief Returns the currently-entered selector for an Objective-C message
5313 * send, formatted like "initWithFoo:bar:". Only guaranteed to return a
5314 * non-empty string for CXCompletionContext_ObjCInstanceMessage and
5315 * CXCompletionContext_ObjCClassMessage.
5316 *
5317 * \param Results the code completion results to query
5318 *
5319 * \returns the selector (or partial selector) that has been entered thus far
5320 * for an Objective-C message send.
5321 */
5322CINDEX_LINKAGE
5323CXString clang_codeCompleteGetObjCSelector(CXCodeCompleteResults *Results);
5324
Douglas Gregor21325842011-07-07 16:03:39 +00005325/**
Douglas Gregor52606ff2010-01-20 01:10:47 +00005326 * @}
5327 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005328
Ted Kremenekc0f3f722010-01-22 22:44:15 +00005329/**
5330 * \defgroup CINDEX_MISC Miscellaneous utility functions
5331 *
5332 * @{
5333 */
Ted Kremenek3e315a22010-01-23 17:51:23 +00005334
5335/**
5336 * \brief Return a version string, suitable for showing to a user, but not
5337 * intended to be parsed (the format is not guaranteed to be stable).
5338 */
NAKAMURA Takumieacd6672013-01-10 02:12:38 +00005339CINDEX_LINKAGE CXString clang_getClangVersion(void);
Ted Kremenekc0f3f722010-01-22 22:44:15 +00005340
Ted Kremenek1ec7b332011-03-18 23:05:39 +00005341/**
5342 * \brief Enable/disable crash recovery.
5343 *
James Dennett574cb4c2012-06-15 05:41:51 +00005344 * \param isEnabled Flag to indicate if crash recovery is enabled. A non-zero
5345 * value enables crash recovery, while 0 disables it.
Ted Kremenek1ec7b332011-03-18 23:05:39 +00005346 */
5347CINDEX_LINKAGE void clang_toggleCrashRecovery(unsigned isEnabled);
5348
Ted Kremenek0b86e3a2010-01-26 19:31:51 +00005349 /**
Ted Kremenekd071c602010-03-13 02:50:34 +00005350 * \brief Visitor invoked for each file in a translation unit
Ted Kremenek0b86e3a2010-01-26 19:31:51 +00005351 * (used with clang_getInclusions()).
5352 *
5353 * This visitor function will be invoked by clang_getInclusions() for each
James Dennett574cb4c2012-06-15 05:41:51 +00005354 * file included (either at the top-level or by \#include directives) within
Ted Kremenek0b86e3a2010-01-26 19:31:51 +00005355 * a translation unit. The first argument is the file being included, and
5356 * the second and third arguments provide the inclusion stack. The
5357 * array is sorted in order of immediate inclusion. For example,
5358 * the first element refers to the location that included 'included_file'.
5359 */
5360typedef void (*CXInclusionVisitor)(CXFile included_file,
5361 CXSourceLocation* inclusion_stack,
5362 unsigned include_len,
5363 CXClientData client_data);
5364
5365/**
5366 * \brief Visit the set of preprocessor inclusions in a translation unit.
5367 * The visitor function is called with the provided data for every included
5368 * file. This does not include headers included by the PCH file (unless one
5369 * is inspecting the inclusions in the PCH file itself).
5370 */
5371CINDEX_LINKAGE void clang_getInclusions(CXTranslationUnit tu,
5372 CXInclusionVisitor visitor,
5373 CXClientData client_data);
5374
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005375typedef enum {
5376 CXEval_Int = 1 ,
5377 CXEval_Float = 2,
5378 CXEval_ObjCStrLiteral = 3,
5379 CXEval_StrLiteral = 4,
5380 CXEval_CFStr = 5,
5381 CXEval_Other = 6,
5382
5383 CXEval_UnExposed = 0
5384
5385} CXEvalResultKind ;
5386
5387/**
5388 * \brief Evaluation result of a cursor
5389 */
5390typedef void * CXEvalResult;
5391
5392/**
5393 * \brief If cursor is a statement declaration tries to evaluate the
5394 * statement and if its variable, tries to evaluate its initializer,
5395 * into its corresponding type.
5396 */
5397CINDEX_LINKAGE CXEvalResult clang_Cursor_Evaluate(CXCursor C);
5398
5399/**
5400 * \brief Returns the kind of the evaluated result.
5401 */
Argyrios Kyrtzidisa851d7e2016-01-16 03:01:20 +00005402CINDEX_LINKAGE CXEvalResultKind clang_EvalResult_getKind(CXEvalResult E);
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005403
5404/**
5405 * \brief Returns the evaluation result as integer if the
5406 * kind is Int.
5407 */
Argyrios Kyrtzidisa851d7e2016-01-16 03:01:20 +00005408CINDEX_LINKAGE int clang_EvalResult_getAsInt(CXEvalResult E);
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005409
5410/**
Argyrios Kyrtzidis5dda1122016-12-01 23:41:27 +00005411 * \brief Returns the evaluation result as a long long integer if the
5412 * kind is Int. This prevents overflows that may happen if the result is
5413 * returned with clang_EvalResult_getAsInt.
5414 */
5415CINDEX_LINKAGE long long clang_EvalResult_getAsLongLong(CXEvalResult E);
5416
5417/**
5418 * \brief Returns a non-zero value if the kind is Int and the evaluation
5419 * result resulted in an unsigned integer.
5420 */
5421CINDEX_LINKAGE unsigned clang_EvalResult_isUnsignedInt(CXEvalResult E);
5422
5423/**
5424 * \brief Returns the evaluation result as an unsigned integer if
5425 * the kind is Int and clang_EvalResult_isUnsignedInt is non-zero.
5426 */
5427CINDEX_LINKAGE unsigned long long clang_EvalResult_getAsUnsigned(CXEvalResult E);
5428
5429/**
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005430 * \brief Returns the evaluation result as double if the
5431 * kind is double.
5432 */
Argyrios Kyrtzidisa851d7e2016-01-16 03:01:20 +00005433CINDEX_LINKAGE double clang_EvalResult_getAsDouble(CXEvalResult E);
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005434
5435/**
5436 * \brief Returns the evaluation result as a constant string if the
5437 * kind is other than Int or float. User must not free this pointer,
5438 * instead call clang_EvalResult_dispose on the CXEvalResult returned
5439 * by clang_Cursor_Evaluate.
5440 */
Argyrios Kyrtzidisa851d7e2016-01-16 03:01:20 +00005441CINDEX_LINKAGE const char* clang_EvalResult_getAsStr(CXEvalResult E);
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005442
5443/**
5444 * \brief Disposes the created Eval memory.
5445 */
Argyrios Kyrtzidisa851d7e2016-01-16 03:01:20 +00005446CINDEX_LINKAGE void clang_EvalResult_dispose(CXEvalResult E);
Ted Kremenek0b86e3a2010-01-26 19:31:51 +00005447/**
Ted Kremenekc0f3f722010-01-22 22:44:15 +00005448 * @}
5449 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005450
Argyrios Kyrtzidisf89cc692011-07-11 20:15:00 +00005451/** \defgroup CINDEX_REMAPPING Remapping functions
5452 *
5453 * @{
5454 */
5455
5456/**
5457 * \brief A remapping of original source files and their translated files.
5458 */
5459typedef void *CXRemapping;
5460
5461/**
5462 * \brief Retrieve a remapping.
5463 *
5464 * \param path the path that contains metadata about remappings.
5465 *
5466 * \returns the requested remapping. This remapping must be freed
5467 * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
5468 */
5469CINDEX_LINKAGE CXRemapping clang_getRemappings(const char *path);
5470
5471/**
Ted Kremenekf7639e12012-03-06 20:06:33 +00005472 * \brief Retrieve a remapping.
5473 *
5474 * \param filePaths pointer to an array of file paths containing remapping info.
5475 *
5476 * \param numFiles number of file paths.
5477 *
5478 * \returns the requested remapping. This remapping must be freed
5479 * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
5480 */
5481CINDEX_LINKAGE
5482CXRemapping clang_getRemappingsFromFileList(const char **filePaths,
5483 unsigned numFiles);
5484
5485/**
Argyrios Kyrtzidisf89cc692011-07-11 20:15:00 +00005486 * \brief Determine the number of remappings.
5487 */
5488CINDEX_LINKAGE unsigned clang_remap_getNumFiles(CXRemapping);
5489
5490/**
5491 * \brief Get the original and the associated filename from the remapping.
5492 *
5493 * \param original If non-NULL, will be set to the original filename.
5494 *
5495 * \param transformed If non-NULL, will be set to the filename that the original
5496 * is associated with.
5497 */
5498CINDEX_LINKAGE void clang_remap_getFilenames(CXRemapping, unsigned index,
5499 CXString *original, CXString *transformed);
5500
5501/**
5502 * \brief Dispose the remapping.
5503 */
5504CINDEX_LINKAGE void clang_remap_dispose(CXRemapping);
5505
5506/**
5507 * @}
5508 */
5509
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00005510/** \defgroup CINDEX_HIGH Higher level API functions
5511 *
5512 * @{
5513 */
5514
5515enum CXVisitorResult {
5516 CXVisit_Break,
5517 CXVisit_Continue
5518};
5519
Saleem Abdulrasoolec988b72016-05-24 01:23:24 +00005520typedef struct CXCursorAndRangeVisitor {
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00005521 void *context;
5522 enum CXVisitorResult (*visit)(void *context, CXCursor, CXSourceRange);
5523} CXCursorAndRangeVisitor;
5524
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00005525typedef enum {
5526 /**
5527 * \brief Function returned successfully.
5528 */
5529 CXResult_Success = 0,
5530 /**
5531 * \brief One of the parameters was invalid for the function.
5532 */
5533 CXResult_Invalid = 1,
5534 /**
5535 * \brief The function was terminated by a callback (e.g. it returned
5536 * CXVisit_Break)
5537 */
5538 CXResult_VisitBreak = 2
5539
5540} CXResult;
5541
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00005542/**
5543 * \brief Find references of a declaration in a specific file.
5544 *
5545 * \param cursor pointing to a declaration or a reference of one.
5546 *
5547 * \param file to search for references.
5548 *
5549 * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
5550 * each reference found.
5551 * The CXSourceRange will point inside the file; if the reference is inside
5552 * a macro (and not a macro argument) the CXSourceRange will be invalid.
Argyrios Kyrtzidis951f61f2013-03-08 20:42:33 +00005553 *
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00005554 * \returns one of the CXResult enumerators.
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00005555 */
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00005556CINDEX_LINKAGE CXResult clang_findReferencesInFile(CXCursor cursor, CXFile file,
5557 CXCursorAndRangeVisitor visitor);
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00005558
Argyrios Kyrtzidis503c83a2013-03-08 02:32:34 +00005559/**
5560 * \brief Find #import/#include directives in a specific file.
5561 *
5562 * \param TU translation unit containing the file to query.
5563 *
5564 * \param file to search for #import/#include directives.
5565 *
5566 * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
5567 * each directive found.
Argyrios Kyrtzidis951f61f2013-03-08 20:42:33 +00005568 *
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00005569 * \returns one of the CXResult enumerators.
Argyrios Kyrtzidis503c83a2013-03-08 02:32:34 +00005570 */
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00005571CINDEX_LINKAGE CXResult clang_findIncludesInFile(CXTranslationUnit TU,
5572 CXFile file,
5573 CXCursorAndRangeVisitor visitor);
Argyrios Kyrtzidis503c83a2013-03-08 02:32:34 +00005574
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00005575#ifdef __has_feature
5576# if __has_feature(blocks)
5577
5578typedef enum CXVisitorResult
5579 (^CXCursorAndRangeVisitorBlock)(CXCursor, CXSourceRange);
5580
5581CINDEX_LINKAGE
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00005582CXResult clang_findReferencesInFileWithBlock(CXCursor, CXFile,
5583 CXCursorAndRangeVisitorBlock);
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00005584
Argyrios Kyrtzidis503c83a2013-03-08 02:32:34 +00005585CINDEX_LINKAGE
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00005586CXResult clang_findIncludesInFileWithBlock(CXTranslationUnit, CXFile,
5587 CXCursorAndRangeVisitorBlock);
Argyrios Kyrtzidis503c83a2013-03-08 02:32:34 +00005588
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00005589# endif
5590#endif
5591
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005592/**
5593 * \brief The client's data object that is associated with a CXFile.
5594 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005595typedef void *CXIdxClientFile;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005596
5597/**
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00005598 * \brief The client's data object that is associated with a semantic entity.
5599 */
5600typedef void *CXIdxClientEntity;
5601
5602/**
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005603 * \brief The client's data object that is associated with a semantic container
5604 * of entities.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005605 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005606typedef void *CXIdxClientContainer;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005607
5608/**
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005609 * \brief The client's data object that is associated with an AST file (PCH
5610 * or module).
5611 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005612typedef void *CXIdxClientASTFile;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005613
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005614/**
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005615 * \brief Source location passed to index callbacks.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005616 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005617typedef struct {
5618 void *ptr_data[2];
5619 unsigned int_data;
5620} CXIdxLoc;
5621
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005622/**
James Dennett574cb4c2012-06-15 05:41:51 +00005623 * \brief Data for ppIncludedFile callback.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005624 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005625typedef struct {
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005626 /**
James Dennett574cb4c2012-06-15 05:41:51 +00005627 * \brief Location of '#' in the \#include/\#import directive.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005628 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005629 CXIdxLoc hashLoc;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005630 /**
James Dennett574cb4c2012-06-15 05:41:51 +00005631 * \brief Filename as written in the \#include/\#import directive.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005632 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005633 const char *filename;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005634 /**
James Dennett574cb4c2012-06-15 05:41:51 +00005635 * \brief The actual file that the \#include/\#import directive resolved to.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005636 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005637 CXFile file;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005638 int isImport;
5639 int isAngled;
Argyrios Kyrtzidis5e2ec482012-10-18 00:17:05 +00005640 /**
5641 * \brief Non-zero if the directive was automatically turned into a module
5642 * import.
5643 */
5644 int isModuleImport;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005645} CXIdxIncludedFileInfo;
5646
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005647/**
James Dennett574cb4c2012-06-15 05:41:51 +00005648 * \brief Data for IndexerCallbacks#importedASTFile.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005649 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005650typedef struct {
Argyrios Kyrtzidis472eda02012-10-02 16:10:38 +00005651 /**
5652 * \brief Top level AST file containing the imported PCH, module or submodule.
5653 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005654 CXFile file;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005655 /**
Argyrios Kyrtzidisdc78f3e2012-10-05 00:22:40 +00005656 * \brief The imported module or NULL if the AST file is a PCH.
5657 */
5658 CXModule module;
5659 /**
Argyrios Kyrtzidis472eda02012-10-02 16:10:38 +00005660 * \brief Location where the file is imported. Applicable only for modules.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005661 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005662 CXIdxLoc loc;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005663 /**
Argyrios Kyrtzidis472eda02012-10-02 16:10:38 +00005664 * \brief Non-zero if an inclusion directive was automatically turned into
Argyrios Kyrtzidisdc78f3e2012-10-05 00:22:40 +00005665 * a module import. Applicable only for modules.
Argyrios Kyrtzidis472eda02012-10-02 16:10:38 +00005666 */
Argyrios Kyrtzidis184b1442012-10-03 21:05:44 +00005667 int isImplicit;
Argyrios Kyrtzidis472eda02012-10-02 16:10:38 +00005668
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005669} CXIdxImportedASTFileInfo;
5670
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005671typedef enum {
5672 CXIdxEntity_Unexposed = 0,
5673 CXIdxEntity_Typedef = 1,
5674 CXIdxEntity_Function = 2,
5675 CXIdxEntity_Variable = 3,
5676 CXIdxEntity_Field = 4,
5677 CXIdxEntity_EnumConstant = 5,
5678
5679 CXIdxEntity_ObjCClass = 6,
5680 CXIdxEntity_ObjCProtocol = 7,
5681 CXIdxEntity_ObjCCategory = 8,
5682
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00005683 CXIdxEntity_ObjCInstanceMethod = 9,
5684 CXIdxEntity_ObjCClassMethod = 10,
5685 CXIdxEntity_ObjCProperty = 11,
5686 CXIdxEntity_ObjCIvar = 12,
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005687
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00005688 CXIdxEntity_Enum = 13,
5689 CXIdxEntity_Struct = 14,
5690 CXIdxEntity_Union = 15,
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00005691
5692 CXIdxEntity_CXXClass = 16,
5693 CXIdxEntity_CXXNamespace = 17,
5694 CXIdxEntity_CXXNamespaceAlias = 18,
5695 CXIdxEntity_CXXStaticVariable = 19,
5696 CXIdxEntity_CXXStaticMethod = 20,
5697 CXIdxEntity_CXXInstanceMethod = 21,
Joao Matose9a3ed42012-08-31 22:18:20 +00005698 CXIdxEntity_CXXConstructor = 22,
5699 CXIdxEntity_CXXDestructor = 23,
5700 CXIdxEntity_CXXConversionFunction = 24,
5701 CXIdxEntity_CXXTypeAlias = 25,
5702 CXIdxEntity_CXXInterface = 26
5703
5704} CXIdxEntityKind;
5705
Argyrios Kyrtzidis52002882011-12-07 20:44:12 +00005706typedef enum {
5707 CXIdxEntityLang_None = 0,
5708 CXIdxEntityLang_C = 1,
5709 CXIdxEntityLang_ObjC = 2,
Argyrios Kyrtzidisb4b85f22017-04-24 14:52:00 +00005710 CXIdxEntityLang_CXX = 3,
5711 CXIdxEntityLang_Swift = 4
Argyrios Kyrtzidis52002882011-12-07 20:44:12 +00005712} CXIdxEntityLanguage;
5713
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00005714/**
5715 * \brief Extra C++ template information for an entity. This can apply to:
5716 * CXIdxEntity_Function
5717 * CXIdxEntity_CXXClass
5718 * CXIdxEntity_CXXStaticMethod
5719 * CXIdxEntity_CXXInstanceMethod
5720 * CXIdxEntity_CXXConstructor
5721 * CXIdxEntity_CXXConversionFunction
5722 * CXIdxEntity_CXXTypeAlias
5723 */
5724typedef enum {
5725 CXIdxEntity_NonTemplate = 0,
5726 CXIdxEntity_Template = 1,
5727 CXIdxEntity_TemplatePartialSpecialization = 2,
5728 CXIdxEntity_TemplateSpecialization = 3
5729} CXIdxEntityCXXTemplateKind;
5730
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00005731typedef enum {
5732 CXIdxAttr_Unexposed = 0,
5733 CXIdxAttr_IBAction = 1,
5734 CXIdxAttr_IBOutlet = 2,
5735 CXIdxAttr_IBOutletCollection = 3
5736} CXIdxAttrKind;
5737
5738typedef struct {
5739 CXIdxAttrKind kind;
5740 CXCursor cursor;
5741 CXIdxLoc loc;
5742} CXIdxAttrInfo;
5743
5744typedef struct {
Argyrios Kyrtzidis4d873b72011-12-15 00:05:00 +00005745 CXIdxEntityKind kind;
5746 CXIdxEntityCXXTemplateKind templateKind;
5747 CXIdxEntityLanguage lang;
5748 const char *name;
5749 const char *USR;
5750 CXCursor cursor;
5751 const CXIdxAttrInfo *const *attributes;
5752 unsigned numAttributes;
5753} CXIdxEntityInfo;
5754
5755typedef struct {
5756 CXCursor cursor;
5757} CXIdxContainerInfo;
5758
5759typedef struct {
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00005760 const CXIdxAttrInfo *attrInfo;
5761 const CXIdxEntityInfo *objcClass;
5762 CXCursor classCursor;
5763 CXIdxLoc classLoc;
5764} CXIdxIBOutletCollectionAttrInfo;
5765
Argyrios Kyrtzidis8b71bc72012-12-06 19:41:16 +00005766typedef enum {
5767 CXIdxDeclFlag_Skipped = 0x1
5768} CXIdxDeclInfoFlags;
5769
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005770typedef struct {
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00005771 const CXIdxEntityInfo *entityInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005772 CXCursor cursor;
5773 CXIdxLoc loc;
Argyrios Kyrtzidis663c8ec2011-12-07 20:44:19 +00005774 const CXIdxContainerInfo *semanticContainer;
5775 /**
James Dennett574cb4c2012-06-15 05:41:51 +00005776 * \brief Generally same as #semanticContainer but can be different in
Argyrios Kyrtzidis663c8ec2011-12-07 20:44:19 +00005777 * cases like out-of-line C++ member functions.
5778 */
5779 const CXIdxContainerInfo *lexicalContainer;
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005780 int isRedeclaration;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005781 int isDefinition;
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00005782 int isContainer;
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00005783 const CXIdxContainerInfo *declAsContainer;
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00005784 /**
5785 * \brief Whether the declaration exists in code or was created implicitly
Nico Weber7deebef2014-04-24 03:17:47 +00005786 * by the compiler, e.g. implicit Objective-C methods for properties.
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00005787 */
5788 int isImplicit;
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00005789 const CXIdxAttrInfo *const *attributes;
5790 unsigned numAttributes;
Argyrios Kyrtzidis8b71bc72012-12-06 19:41:16 +00005791
5792 unsigned flags;
5793
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005794} CXIdxDeclInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005795
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005796typedef enum {
5797 CXIdxObjCContainer_ForwardRef = 0,
5798 CXIdxObjCContainer_Interface = 1,
5799 CXIdxObjCContainer_Implementation = 2
5800} CXIdxObjCContainerKind;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005801
5802typedef struct {
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00005803 const CXIdxDeclInfo *declInfo;
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005804 CXIdxObjCContainerKind kind;
5805} CXIdxObjCContainerDeclInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005806
5807typedef struct {
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00005808 const CXIdxEntityInfo *base;
5809 CXCursor cursor;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005810 CXIdxLoc loc;
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00005811} CXIdxBaseClassInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005812
5813typedef struct {
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00005814 const CXIdxEntityInfo *protocol;
5815 CXCursor cursor;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005816 CXIdxLoc loc;
5817} CXIdxObjCProtocolRefInfo;
5818
5819typedef struct {
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00005820 const CXIdxObjCProtocolRefInfo *const *protocols;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005821 unsigned numProtocols;
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00005822} CXIdxObjCProtocolRefListInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005823
5824typedef struct {
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00005825 const CXIdxObjCContainerDeclInfo *containerInfo;
5826 const CXIdxBaseClassInfo *superInfo;
5827 const CXIdxObjCProtocolRefListInfo *protocols;
5828} CXIdxObjCInterfaceDeclInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005829
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00005830typedef struct {
Argyrios Kyrtzidis9b9f7a92011-12-13 18:47:45 +00005831 const CXIdxObjCContainerDeclInfo *containerInfo;
5832 const CXIdxEntityInfo *objcClass;
5833 CXCursor classCursor;
5834 CXIdxLoc classLoc;
5835 const CXIdxObjCProtocolRefListInfo *protocols;
5836} CXIdxObjCCategoryDeclInfo;
5837
5838typedef struct {
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00005839 const CXIdxDeclInfo *declInfo;
Argyrios Kyrtzidis93db2922012-02-28 17:50:33 +00005840 const CXIdxEntityInfo *getter;
5841 const CXIdxEntityInfo *setter;
5842} CXIdxObjCPropertyDeclInfo;
5843
5844typedef struct {
5845 const CXIdxDeclInfo *declInfo;
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00005846 const CXIdxBaseClassInfo *const *bases;
5847 unsigned numBases;
5848} CXIdxCXXClassDeclInfo;
5849
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005850/**
James Dennett574cb4c2012-06-15 05:41:51 +00005851 * \brief Data for IndexerCallbacks#indexEntityReference.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005852 */
Argyrios Kyrtzidis0c7735e52011-10-18 15:50:50 +00005853typedef enum {
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005854 /**
5855 * \brief The entity is referenced directly in user's code.
5856 */
Argyrios Kyrtzidis0c7735e52011-10-18 15:50:50 +00005857 CXIdxEntityRef_Direct = 1,
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005858 /**
Nico Weber7deebef2014-04-24 03:17:47 +00005859 * \brief An implicit reference, e.g. a reference of an Objective-C method
5860 * via the dot syntax.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005861 */
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00005862 CXIdxEntityRef_Implicit = 2
Argyrios Kyrtzidis0c7735e52011-10-18 15:50:50 +00005863} CXIdxEntityRefKind;
5864
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005865/**
James Dennett574cb4c2012-06-15 05:41:51 +00005866 * \brief Data for IndexerCallbacks#indexEntityReference.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005867 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005868typedef struct {
Argyrios Kyrtzidis663c8ec2011-12-07 20:44:19 +00005869 CXIdxEntityRefKind kind;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005870 /**
5871 * \brief Reference cursor.
5872 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005873 CXCursor cursor;
5874 CXIdxLoc loc;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005875 /**
5876 * \brief The entity that gets referenced.
5877 */
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00005878 const CXIdxEntityInfo *referencedEntity;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005879 /**
5880 * \brief Immediate "parent" of the reference. For example:
5881 *
5882 * \code
5883 * Foo *var;
5884 * \endcode
5885 *
5886 * The parent of reference of type 'Foo' is the variable 'var'.
Argyrios Kyrtzidis25cb0ff2011-12-13 18:47:41 +00005887 * For references inside statement bodies of functions/methods,
5888 * the parentEntity will be the function/method.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005889 */
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00005890 const CXIdxEntityInfo *parentEntity;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005891 /**
Argyrios Kyrtzidis25cb0ff2011-12-13 18:47:41 +00005892 * \brief Lexical container context of the reference.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005893 */
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00005894 const CXIdxContainerInfo *container;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005895} CXIdxEntityRefInfo;
5896
James Dennett574cb4c2012-06-15 05:41:51 +00005897/**
5898 * \brief A group of callbacks used by #clang_indexSourceFile and
5899 * #clang_indexTranslationUnit.
5900 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005901typedef struct {
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005902 /**
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00005903 * \brief Called periodically to check whether indexing should be aborted.
5904 * Should return 0 to continue, and non-zero to abort.
5905 */
5906 int (*abortQuery)(CXClientData client_data, void *reserved);
5907
5908 /**
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00005909 * \brief Called at the end of indexing; passes the complete diagnostic set.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005910 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005911 void (*diagnostic)(CXClientData client_data,
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00005912 CXDiagnosticSet, void *reserved);
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005913
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005914 CXIdxClientFile (*enteredMainFile)(CXClientData client_data,
James Dennett574cb4c2012-06-15 05:41:51 +00005915 CXFile mainFile, void *reserved);
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005916
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005917 /**
James Dennett574cb4c2012-06-15 05:41:51 +00005918 * \brief Called when a file gets \#included/\#imported.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005919 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005920 CXIdxClientFile (*ppIncludedFile)(CXClientData client_data,
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00005921 const CXIdxIncludedFileInfo *);
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005922
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005923 /**
5924 * \brief Called when a AST file (PCH or module) gets imported.
5925 *
5926 * AST files will not get indexed (there will not be callbacks to index all
5927 * the entities in an AST file). The recommended action is that, if the AST
Argyrios Kyrtzidis472eda02012-10-02 16:10:38 +00005928 * file is not already indexed, to initiate a new indexing job specific to
5929 * the AST file.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005930 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005931 CXIdxClientASTFile (*importedASTFile)(CXClientData client_data,
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00005932 const CXIdxImportedASTFileInfo *);
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005933
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005934 /**
5935 * \brief Called at the beginning of indexing a translation unit.
5936 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005937 CXIdxClientContainer (*startedTranslationUnit)(CXClientData client_data,
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00005938 void *reserved);
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005939
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00005940 void (*indexDeclaration)(CXClientData client_data,
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00005941 const CXIdxDeclInfo *);
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005942
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005943 /**
5944 * \brief Called to index a reference of an entity.
5945 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005946 void (*indexEntityReference)(CXClientData client_data,
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00005947 const CXIdxEntityRefInfo *);
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005948
5949} IndexerCallbacks;
5950
NAKAMURA Takumiaacef7e2011-11-11 02:51:09 +00005951CINDEX_LINKAGE int clang_index_isEntityObjCContainerKind(CXIdxEntityKind);
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00005952CINDEX_LINKAGE const CXIdxObjCContainerDeclInfo *
5953clang_index_getObjCContainerDeclInfo(const CXIdxDeclInfo *);
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005954
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00005955CINDEX_LINKAGE const CXIdxObjCInterfaceDeclInfo *
5956clang_index_getObjCInterfaceDeclInfo(const CXIdxDeclInfo *);
5957
NAKAMURA Takumiaacef7e2011-11-11 02:51:09 +00005958CINDEX_LINKAGE
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00005959const CXIdxObjCCategoryDeclInfo *
5960clang_index_getObjCCategoryDeclInfo(const CXIdxDeclInfo *);
5961
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00005962CINDEX_LINKAGE const CXIdxObjCProtocolRefListInfo *
5963clang_index_getObjCProtocolRefListInfo(const CXIdxDeclInfo *);
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005964
Argyrios Kyrtzidis93db2922012-02-28 17:50:33 +00005965CINDEX_LINKAGE const CXIdxObjCPropertyDeclInfo *
5966clang_index_getObjCPropertyDeclInfo(const CXIdxDeclInfo *);
5967
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00005968CINDEX_LINKAGE const CXIdxIBOutletCollectionAttrInfo *
5969clang_index_getIBOutletCollectionAttrInfo(const CXIdxAttrInfo *);
5970
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00005971CINDEX_LINKAGE const CXIdxCXXClassDeclInfo *
5972clang_index_getCXXClassDeclInfo(const CXIdxDeclInfo *);
5973
5974/**
5975 * \brief For retrieving a custom CXIdxClientContainer attached to a
5976 * container.
5977 */
5978CINDEX_LINKAGE CXIdxClientContainer
5979clang_index_getClientContainer(const CXIdxContainerInfo *);
5980
5981/**
5982 * \brief For setting a custom CXIdxClientContainer attached to a
5983 * container.
5984 */
5985CINDEX_LINKAGE void
5986clang_index_setClientContainer(const CXIdxContainerInfo *,CXIdxClientContainer);
5987
5988/**
5989 * \brief For retrieving a custom CXIdxClientEntity attached to an entity.
5990 */
5991CINDEX_LINKAGE CXIdxClientEntity
5992clang_index_getClientEntity(const CXIdxEntityInfo *);
5993
5994/**
5995 * \brief For setting a custom CXIdxClientEntity attached to an entity.
5996 */
5997CINDEX_LINKAGE void
5998clang_index_setClientEntity(const CXIdxEntityInfo *, CXIdxClientEntity);
5999
6000/**
Argyrios Kyrtzidis8b71bc72012-12-06 19:41:16 +00006001 * \brief An indexing action/session, to be applied to one or multiple
6002 * translation units.
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006003 */
6004typedef void *CXIndexAction;
6005
6006/**
Argyrios Kyrtzidis8b71bc72012-12-06 19:41:16 +00006007 * \brief An indexing action/session, to be applied to one or multiple
6008 * translation units.
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006009 *
6010 * \param CIdx The index object with which the index action will be associated.
6011 */
6012CINDEX_LINKAGE CXIndexAction clang_IndexAction_create(CXIndex CIdx);
6013
6014/**
6015 * \brief Destroy the given index action.
6016 *
6017 * The index action must not be destroyed until all of the translation units
6018 * created within that index action have been destroyed.
6019 */
6020CINDEX_LINKAGE void clang_IndexAction_dispose(CXIndexAction);
6021
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006022typedef enum {
6023 /**
6024 * \brief Used to indicate that no special indexing options are needed.
6025 */
6026 CXIndexOpt_None = 0x0,
6027
6028 /**
James Dennett574cb4c2012-06-15 05:41:51 +00006029 * \brief Used to indicate that IndexerCallbacks#indexEntityReference should
6030 * be invoked for only one reference of an entity per source file that does
6031 * not also include a declaration/definition of the entity.
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006032 */
Argyrios Kyrtzidisfb7d1452012-01-14 00:11:49 +00006033 CXIndexOpt_SuppressRedundantRefs = 0x1,
6034
6035 /**
6036 * \brief Function-local symbols should be indexed. If this is not set
6037 * function-local symbols will be ignored.
6038 */
Argyrios Kyrtzidis7e747952012-02-14 22:23:11 +00006039 CXIndexOpt_IndexFunctionLocalSymbols = 0x2,
6040
6041 /**
6042 * \brief Implicit function/class template instantiations should be indexed.
6043 * If this is not set, implicit instantiations will be ignored.
6044 */
Argyrios Kyrtzidis6c9ed7d2012-03-27 21:38:03 +00006045 CXIndexOpt_IndexImplicitTemplateInstantiations = 0x4,
6046
6047 /**
6048 * \brief Suppress all compiler warnings when parsing for indexing.
6049 */
Argyrios Kyrtzidis8b71bc72012-12-06 19:41:16 +00006050 CXIndexOpt_SuppressWarnings = 0x8,
6051
6052 /**
6053 * \brief Skip a function/method body that was already parsed during an
Nico Weber7deebef2014-04-24 03:17:47 +00006054 * indexing session associated with a \c CXIndexAction object.
Argyrios Kyrtzidis8b71bc72012-12-06 19:41:16 +00006055 * Bodies in system headers are always skipped.
6056 */
6057 CXIndexOpt_SkipParsedBodiesInSession = 0x10
6058
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006059} CXIndexOptFlags;
6060
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006061/**
6062 * \brief Index the given source file and the translation unit corresponding
James Dennett574cb4c2012-06-15 05:41:51 +00006063 * to that file via callbacks implemented through #IndexerCallbacks.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006064 *
6065 * \param client_data pointer data supplied by the client, which will
6066 * be passed to the invoked callbacks.
6067 *
6068 * \param index_callbacks Pointer to indexing callbacks that the client
6069 * implements.
6070 *
James Dennett574cb4c2012-06-15 05:41:51 +00006071 * \param index_callbacks_size Size of #IndexerCallbacks structure that gets
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006072 * passed in index_callbacks.
6073 *
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006074 * \param index_options A bitmask of options that affects how indexing is
6075 * performed. This should be a bitwise OR of the CXIndexOpt_XXX flags.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006076 *
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00006077 * \param[out] out_TU pointer to store a \c CXTranslationUnit that can be
6078 * reused after indexing is finished. Set to \c NULL if you do not require it.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006079 *
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00006080 * \returns 0 on success or if there were errors from which the compiler could
Eric Christopher2c4555a2015-06-19 01:52:53 +00006081 * recover. If there is a failure from which there is no recovery, returns
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00006082 * a non-zero \c CXErrorCode.
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006083 *
James Dennett574cb4c2012-06-15 05:41:51 +00006084 * The rest of the parameters are the same as #clang_parseTranslationUnit.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006085 */
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006086CINDEX_LINKAGE int clang_indexSourceFile(CXIndexAction,
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006087 CXClientData client_data,
6088 IndexerCallbacks *index_callbacks,
6089 unsigned index_callbacks_size,
6090 unsigned index_options,
6091 const char *source_filename,
6092 const char * const *command_line_args,
6093 int num_command_line_args,
6094 struct CXUnsavedFile *unsaved_files,
6095 unsigned num_unsaved_files,
6096 CXTranslationUnit *out_TU,
6097 unsigned TU_options);
6098
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006099/**
Benjamin Kramerc02670e2015-11-18 16:14:27 +00006100 * \brief Same as clang_indexSourceFile but requires a full command line
6101 * for \c command_line_args including argv[0]. This is useful if the standard
6102 * library paths are relative to the binary.
6103 */
6104CINDEX_LINKAGE int clang_indexSourceFileFullArgv(
6105 CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks,
6106 unsigned index_callbacks_size, unsigned index_options,
6107 const char *source_filename, const char *const *command_line_args,
6108 int num_command_line_args, struct CXUnsavedFile *unsaved_files,
6109 unsigned num_unsaved_files, CXTranslationUnit *out_TU, unsigned TU_options);
6110
6111/**
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006112 * \brief Index the given translation unit via callbacks implemented through
James Dennett574cb4c2012-06-15 05:41:51 +00006113 * #IndexerCallbacks.
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006114 *
6115 * The order of callback invocations is not guaranteed to be the same as
6116 * when indexing a source file. The high level order will be:
6117 *
6118 * -Preprocessor callbacks invocations
6119 * -Declaration/reference callbacks invocations
6120 * -Diagnostic callback invocations
6121 *
James Dennett574cb4c2012-06-15 05:41:51 +00006122 * The parameters are the same as #clang_indexSourceFile.
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006123 *
Eric Christopher2c4555a2015-06-19 01:52:53 +00006124 * \returns If there is a failure from which there is no recovery, returns
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006125 * non-zero, otherwise returns 0.
6126 */
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006127CINDEX_LINKAGE int clang_indexTranslationUnit(CXIndexAction,
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006128 CXClientData client_data,
6129 IndexerCallbacks *index_callbacks,
6130 unsigned index_callbacks_size,
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006131 unsigned index_options,
6132 CXTranslationUnit);
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006133
6134/**
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006135 * \brief Retrieve the CXIdxFile, file, line, column, and offset represented by
6136 * the given CXIdxLoc.
6137 *
6138 * If the location refers into a macro expansion, retrieves the
6139 * location of the macro expansion and if it refers into a macro argument
6140 * retrieves the location of the argument.
6141 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006142CINDEX_LINKAGE void clang_indexLoc_getFileLocation(CXIdxLoc loc,
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006143 CXIdxClientFile *indexFile,
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006144 CXFile *file,
6145 unsigned *line,
6146 unsigned *column,
6147 unsigned *offset);
6148
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006149/**
6150 * \brief Retrieve the CXSourceLocation represented by the given CXIdxLoc.
6151 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006152CINDEX_LINKAGE
6153CXSourceLocation clang_indexLoc_getCXSourceLocation(CXIdxLoc loc);
6154
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00006155/**
Argyrios Kyrtzidis2bff5162015-04-13 16:55:04 +00006156 * \brief Visitor invoked for each field found by a traversal.
6157 *
6158 * This visitor function will be invoked for each field found by
6159 * \c clang_Type_visitFields. Its first argument is the cursor being
6160 * visited, its second argument is the client data provided to
6161 * \c clang_Type_visitFields.
6162 *
6163 * The visitor should return one of the \c CXVisitorResult values
6164 * to direct \c clang_Type_visitFields.
6165 */
6166typedef enum CXVisitorResult (*CXFieldVisitor)(CXCursor C,
6167 CXClientData client_data);
6168
6169/**
6170 * \brief Visit the fields of a particular type.
6171 *
6172 * This function visits all the direct fields of the given cursor,
6173 * invoking the given \p visitor function with the cursors of each
6174 * visited field. The traversal may be ended prematurely, if
6175 * the visitor returns \c CXFieldVisit_Break.
6176 *
6177 * \param T the record type whose field may be visited.
6178 *
6179 * \param visitor the visitor function that will be invoked for each
6180 * field of \p T.
6181 *
6182 * \param client_data pointer data supplied by the client, which will
6183 * be passed to the visitor each time it is invoked.
6184 *
6185 * \returns a non-zero value if the traversal was terminated
6186 * prematurely by the visitor returning \c CXFieldVisit_Break.
6187 */
6188CINDEX_LINKAGE unsigned clang_Type_visitFields(CXType T,
6189 CXFieldVisitor visitor,
6190 CXClientData client_data);
6191
Argyrios Kyrtzidis2bff5162015-04-13 16:55:04 +00006192/**
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00006193 * @}
6194 */
6195
Douglas Gregor6007cf22010-01-22 22:29:16 +00006196/**
6197 * @}
6198 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00006199
Ted Kremenekb60d87c2009-08-26 22:36:44 +00006200#ifdef __cplusplus
6201}
6202#endif
6203#endif