blob: ff14d6e729a5209d672164f69fd1a95a46a4b5cd [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|* *|
Marc-Andre Laperlef9abd402017-06-16 20:58:26 +000010|* This header provides a public interface to a Clang library for extracting *|
Ted Kremenekb60d87c2009-08-26 22:36:44 +000011|* 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/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000027 * The version constants for the libclang API.
Argyrios Kyrtzidis1c4db8d2012-11-06 21:21:49 +000028 * 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
Ivan Donchevskii65c766e2018-01-03 10:40:11 +000032 * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
33 */
34#define CINDEX_VERSION_MAJOR 0
Fangrui Song31b97192018-02-12 17:42:09 +000035#define CINDEX_VERSION_MINOR 48
Ivan Donchevskii65c766e2018-01-03 10:40:11 +000036
37#define CINDEX_VERSION_ENCODE(major, minor) ( \
38 ((major) * 10000) \
Argyrios Kyrtzidis5b216ed2012-10-29 23:24:44 +000039 + ((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/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000078 * An "index" that consists of a set of translation units that would
Douglas Gregor802f12f2010-01-20 22:28:27 +000079 * 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/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000084 * An opaque type representing target information for a given translation
Emilio Cobos Alvarez485ad422017-04-28 15:56:39 +000085 * unit.
86 */
87typedef struct CXTargetInfoImpl *CXTargetInfo;
88
89/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000090 * A single translation unit, which resides in an index.
Douglas Gregor802f12f2010-01-20 22:28:27 +000091 */
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/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000095 * Opaque pointer representing client data that will be passed through
Douglas Gregor6007cf22010-01-22 22:29:16 +000096 * 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/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000101 * Provides the contents of a file that has not yet been saved to disk.
Douglas Gregor9485bf92009-12-02 09:21:34 +0000102 *
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 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000109 * 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 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000116 * A buffer containing the unsaved contents of this file.
Douglas Gregor9485bf92009-12-02 09:21:34 +0000117 */
118 const char *Contents;
119
120 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000121 * 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/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000127 * Describes the availability of a particular entity, which indicates
Peter Collingbourne5caf5af2010-08-24 00:31:37 +0000128 * 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 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000133 * The entity is available.
Peter Collingbourne5caf5af2010-08-24 00:31:37 +0000134 */
Douglas Gregorf757a122010-08-23 23:00:57 +0000135 CXAvailability_Available,
Peter Collingbourne5caf5af2010-08-24 00:31:37 +0000136 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000137 * The entity is available, but has been deprecated (and its use is
Peter Collingbourne5caf5af2010-08-24 00:31:37 +0000138 * not recommended).
139 */
Douglas Gregorf757a122010-08-23 23:00:57 +0000140 CXAvailability_Deprecated,
Peter Collingbourne5caf5af2010-08-24 00:31:37 +0000141 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000142 * The entity is not available; any use of it will be an error.
Peter Collingbourne5caf5af2010-08-24 00:31:37 +0000143 */
Erik Verbruggen2e657ff2011-10-06 07:27:49 +0000144 CXAvailability_NotAvailable,
145 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000146 * The entity is available, but not accessible; any use of it will be
Erik Verbruggen2e657ff2011-10-06 07:27:49 +0000147 * an error.
148 */
149 CXAvailability_NotAccessible
Douglas Gregorf757a122010-08-23 23:00:57 +0000150};
Douglas Gregord6225d32012-05-08 00:14:45 +0000151
152/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000153 * Describes a version number of the form major.minor.subminor.
Douglas Gregord6225d32012-05-08 00:14:45 +0000154 */
155typedef struct CXVersion {
156 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000157 * The major version number, e.g., the '10' in '10.7.3'. A negative
Douglas Gregord6225d32012-05-08 00:14:45 +0000158 * value indicates that there is no version number at all.
159 */
160 int Major;
161 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000162 * The minor version number, e.g., the '7' in '10.7.3'. This value
Douglas Gregord6225d32012-05-08 00:14:45 +0000163 * will be negative if no minor version number was provided, e.g., for
164 * version '10'.
165 */
166 int Minor;
167 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000168 * The subminor version number, e.g., the '3' in '10.7.3'. This value
Douglas Gregord6225d32012-05-08 00:14:45 +0000169 * 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;
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000174
175/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000176 * Describes the exception specification of a cursor.
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000177 *
178 * A negative value indicates that the cursor is not a function declaration.
179 */
180enum CXCursor_ExceptionSpecificationKind {
181
182 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000183 * The cursor has no exception specification.
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000184 */
185 CXCursor_ExceptionSpecificationKind_None,
186
187 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000188 * The cursor has exception specification throw()
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000189 */
190 CXCursor_ExceptionSpecificationKind_DynamicNone,
191
192 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000193 * The cursor has exception specification throw(T1, T2)
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000194 */
195 CXCursor_ExceptionSpecificationKind_Dynamic,
196
197 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000198 * The cursor has exception specification throw(...).
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000199 */
200 CXCursor_ExceptionSpecificationKind_MSAny,
201
202 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000203 * The cursor has exception specification basic noexcept.
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000204 */
205 CXCursor_ExceptionSpecificationKind_BasicNoexcept,
206
207 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000208 * The cursor has exception specification computed noexcept.
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000209 */
210 CXCursor_ExceptionSpecificationKind_ComputedNoexcept,
211
212 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000213 * The exception specification has not yet been evaluated.
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000214 */
215 CXCursor_ExceptionSpecificationKind_Unevaluated,
216
217 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000218 * The exception specification has not yet been instantiated.
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000219 */
220 CXCursor_ExceptionSpecificationKind_Uninstantiated,
221
222 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000223 * The exception specification has not been parsed yet.
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000224 */
225 CXCursor_ExceptionSpecificationKind_Unparsed
226};
227
Douglas Gregor802f12f2010-01-20 22:28:27 +0000228/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000229 * Provides a shared context for creating translation units.
James Dennett574cb4c2012-06-15 05:41:51 +0000230 *
231 * It provides two options:
Steve Naroff531e2842009-10-20 14:46:24 +0000232 *
233 * - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local"
234 * declarations (when loading any new translation units). A "local" declaration
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000235 * is one that belongs in the translation unit itself and not in a precompiled
Steve Naroff531e2842009-10-20 14:46:24 +0000236 * header that was used by the translation unit. If zero, all declarations
237 * will be enumerated.
238 *
Steve Naroffbb4568a2009-10-20 16:36:34 +0000239 * Here is an example:
240 *
James Dennett574cb4c2012-06-15 05:41:51 +0000241 * \code
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000242 * // excludeDeclsFromPCH = 1, displayDiagnostics=1
243 * Idx = clang_createIndex(1, 1);
Steve Naroffbb4568a2009-10-20 16:36:34 +0000244 *
245 * // IndexTest.pch was produced with the following command:
246 * // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch"
247 * TU = clang_createTranslationUnit(Idx, "IndexTest.pch");
248 *
249 * // This will load all the symbols from 'IndexTest.pch'
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000250 * clang_visitChildren(clang_getTranslationUnitCursor(TU),
Douglas Gregor990b5762010-01-20 21:37:00 +0000251 * TranslationUnitVisitor, 0);
Steve Naroffbb4568a2009-10-20 16:36:34 +0000252 * clang_disposeTranslationUnit(TU);
253 *
254 * // This will load all the symbols from 'IndexTest.c', excluding symbols
255 * // from 'IndexTest.pch'.
Daniel Dunbard0159262010-01-25 00:43:14 +0000256 * char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" };
257 * TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args,
258 * 0, 0);
Douglas Gregorfed36b12010-01-20 23:57:43 +0000259 * clang_visitChildren(clang_getTranslationUnitCursor(TU),
260 * TranslationUnitVisitor, 0);
Steve Naroffbb4568a2009-10-20 16:36:34 +0000261 * clang_disposeTranslationUnit(TU);
James Dennett574cb4c2012-06-15 05:41:51 +0000262 * \endcode
Steve Naroffbb4568a2009-10-20 16:36:34 +0000263 *
264 * This process of creating the 'pch', loading it separately, and using it (via
265 * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks
266 * (which gives the indexer the same performance benefit as the compiler).
Steve Naroff531e2842009-10-20 14:46:24 +0000267 */
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000268CINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH,
269 int displayDiagnostics);
Ted Kremenekd071c602010-03-13 02:50:34 +0000270
Douglas Gregor408bb742010-02-08 23:03:06 +0000271/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000272 * Destroy the given index.
Douglas Gregor408bb742010-02-08 23:03:06 +0000273 *
274 * The index must not be destroyed until all of the translation units created
275 * within that index have been destroyed.
276 */
Daniel Dunbar11089662009-12-03 01:54:28 +0000277CINDEX_LINKAGE void clang_disposeIndex(CXIndex index);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000278
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000279typedef enum {
280 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000281 * Used to indicate that no special CXIndex options are needed.
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000282 */
283 CXGlobalOpt_None = 0x0,
284
285 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000286 * Used to indicate that threads that libclang creates for indexing
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000287 * purposes should use background priority.
James Dennett574cb4c2012-06-15 05:41:51 +0000288 *
289 * Affects #clang_indexSourceFile, #clang_indexTranslationUnit,
290 * #clang_parseTranslationUnit, #clang_saveTranslationUnit.
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000291 */
292 CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1,
293
294 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000295 * Used to indicate that threads that libclang creates for editing
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000296 * purposes should use background priority.
James Dennett574cb4c2012-06-15 05:41:51 +0000297 *
298 * Affects #clang_reparseTranslationUnit, #clang_codeCompleteAt,
299 * #clang_annotateTokens
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000300 */
301 CXGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2,
302
303 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000304 * Used to indicate that all threads that libclang creates should use
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000305 * background priority.
306 */
307 CXGlobalOpt_ThreadBackgroundPriorityForAll =
308 CXGlobalOpt_ThreadBackgroundPriorityForIndexing |
309 CXGlobalOpt_ThreadBackgroundPriorityForEditing
310
311} CXGlobalOptFlags;
312
313/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000314 * Sets general options associated with a CXIndex.
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000315 *
316 * For example:
317 * \code
318 * CXIndex idx = ...;
319 * clang_CXIndex_setGlobalOptions(idx,
320 * clang_CXIndex_getGlobalOptions(idx) |
321 * CXGlobalOpt_ThreadBackgroundPriorityForIndexing);
322 * \endcode
323 *
324 * \param options A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags.
325 */
326CINDEX_LINKAGE void clang_CXIndex_setGlobalOptions(CXIndex, unsigned options);
327
328/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000329 * Gets the general options associated with a CXIndex.
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000330 *
331 * \returns A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags that
332 * are associated with the given CXIndex object.
333 */
334CINDEX_LINKAGE unsigned clang_CXIndex_getGlobalOptions(CXIndex);
335
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000336/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000337 * Sets the invocation emission path option in a CXIndex.
Alex Lorenz08615792017-12-04 21:56:36 +0000338 *
339 * The invocation emission path specifies a path which will contain log
340 * files for certain libclang invocations. A null value (default) implies that
341 * libclang invocations are not logged..
342 */
343CINDEX_LINKAGE void
344clang_CXIndex_setInvocationEmissionPathOption(CXIndex, const char *Path);
345
346/**
Douglas Gregor6007cf22010-01-22 22:29:16 +0000347 * \defgroup CINDEX_FILES File manipulation routines
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000348 *
349 * @{
350 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000351
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000352/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000353 * A particular source file that is part of a translation unit.
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000354 */
355typedef void *CXFile;
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000356
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000357/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000358 * Retrieve the complete file and path name of the given file.
Steve Naroff6231f182009-10-27 14:35:18 +0000359 */
Ted Kremenekc560b682010-02-17 00:41:20 +0000360CINDEX_LINKAGE CXString clang_getFileName(CXFile SFile);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000361
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000362/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000363 * Retrieve the last modification time of the given file.
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000364 */
Douglas Gregor249c1212009-10-31 15:48:08 +0000365CINDEX_LINKAGE time_t clang_getFileTime(CXFile SFile);
Steve Naroff6231f182009-10-27 14:35:18 +0000366
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000367/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000368 * Uniquely identifies a CXFile, that refers to the same underlying file,
Argyrios Kyrtzidisac08b262013-01-26 04:52:52 +0000369 * across an indexing session.
370 */
371typedef struct {
372 unsigned long long data[3];
373} CXFileUniqueID;
374
375/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000376 * Retrieve the unique ID for the given \c file.
Argyrios Kyrtzidisac08b262013-01-26 04:52:52 +0000377 *
378 * \param file the file to get the ID for.
379 * \param outID stores the returned CXFileUniqueID.
380 * \returns If there was a failure getting the unique ID, returns non-zero,
381 * otherwise returns 0.
382*/
383CINDEX_LINKAGE int clang_getFileUniqueID(CXFile file, CXFileUniqueID *outID);
384
385/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000386 * Determine whether the given header is guarded against
Douglas Gregor37aa4932011-05-04 00:14:37 +0000387 * multiple inclusions, either with the conventional
James Dennett574cb4c2012-06-15 05:41:51 +0000388 * \#ifndef/\#define/\#endif macro guards or with \#pragma once.
Douglas Gregor37aa4932011-05-04 00:14:37 +0000389 */
390CINDEX_LINKAGE unsigned
391clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu, CXFile file);
392
393/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000394 * Retrieve a file handle within the given translation unit.
Douglas Gregor816fd362010-01-22 21:44:22 +0000395 *
396 * \param tu the translation unit
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000397 *
Samuel Antao4c8035b2016-12-12 18:00:20 +0000398 * \param file_name the name of the file.
Douglas Gregor816fd362010-01-22 21:44:22 +0000399 *
400 * \returns the file handle for the named file in the translation unit \p tu,
401 * or a NULL file handle if the file was not a part of this translation unit.
402 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000403CINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu,
Douglas Gregor816fd362010-01-22 21:44:22 +0000404 const char *file_name);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000405
Douglas Gregor816fd362010-01-22 21:44:22 +0000406/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000407 * Retrieve the buffer associated with the given file.
Erik Verbruggen3afa3ce2017-12-06 09:02:52 +0000408 *
409 * \param tu the translation unit
410 *
411 * \param file the file for which to retrieve the buffer.
412 *
413 * \param size [out] if non-NULL, will be set to the size of the buffer.
414 *
415 * \returns a pointer to the buffer in memory that holds the contents of
416 * \p file, or a NULL pointer when the file is not loaded.
417 */
418CINDEX_LINKAGE const char *clang_getFileContents(CXTranslationUnit tu,
419 CXFile file, size_t *size);
420
421/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000422 * Returns non-zero if the \c file1 and \c file2 point to the same file,
Argyrios Kyrtzidisac3997e2014-08-16 00:26:19 +0000423 * or they are both NULL.
424 */
425CINDEX_LINKAGE int clang_File_isEqual(CXFile file1, CXFile file2);
426
427/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000428 * Returns the real path name of \c file.
Fangrui Songe46ac5f2018-04-07 20:50:35 +0000429 *
430 * An empty string may be returned. Use \c clang_getFileName() in that case.
431 */
432CINDEX_LINKAGE CXString clang_File_tryGetRealPathName(CXFile file);
433
434/**
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000435 * @}
436 */
437
438/**
439 * \defgroup CINDEX_LOCATIONS Physical source locations
440 *
441 * Clang represents physical source locations in its abstract syntax tree in
442 * great detail, with file, line, and column information for the majority of
443 * the tokens parsed in the source code. These data types and functions are
444 * used to represent source location information, either for a particular
445 * point in the program or for a range of points in the program, and extract
446 * specific location information from those data types.
447 *
448 * @{
449 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000450
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000451/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000452 * Identifies a specific source location within a translation
Douglas Gregor4f46e782010-01-19 21:36:55 +0000453 * unit.
454 *
Chandler Carruth4aa01ef2011-08-31 16:53:37 +0000455 * Use clang_getExpansionLocation() or clang_getSpellingLocation()
Douglas Gregor229bebd2010-11-09 06:24:54 +0000456 * to map a source location to a particular file, line, and column.
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000457 */
458typedef struct {
Argyrios Kyrtzidis49d9d0292013-01-11 22:29:47 +0000459 const void *ptr_data[2];
Douglas Gregor4f46e782010-01-19 21:36:55 +0000460 unsigned int_data;
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000461} CXSourceLocation;
Ted Kremeneka44d99c2010-01-05 23:18:49 +0000462
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000463/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000464 * Identifies a half-open character range in the source code.
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000465 *
Douglas Gregor4f46e782010-01-19 21:36:55 +0000466 * Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the
467 * starting and end locations from a source range, respectively.
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000468 */
469typedef struct {
Argyrios Kyrtzidis49d9d0292013-01-11 22:29:47 +0000470 const void *ptr_data[2];
Douglas Gregor4f46e782010-01-19 21:36:55 +0000471 unsigned begin_int_data;
472 unsigned end_int_data;
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000473} CXSourceRange;
Ted Kremeneka44d99c2010-01-05 23:18:49 +0000474
Douglas Gregor4f46e782010-01-19 21:36:55 +0000475/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000476 * Retrieve a NULL (invalid) source location.
Douglas Gregor816fd362010-01-22 21:44:22 +0000477 */
NAKAMURA Takumieacd6672013-01-10 02:12:38 +0000478CINDEX_LINKAGE CXSourceLocation clang_getNullLocation(void);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000479
Douglas Gregor816fd362010-01-22 21:44:22 +0000480/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000481 * Determine whether two source locations, which must refer into
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000482 * the same translation unit, refer to exactly the same point in the source
Douglas Gregor816fd362010-01-22 21:44:22 +0000483 * code.
484 *
485 * \returns non-zero if the source locations refer to the same location, zero
486 * if they refer to different locations.
487 */
488CINDEX_LINKAGE unsigned clang_equalLocations(CXSourceLocation loc1,
489 CXSourceLocation loc2);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000490
Douglas Gregor816fd362010-01-22 21:44:22 +0000491/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000492 * Retrieves the source location associated with a given file/line/column
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000493 * in a particular translation unit.
Douglas Gregor816fd362010-01-22 21:44:22 +0000494 */
495CINDEX_LINKAGE CXSourceLocation clang_getLocation(CXTranslationUnit tu,
496 CXFile file,
497 unsigned line,
498 unsigned column);
David Chisnall2e16ac52010-10-15 17:07:39 +0000499/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000500 * Retrieves the source location associated with a given character offset
David Chisnall2e16ac52010-10-15 17:07:39 +0000501 * in a particular translation unit.
502 */
503CINDEX_LINKAGE CXSourceLocation clang_getLocationForOffset(CXTranslationUnit tu,
504 CXFile file,
505 unsigned offset);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000506
Douglas Gregor816fd362010-01-22 21:44:22 +0000507/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000508 * Returns non-zero if the given source location is in a system header.
Argyrios Kyrtzidis25f7af12013-04-12 17:06:51 +0000509 */
510CINDEX_LINKAGE int clang_Location_isInSystemHeader(CXSourceLocation location);
511
512/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000513 * Returns non-zero if the given source location is in the main file of
Stefanus Du Toitdb51c632013-08-08 17:48:14 +0000514 * the corresponding translation unit.
515 */
516CINDEX_LINKAGE int clang_Location_isFromMainFile(CXSourceLocation location);
517
518/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000519 * Retrieve a NULL (invalid) source range.
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000520 */
NAKAMURA Takumieacd6672013-01-10 02:12:38 +0000521CINDEX_LINKAGE CXSourceRange clang_getNullRange(void);
Ted Kremenekd071c602010-03-13 02:50:34 +0000522
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000523/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000524 * Retrieve a source range given the beginning and ending source
Douglas Gregor816fd362010-01-22 21:44:22 +0000525 * locations.
526 */
527CINDEX_LINKAGE CXSourceRange clang_getRange(CXSourceLocation begin,
528 CXSourceLocation end);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000529
Douglas Gregor816fd362010-01-22 21:44:22 +0000530/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000531 * Determine whether two ranges are equivalent.
Douglas Gregor757e38b2011-07-23 19:35:14 +0000532 *
533 * \returns non-zero if the ranges are the same, zero if they differ.
534 */
535CINDEX_LINKAGE unsigned clang_equalRanges(CXSourceRange range1,
536 CXSourceRange range2);
537
538/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000539 * Returns non-zero if \p range is null.
Argyrios Kyrtzidise7e42912011-09-28 18:14:21 +0000540 */
Erik Verbruggend610b0f2011-10-06 12:11:57 +0000541CINDEX_LINKAGE int clang_Range_isNull(CXSourceRange range);
Argyrios Kyrtzidise7e42912011-09-28 18:14:21 +0000542
543/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000544 * Retrieve the file, line, column, and offset represented by
Douglas Gregor9bd6db52010-01-26 19:19:08 +0000545 * the given source location.
Douglas Gregor4f46e782010-01-19 21:36:55 +0000546 *
Chandler Carruth4aa01ef2011-08-31 16:53:37 +0000547 * If the location refers into a macro expansion, retrieves the
548 * location of the macro expansion.
Douglas Gregor229bebd2010-11-09 06:24:54 +0000549 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000550 * \param location the location within a source file that will be decomposed
551 * into its parts.
Douglas Gregor4f46e782010-01-19 21:36:55 +0000552 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000553 * \param file [out] if non-NULL, will be set to the file to which the given
Douglas Gregor4f46e782010-01-19 21:36:55 +0000554 * source location points.
555 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000556 * \param line [out] if non-NULL, will be set to the line to which the given
Douglas Gregor4f46e782010-01-19 21:36:55 +0000557 * source location points.
558 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000559 * \param column [out] if non-NULL, will be set to the column to which the given
560 * source location points.
Douglas Gregor9bd6db52010-01-26 19:19:08 +0000561 *
562 * \param offset [out] if non-NULL, will be set to the offset into the
563 * buffer to which the given source location points.
Douglas Gregor4f46e782010-01-19 21:36:55 +0000564 */
Chandler Carruth4aa01ef2011-08-31 16:53:37 +0000565CINDEX_LINKAGE void clang_getExpansionLocation(CXSourceLocation location,
566 CXFile *file,
567 unsigned *line,
568 unsigned *column,
569 unsigned *offset);
570
571/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000572 * Retrieve the file, line and column represented by the given source
Vassil Vassilev4b8e29d2017-04-06 10:05:46 +0000573 * location, as specified in a # line directive.
Argyrios Kyrtzidis91672b32011-09-13 21:49:08 +0000574 *
575 * Example: given the following source code in a file somefile.c
576 *
James Dennett574cb4c2012-06-15 05:41:51 +0000577 * \code
Argyrios Kyrtzidis91672b32011-09-13 21:49:08 +0000578 * #123 "dummy.c" 1
579 *
580 * static int func(void)
581 * {
582 * return 0;
583 * }
James Dennett574cb4c2012-06-15 05:41:51 +0000584 * \endcode
Argyrios Kyrtzidis91672b32011-09-13 21:49:08 +0000585 *
586 * the location information returned by this function would be
587 *
588 * File: dummy.c Line: 124 Column: 12
589 *
590 * whereas clang_getExpansionLocation would have returned
591 *
592 * File: somefile.c Line: 3 Column: 12
593 *
594 * \param location the location within a source file that will be decomposed
595 * into its parts.
596 *
597 * \param filename [out] if non-NULL, will be set to the filename of the
598 * source location. Note that filenames returned will be for "virtual" files,
599 * which don't necessarily exist on the machine running clang - e.g. when
600 * parsing preprocessed output obtained from a different environment. If
601 * a non-NULL value is passed in, remember to dispose of the returned value
602 * using \c clang_disposeString() once you've finished with it. For an invalid
603 * source location, an empty string is returned.
604 *
605 * \param line [out] if non-NULL, will be set to the line number of the
606 * source location. For an invalid source location, zero is returned.
607 *
608 * \param column [out] if non-NULL, will be set to the column number of the
609 * source location. For an invalid source location, zero is returned.
610 */
611CINDEX_LINKAGE void clang_getPresumedLocation(CXSourceLocation location,
612 CXString *filename,
613 unsigned *line,
614 unsigned *column);
615
616/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000617 * Legacy API to retrieve the file, line, column, and offset represented
Chandler Carruth4aa01ef2011-08-31 16:53:37 +0000618 * by the given source location.
619 *
620 * This interface has been replaced by the newer interface
James Dennett574cb4c2012-06-15 05:41:51 +0000621 * #clang_getExpansionLocation(). See that interface's documentation for
Chandler Carruth4aa01ef2011-08-31 16:53:37 +0000622 * details.
623 */
Douglas Gregor4f46e782010-01-19 21:36:55 +0000624CINDEX_LINKAGE void clang_getInstantiationLocation(CXSourceLocation location,
625 CXFile *file,
626 unsigned *line,
Douglas Gregor9bd6db52010-01-26 19:19:08 +0000627 unsigned *column,
628 unsigned *offset);
Douglas Gregor47751d62010-01-26 03:07:15 +0000629
630/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000631 * Retrieve the file, line, column, and offset represented by
Douglas Gregor229bebd2010-11-09 06:24:54 +0000632 * the given source location.
633 *
634 * If the location refers into a macro instantiation, return where the
635 * location was originally spelled in the source file.
636 *
637 * \param location the location within a source file that will be decomposed
638 * into its parts.
639 *
640 * \param file [out] if non-NULL, will be set to the file to which the given
641 * source location points.
642 *
643 * \param line [out] if non-NULL, will be set to the line to which the given
644 * source location points.
645 *
646 * \param column [out] if non-NULL, will be set to the column to which the given
647 * source location points.
648 *
649 * \param offset [out] if non-NULL, will be set to the offset into the
650 * buffer to which the given source location points.
651 */
652CINDEX_LINKAGE void clang_getSpellingLocation(CXSourceLocation location,
653 CXFile *file,
654 unsigned *line,
655 unsigned *column,
656 unsigned *offset);
657
658/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000659 * Retrieve the file, line, column, and offset represented by
Argyrios Kyrtzidis56be7162013-01-04 18:30:13 +0000660 * the given source location.
661 *
662 * If the location refers into a macro expansion, return where the macro was
663 * expanded or where the macro argument was written, if the location points at
664 * a macro argument.
665 *
666 * \param location the location within a source file that will be decomposed
667 * into its parts.
668 *
669 * \param file [out] if non-NULL, will be set to the file to which the given
670 * source location points.
671 *
672 * \param line [out] if non-NULL, will be set to the line to which the given
673 * source location points.
674 *
675 * \param column [out] if non-NULL, will be set to the column to which the given
676 * source location points.
677 *
678 * \param offset [out] if non-NULL, will be set to the offset into the
679 * buffer to which the given source location points.
680 */
681CINDEX_LINKAGE void clang_getFileLocation(CXSourceLocation location,
682 CXFile *file,
683 unsigned *line,
684 unsigned *column,
685 unsigned *offset);
686
687/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000688 * Retrieve a source location representing the first character within a
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000689 * source range.
Douglas Gregor4f46e782010-01-19 21:36:55 +0000690 */
691CINDEX_LINKAGE CXSourceLocation clang_getRangeStart(CXSourceRange range);
692
693/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000694 * Retrieve a source location representing the last character within a
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000695 * source range.
Douglas Gregor4f46e782010-01-19 21:36:55 +0000696 */
697CINDEX_LINKAGE CXSourceLocation clang_getRangeEnd(CXSourceRange range);
698
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000699/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000700 * Identifies an array of ranges.
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000701 */
702typedef struct {
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000703 /** The number of ranges in the \c ranges array. */
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000704 unsigned count;
705 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000706 * An array of \c CXSourceRanges.
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000707 */
708 CXSourceRange *ranges;
Argyrios Kyrtzidis0e282ef2013-12-06 18:55:45 +0000709} CXSourceRangeList;
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000710
711/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000712 * Retrieve all ranges that were skipped by the preprocessor.
Argyrios Kyrtzidis0e282ef2013-12-06 18:55:45 +0000713 *
714 * The preprocessor will skip lines when they are surrounded by an
715 * if/ifdef/ifndef directive whose condition does not evaluate to true.
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000716 */
Argyrios Kyrtzidis0e282ef2013-12-06 18:55:45 +0000717CINDEX_LINKAGE CXSourceRangeList *clang_getSkippedRanges(CXTranslationUnit tu,
718 CXFile file);
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000719
720/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000721 * Retrieve all ranges from all files that were skipped by the
Cameron Desrochersd8091282016-08-18 15:43:55 +0000722 * preprocessor.
723 *
724 * The preprocessor will skip lines when they are surrounded by an
725 * if/ifdef/ifndef directive whose condition does not evaluate to true.
726 */
727CINDEX_LINKAGE CXSourceRangeList *clang_getAllSkippedRanges(CXTranslationUnit tu);
728
729/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000730 * Destroy the given \c CXSourceRangeList.
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000731 */
Argyrios Kyrtzidis0e282ef2013-12-06 18:55:45 +0000732CINDEX_LINKAGE void clang_disposeSourceRangeList(CXSourceRangeList *ranges);
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000733
734/**
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000735 * @}
736 */
Douglas Gregor6007cf22010-01-22 22:29:16 +0000737
738/**
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000739 * \defgroup CINDEX_DIAG Diagnostic reporting
740 *
741 * @{
742 */
743
744/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000745 * Describes the severity of a particular diagnostic.
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000746 */
747enum CXDiagnosticSeverity {
748 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000749 * A diagnostic that has been suppressed, e.g., by a command-line
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000750 * option.
751 */
752 CXDiagnostic_Ignored = 0,
Ted Kremenekd071c602010-03-13 02:50:34 +0000753
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000754 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000755 * This diagnostic is a note that should be attached to the
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000756 * previous (non-note) diagnostic.
757 */
758 CXDiagnostic_Note = 1,
759
760 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000761 * This diagnostic indicates suspicious code that may not be
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000762 * wrong.
763 */
764 CXDiagnostic_Warning = 2,
765
766 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000767 * This diagnostic indicates that the code is ill-formed.
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000768 */
769 CXDiagnostic_Error = 3,
770
771 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000772 * This diagnostic indicates that the code is ill-formed such
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000773 * that future parser recovery is unlikely to produce useful
774 * results.
775 */
776 CXDiagnostic_Fatal = 4
777};
778
779/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000780 * A single diagnostic, containing the diagnostic's severity,
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000781 * location, text, source ranges, and fix-it hints.
782 */
783typedef void *CXDiagnostic;
784
785/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000786 * A group of CXDiagnostics.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000787 */
788typedef void *CXDiagnosticSet;
789
790/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000791 * Determine the number of diagnostics in a CXDiagnosticSet.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000792 */
793CINDEX_LINKAGE unsigned clang_getNumDiagnosticsInSet(CXDiagnosticSet Diags);
794
795/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000796 * Retrieve a diagnostic associated with the given CXDiagnosticSet.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000797 *
James Dennett574cb4c2012-06-15 05:41:51 +0000798 * \param Diags the CXDiagnosticSet to query.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000799 * \param Index the zero-based diagnostic number to retrieve.
800 *
801 * \returns the requested diagnostic. This diagnostic must be freed
802 * via a call to \c clang_disposeDiagnostic().
803 */
804CINDEX_LINKAGE CXDiagnostic clang_getDiagnosticInSet(CXDiagnosticSet Diags,
805 unsigned Index);
806
Ted Kremenekd010ba42011-11-10 08:43:12 +0000807/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000808 * Describes the kind of error that occurred (if any) in a call to
Ted Kremenekd010ba42011-11-10 08:43:12 +0000809 * \c clang_loadDiagnostics.
810 */
811enum CXLoadDiag_Error {
812 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000813 * Indicates that no error occurred.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000814 */
815 CXLoadDiag_None = 0,
816
817 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000818 * Indicates that an unknown error occurred while attempting to
Ted Kremenekd010ba42011-11-10 08:43:12 +0000819 * deserialize diagnostics.
820 */
821 CXLoadDiag_Unknown = 1,
822
823 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000824 * Indicates that the file containing the serialized diagnostics
Ted Kremenekd010ba42011-11-10 08:43:12 +0000825 * could not be opened.
826 */
827 CXLoadDiag_CannotLoad = 2,
828
829 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000830 * Indicates that the serialized diagnostics file is invalid or
James Dennett574cb4c2012-06-15 05:41:51 +0000831 * corrupt.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000832 */
833 CXLoadDiag_InvalidFile = 3
834};
835
836/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000837 * Deserialize a set of diagnostics from a Clang diagnostics bitcode
James Dennett574cb4c2012-06-15 05:41:51 +0000838 * file.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000839 *
James Dennett574cb4c2012-06-15 05:41:51 +0000840 * \param file The name of the file to deserialize.
841 * \param error A pointer to a enum value recording if there was a problem
Ted Kremenekd010ba42011-11-10 08:43:12 +0000842 * deserializing the diagnostics.
James Dennett574cb4c2012-06-15 05:41:51 +0000843 * \param errorString A pointer to a CXString for recording the error string
Ted Kremenekd010ba42011-11-10 08:43:12 +0000844 * if the file was not successfully loaded.
845 *
846 * \returns A loaded CXDiagnosticSet if successful, and NULL otherwise. These
James Dennett574cb4c2012-06-15 05:41:51 +0000847 * diagnostics should be released using clang_disposeDiagnosticSet().
Ted Kremenekd010ba42011-11-10 08:43:12 +0000848 */
849CINDEX_LINKAGE CXDiagnosticSet clang_loadDiagnostics(const char *file,
850 enum CXLoadDiag_Error *error,
851 CXString *errorString);
852
853/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000854 * Release a CXDiagnosticSet and all of its contained diagnostics.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000855 */
856CINDEX_LINKAGE void clang_disposeDiagnosticSet(CXDiagnosticSet Diags);
857
858/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000859 * Retrieve the child diagnostics of a CXDiagnostic.
James Dennett574cb4c2012-06-15 05:41:51 +0000860 *
861 * This CXDiagnosticSet does not need to be released by
Sylvestre Ledrud29d97c2013-11-17 09:46:45 +0000862 * clang_disposeDiagnosticSet.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000863 */
864CINDEX_LINKAGE CXDiagnosticSet clang_getChildDiagnostics(CXDiagnostic D);
865
866/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000867 * Determine the number of diagnostics produced for the given
Douglas Gregor33cdd812010-02-18 18:08:43 +0000868 * translation unit.
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000869 */
Douglas Gregor33cdd812010-02-18 18:08:43 +0000870CINDEX_LINKAGE unsigned clang_getNumDiagnostics(CXTranslationUnit Unit);
871
872/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000873 * Retrieve a diagnostic associated with the given translation unit.
Douglas Gregor33cdd812010-02-18 18:08:43 +0000874 *
875 * \param Unit the translation unit to query.
876 * \param Index the zero-based diagnostic number to retrieve.
877 *
878 * \returns the requested diagnostic. This diagnostic must be freed
879 * via a call to \c clang_disposeDiagnostic().
880 */
881CINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit,
882 unsigned Index);
883
884/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000885 * Retrieve the complete set of diagnostics associated with a
Ted Kremenekb4a8b052011-12-09 22:28:32 +0000886 * translation unit.
887 *
888 * \param Unit the translation unit to query.
889 */
890CINDEX_LINKAGE CXDiagnosticSet
891 clang_getDiagnosticSetFromTU(CXTranslationUnit Unit);
892
893/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000894 * Destroy a diagnostic.
Douglas Gregor33cdd812010-02-18 18:08:43 +0000895 */
896CINDEX_LINKAGE void clang_disposeDiagnostic(CXDiagnostic Diagnostic);
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000897
898/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000899 * Options to control the display of diagnostics.
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000900 *
901 * The values in this enum are meant to be combined to customize the
Sylvestre Ledrud29d97c2013-11-17 09:46:45 +0000902 * behavior of \c clang_formatDiagnostic().
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000903 */
904enum CXDiagnosticDisplayOptions {
905 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000906 * Display the source-location information where the
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000907 * diagnostic was located.
908 *
909 * When set, diagnostics will be prefixed by the file, line, and
910 * (optionally) column to which the diagnostic refers. For example,
911 *
912 * \code
913 * test.c:28: warning: extra tokens at end of #endif directive
914 * \endcode
915 *
916 * This option corresponds to the clang flag \c -fshow-source-location.
917 */
918 CXDiagnostic_DisplaySourceLocation = 0x01,
919
920 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000921 * If displaying the source-location information of the
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000922 * diagnostic, also include the column number.
923 *
924 * This option corresponds to the clang flag \c -fshow-column.
925 */
926 CXDiagnostic_DisplayColumn = 0x02,
927
928 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000929 * If displaying the source-location information of the
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000930 * diagnostic, also include information about source ranges in a
931 * machine-parsable format.
932 *
Ted Kremenekd071c602010-03-13 02:50:34 +0000933 * This option corresponds to the clang flag
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000934 * \c -fdiagnostics-print-source-range-info.
935 */
Douglas Gregora750e8e2010-11-19 16:18:16 +0000936 CXDiagnostic_DisplaySourceRanges = 0x04,
937
938 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000939 * Display the option name associated with this diagnostic, if any.
Douglas Gregora750e8e2010-11-19 16:18:16 +0000940 *
941 * The option name displayed (e.g., -Wconversion) will be placed in brackets
942 * after the diagnostic text. This option corresponds to the clang flag
943 * \c -fdiagnostics-show-option.
944 */
945 CXDiagnostic_DisplayOption = 0x08,
946
947 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000948 * Display the category number associated with this diagnostic, if any.
Douglas Gregora750e8e2010-11-19 16:18:16 +0000949 *
950 * The category number is displayed within brackets after the diagnostic text.
951 * This option corresponds to the clang flag
952 * \c -fdiagnostics-show-category=id.
953 */
954 CXDiagnostic_DisplayCategoryId = 0x10,
955
956 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000957 * Display the category name associated with this diagnostic, if any.
Douglas Gregora750e8e2010-11-19 16:18:16 +0000958 *
959 * The category name is displayed within brackets after the diagnostic text.
960 * This option corresponds to the clang flag
961 * \c -fdiagnostics-show-category=name.
962 */
963 CXDiagnostic_DisplayCategoryName = 0x20
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000964};
965
966/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000967 * Format the given diagnostic in a manner that is suitable for display.
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000968 *
Douglas Gregord770f732010-02-22 23:17:23 +0000969 * This routine will format the given diagnostic to a string, rendering
Ted Kremenekd071c602010-03-13 02:50:34 +0000970 * the diagnostic according to the various options given. The
971 * \c clang_defaultDiagnosticDisplayOptions() function returns the set of
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000972 * options that most closely mimics the behavior of the clang compiler.
973 *
974 * \param Diagnostic The diagnostic to print.
975 *
Ted Kremenekd071c602010-03-13 02:50:34 +0000976 * \param Options A set of options that control the diagnostic display,
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000977 * created by combining \c CXDiagnosticDisplayOptions values.
Douglas Gregord770f732010-02-22 23:17:23 +0000978 *
979 * \returns A new string containing for formatted diagnostic.
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000980 */
Douglas Gregord770f732010-02-22 23:17:23 +0000981CINDEX_LINKAGE CXString clang_formatDiagnostic(CXDiagnostic Diagnostic,
982 unsigned Options);
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000983
984/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000985 * Retrieve the set of display options most similar to the
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000986 * default behavior of the clang compiler.
987 *
988 * \returns A set of display options suitable for use with \c
Sylvestre Ledrud29d97c2013-11-17 09:46:45 +0000989 * clang_formatDiagnostic().
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000990 */
991CINDEX_LINKAGE unsigned clang_defaultDiagnosticDisplayOptions(void);
992
993/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000994 * Determine the severity of the given diagnostic.
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000995 */
Ted Kremenekd071c602010-03-13 02:50:34 +0000996CINDEX_LINKAGE enum CXDiagnosticSeverity
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000997clang_getDiagnosticSeverity(CXDiagnostic);
998
999/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001000 * Retrieve the source location of the given diagnostic.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001001 *
1002 * This location is where Clang would print the caret ('^') when
1003 * displaying the diagnostic on the command line.
1004 */
1005CINDEX_LINKAGE CXSourceLocation clang_getDiagnosticLocation(CXDiagnostic);
1006
1007/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001008 * Retrieve the text of the given diagnostic.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001009 */
1010CINDEX_LINKAGE CXString clang_getDiagnosticSpelling(CXDiagnostic);
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +00001011
1012/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001013 * Retrieve the name of the command-line option that enabled this
Douglas Gregora750e8e2010-11-19 16:18:16 +00001014 * diagnostic.
1015 *
1016 * \param Diag The diagnostic to be queried.
1017 *
1018 * \param Disable If non-NULL, will be set to the option that disables this
1019 * diagnostic (if any).
1020 *
1021 * \returns A string that contains the command-line option used to enable this
1022 * warning, such as "-Wconversion" or "-pedantic".
1023 */
1024CINDEX_LINKAGE CXString clang_getDiagnosticOption(CXDiagnostic Diag,
1025 CXString *Disable);
1026
1027/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001028 * Retrieve the category number for this diagnostic.
Douglas Gregora750e8e2010-11-19 16:18:16 +00001029 *
1030 * Diagnostics can be categorized into groups along with other, related
1031 * diagnostics (e.g., diagnostics under the same warning flag). This routine
1032 * retrieves the category number for the given diagnostic.
1033 *
1034 * \returns The number of the category that contains this diagnostic, or zero
1035 * if this diagnostic is uncategorized.
1036 */
1037CINDEX_LINKAGE unsigned clang_getDiagnosticCategory(CXDiagnostic);
1038
1039/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001040 * Retrieve the name of a particular diagnostic category. This
Ted Kremenek26a6d492012-04-12 00:03:31 +00001041 * is now deprecated. Use clang_getDiagnosticCategoryText()
1042 * instead.
Douglas Gregora750e8e2010-11-19 16:18:16 +00001043 *
1044 * \param Category A diagnostic category number, as returned by
1045 * \c clang_getDiagnosticCategory().
1046 *
1047 * \returns The name of the given diagnostic category.
1048 */
Ted Kremenek26a6d492012-04-12 00:03:31 +00001049CINDEX_DEPRECATED CINDEX_LINKAGE
1050CXString clang_getDiagnosticCategoryName(unsigned Category);
1051
1052/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001053 * Retrieve the diagnostic category text for a given diagnostic.
Ted Kremenek26a6d492012-04-12 00:03:31 +00001054 *
Ted Kremenek26a6d492012-04-12 00:03:31 +00001055 * \returns The text of the given diagnostic category.
1056 */
1057CINDEX_LINKAGE CXString clang_getDiagnosticCategoryText(CXDiagnostic);
Douglas Gregora750e8e2010-11-19 16:18:16 +00001058
1059/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001060 * Determine the number of source ranges associated with the given
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +00001061 * diagnostic.
1062 */
1063CINDEX_LINKAGE unsigned clang_getDiagnosticNumRanges(CXDiagnostic);
Ted Kremenekd071c602010-03-13 02:50:34 +00001064
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001065/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001066 * Retrieve a source range associated with the diagnostic.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001067 *
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +00001068 * A diagnostic's source ranges highlight important elements in the source
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001069 * code. On the command line, Clang displays source ranges by
Ted Kremenekd071c602010-03-13 02:50:34 +00001070 * underlining them with '~' characters.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001071 *
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +00001072 * \param Diagnostic the diagnostic whose range is being extracted.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001073 *
Ted Kremenekd071c602010-03-13 02:50:34 +00001074 * \param Range the zero-based index specifying which range to
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001075 *
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +00001076 * \returns the requested source range.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001077 */
Ted Kremenekd071c602010-03-13 02:50:34 +00001078CINDEX_LINKAGE CXSourceRange clang_getDiagnosticRange(CXDiagnostic Diagnostic,
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +00001079 unsigned Range);
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001080
1081/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001082 * Determine the number of fix-it hints associated with the
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001083 * given diagnostic.
1084 */
1085CINDEX_LINKAGE unsigned clang_getDiagnosticNumFixIts(CXDiagnostic Diagnostic);
1086
1087/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001088 * Retrieve the replacement information for a given fix-it.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001089 *
Douglas Gregor836ec942010-02-19 18:16:06 +00001090 * Fix-its are described in terms of a source range whose contents
1091 * should be replaced by a string. This approach generalizes over
1092 * three kinds of operations: removal of source code (the range covers
1093 * the code to be removed and the replacement string is empty),
1094 * replacement of source code (the range covers the code to be
1095 * replaced and the replacement string provides the new code), and
1096 * insertion (both the start and end of the range point at the
1097 * insertion location, and the replacement string provides the text to
1098 * insert).
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001099 *
Douglas Gregor836ec942010-02-19 18:16:06 +00001100 * \param Diagnostic The diagnostic whose fix-its are being queried.
1101 *
1102 * \param FixIt The zero-based index of the fix-it.
1103 *
1104 * \param ReplacementRange The source range whose contents will be
1105 * replaced with the returned replacement string. Note that source
1106 * ranges are half-open ranges [a, b), so the source code should be
1107 * replaced from a and up to (but not including) b.
1108 *
1109 * \returns A string containing text that should be replace the source
1110 * code indicated by the \c ReplacementRange.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001111 */
Ted Kremenekd071c602010-03-13 02:50:34 +00001112CINDEX_LINKAGE CXString clang_getDiagnosticFixIt(CXDiagnostic Diagnostic,
Douglas Gregor836ec942010-02-19 18:16:06 +00001113 unsigned FixIt,
1114 CXSourceRange *ReplacementRange);
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001115
1116/**
1117 * @}
1118 */
1119
1120/**
1121 * \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation
1122 *
1123 * The routines in this group provide the ability to create and destroy
1124 * translation units from files, either by parsing the contents of the files or
1125 * by reading in a serialized representation of a translation unit.
1126 *
1127 * @{
1128 */
Ted Kremenekd071c602010-03-13 02:50:34 +00001129
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001130/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001131 * Get the original translation unit source file name.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001132 */
1133CINDEX_LINKAGE CXString
1134clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit);
1135
1136/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001137 * Return the CXTranslationUnit for a given source file and the provided
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001138 * command line arguments one would pass to the compiler.
1139 *
1140 * Note: The 'source_filename' argument is optional. If the caller provides a
1141 * NULL pointer, the name of the source file is expected to reside in the
1142 * specified command line arguments.
1143 *
1144 * Note: When encountered in 'clang_command_line_args', the following options
1145 * are ignored:
1146 *
1147 * '-c'
1148 * '-emit-ast'
1149 * '-fsyntax-only'
James Dennett574cb4c2012-06-15 05:41:51 +00001150 * '-o \<output file>' (both '-o' and '\<output file>' are ignored)
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001151 *
Ted Kremenekbd4972442010-11-08 04:28:51 +00001152 * \param CIdx The index object with which the translation unit will be
1153 * associated.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001154 *
James Dennett574cb4c2012-06-15 05:41:51 +00001155 * \param source_filename The name of the source file to load, or NULL if the
Ted Kremenekbd4972442010-11-08 04:28:51 +00001156 * source file is included in \p clang_command_line_args.
1157 *
1158 * \param num_clang_command_line_args The number of command-line arguments in
1159 * \p clang_command_line_args.
1160 *
1161 * \param clang_command_line_args The command-line arguments that would be
1162 * passed to the \c clang executable if it were being invoked out-of-process.
1163 * These command-line options will be parsed and will affect how the translation
1164 * unit is parsed. Note that the following options are ignored: '-c',
James Dennett574cb4c2012-06-15 05:41:51 +00001165 * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001166 *
1167 * \param num_unsaved_files the number of unsaved file entries in \p
1168 * unsaved_files.
1169 *
1170 * \param unsaved_files the files that have not yet been saved to disk
1171 * but may be required for code completion, including the contents of
Ted Kremenekde24a942010-04-12 18:47:26 +00001172 * those files. The contents and name of these files (as specified by
1173 * CXUnsavedFile) are copied when necessary, so the client only needs to
1174 * guarantee their validity until the call to this function returns.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001175 */
1176CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnitFromSourceFile(
1177 CXIndex CIdx,
1178 const char *source_filename,
1179 int num_clang_command_line_args,
Douglas Gregor57879fa2010-09-01 16:43:19 +00001180 const char * const *clang_command_line_args,
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001181 unsigned num_unsaved_files,
Douglas Gregor33cdd812010-02-18 18:08:43 +00001182 struct CXUnsavedFile *unsaved_files);
Ted Kremenekd071c602010-03-13 02:50:34 +00001183
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001184/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001185 * Same as \c clang_createTranslationUnit2, but returns
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001186 * the \c CXTranslationUnit instead of an error code. In case of an error this
1187 * routine returns a \c NULL \c CXTranslationUnit, without further detailed
1188 * error codes.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001189 */
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001190CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnit(
1191 CXIndex CIdx,
1192 const char *ast_filename);
1193
1194/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001195 * Create a translation unit from an AST file (\c -emit-ast).
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001196 *
1197 * \param[out] out_TU A non-NULL pointer to store the created
1198 * \c CXTranslationUnit.
1199 *
1200 * \returns Zero on success, otherwise returns an error code.
1201 */
1202CINDEX_LINKAGE enum CXErrorCode clang_createTranslationUnit2(
1203 CXIndex CIdx,
1204 const char *ast_filename,
1205 CXTranslationUnit *out_TU);
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001206
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001207/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001208 * Flags that control the creation of translation units.
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001209 *
1210 * The enumerators in this enumeration type are meant to be bitwise
1211 * ORed together to specify which options should be used when
1212 * constructing the translation unit.
1213 */
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001214enum CXTranslationUnit_Flags {
1215 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001216 * Used to indicate that no special translation-unit options are
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001217 * needed.
1218 */
1219 CXTranslationUnit_None = 0x0,
1220
1221 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001222 * Used to indicate that the parser should construct a "detailed"
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001223 * preprocessing record, including all macro definitions and instantiations.
1224 *
1225 * Constructing a detailed preprocessing record requires more memory
1226 * and time to parse, since the information contained in the record
1227 * is usually not retained. However, it can be useful for
1228 * applications that require more detailed information about the
1229 * behavior of the preprocessor.
1230 */
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001231 CXTranslationUnit_DetailedPreprocessingRecord = 0x01,
1232
1233 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001234 * Used to indicate that the translation unit is incomplete.
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001235 *
Douglas Gregor4a47bca2010-08-09 22:28:58 +00001236 * When a translation unit is considered "incomplete", semantic
1237 * analysis that is typically performed at the end of the
1238 * translation unit will be suppressed. For example, this suppresses
1239 * the completion of tentative declarations in C and of
1240 * instantiation of implicitly-instantiation function templates in
1241 * C++. This option is typically used when parsing a header with the
1242 * intent of producing a precompiled header.
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001243 */
Douglas Gregor4a47bca2010-08-09 22:28:58 +00001244 CXTranslationUnit_Incomplete = 0x02,
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001245
1246 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001247 * Used to indicate that the translation unit should be built with an
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001248 * implicit precompiled header for the preamble.
1249 *
1250 * An implicit precompiled header is used as an optimization when a
1251 * particular translation unit is likely to be reparsed many times
1252 * when the sources aren't changing that often. In this case, an
1253 * implicit precompiled header will be built containing all of the
1254 * initial includes at the top of the main file (what we refer to as
1255 * the "preamble" of the file). In subsequent parses, if the
1256 * preamble or the files in it have not changed, \c
1257 * clang_reparseTranslationUnit() will re-use the implicit
1258 * precompiled header to improve parsing performance.
1259 */
Douglas Gregorde051182010-08-11 15:58:42 +00001260 CXTranslationUnit_PrecompiledPreamble = 0x04,
1261
1262 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001263 * Used to indicate that the translation unit should cache some
Douglas Gregorde051182010-08-11 15:58:42 +00001264 * code-completion results with each reparse of the source file.
1265 *
1266 * Caching of code-completion results is a performance optimization that
1267 * introduces some overhead to reparsing but improves the performance of
1268 * code-completion operations.
1269 */
Douglas Gregorf5a18542010-10-27 17:24:53 +00001270 CXTranslationUnit_CacheCompletionResults = 0x08,
Argyrios Kyrtzidis0db720f2012-10-11 16:05:00 +00001271
Douglas Gregorf5a18542010-10-27 17:24:53 +00001272 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001273 * Used to indicate that the translation unit will be serialized with
Argyrios Kyrtzidis0db720f2012-10-11 16:05:00 +00001274 * \c clang_saveTranslationUnit.
Douglas Gregorf5a18542010-10-27 17:24:53 +00001275 *
Argyrios Kyrtzidis0db720f2012-10-11 16:05:00 +00001276 * This option is typically used when parsing a header with the intent of
1277 * producing a precompiled header.
Douglas Gregorf5a18542010-10-27 17:24:53 +00001278 */
Argyrios Kyrtzidis0db720f2012-10-11 16:05:00 +00001279 CXTranslationUnit_ForSerialization = 0x10,
Douglas Gregorf5a18542010-10-27 17:24:53 +00001280
1281 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001282 * DEPRECATED: Enabled chained precompiled preambles in C++.
Douglas Gregorf5a18542010-10-27 17:24:53 +00001283 *
1284 * Note: this is a *temporary* option that is available only while
Douglas Gregor2ed0ee12011-08-25 22:54:01 +00001285 * we are testing C++ precompiled preamble support. It is deprecated.
Douglas Gregorf5a18542010-10-27 17:24:53 +00001286 */
Erik Verbruggen6e922512012-04-12 10:11:59 +00001287 CXTranslationUnit_CXXChainedPCH = 0x20,
1288
1289 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001290 * Used to indicate that function/method bodies should be skipped while
Erik Verbruggen6e922512012-04-12 10:11:59 +00001291 * parsing.
1292 *
1293 * This option can be used to search for declarations/definitions while
1294 * ignoring the usages.
1295 */
Dmitri Gribenko3292d062012-07-02 17:35:10 +00001296 CXTranslationUnit_SkipFunctionBodies = 0x40,
1297
1298 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001299 * Used to indicate that brief documentation comments should be
Dmitri Gribenko3292d062012-07-02 17:35:10 +00001300 * included into the set of code completions returned from this translation
1301 * unit.
1302 */
Benjamin Kramer5c248d82015-12-15 09:30:31 +00001303 CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 0x80,
1304
1305 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001306 * Used to indicate that the precompiled preamble should be created on
Benjamin Kramer5c248d82015-12-15 09:30:31 +00001307 * the first parse. Otherwise it will be created on the first reparse. This
1308 * trades runtime on the first parse (serializing the preamble takes time) for
1309 * reduced runtime on the second parse (can now reuse the preamble).
1310 */
Manuel Klimek016c0242016-03-01 10:56:19 +00001311 CXTranslationUnit_CreatePreambleOnFirstParse = 0x100,
1312
1313 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001314 * Do not stop processing when fatal errors are encountered.
Manuel Klimek016c0242016-03-01 10:56:19 +00001315 *
1316 * When fatal errors are encountered while parsing a translation unit,
1317 * semantic analysis is typically stopped early when compiling code. A common
1318 * source for fatal errors are unresolvable include files. For the
1319 * purposes of an IDE, this is undesirable behavior and as much information
1320 * as possible should be reported. Use this flag to enable this behavior.
1321 */
Argyrios Kyrtzidis735e92c2017-06-09 01:20:48 +00001322 CXTranslationUnit_KeepGoing = 0x200,
1323
Ivan Donchevskiif70d28b2018-05-17 09:15:22 +00001324 /**
1325 * Sets the preprocessor in a mode for parsing a single file only.
1326 */
Ivan Donchevskii6e895282018-05-17 09:24:37 +00001327 CXTranslationUnit_SingleFileParse = 0x400,
1328
1329 /**
1330 * \brief Used in combination with CXTranslationUnit_SkipFunctionBodies to
1331 * constrain the skipping of function bodies to the preamble.
1332 *
1333 * The function bodies of the main file are not skipped.
1334 */
1335 CXTranslationUnit_LimitSkipFunctionBodiesToPreamble = 0x800
Ivan Donchevskiif70d28b2018-05-17 09:15:22 +00001336};
1337
1338/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001339 * Returns the set of flags that is suitable for parsing a translation
Douglas Gregor4a47bca2010-08-09 22:28:58 +00001340 * unit that is being edited.
1341 *
1342 * The set of flags returned provide options for \c clang_parseTranslationUnit()
1343 * to indicate that the translation unit is likely to be reparsed many times,
1344 * either explicitly (via \c clang_reparseTranslationUnit()) or implicitly
1345 * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag
1346 * set contains an unspecified set of optimizations (e.g., the precompiled
1347 * preamble) geared toward improving the performance of these routines. The
1348 * set of optimizations enabled may change from one version to the next.
1349 */
Douglas Gregorde051182010-08-11 15:58:42 +00001350CINDEX_LINKAGE unsigned clang_defaultEditingTranslationUnitOptions(void);
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001351
1352/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001353 * Same as \c clang_parseTranslationUnit2, but returns
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001354 * the \c CXTranslationUnit instead of an error code. In case of an error this
1355 * routine returns a \c NULL \c CXTranslationUnit, without further detailed
1356 * error codes.
1357 */
1358CINDEX_LINKAGE CXTranslationUnit
1359clang_parseTranslationUnit(CXIndex CIdx,
1360 const char *source_filename,
1361 const char *const *command_line_args,
1362 int num_command_line_args,
1363 struct CXUnsavedFile *unsaved_files,
1364 unsigned num_unsaved_files,
1365 unsigned options);
1366
Douglas Gregor4a47bca2010-08-09 22:28:58 +00001367/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001368 * Parse the given source file and the translation unit corresponding
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001369 * to that file.
1370 *
1371 * This routine is the main entry point for the Clang C API, providing the
1372 * ability to parse a source file into a translation unit that can then be
1373 * queried by other functions in the API. This routine accepts a set of
1374 * command-line arguments so that the compilation can be configured in the same
1375 * way that the compiler is configured on the command line.
1376 *
1377 * \param CIdx The index object with which the translation unit will be
1378 * associated.
1379 *
1380 * \param source_filename The name of the source file to load, or NULL if the
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001381 * source file is included in \c command_line_args.
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001382 *
1383 * \param command_line_args The command-line arguments that would be
1384 * passed to the \c clang executable if it were being invoked out-of-process.
1385 * These command-line options will be parsed and will affect how the translation
1386 * unit is parsed. Note that the following options are ignored: '-c',
James Dennett574cb4c2012-06-15 05:41:51 +00001387 * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001388 *
1389 * \param num_command_line_args The number of command-line arguments in
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001390 * \c command_line_args.
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001391 *
1392 * \param unsaved_files the files that have not yet been saved to disk
Douglas Gregor8e984da2010-08-04 16:47:14 +00001393 * but may be required for parsing, including the contents of
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001394 * those files. The contents and name of these files (as specified by
1395 * CXUnsavedFile) are copied when necessary, so the client only needs to
1396 * guarantee their validity until the call to this function returns.
1397 *
1398 * \param num_unsaved_files the number of unsaved file entries in \p
1399 * unsaved_files.
1400 *
1401 * \param options A bitmask of options that affects how the translation unit
1402 * is managed but not its compilation. This should be a bitwise OR of the
1403 * CXTranslationUnit_XXX flags.
1404 *
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001405 * \param[out] out_TU A non-NULL pointer to store the created
1406 * \c CXTranslationUnit, describing the parsed code and containing any
1407 * diagnostics produced by the compiler.
1408 *
1409 * \returns Zero on success, otherwise returns an error code.
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001410 */
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001411CINDEX_LINKAGE enum CXErrorCode
1412clang_parseTranslationUnit2(CXIndex CIdx,
1413 const char *source_filename,
1414 const char *const *command_line_args,
1415 int num_command_line_args,
1416 struct CXUnsavedFile *unsaved_files,
1417 unsigned num_unsaved_files,
1418 unsigned options,
1419 CXTranslationUnit *out_TU);
1420
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001421/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001422 * Same as clang_parseTranslationUnit2 but requires a full command line
Benjamin Kramerc02670e2015-11-18 16:14:27 +00001423 * for \c command_line_args including argv[0]. This is useful if the standard
1424 * library paths are relative to the binary.
1425 */
1426CINDEX_LINKAGE enum CXErrorCode clang_parseTranslationUnit2FullArgv(
1427 CXIndex CIdx, const char *source_filename,
1428 const char *const *command_line_args, int num_command_line_args,
1429 struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files,
1430 unsigned options, CXTranslationUnit *out_TU);
1431
1432/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001433 * Flags that control how translation units are saved.
Douglas Gregor6bb92ec2010-08-13 15:35:05 +00001434 *
1435 * The enumerators in this enumeration type are meant to be bitwise
1436 * ORed together to specify which options should be used when
1437 * saving the translation unit.
1438 */
1439enum CXSaveTranslationUnit_Flags {
1440 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001441 * Used to indicate that no special saving options are needed.
Douglas Gregor6bb92ec2010-08-13 15:35:05 +00001442 */
1443 CXSaveTranslationUnit_None = 0x0
1444};
1445
1446/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001447 * Returns the set of flags that is suitable for saving a translation
Douglas Gregor6bb92ec2010-08-13 15:35:05 +00001448 * unit.
1449 *
1450 * The set of flags returned provide options for
1451 * \c clang_saveTranslationUnit() by default. The returned flag
1452 * set contains an unspecified set of options that save translation units with
1453 * the most commonly-requested data.
1454 */
1455CINDEX_LINKAGE unsigned clang_defaultSaveOptions(CXTranslationUnit TU);
1456
1457/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001458 * Describes the kind of error that occurred (if any) in a call to
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001459 * \c clang_saveTranslationUnit().
1460 */
1461enum CXSaveError {
1462 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001463 * Indicates that no error occurred while saving a translation unit.
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001464 */
1465 CXSaveError_None = 0,
1466
1467 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001468 * Indicates that an unknown error occurred while attempting to save
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001469 * the file.
1470 *
1471 * This error typically indicates that file I/O failed when attempting to
1472 * write the file.
1473 */
1474 CXSaveError_Unknown = 1,
1475
1476 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001477 * Indicates that errors during translation prevented this attempt
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001478 * to save the translation unit.
1479 *
1480 * Errors that prevent the translation unit from being saved can be
1481 * extracted using \c clang_getNumDiagnostics() and \c clang_getDiagnostic().
1482 */
1483 CXSaveError_TranslationErrors = 2,
1484
1485 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001486 * Indicates that the translation unit to be saved was somehow
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001487 * invalid (e.g., NULL).
1488 */
1489 CXSaveError_InvalidTU = 3
1490};
1491
1492/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001493 * Saves a translation unit into a serialized representation of
Douglas Gregore9386682010-08-13 05:36:37 +00001494 * that translation unit on disk.
1495 *
1496 * Any translation unit that was parsed without error can be saved
1497 * into a file. The translation unit can then be deserialized into a
1498 * new \c CXTranslationUnit with \c clang_createTranslationUnit() or,
1499 * if it is an incomplete translation unit that corresponds to a
1500 * header, used as a precompiled header when parsing other translation
1501 * units.
1502 *
1503 * \param TU The translation unit to save.
Douglas Gregor6bb92ec2010-08-13 15:35:05 +00001504 *
Douglas Gregore9386682010-08-13 05:36:37 +00001505 * \param FileName The file to which the translation unit will be saved.
1506 *
Douglas Gregor6bb92ec2010-08-13 15:35:05 +00001507 * \param options A bitmask of options that affects how the translation unit
1508 * is saved. This should be a bitwise OR of the
1509 * CXSaveTranslationUnit_XXX flags.
1510 *
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001511 * \returns A value that will match one of the enumerators of the CXSaveError
1512 * enumeration. Zero (CXSaveError_None) indicates that the translation unit was
1513 * saved successfully, while a non-zero value indicates that a problem occurred.
Douglas Gregore9386682010-08-13 05:36:37 +00001514 */
1515CINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU,
Douglas Gregor6bb92ec2010-08-13 15:35:05 +00001516 const char *FileName,
1517 unsigned options);
Douglas Gregore9386682010-08-13 05:36:37 +00001518
1519/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001520 * Suspend a translation unit in order to free memory associated with it.
Erik Verbruggen346066b2017-05-30 14:25:54 +00001521 *
1522 * A suspended translation unit uses significantly less memory but on the other
1523 * side does not support any other calls than \c clang_reparseTranslationUnit
1524 * to resume it or \c clang_disposeTranslationUnit to dispose it completely.
1525 */
1526CINDEX_LINKAGE unsigned clang_suspendTranslationUnit(CXTranslationUnit);
1527
1528/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001529 * Destroy the specified CXTranslationUnit object.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001530 */
1531CINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit);
Ted Kremenekd071c602010-03-13 02:50:34 +00001532
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001533/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001534 * Flags that control the reparsing of translation units.
Douglas Gregorde051182010-08-11 15:58:42 +00001535 *
1536 * The enumerators in this enumeration type are meant to be bitwise
1537 * ORed together to specify which options should be used when
1538 * reparsing the translation unit.
1539 */
1540enum CXReparse_Flags {
1541 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001542 * Used to indicate that no special reparsing options are needed.
Douglas Gregorde051182010-08-11 15:58:42 +00001543 */
1544 CXReparse_None = 0x0
1545};
1546
1547/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001548 * Returns the set of flags that is suitable for reparsing a translation
Douglas Gregorde051182010-08-11 15:58:42 +00001549 * unit.
1550 *
1551 * The set of flags returned provide options for
1552 * \c clang_reparseTranslationUnit() by default. The returned flag
1553 * set contains an unspecified set of optimizations geared toward common uses
1554 * of reparsing. The set of optimizations enabled may change from one version
1555 * to the next.
1556 */
1557CINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU);
1558
1559/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001560 * Reparse the source files that produced this translation unit.
Douglas Gregoraa21cc42010-07-19 21:46:24 +00001561 *
1562 * This routine can be used to re-parse the source files that originally
1563 * created the given translation unit, for example because those source files
1564 * have changed (either on disk or as passed via \p unsaved_files). The
1565 * source code will be reparsed with the same command-line options as it
1566 * was originally parsed.
1567 *
1568 * Reparsing a translation unit invalidates all cursors and source locations
1569 * that refer into that translation unit. This makes reparsing a translation
1570 * unit semantically equivalent to destroying the translation unit and then
1571 * creating a new translation unit with the same command-line arguments.
1572 * However, it may be more efficient to reparse a translation
1573 * unit using this routine.
1574 *
1575 * \param TU The translation unit whose contents will be re-parsed. The
1576 * translation unit must originally have been built with
1577 * \c clang_createTranslationUnitFromSourceFile().
1578 *
1579 * \param num_unsaved_files The number of unsaved file entries in \p
1580 * unsaved_files.
1581 *
1582 * \param unsaved_files The files that have not yet been saved to disk
1583 * but may be required for parsing, including the contents of
1584 * those files. The contents and name of these files (as specified by
1585 * CXUnsavedFile) are copied when necessary, so the client only needs to
1586 * guarantee their validity until the call to this function returns.
1587 *
Douglas Gregorde051182010-08-11 15:58:42 +00001588 * \param options A bitset of options composed of the flags in CXReparse_Flags.
1589 * The function \c clang_defaultReparseOptions() produces a default set of
1590 * options recommended for most uses, based on the translation unit.
1591 *
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001592 * \returns 0 if the sources could be reparsed. A non-zero error code will be
Douglas Gregoraa21cc42010-07-19 21:46:24 +00001593 * returned if reparsing was impossible, such that the translation unit is
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001594 * invalid. In such cases, the only valid call for \c TU is
1595 * \c clang_disposeTranslationUnit(TU). The error codes returned by this
1596 * routine are described by the \c CXErrorCode enum.
Douglas Gregoraa21cc42010-07-19 21:46:24 +00001597 */
1598CINDEX_LINKAGE int clang_reparseTranslationUnit(CXTranslationUnit TU,
1599 unsigned num_unsaved_files,
Douglas Gregorde051182010-08-11 15:58:42 +00001600 struct CXUnsavedFile *unsaved_files,
1601 unsigned options);
Ted Kremenek83f642e2011-04-18 22:47:10 +00001602
1603/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001604 * Categorizes how memory is being used by a translation unit.
Ted Kremenek83f642e2011-04-18 22:47:10 +00001605 */
Ted Kremenek23324122011-04-20 16:41:07 +00001606enum CXTUResourceUsageKind {
1607 CXTUResourceUsage_AST = 1,
1608 CXTUResourceUsage_Identifiers = 2,
1609 CXTUResourceUsage_Selectors = 3,
1610 CXTUResourceUsage_GlobalCompletionResults = 4,
Ted Kremenek21735e62011-04-28 04:10:31 +00001611 CXTUResourceUsage_SourceManagerContentCache = 5,
Ted Kremenekf5df0ce2011-04-28 04:53:38 +00001612 CXTUResourceUsage_AST_SideTables = 6,
Ted Kremenek8d587902011-04-28 20:36:42 +00001613 CXTUResourceUsage_SourceManager_Membuffer_Malloc = 7,
Ted Kremenek5e1ed7b2011-04-28 23:46:20 +00001614 CXTUResourceUsage_SourceManager_Membuffer_MMap = 8,
1615 CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc = 9,
1616 CXTUResourceUsage_ExternalASTSource_Membuffer_MMap = 10,
Ted Kremenek2160a0d2011-05-04 01:38:46 +00001617 CXTUResourceUsage_Preprocessor = 11,
1618 CXTUResourceUsage_PreprocessingRecord = 12,
Ted Kremenek120992a2011-07-26 23:46:06 +00001619 CXTUResourceUsage_SourceManager_DataStructures = 13,
Ted Kremenekfbcce6f2011-07-26 23:46:11 +00001620 CXTUResourceUsage_Preprocessor_HeaderSearch = 14,
Ted Kremenek23324122011-04-20 16:41:07 +00001621 CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST,
1622 CXTUResourceUsage_MEMORY_IN_BYTES_END =
Ted Kremenekfbcce6f2011-07-26 23:46:11 +00001623 CXTUResourceUsage_Preprocessor_HeaderSearch,
Ted Kremenek23324122011-04-20 16:41:07 +00001624
1625 CXTUResourceUsage_First = CXTUResourceUsage_AST,
Ted Kremenekfbcce6f2011-07-26 23:46:11 +00001626 CXTUResourceUsage_Last = CXTUResourceUsage_Preprocessor_HeaderSearch
Ted Kremenek83f642e2011-04-18 22:47:10 +00001627};
1628
1629/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001630 * Returns the human-readable null-terminated C string that represents
Ted Kremenek23324122011-04-20 16:41:07 +00001631 * the name of the memory category. This string should never be freed.
Ted Kremenek83f642e2011-04-18 22:47:10 +00001632 */
1633CINDEX_LINKAGE
Ted Kremenek23324122011-04-20 16:41:07 +00001634const char *clang_getTUResourceUsageName(enum CXTUResourceUsageKind kind);
Ted Kremenek83f642e2011-04-18 22:47:10 +00001635
Ted Kremenek23324122011-04-20 16:41:07 +00001636typedef struct CXTUResourceUsageEntry {
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001637 /* The memory usage category. */
Ted Kremenek23324122011-04-20 16:41:07 +00001638 enum CXTUResourceUsageKind kind;
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001639 /* Amount of resources used.
Ted Kremenek23324122011-04-20 16:41:07 +00001640 The units will depend on the resource kind. */
Ted Kremenek83f642e2011-04-18 22:47:10 +00001641 unsigned long amount;
Ted Kremenek23324122011-04-20 16:41:07 +00001642} CXTUResourceUsageEntry;
Ted Kremenek83f642e2011-04-18 22:47:10 +00001643
1644/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001645 * The memory usage of a CXTranslationUnit, broken into categories.
Ted Kremenek83f642e2011-04-18 22:47:10 +00001646 */
Ted Kremenek23324122011-04-20 16:41:07 +00001647typedef struct CXTUResourceUsage {
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001648 /* Private data member, used for queries. */
Ted Kremenek83f642e2011-04-18 22:47:10 +00001649 void *data;
1650
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001651 /* The number of entries in the 'entries' array. */
Ted Kremenek83f642e2011-04-18 22:47:10 +00001652 unsigned numEntries;
1653
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001654 /* An array of key-value pairs, representing the breakdown of memory
Ted Kremenek83f642e2011-04-18 22:47:10 +00001655 usage. */
Ted Kremenek23324122011-04-20 16:41:07 +00001656 CXTUResourceUsageEntry *entries;
Ted Kremenek83f642e2011-04-18 22:47:10 +00001657
Ted Kremenek23324122011-04-20 16:41:07 +00001658} CXTUResourceUsage;
Ted Kremenek83f642e2011-04-18 22:47:10 +00001659
1660/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001661 * Return the memory usage of a translation unit. This object
Ted Kremenek23324122011-04-20 16:41:07 +00001662 * should be released with clang_disposeCXTUResourceUsage().
Ted Kremenek83f642e2011-04-18 22:47:10 +00001663 */
Ted Kremenek23324122011-04-20 16:41:07 +00001664CINDEX_LINKAGE CXTUResourceUsage clang_getCXTUResourceUsage(CXTranslationUnit TU);
Ted Kremenek83f642e2011-04-18 22:47:10 +00001665
Ted Kremenek23324122011-04-20 16:41:07 +00001666CINDEX_LINKAGE void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage);
Ted Kremenek83f642e2011-04-18 22:47:10 +00001667
Douglas Gregoraa21cc42010-07-19 21:46:24 +00001668/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001669 * Get target information for this translation unit.
Emilio Cobos Alvarez485ad422017-04-28 15:56:39 +00001670 *
1671 * The CXTargetInfo object cannot outlive the CXTranslationUnit object.
1672 */
1673CINDEX_LINKAGE CXTargetInfo
1674clang_getTranslationUnitTargetInfo(CXTranslationUnit CTUnit);
1675
1676/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001677 * Destroy the CXTargetInfo object.
Emilio Cobos Alvarez485ad422017-04-28 15:56:39 +00001678 */
1679CINDEX_LINKAGE void
1680clang_TargetInfo_dispose(CXTargetInfo Info);
1681
1682/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001683 * Get the normalized target triple as a string.
Emilio Cobos Alvarez485ad422017-04-28 15:56:39 +00001684 *
1685 * Returns the empty string in case of any error.
1686 */
1687CINDEX_LINKAGE CXString
1688clang_TargetInfo_getTriple(CXTargetInfo Info);
1689
1690/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001691 * Get the pointer width of the target in bits.
Emilio Cobos Alvarez485ad422017-04-28 15:56:39 +00001692 *
1693 * Returns -1 in case of error.
1694 */
1695CINDEX_LINKAGE int
1696clang_TargetInfo_getPointerWidth(CXTargetInfo Info);
1697
1698/**
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001699 * @}
1700 */
Ted Kremenekd071c602010-03-13 02:50:34 +00001701
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001702/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001703 * Describes the kind of entity that a cursor refers to.
Douglas Gregor6007cf22010-01-22 22:29:16 +00001704 */
1705enum CXCursorKind {
1706 /* Declarations */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001707 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001708 * A declaration whose specific kind is not exposed via this
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001709 * interface.
Douglas Gregor6007cf22010-01-22 22:29:16 +00001710 *
1711 * Unexposed declarations have the same operations as any other kind
1712 * of declaration; one can extract their location information,
1713 * spelling, find their definitions, etc. However, the specific kind
1714 * of the declaration is not reported.
1715 */
1716 CXCursor_UnexposedDecl = 1,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001717 /** A C or C++ struct. */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001718 CXCursor_StructDecl = 2,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001719 /** A C or C++ union. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001720 CXCursor_UnionDecl = 3,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001721 /** A C++ class. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001722 CXCursor_ClassDecl = 4,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001723 /** An enumeration. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001724 CXCursor_EnumDecl = 5,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001725 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001726 * A field (in C) or non-static data member (in C++) in a
Douglas Gregor6007cf22010-01-22 22:29:16 +00001727 * struct, union, or C++ class.
1728 */
1729 CXCursor_FieldDecl = 6,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001730 /** An enumerator constant. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001731 CXCursor_EnumConstantDecl = 7,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001732 /** A function. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001733 CXCursor_FunctionDecl = 8,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001734 /** A variable. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001735 CXCursor_VarDecl = 9,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001736 /** A function or method parameter. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001737 CXCursor_ParmDecl = 10,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001738 /** An Objective-C \@interface. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001739 CXCursor_ObjCInterfaceDecl = 11,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001740 /** An Objective-C \@interface for a category. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001741 CXCursor_ObjCCategoryDecl = 12,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001742 /** An Objective-C \@protocol declaration. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001743 CXCursor_ObjCProtocolDecl = 13,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001744 /** An Objective-C \@property declaration. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001745 CXCursor_ObjCPropertyDecl = 14,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001746 /** An Objective-C instance variable. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001747 CXCursor_ObjCIvarDecl = 15,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001748 /** An Objective-C instance method. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001749 CXCursor_ObjCInstanceMethodDecl = 16,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001750 /** An Objective-C class method. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001751 CXCursor_ObjCClassMethodDecl = 17,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001752 /** An Objective-C \@implementation. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001753 CXCursor_ObjCImplementationDecl = 18,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001754 /** An Objective-C \@implementation for a category. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001755 CXCursor_ObjCCategoryImplDecl = 19,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001756 /** A typedef. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001757 CXCursor_TypedefDecl = 20,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001758 /** A C++ class method. */
Ted Kremenek225b8e32010-04-13 23:39:06 +00001759 CXCursor_CXXMethod = 21,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001760 /** A C++ namespace. */
Ted Kremenekbd67fb22010-05-06 23:38:21 +00001761 CXCursor_Namespace = 22,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001762 /** A linkage specification, e.g. 'extern "C"'. */
Ted Kremenekb80cba52010-05-07 01:04:29 +00001763 CXCursor_LinkageSpec = 23,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001764 /** A C++ constructor. */
Douglas Gregor12bca222010-08-31 14:41:23 +00001765 CXCursor_Constructor = 24,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001766 /** A C++ destructor. */
Douglas Gregor12bca222010-08-31 14:41:23 +00001767 CXCursor_Destructor = 25,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001768 /** A C++ conversion function. */
Douglas Gregor12bca222010-08-31 14:41:23 +00001769 CXCursor_ConversionFunction = 26,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001770 /** A C++ template type parameter. */
Douglas Gregor713602b2010-08-31 17:01:39 +00001771 CXCursor_TemplateTypeParameter = 27,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001772 /** A C++ non-type template parameter. */
Douglas Gregor713602b2010-08-31 17:01:39 +00001773 CXCursor_NonTypeTemplateParameter = 28,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001774 /** A C++ template template parameter. */
Douglas Gregor713602b2010-08-31 17:01:39 +00001775 CXCursor_TemplateTemplateParameter = 29,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001776 /** A C++ function template. */
Douglas Gregor713602b2010-08-31 17:01:39 +00001777 CXCursor_FunctionTemplate = 30,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001778 /** A C++ class template. */
Douglas Gregor1fbaeb12010-08-31 19:02:00 +00001779 CXCursor_ClassTemplate = 31,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001780 /** A C++ class template partial specialization. */
Douglas Gregorf96abb22010-08-31 19:31:58 +00001781 CXCursor_ClassTemplatePartialSpecialization = 32,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001782 /** A C++ namespace alias declaration. */
Douglas Gregora89314e2010-08-31 23:48:11 +00001783 CXCursor_NamespaceAlias = 33,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001784 /** A C++ using directive. */
Douglas Gregor01a430132010-09-01 03:07:18 +00001785 CXCursor_UsingDirective = 34,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001786 /** A C++ using declaration. */
Douglas Gregora9aa29c2010-09-01 19:52:22 +00001787 CXCursor_UsingDeclaration = 35,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001788 /** A C++ alias declaration */
Richard Smithdda56e42011-04-15 14:24:37 +00001789 CXCursor_TypeAliasDecl = 36,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001790 /** An Objective-C \@synthesize definition. */
Douglas Gregor4cd65962011-06-03 23:08:58 +00001791 CXCursor_ObjCSynthesizeDecl = 37,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001792 /** An Objective-C \@dynamic definition. */
Douglas Gregor4cd65962011-06-03 23:08:58 +00001793 CXCursor_ObjCDynamicDecl = 38,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001794 /** An access specifier. */
Argyrios Kyrtzidis12afd702011-09-30 17:58:23 +00001795 CXCursor_CXXAccessSpecifier = 39,
Douglas Gregor4c362d52011-10-05 19:00:14 +00001796
Ted Kremenek08de5c12010-05-19 21:51:10 +00001797 CXCursor_FirstDecl = CXCursor_UnexposedDecl,
Argyrios Kyrtzidis12afd702011-09-30 17:58:23 +00001798 CXCursor_LastDecl = CXCursor_CXXAccessSpecifier,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001799
Douglas Gregor6007cf22010-01-22 22:29:16 +00001800 /* References */
1801 CXCursor_FirstRef = 40, /* Decl references */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001802 CXCursor_ObjCSuperClassRef = 40,
Douglas Gregor6007cf22010-01-22 22:29:16 +00001803 CXCursor_ObjCProtocolRef = 41,
1804 CXCursor_ObjCClassRef = 42,
1805 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001806 * A reference to a type declaration.
Douglas Gregor6007cf22010-01-22 22:29:16 +00001807 *
1808 * A type reference occurs anywhere where a type is named but not
1809 * declared. For example, given:
1810 *
1811 * \code
1812 * typedef unsigned size_type;
1813 * size_type size;
1814 * \endcode
1815 *
1816 * The typedef is a declaration of size_type (CXCursor_TypedefDecl),
1817 * while the type of the variable "size" is referenced. The cursor
1818 * referenced by the type of size is the typedef for size_type.
1819 */
1820 CXCursor_TypeRef = 43,
Ted Kremenekae9e2212010-08-27 21:34:58 +00001821 CXCursor_CXXBaseSpecifier = 44,
Douglas Gregora23e8f72010-08-31 20:37:03 +00001822 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001823 * A reference to a class template, function template, template
Douglas Gregorf3af3112010-09-09 21:42:20 +00001824 * template parameter, or class template partial specialization.
Douglas Gregora23e8f72010-08-31 20:37:03 +00001825 */
1826 CXCursor_TemplateRef = 45,
Douglas Gregora89314e2010-08-31 23:48:11 +00001827 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001828 * A reference to a namespace or namespace alias.
Douglas Gregora89314e2010-08-31 23:48:11 +00001829 */
1830 CXCursor_NamespaceRef = 46,
Douglas Gregorf3af3112010-09-09 21:42:20 +00001831 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001832 * A reference to a member of a struct, union, or class that occurs in
Douglas Gregora93ab662010-09-10 00:22:18 +00001833 * some non-expression context, e.g., a designated initializer.
Douglas Gregorf3af3112010-09-09 21:42:20 +00001834 */
1835 CXCursor_MemberRef = 47,
Douglas Gregora93ab662010-09-10 00:22:18 +00001836 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001837 * A reference to a labeled statement.
Douglas Gregora93ab662010-09-10 00:22:18 +00001838 *
1839 * This cursor kind is used to describe the jump to "start_over" in the
1840 * goto statement in the following example:
1841 *
1842 * \code
1843 * start_over:
1844 * ++counter;
1845 *
1846 * goto start_over;
1847 * \endcode
1848 *
1849 * A label reference cursor refers to a label statement.
1850 */
1851 CXCursor_LabelRef = 48,
1852
Douglas Gregor16a2bdd2010-09-13 22:52:57 +00001853 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001854 * A reference to a set of overloaded functions or function templates
Douglas Gregor16a2bdd2010-09-13 22:52:57 +00001855 * that has not yet been resolved to a specific function or function template.
1856 *
1857 * An overloaded declaration reference cursor occurs in C++ templates where
1858 * a dependent name refers to a function. For example:
1859 *
1860 * \code
1861 * template<typename T> void swap(T&, T&);
1862 *
1863 * struct X { ... };
1864 * void swap(X&, X&);
1865 *
1866 * template<typename T>
1867 * void reverse(T* first, T* last) {
1868 * while (first < last - 1) {
1869 * swap(*first, *--last);
1870 * ++first;
1871 * }
1872 * }
1873 *
1874 * struct Y { };
1875 * void swap(Y&, Y&);
1876 * \endcode
1877 *
1878 * Here, the identifier "swap" is associated with an overloaded declaration
1879 * reference. In the template definition, "swap" refers to either of the two
1880 * "swap" functions declared above, so both results will be available. At
1881 * instantiation time, "swap" may also refer to other functions found via
1882 * argument-dependent lookup (e.g., the "swap" function at the end of the
1883 * example).
1884 *
1885 * The functions \c clang_getNumOverloadedDecls() and
1886 * \c clang_getOverloadedDecl() can be used to retrieve the definitions
1887 * referenced by this cursor.
1888 */
1889 CXCursor_OverloadedDeclRef = 49,
1890
Douglas Gregor30093832012-02-15 00:54:55 +00001891 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001892 * A reference to a variable that occurs in some non-expression
Douglas Gregor30093832012-02-15 00:54:55 +00001893 * context, e.g., a C++ lambda capture list.
1894 */
1895 CXCursor_VariableRef = 50,
1896
1897 CXCursor_LastRef = CXCursor_VariableRef,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001898
Douglas Gregor6007cf22010-01-22 22:29:16 +00001899 /* Error conditions */
1900 CXCursor_FirstInvalid = 70,
1901 CXCursor_InvalidFile = 70,
1902 CXCursor_NoDeclFound = 71,
1903 CXCursor_NotImplemented = 72,
Ted Kremeneke184ac52010-03-19 20:39:03 +00001904 CXCursor_InvalidCode = 73,
1905 CXCursor_LastInvalid = CXCursor_InvalidCode,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001906
Douglas Gregor6007cf22010-01-22 22:29:16 +00001907 /* Expressions */
1908 CXCursor_FirstExpr = 100,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001909
Douglas Gregor6007cf22010-01-22 22:29:16 +00001910 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001911 * An expression whose specific kind is not exposed via this
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001912 * interface.
Douglas Gregor6007cf22010-01-22 22:29:16 +00001913 *
1914 * Unexposed expressions have the same operations as any other kind
1915 * of expression; one can extract their location information,
1916 * spelling, children, etc. However, the specific kind of the
1917 * expression is not reported.
1918 */
1919 CXCursor_UnexposedExpr = 100,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001920
Douglas Gregor6007cf22010-01-22 22:29:16 +00001921 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001922 * An expression that refers to some value declaration, such
Nico Weber7deebef2014-04-24 03:17:47 +00001923 * as a function, variable, or enumerator.
Douglas Gregor6007cf22010-01-22 22:29:16 +00001924 */
1925 CXCursor_DeclRefExpr = 101,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001926
Douglas Gregor6007cf22010-01-22 22:29:16 +00001927 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001928 * An expression that refers to a member of a struct, union,
Douglas Gregor6007cf22010-01-22 22:29:16 +00001929 * class, Objective-C class, etc.
1930 */
1931 CXCursor_MemberRefExpr = 102,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001932
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001933 /** An expression that calls a function. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001934 CXCursor_CallExpr = 103,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001935
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001936 /** An expression that sends a message to an Objective-C
Douglas Gregor6007cf22010-01-22 22:29:16 +00001937 object or class. */
1938 CXCursor_ObjCMessageExpr = 104,
Ted Kremenek33b9a422010-04-11 21:47:37 +00001939
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001940 /** An expression that represents a block literal. */
Ted Kremenek33b9a422010-04-11 21:47:37 +00001941 CXCursor_BlockExpr = 105,
1942
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001943 /** An integer literal.
Douglas Gregor4c362d52011-10-05 19:00:14 +00001944 */
1945 CXCursor_IntegerLiteral = 106,
1946
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001947 /** A floating point number literal.
Douglas Gregor4c362d52011-10-05 19:00:14 +00001948 */
1949 CXCursor_FloatingLiteral = 107,
1950
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001951 /** An imaginary number literal.
Douglas Gregor4c362d52011-10-05 19:00:14 +00001952 */
1953 CXCursor_ImaginaryLiteral = 108,
1954
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001955 /** A string literal.
Douglas Gregor4c362d52011-10-05 19:00:14 +00001956 */
1957 CXCursor_StringLiteral = 109,
1958
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001959 /** A character literal.
Douglas Gregor4c362d52011-10-05 19:00:14 +00001960 */
1961 CXCursor_CharacterLiteral = 110,
1962
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001963 /** A parenthesized expression, e.g. "(1)".
Douglas Gregor4c362d52011-10-05 19:00:14 +00001964 *
1965 * This AST node is only formed if full location information is requested.
1966 */
1967 CXCursor_ParenExpr = 111,
1968
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001969 /** This represents the unary-expression's (except sizeof and
Douglas Gregor4c362d52011-10-05 19:00:14 +00001970 * alignof).
1971 */
1972 CXCursor_UnaryOperator = 112,
1973
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001974 /** [C99 6.5.2.1] Array Subscripting.
Douglas Gregor4c362d52011-10-05 19:00:14 +00001975 */
1976 CXCursor_ArraySubscriptExpr = 113,
1977
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001978 /** A builtin binary operation expression such as "x + y" or
Douglas Gregor4c362d52011-10-05 19:00:14 +00001979 * "x <= y".
1980 */
1981 CXCursor_BinaryOperator = 114,
1982
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001983 /** Compound assignment such as "+=".
Douglas Gregor4c362d52011-10-05 19:00:14 +00001984 */
1985 CXCursor_CompoundAssignOperator = 115,
1986
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001987 /** The ?: ternary operator.
Douglas Gregor4c362d52011-10-05 19:00:14 +00001988 */
1989 CXCursor_ConditionalOperator = 116,
1990
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001991 /** An explicit cast in C (C99 6.5.4) or a C-style cast in C++
Douglas Gregor4c362d52011-10-05 19:00:14 +00001992 * (C++ [expr.cast]), which uses the syntax (Type)expr.
1993 *
1994 * For example: (int)f.
1995 */
1996 CXCursor_CStyleCastExpr = 117,
1997
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001998 /** [C99 6.5.2.5]
Douglas Gregor4c362d52011-10-05 19:00:14 +00001999 */
2000 CXCursor_CompoundLiteralExpr = 118,
2001
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002002 /** Describes an C or C++ initializer list.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002003 */
2004 CXCursor_InitListExpr = 119,
2005
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002006 /** The GNU address of label extension, representing &&label.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002007 */
2008 CXCursor_AddrLabelExpr = 120,
2009
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002010 /** This is the GNU Statement Expression extension: ({int X=4; X;})
Douglas Gregor4c362d52011-10-05 19:00:14 +00002011 */
2012 CXCursor_StmtExpr = 121,
2013
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002014 /** Represents a C11 generic selection.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002015 */
2016 CXCursor_GenericSelectionExpr = 122,
2017
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002018 /** Implements the GNU __null extension, which is a name for a null
Douglas Gregor4c362d52011-10-05 19:00:14 +00002019 * pointer constant that has integral type (e.g., int or long) and is the same
2020 * size and alignment as a pointer.
2021 *
2022 * The __null extension is typically only used by system headers, which define
2023 * NULL as __null in C++ rather than using 0 (which is an integer that may not
2024 * match the size of a pointer).
2025 */
2026 CXCursor_GNUNullExpr = 123,
2027
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002028 /** C++'s static_cast<> expression.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002029 */
2030 CXCursor_CXXStaticCastExpr = 124,
2031
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002032 /** C++'s dynamic_cast<> expression.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002033 */
2034 CXCursor_CXXDynamicCastExpr = 125,
2035
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002036 /** C++'s reinterpret_cast<> expression.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002037 */
2038 CXCursor_CXXReinterpretCastExpr = 126,
2039
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002040 /** C++'s const_cast<> expression.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002041 */
2042 CXCursor_CXXConstCastExpr = 127,
2043
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002044 /** Represents an explicit C++ type conversion that uses "functional"
Douglas Gregor4c362d52011-10-05 19:00:14 +00002045 * notion (C++ [expr.type.conv]).
2046 *
2047 * Example:
2048 * \code
2049 * x = int(0.5);
2050 * \endcode
2051 */
2052 CXCursor_CXXFunctionalCastExpr = 128,
2053
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002054 /** A C++ typeid expression (C++ [expr.typeid]).
Douglas Gregor4c362d52011-10-05 19:00:14 +00002055 */
2056 CXCursor_CXXTypeidExpr = 129,
2057
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002058 /** [C++ 2.13.5] C++ Boolean Literal.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002059 */
2060 CXCursor_CXXBoolLiteralExpr = 130,
2061
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002062 /** [C++0x 2.14.7] C++ Pointer Literal.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002063 */
2064 CXCursor_CXXNullPtrLiteralExpr = 131,
2065
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002066 /** Represents the "this" expression in C++
Douglas Gregor4c362d52011-10-05 19:00:14 +00002067 */
2068 CXCursor_CXXThisExpr = 132,
2069
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002070 /** [C++ 15] C++ Throw Expression.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002071 *
2072 * This handles 'throw' and 'throw' assignment-expression. When
2073 * assignment-expression isn't present, Op will be null.
2074 */
2075 CXCursor_CXXThrowExpr = 133,
2076
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002077 /** A new expression for memory allocation and constructor calls, e.g:
Douglas Gregor4c362d52011-10-05 19:00:14 +00002078 * "new CXXNewExpr(foo)".
2079 */
2080 CXCursor_CXXNewExpr = 134,
2081
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002082 /** A delete expression for memory deallocation and destructor calls,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002083 * e.g. "delete[] pArray".
2084 */
2085 CXCursor_CXXDeleteExpr = 135,
2086
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002087 /** A unary expression. (noexcept, sizeof, or other traits)
Douglas Gregor4c362d52011-10-05 19:00:14 +00002088 */
2089 CXCursor_UnaryExpr = 136,
2090
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002091 /** An Objective-C string literal i.e. @"foo".
Douglas Gregor4c362d52011-10-05 19:00:14 +00002092 */
2093 CXCursor_ObjCStringLiteral = 137,
2094
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002095 /** An Objective-C \@encode expression.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002096 */
2097 CXCursor_ObjCEncodeExpr = 138,
2098
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002099 /** An Objective-C \@selector expression.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002100 */
2101 CXCursor_ObjCSelectorExpr = 139,
2102
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002103 /** An Objective-C \@protocol expression.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002104 */
2105 CXCursor_ObjCProtocolExpr = 140,
2106
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002107 /** An Objective-C "bridged" cast expression, which casts between
Douglas Gregor4c362d52011-10-05 19:00:14 +00002108 * Objective-C pointers and C pointers, transferring ownership in the process.
2109 *
2110 * \code
2111 * NSString *str = (__bridge_transfer NSString *)CFCreateString();
2112 * \endcode
2113 */
2114 CXCursor_ObjCBridgedCastExpr = 141,
2115
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002116 /** Represents a C++0x pack expansion that produces a sequence of
Douglas Gregor4c362d52011-10-05 19:00:14 +00002117 * expressions.
2118 *
2119 * A pack expansion expression contains a pattern (which itself is an
2120 * expression) followed by an ellipsis. For example:
2121 *
2122 * \code
2123 * template<typename F, typename ...Types>
2124 * void forward(F f, Types &&...args) {
2125 * f(static_cast<Types&&>(args)...);
2126 * }
2127 * \endcode
2128 */
2129 CXCursor_PackExpansionExpr = 142,
2130
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002131 /** Represents an expression that computes the length of a parameter
Douglas Gregor4c362d52011-10-05 19:00:14 +00002132 * pack.
2133 *
2134 * \code
2135 * template<typename ...Types>
2136 * struct count {
2137 * static const unsigned value = sizeof...(Types);
2138 * };
2139 * \endcode
2140 */
2141 CXCursor_SizeOfPackExpr = 143,
2142
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002143 /* Represents a C++ lambda expression that produces a local function
Douglas Gregor30093832012-02-15 00:54:55 +00002144 * object.
2145 *
2146 * \code
2147 * void abssort(float *x, unsigned N) {
2148 * std::sort(x, x + N,
2149 * [](float a, float b) {
2150 * return std::abs(a) < std::abs(b);
2151 * });
2152 * }
2153 * \endcode
2154 */
2155 CXCursor_LambdaExpr = 144,
2156
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002157 /** Objective-c Boolean Literal.
Ted Kremenek77006f62012-03-06 20:06:06 +00002158 */
2159 CXCursor_ObjCBoolLiteralExpr = 145,
2160
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002161 /** Represents the "self" expression in an Objective-C method.
Argyrios Kyrtzidisc2233be2013-04-23 17:57:17 +00002162 */
2163 CXCursor_ObjCSelfExpr = 146,
2164
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002165 /** OpenMP 4.0 [2.4, Array Section].
Alexey Bataev1a3320e2015-08-25 14:24:04 +00002166 */
2167 CXCursor_OMPArraySectionExpr = 147,
2168
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002169 /** Represents an @available(...) check.
Erik Pilkington29099de2016-07-16 00:35:23 +00002170 */
2171 CXCursor_ObjCAvailabilityCheckExpr = 148,
2172
2173 CXCursor_LastExpr = CXCursor_ObjCAvailabilityCheckExpr,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002174
Douglas Gregor6007cf22010-01-22 22:29:16 +00002175 /* Statements */
2176 CXCursor_FirstStmt = 200,
2177 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002178 * A statement whose specific kind is not exposed via this
Douglas Gregor6007cf22010-01-22 22:29:16 +00002179 * interface.
2180 *
2181 * Unexposed statements have the same operations as any other kind of
2182 * statement; one can extract their location information, spelling,
2183 * children, etc. However, the specific kind of the statement is not
2184 * reported.
2185 */
2186 CXCursor_UnexposedStmt = 200,
Douglas Gregora93ab662010-09-10 00:22:18 +00002187
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002188 /** A labelled statement in a function.
Douglas Gregora93ab662010-09-10 00:22:18 +00002189 *
2190 * This cursor kind is used to describe the "start_over:" label statement in
2191 * the following example:
2192 *
2193 * \code
2194 * start_over:
2195 * ++counter;
2196 * \endcode
2197 *
2198 */
2199 CXCursor_LabelStmt = 201,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002200
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002201 /** A group of statements like { stmt stmt }.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002202 *
2203 * This cursor kind is used to describe compound statements, e.g. function
2204 * bodies.
2205 */
2206 CXCursor_CompoundStmt = 202,
2207
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002208 /** A case statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002209 */
2210 CXCursor_CaseStmt = 203,
2211
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002212 /** A default statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002213 */
2214 CXCursor_DefaultStmt = 204,
2215
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002216 /** An if statement
Douglas Gregor4c362d52011-10-05 19:00:14 +00002217 */
2218 CXCursor_IfStmt = 205,
2219
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002220 /** A switch statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002221 */
2222 CXCursor_SwitchStmt = 206,
2223
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002224 /** A while statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002225 */
2226 CXCursor_WhileStmt = 207,
2227
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002228 /** A do statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002229 */
2230 CXCursor_DoStmt = 208,
2231
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002232 /** A for statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002233 */
2234 CXCursor_ForStmt = 209,
2235
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002236 /** A goto statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002237 */
2238 CXCursor_GotoStmt = 210,
2239
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002240 /** An indirect goto statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002241 */
2242 CXCursor_IndirectGotoStmt = 211,
2243
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002244 /** A continue statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002245 */
2246 CXCursor_ContinueStmt = 212,
2247
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002248 /** A break statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002249 */
2250 CXCursor_BreakStmt = 213,
2251
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002252 /** A return statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002253 */
2254 CXCursor_ReturnStmt = 214,
2255
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002256 /** A GCC inline assembly statement extension.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002257 */
Chad Rosierde70e0e2012-08-25 00:11:56 +00002258 CXCursor_GCCAsmStmt = 215,
Argyrios Kyrtzidis5eae0732012-09-24 19:27:20 +00002259 CXCursor_AsmStmt = CXCursor_GCCAsmStmt,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002260
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002261 /** Objective-C's overall \@try-\@catch-\@finally statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002262 */
2263 CXCursor_ObjCAtTryStmt = 216,
2264
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002265 /** Objective-C's \@catch statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002266 */
2267 CXCursor_ObjCAtCatchStmt = 217,
2268
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002269 /** Objective-C's \@finally statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002270 */
2271 CXCursor_ObjCAtFinallyStmt = 218,
2272
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002273 /** Objective-C's \@throw statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002274 */
2275 CXCursor_ObjCAtThrowStmt = 219,
2276
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002277 /** Objective-C's \@synchronized statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002278 */
2279 CXCursor_ObjCAtSynchronizedStmt = 220,
2280
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002281 /** Objective-C's autorelease pool statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002282 */
2283 CXCursor_ObjCAutoreleasePoolStmt = 221,
2284
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002285 /** Objective-C's collection statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002286 */
2287 CXCursor_ObjCForCollectionStmt = 222,
2288
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002289 /** C++'s catch statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002290 */
2291 CXCursor_CXXCatchStmt = 223,
2292
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002293 /** C++'s try statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002294 */
2295 CXCursor_CXXTryStmt = 224,
2296
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002297 /** C++'s for (* : *) statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002298 */
2299 CXCursor_CXXForRangeStmt = 225,
2300
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002301 /** Windows Structured Exception Handling's try statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002302 */
2303 CXCursor_SEHTryStmt = 226,
2304
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002305 /** Windows Structured Exception Handling's except statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002306 */
2307 CXCursor_SEHExceptStmt = 227,
2308
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002309 /** Windows Structured Exception Handling's finally statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002310 */
2311 CXCursor_SEHFinallyStmt = 228,
2312
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002313 /** A MS inline assembly statement extension.
Chad Rosier32503022012-06-11 20:47:18 +00002314 */
2315 CXCursor_MSAsmStmt = 229,
2316
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002317 /** The null statement ";": C99 6.8.3p3.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002318 *
2319 * This cursor kind is used to describe the null statement.
2320 */
2321 CXCursor_NullStmt = 230,
2322
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002323 /** Adaptor class for mixing declarations with statements and
Douglas Gregor4c362d52011-10-05 19:00:14 +00002324 * expressions.
2325 */
2326 CXCursor_DeclStmt = 231,
2327
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002328 /** OpenMP parallel directive.
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002329 */
2330 CXCursor_OMPParallelDirective = 232,
2331
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002332 /** OpenMP SIMD directive.
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002333 */
2334 CXCursor_OMPSimdDirective = 233,
2335
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002336 /** OpenMP for directive.
Alexey Bataevf29276e2014-06-18 04:14:57 +00002337 */
2338 CXCursor_OMPForDirective = 234,
2339
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002340 /** OpenMP sections directive.
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002341 */
2342 CXCursor_OMPSectionsDirective = 235,
2343
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002344 /** OpenMP section directive.
Alexey Bataev1e0498a2014-06-26 08:21:58 +00002345 */
2346 CXCursor_OMPSectionDirective = 236,
2347
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002348 /** OpenMP single directive.
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00002349 */
2350 CXCursor_OMPSingleDirective = 237,
2351
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002352 /** OpenMP parallel for directive.
Alexey Bataev4acb8592014-07-07 13:01:15 +00002353 */
2354 CXCursor_OMPParallelForDirective = 238,
2355
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002356 /** OpenMP parallel sections directive.
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002357 */
2358 CXCursor_OMPParallelSectionsDirective = 239,
2359
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002360 /** OpenMP task directive.
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002361 */
2362 CXCursor_OMPTaskDirective = 240,
2363
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002364 /** OpenMP master directive.
Alexander Musman80c22892014-07-17 08:54:58 +00002365 */
2366 CXCursor_OMPMasterDirective = 241,
2367
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002368 /** OpenMP critical directive.
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002369 */
2370 CXCursor_OMPCriticalDirective = 242,
2371
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002372 /** OpenMP taskyield directive.
Alexey Bataev68446b72014-07-18 07:47:19 +00002373 */
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002374 CXCursor_OMPTaskyieldDirective = 243,
Alexey Bataev68446b72014-07-18 07:47:19 +00002375
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002376 /** OpenMP barrier directive.
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00002377 */
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002378 CXCursor_OMPBarrierDirective = 244,
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00002379
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002380 /** OpenMP taskwait directive.
Alexey Bataev2df347a2014-07-18 10:17:07 +00002381 */
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002382 CXCursor_OMPTaskwaitDirective = 245,
Alexey Bataev2df347a2014-07-18 10:17:07 +00002383
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002384 /** OpenMP flush directive.
Alexey Bataev6125da92014-07-21 11:26:11 +00002385 */
2386 CXCursor_OMPFlushDirective = 246,
Alexey Bataev0162e452014-07-22 10:10:35 +00002387
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002388 /** Windows Structured Exception Handling's leave statement.
Reid Klecknerba764482014-07-24 18:22:15 +00002389 */
2390 CXCursor_SEHLeaveStmt = 247,
2391
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002392 /** OpenMP ordered directive.
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002393 */
Reid Klecknerba764482014-07-24 18:22:15 +00002394 CXCursor_OMPOrderedDirective = 248,
Alexey Bataev6125da92014-07-21 11:26:11 +00002395
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002396 /** OpenMP atomic directive.
Alexey Bataev0162e452014-07-22 10:10:35 +00002397 */
Reid Klecknerba764482014-07-24 18:22:15 +00002398 CXCursor_OMPAtomicDirective = 249,
Alexey Bataev0162e452014-07-22 10:10:35 +00002399
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002400 /** OpenMP for SIMD directive.
Alexander Musmanf82886e2014-09-18 05:12:34 +00002401 */
2402 CXCursor_OMPForSimdDirective = 250,
2403
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002404 /** OpenMP parallel for SIMD directive.
Alexander Musmane4e893b2014-09-23 09:33:00 +00002405 */
2406 CXCursor_OMPParallelForSimdDirective = 251,
2407
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002408 /** OpenMP target directive.
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002409 */
Alexander Musmane4e893b2014-09-23 09:33:00 +00002410 CXCursor_OMPTargetDirective = 252,
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002411
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002412 /** OpenMP teams directive.
Alexey Bataev13314bf2014-10-09 04:18:56 +00002413 */
2414 CXCursor_OMPTeamsDirective = 253,
2415
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002416 /** OpenMP taskgroup directive.
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002417 */
Michael Wong65f367f2015-07-21 13:44:28 +00002418 CXCursor_OMPTaskgroupDirective = 254,
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002419
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002420 /** OpenMP cancellation point directive.
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002421 */
Michael Wong65f367f2015-07-21 13:44:28 +00002422 CXCursor_OMPCancellationPointDirective = 255,
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002423
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002424 /** OpenMP cancel directive.
Alexey Bataev80909872015-07-02 11:25:17 +00002425 */
Michael Wong65f367f2015-07-21 13:44:28 +00002426 CXCursor_OMPCancelDirective = 256,
Alexey Bataev80909872015-07-02 11:25:17 +00002427
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002428 /** OpenMP target data directive.
Michael Wong65f367f2015-07-21 13:44:28 +00002429 */
2430 CXCursor_OMPTargetDataDirective = 257,
2431
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002432 /** OpenMP taskloop directive.
Alexey Bataev49f6e782015-12-01 04:18:41 +00002433 */
2434 CXCursor_OMPTaskLoopDirective = 258,
2435
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002436 /** OpenMP taskloop simd directive.
Alexey Bataev0a6ed842015-12-03 09:40:15 +00002437 */
2438 CXCursor_OMPTaskLoopSimdDirective = 259,
2439
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002440 /** OpenMP distribute directive.
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00002441 */
2442 CXCursor_OMPDistributeDirective = 260,
2443
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002444 /** OpenMP target enter data directive.
Samuel Antaodf67fc42016-01-19 19:15:56 +00002445 */
2446 CXCursor_OMPTargetEnterDataDirective = 261,
2447
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002448 /** OpenMP target exit data directive.
Samuel Antao72590762016-01-19 20:04:50 +00002449 */
2450 CXCursor_OMPTargetExitDataDirective = 262,
2451
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002452 /** OpenMP target parallel directive.
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002453 */
2454 CXCursor_OMPTargetParallelDirective = 263,
2455
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002456 /** OpenMP target parallel for directive.
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00002457 */
2458 CXCursor_OMPTargetParallelForDirective = 264,
2459
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002460 /** OpenMP target update directive.
Samuel Antao686c70c2016-05-26 17:30:50 +00002461 */
2462 CXCursor_OMPTargetUpdateDirective = 265,
2463
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002464 /** OpenMP distribute parallel for directive.
Carlo Bertolli9925f152016-06-27 14:55:37 +00002465 */
2466 CXCursor_OMPDistributeParallelForDirective = 266,
2467
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002468 /** OpenMP distribute parallel for simd directive.
Kelvin Li4a39add2016-07-05 05:00:15 +00002469 */
2470 CXCursor_OMPDistributeParallelForSimdDirective = 267,
2471
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002472 /** OpenMP distribute simd directive.
Kelvin Li787f3fc2016-07-06 04:45:38 +00002473 */
2474 CXCursor_OMPDistributeSimdDirective = 268,
2475
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002476 /** OpenMP target parallel for simd directive.
Kelvin Lia579b912016-07-14 02:54:56 +00002477 */
2478 CXCursor_OMPTargetParallelForSimdDirective = 269,
2479
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002480 /** OpenMP target simd directive.
Kelvin Li986330c2016-07-20 22:57:10 +00002481 */
2482 CXCursor_OMPTargetSimdDirective = 270,
2483
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002484 /** OpenMP teams distribute directive.
Kelvin Li02532872016-08-05 14:37:37 +00002485 */
2486 CXCursor_OMPTeamsDistributeDirective = 271,
2487
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002488 /** OpenMP teams distribute simd directive.
Kelvin Li4e325f72016-10-25 12:50:55 +00002489 */
2490 CXCursor_OMPTeamsDistributeSimdDirective = 272,
2491
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002492 /** OpenMP teams distribute parallel for simd directive.
Kelvin Li579e41c2016-11-30 23:51:03 +00002493 */
2494 CXCursor_OMPTeamsDistributeParallelForSimdDirective = 273,
2495
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002496 /** OpenMP teams distribute parallel for directive.
Kelvin Li7ade93f2016-12-09 03:24:30 +00002497 */
2498 CXCursor_OMPTeamsDistributeParallelForDirective = 274,
2499
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002500 /** OpenMP target teams directive.
Kelvin Libf594a52016-12-17 05:48:59 +00002501 */
2502 CXCursor_OMPTargetTeamsDirective = 275,
2503
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002504 /** OpenMP target teams distribute directive.
Kelvin Li83c451e2016-12-25 04:52:54 +00002505 */
2506 CXCursor_OMPTargetTeamsDistributeDirective = 276,
2507
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002508 /** OpenMP target teams distribute parallel for directive.
Kelvin Li80e8f562016-12-29 22:16:30 +00002509 */
2510 CXCursor_OMPTargetTeamsDistributeParallelForDirective = 277,
2511
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002512 /** OpenMP target teams distribute parallel for simd directive.
Kelvin Li1851df52017-01-03 05:23:48 +00002513 */
2514 CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective = 278,
2515
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002516 /** OpenMP target teams distribute simd directive.
Kelvin Lida681182017-01-10 18:08:18 +00002517 */
2518 CXCursor_OMPTargetTeamsDistributeSimdDirective = 279,
2519
2520 CXCursor_LastStmt = CXCursor_OMPTargetTeamsDistributeSimdDirective,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002521
Douglas Gregor6007cf22010-01-22 22:29:16 +00002522 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002523 * Cursor that represents the translation unit itself.
Douglas Gregor6007cf22010-01-22 22:29:16 +00002524 *
2525 * The translation unit cursor exists primarily to act as the root
2526 * cursor for traversing the contents of a translation unit.
2527 */
Ted Kremenekbff31432010-02-18 03:09:07 +00002528 CXCursor_TranslationUnit = 300,
2529
Bill Wendling44426052012-12-20 19:22:21 +00002530 /* Attributes */
Ted Kremenekbff31432010-02-18 03:09:07 +00002531 CXCursor_FirstAttr = 400,
2532 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002533 * An attribute whose specific kind is not exposed via this
Ted Kremenekbff31432010-02-18 03:09:07 +00002534 * interface.
2535 */
2536 CXCursor_UnexposedAttr = 400,
2537
2538 CXCursor_IBActionAttr = 401,
2539 CXCursor_IBOutletAttr = 402,
Ted Kremenek26bde772010-05-19 17:38:06 +00002540 CXCursor_IBOutletCollectionAttr = 403,
Argyrios Kyrtzidis2cb4e3c2011-09-13 17:39:31 +00002541 CXCursor_CXXFinalAttr = 404,
2542 CXCursor_CXXOverrideAttr = 405,
Erik Verbruggenca98f2a2011-10-13 09:41:32 +00002543 CXCursor_AnnotateAttr = 406,
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00002544 CXCursor_AsmLabelAttr = 407,
Argyrios Kyrtzidis16834f12013-09-25 00:14:38 +00002545 CXCursor_PackedAttr = 408,
Joey Gouly81228382014-05-01 15:41:58 +00002546 CXCursor_PureAttr = 409,
2547 CXCursor_ConstAttr = 410,
2548 CXCursor_NoDuplicateAttr = 411,
Eli Bendersky2581e662014-05-28 19:29:58 +00002549 CXCursor_CUDAConstantAttr = 412,
2550 CXCursor_CUDADeviceAttr = 413,
2551 CXCursor_CUDAGlobalAttr = 414,
2552 CXCursor_CUDAHostAttr = 415,
Eli Bendersky9b071472014-08-08 14:59:00 +00002553 CXCursor_CUDASharedAttr = 416,
Saleem Abdulrasool79c69712015-09-05 18:53:43 +00002554 CXCursor_VisibilityAttr = 417,
Saleem Abdulrasool8aa0b802015-12-10 18:45:18 +00002555 CXCursor_DLLExport = 418,
2556 CXCursor_DLLImport = 419,
2557 CXCursor_LastAttr = CXCursor_DLLImport,
Eli Bendersky2581e662014-05-28 19:29:58 +00002558
Douglas Gregor92a524f2010-03-18 00:42:48 +00002559 /* Preprocessing */
2560 CXCursor_PreprocessingDirective = 500,
Douglas Gregor06d6d322010-03-18 18:04:21 +00002561 CXCursor_MacroDefinition = 501,
Chandler Carruth9e4704a2011-07-14 08:41:15 +00002562 CXCursor_MacroExpansion = 502,
2563 CXCursor_MacroInstantiation = CXCursor_MacroExpansion,
Douglas Gregor796d76a2010-10-20 22:00:55 +00002564 CXCursor_InclusionDirective = 503,
Douglas Gregor92a524f2010-03-18 00:42:48 +00002565 CXCursor_FirstPreprocessing = CXCursor_PreprocessingDirective,
Argyrios Kyrtzidis50e5b1d2012-10-05 00:22:24 +00002566 CXCursor_LastPreprocessing = CXCursor_InclusionDirective,
2567
2568 /* Extra Declarations */
2569 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002570 * A module import declaration.
Argyrios Kyrtzidis50e5b1d2012-10-05 00:22:24 +00002571 */
2572 CXCursor_ModuleImportDecl = 600,
Sergey Kalinichev8f3b1872015-11-15 13:48:32 +00002573 CXCursor_TypeAliasTemplateDecl = 601,
Olivier Goffart81978012016-06-09 16:15:55 +00002574 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002575 * A static_assert or _Static_assert node
Olivier Goffart81978012016-06-09 16:15:55 +00002576 */
2577 CXCursor_StaticAssert = 602,
Olivier Goffartd211c642016-11-04 06:29:27 +00002578 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002579 * a friend declaration.
Olivier Goffartd211c642016-11-04 06:29:27 +00002580 */
2581 CXCursor_FriendDecl = 603,
Argyrios Kyrtzidis50e5b1d2012-10-05 00:22:24 +00002582 CXCursor_FirstExtraDecl = CXCursor_ModuleImportDecl,
Olivier Goffartd211c642016-11-04 06:29:27 +00002583 CXCursor_LastExtraDecl = CXCursor_FriendDecl,
Francisco Lopes da Silva975a9f62015-01-21 16:24:11 +00002584
2585 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002586 * A code completion overload candidate.
Francisco Lopes da Silva975a9f62015-01-21 16:24:11 +00002587 */
2588 CXCursor_OverloadCandidate = 700
Douglas Gregor6007cf22010-01-22 22:29:16 +00002589};
2590
2591/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002592 * A cursor representing some element in the abstract syntax tree for
Douglas Gregor6007cf22010-01-22 22:29:16 +00002593 * a translation unit.
2594 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002595 * The cursor abstraction unifies the different kinds of entities in a
Douglas Gregor6007cf22010-01-22 22:29:16 +00002596 * program--declaration, statements, expressions, references to declarations,
2597 * etc.--under a single "cursor" abstraction with a common set of operations.
2598 * Common operation for a cursor include: getting the physical location in
2599 * a source file where the cursor points, getting the name associated with a
2600 * cursor, and retrieving cursors for any child nodes of a particular cursor.
2601 *
2602 * Cursors can be produced in two specific ways.
2603 * clang_getTranslationUnitCursor() produces a cursor for a translation unit,
2604 * from which one can use clang_visitChildren() to explore the rest of the
2605 * translation unit. clang_getCursor() maps from a physical source location
2606 * to the entity that resides at that location, allowing one to map from the
2607 * source code into the AST.
2608 */
2609typedef struct {
2610 enum CXCursorKind kind;
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00002611 int xdata;
Dmitri Gribenkoba2f7462013-01-11 21:01:49 +00002612 const void *data[3];
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002613} CXCursor;
Douglas Gregor6007cf22010-01-22 22:29:16 +00002614
2615/**
2616 * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations
2617 *
2618 * @{
2619 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002620
Douglas Gregor6007cf22010-01-22 22:29:16 +00002621/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002622 * Retrieve the NULL cursor, which represents no entity.
Douglas Gregor6007cf22010-01-22 22:29:16 +00002623 */
2624CINDEX_LINKAGE CXCursor clang_getNullCursor(void);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002625
Douglas Gregor6007cf22010-01-22 22:29:16 +00002626/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002627 * Retrieve the cursor that represents the given translation unit.
Douglas Gregor6007cf22010-01-22 22:29:16 +00002628 *
2629 * The translation unit cursor can be used to start traversing the
2630 * various declarations within the given translation unit.
2631 */
2632CINDEX_LINKAGE CXCursor clang_getTranslationUnitCursor(CXTranslationUnit);
2633
2634/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002635 * Determine whether two cursors are equivalent.
Douglas Gregor6007cf22010-01-22 22:29:16 +00002636 */
2637CINDEX_LINKAGE unsigned clang_equalCursors(CXCursor, CXCursor);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002638
Douglas Gregor6007cf22010-01-22 22:29:16 +00002639/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002640 * Returns non-zero if \p cursor is null.
Argyrios Kyrtzidisd6e9fa52011-09-27 00:30:30 +00002641 */
Dmitri Gribenko8994e0c2012-09-13 13:11:20 +00002642CINDEX_LINKAGE int clang_Cursor_isNull(CXCursor cursor);
Argyrios Kyrtzidisd6e9fa52011-09-27 00:30:30 +00002643
2644/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002645 * Compute a hash value for the given cursor.
Douglas Gregor06a3f302010-11-20 00:09:34 +00002646 */
2647CINDEX_LINKAGE unsigned clang_hashCursor(CXCursor);
2648
2649/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002650 * Retrieve the kind of the given cursor.
Douglas Gregor6007cf22010-01-22 22:29:16 +00002651 */
2652CINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor);
2653
2654/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002655 * Determine whether the given cursor kind represents a declaration.
Ivan Donchevskii65c766e2018-01-03 10:40:11 +00002656 */
2657CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind);
2658
2659/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002660 * Determine whether the given declaration is invalid.
Ivan Donchevskii08ff9102018-01-04 10:59:50 +00002661 *
2662 * A declaration is invalid if it could not be parsed successfully.
2663 *
2664 * \returns non-zero if the cursor represents a declaration and it is
2665 * invalid, otherwise NULL.
2666 */
2667CINDEX_LINKAGE unsigned clang_isInvalidDeclaration(CXCursor);
2668
2669/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002670 * Determine whether the given cursor kind represents a simple
Ivan Donchevskii65c766e2018-01-03 10:40:11 +00002671 * reference.
Douglas Gregor6007cf22010-01-22 22:29:16 +00002672 *
2673 * Note that other kinds of cursors (such as expressions) can also refer to
2674 * other cursors. Use clang_getCursorReferenced() to determine whether a
2675 * particular cursor refers to another entity.
2676 */
2677CINDEX_LINKAGE unsigned clang_isReference(enum CXCursorKind);
2678
2679/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002680 * Determine whether the given cursor kind represents an expression.
Douglas Gregor6007cf22010-01-22 22:29:16 +00002681 */
2682CINDEX_LINKAGE unsigned clang_isExpression(enum CXCursorKind);
2683
2684/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002685 * Determine whether the given cursor kind represents a statement.
Douglas Gregor6007cf22010-01-22 22:29:16 +00002686 */
2687CINDEX_LINKAGE unsigned clang_isStatement(enum CXCursorKind);
2688
2689/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002690 * Determine whether the given cursor kind represents an attribute.
Douglas Gregora98034a2011-07-06 03:00:34 +00002691 */
2692CINDEX_LINKAGE unsigned clang_isAttribute(enum CXCursorKind);
2693
2694/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002695 * Determine whether the given cursor has any attributes.
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00002696 */
2697CINDEX_LINKAGE unsigned clang_Cursor_hasAttrs(CXCursor C);
2698
2699/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002700 * Determine whether the given cursor kind represents an invalid
Douglas Gregor6007cf22010-01-22 22:29:16 +00002701 * cursor.
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002702 */
Douglas Gregor6007cf22010-01-22 22:29:16 +00002703CINDEX_LINKAGE unsigned clang_isInvalid(enum CXCursorKind);
2704
2705/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002706 * Determine whether the given cursor kind represents a translation
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002707 * unit.
Douglas Gregor6007cf22010-01-22 22:29:16 +00002708 */
2709CINDEX_LINKAGE unsigned clang_isTranslationUnit(enum CXCursorKind);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002710
Ted Kremenekff9021b2010-03-08 21:17:29 +00002711/***
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002712 * Determine whether the given cursor represents a preprocessing
Douglas Gregor92a524f2010-03-18 00:42:48 +00002713 * element, such as a preprocessor directive or macro instantiation.
2714 */
2715CINDEX_LINKAGE unsigned clang_isPreprocessing(enum CXCursorKind);
2716
2717/***
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002718 * Determine whether the given cursor represents a currently
Ted Kremenekff9021b2010-03-08 21:17:29 +00002719 * unexposed piece of the AST (e.g., CXCursor_UnexposedStmt).
2720 */
2721CINDEX_LINKAGE unsigned clang_isUnexposed(enum CXCursorKind);
2722
Douglas Gregor6007cf22010-01-22 22:29:16 +00002723/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002724 * Describe the linkage of the entity referred to by a cursor.
Ted Kremenekfb4961d2010-03-03 06:36:57 +00002725 */
2726enum CXLinkageKind {
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002727 /** This value indicates that no linkage information is available
Ted Kremenekfb4961d2010-03-03 06:36:57 +00002728 * for a provided CXCursor. */
2729 CXLinkage_Invalid,
2730 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002731 * This is the linkage for variables, parameters, and so on that
Ted Kremenekfb4961d2010-03-03 06:36:57 +00002732 * have automatic storage. This covers normal (non-extern) local variables.
2733 */
2734 CXLinkage_NoLinkage,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002735 /** This is the linkage for static variables and static functions. */
Ted Kremenekfb4961d2010-03-03 06:36:57 +00002736 CXLinkage_Internal,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002737 /** This is the linkage for entities with external linkage that live
Ted Kremenekfb4961d2010-03-03 06:36:57 +00002738 * in C++ anonymous namespaces.*/
2739 CXLinkage_UniqueExternal,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002740 /** This is the linkage for entities with true, external linkage. */
Ted Kremenekfb4961d2010-03-03 06:36:57 +00002741 CXLinkage_External
2742};
2743
2744/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002745 * Determine the linkage of the entity referred to by a given cursor.
Ted Kremenekfb4961d2010-03-03 06:36:57 +00002746 */
2747CINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor);
2748
Ehsan Akhgarib743de72016-05-31 15:55:51 +00002749enum CXVisibilityKind {
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002750 /** This value indicates that no visibility information is available
Ehsan Akhgarib743de72016-05-31 15:55:51 +00002751 * for a provided CXCursor. */
2752 CXVisibility_Invalid,
2753
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002754 /** Symbol not seen by the linker. */
Ehsan Akhgarib743de72016-05-31 15:55:51 +00002755 CXVisibility_Hidden,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002756 /** Symbol seen by the linker but resolves to a symbol inside this object. */
Ehsan Akhgarib743de72016-05-31 15:55:51 +00002757 CXVisibility_Protected,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002758 /** Symbol seen by the linker and acts like a normal symbol. */
Ehsan Akhgarib743de72016-05-31 15:55:51 +00002759 CXVisibility_Default
2760};
2761
2762/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002763 * Describe the visibility of the entity referred to by a cursor.
Ehsan Akhgarib743de72016-05-31 15:55:51 +00002764 *
2765 * This returns the default visibility if not explicitly specified by
2766 * a visibility attribute. The default visibility may be changed by
2767 * commandline arguments.
2768 *
2769 * \param cursor The cursor to query.
2770 *
2771 * \returns The visibility of the cursor.
2772 */
2773CINDEX_LINKAGE enum CXVisibilityKind clang_getCursorVisibility(CXCursor cursor);
2774
Ehsan Akhgari93697fa2015-11-23 19:56:46 +00002775/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002776 * Determine the availability of the entity that this cursor refers to,
Douglas Gregord6225d32012-05-08 00:14:45 +00002777 * taking the current target platform into account.
Douglas Gregorf757a122010-08-23 23:00:57 +00002778 *
2779 * \param cursor The cursor to query.
2780 *
2781 * \returns The availability of the cursor.
2782 */
2783CINDEX_LINKAGE enum CXAvailabilityKind
2784clang_getCursorAvailability(CXCursor cursor);
2785
2786/**
Douglas Gregord6225d32012-05-08 00:14:45 +00002787 * Describes the availability of a given entity on a particular platform, e.g.,
2788 * a particular class might only be available on Mac OS 10.7 or newer.
2789 */
2790typedef struct CXPlatformAvailability {
2791 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002792 * A string that describes the platform for which this structure
Douglas Gregord6225d32012-05-08 00:14:45 +00002793 * provides availability information.
2794 *
Manman Renccf25bb2016-06-28 20:55:30 +00002795 * Possible values are "ios" or "macos".
Douglas Gregord6225d32012-05-08 00:14:45 +00002796 */
2797 CXString Platform;
2798 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002799 * The version number in which this entity was introduced.
Douglas Gregord6225d32012-05-08 00:14:45 +00002800 */
2801 CXVersion Introduced;
2802 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002803 * The version number in which this entity was deprecated (but is
Douglas Gregord6225d32012-05-08 00:14:45 +00002804 * still available).
2805 */
2806 CXVersion Deprecated;
2807 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002808 * The version number in which this entity was obsoleted, and therefore
Douglas Gregord6225d32012-05-08 00:14:45 +00002809 * is no longer available.
2810 */
2811 CXVersion Obsoleted;
2812 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002813 * Whether the entity is unconditionally unavailable on this platform.
Douglas Gregord6225d32012-05-08 00:14:45 +00002814 */
2815 int Unavailable;
2816 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002817 * An optional message to provide to a user of this API, e.g., to
Douglas Gregord6225d32012-05-08 00:14:45 +00002818 * suggest replacement APIs.
2819 */
2820 CXString Message;
2821} CXPlatformAvailability;
2822
2823/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002824 * Determine the availability of the entity that this cursor refers to
Douglas Gregord6225d32012-05-08 00:14:45 +00002825 * on any platforms for which availability information is known.
2826 *
2827 * \param cursor The cursor to query.
2828 *
2829 * \param always_deprecated If non-NULL, will be set to indicate whether the
2830 * entity is deprecated on all platforms.
2831 *
2832 * \param deprecated_message If non-NULL, will be set to the message text
2833 * provided along with the unconditional deprecation of this entity. The client
2834 * is responsible for deallocating this string.
2835 *
James Dennett574cb4c2012-06-15 05:41:51 +00002836 * \param always_unavailable If non-NULL, will be set to indicate whether the
Douglas Gregord6225d32012-05-08 00:14:45 +00002837 * entity is unavailable on all platforms.
2838 *
2839 * \param unavailable_message If non-NULL, will be set to the message text
2840 * provided along with the unconditional unavailability of this entity. The
2841 * client is responsible for deallocating this string.
2842 *
2843 * \param availability If non-NULL, an array of CXPlatformAvailability instances
2844 * that will be populated with platform availability information, up to either
2845 * the number of platforms for which availability information is available (as
2846 * returned by this function) or \c availability_size, whichever is smaller.
2847 *
2848 * \param availability_size The number of elements available in the
2849 * \c availability array.
2850 *
2851 * \returns The number of platforms (N) for which availability information is
2852 * available (which is unrelated to \c availability_size).
2853 *
2854 * Note that the client is responsible for calling
2855 * \c clang_disposeCXPlatformAvailability to free each of the
2856 * platform-availability structures returned. There are
2857 * \c min(N, availability_size) such structures.
2858 */
2859CINDEX_LINKAGE int
2860clang_getCursorPlatformAvailability(CXCursor cursor,
2861 int *always_deprecated,
2862 CXString *deprecated_message,
2863 int *always_unavailable,
2864 CXString *unavailable_message,
2865 CXPlatformAvailability *availability,
2866 int availability_size);
2867
2868/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002869 * Free the memory associated with a \c CXPlatformAvailability structure.
Douglas Gregord6225d32012-05-08 00:14:45 +00002870 */
2871CINDEX_LINKAGE void
2872clang_disposeCXPlatformAvailability(CXPlatformAvailability *availability);
2873
2874/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002875 * Describe the "language" of the entity referred to by a cursor.
Ted Kremenek4ed29252010-04-12 21:22:16 +00002876 */
Reid Kleckner9e3bc722013-12-30 17:48:49 +00002877enum CXLanguageKind {
Ted Kremenekee457512010-04-14 20:58:32 +00002878 CXLanguage_Invalid = 0,
Ted Kremenek4ed29252010-04-12 21:22:16 +00002879 CXLanguage_C,
2880 CXLanguage_ObjC,
Ted Kremenekee457512010-04-14 20:58:32 +00002881 CXLanguage_CPlusPlus
Ted Kremenek4ed29252010-04-12 21:22:16 +00002882};
2883
2884/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002885 * Determine the "language" of the entity referred to by a given cursor.
Ted Kremenek4ed29252010-04-12 21:22:16 +00002886 */
2887CINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor);
2888
Argyrios Kyrtzidisd6e9fa52011-09-27 00:30:30 +00002889/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002890 * Describe the "thread-local storage (TLS) kind" of the declaration
Saleem Abdulrasool50bc5652017-09-13 02:15:09 +00002891 * referred to by a cursor.
2892 */
2893enum CXTLSKind {
2894 CXTLS_None = 0,
2895 CXTLS_Dynamic,
2896 CXTLS_Static
2897};
2898
2899/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002900 * Determine the "thread-local storage (TLS) kind" of the declaration
Saleem Abdulrasool50bc5652017-09-13 02:15:09 +00002901 * referred to by a cursor.
2902 */
2903CINDEX_LINKAGE enum CXTLSKind clang_getCursorTLSKind(CXCursor cursor);
2904
2905/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002906 * Returns the translation unit that a cursor originated from.
Argyrios Kyrtzidisd6e9fa52011-09-27 00:30:30 +00002907 */
2908CINDEX_LINKAGE CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor);
2909
Ted Kremenekc0b98662013-04-24 07:17:12 +00002910/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002911 * A fast container representing a set of CXCursors.
Ted Kremenekc0b98662013-04-24 07:17:12 +00002912 */
2913typedef struct CXCursorSetImpl *CXCursorSet;
2914
2915/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002916 * Creates an empty CXCursorSet.
Ted Kremenekc0b98662013-04-24 07:17:12 +00002917 */
2918CINDEX_LINKAGE CXCursorSet clang_createCXCursorSet(void);
2919
2920/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002921 * Disposes a CXCursorSet and releases its associated memory.
Ted Kremenekc0b98662013-04-24 07:17:12 +00002922 */
2923CINDEX_LINKAGE void clang_disposeCXCursorSet(CXCursorSet cset);
2924
2925/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002926 * Queries a CXCursorSet to see if it contains a specific CXCursor.
Ted Kremenekc0b98662013-04-24 07:17:12 +00002927 *
2928 * \returns non-zero if the set contains the specified cursor.
2929*/
2930CINDEX_LINKAGE unsigned clang_CXCursorSet_contains(CXCursorSet cset,
2931 CXCursor cursor);
2932
2933/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002934 * Inserts a CXCursor into a CXCursorSet.
Ted Kremenekc0b98662013-04-24 07:17:12 +00002935 *
2936 * \returns zero if the CXCursor was already in the set, and non-zero otherwise.
2937*/
2938CINDEX_LINKAGE unsigned clang_CXCursorSet_insert(CXCursorSet cset,
2939 CXCursor cursor);
2940
Douglas Gregor0576ce72010-09-22 21:22:29 +00002941/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002942 * Determine the semantic parent of the given cursor.
Douglas Gregor0576ce72010-09-22 21:22:29 +00002943 *
2944 * The semantic parent of a cursor is the cursor that semantically contains
2945 * the given \p cursor. For many declarations, the lexical and semantic parents
2946 * are equivalent (the lexical parent is returned by
2947 * \c clang_getCursorLexicalParent()). They diverge when declarations or
2948 * definitions are provided out-of-line. For example:
2949 *
2950 * \code
2951 * class C {
2952 * void f();
2953 * };
2954 *
2955 * void C::f() { }
2956 * \endcode
2957 *
Nico Weber7deebef2014-04-24 03:17:47 +00002958 * In the out-of-line definition of \c C::f, the semantic parent is
Douglas Gregor0576ce72010-09-22 21:22:29 +00002959 * the class \c C, of which this function is a member. The lexical parent is
2960 * the place where the declaration actually occurs in the source code; in this
Nico Weber7deebef2014-04-24 03:17:47 +00002961 * case, the definition occurs in the translation unit. In general, the
Douglas Gregor0576ce72010-09-22 21:22:29 +00002962 * lexical parent for a given entity can change without affecting the semantics
2963 * of the program, and the lexical parent of different declarations of the
2964 * same entity may be different. Changing the semantic parent of a declaration,
2965 * on the other hand, can have a major impact on semantics, and redeclarations
2966 * of a particular entity should all have the same semantic context.
2967 *
2968 * In the example above, both declarations of \c C::f have \c C as their
2969 * semantic context, while the lexical context of the first \c C::f is \c C
2970 * and the lexical context of the second \c C::f is the translation unit.
Douglas Gregor7ecd19e2010-12-21 07:55:45 +00002971 *
2972 * For global declarations, the semantic parent is the translation unit.
Douglas Gregor0576ce72010-09-22 21:22:29 +00002973 */
2974CINDEX_LINKAGE CXCursor clang_getCursorSemanticParent(CXCursor cursor);
2975
2976/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002977 * Determine the lexical parent of the given cursor.
Douglas Gregor0576ce72010-09-22 21:22:29 +00002978 *
2979 * The lexical parent of a cursor is the cursor in which the given \p cursor
2980 * was actually written. For many declarations, the lexical and semantic parents
2981 * are equivalent (the semantic parent is returned by
2982 * \c clang_getCursorSemanticParent()). They diverge when declarations or
2983 * definitions are provided out-of-line. For example:
2984 *
2985 * \code
2986 * class C {
2987 * void f();
2988 * };
2989 *
2990 * void C::f() { }
2991 * \endcode
2992 *
Nico Weber7deebef2014-04-24 03:17:47 +00002993 * In the out-of-line definition of \c C::f, the semantic parent is
Douglas Gregor0576ce72010-09-22 21:22:29 +00002994 * the class \c C, of which this function is a member. The lexical parent is
2995 * the place where the declaration actually occurs in the source code; in this
Nico Weber7deebef2014-04-24 03:17:47 +00002996 * case, the definition occurs in the translation unit. In general, the
Douglas Gregor0576ce72010-09-22 21:22:29 +00002997 * lexical parent for a given entity can change without affecting the semantics
2998 * of the program, and the lexical parent of different declarations of the
2999 * same entity may be different. Changing the semantic parent of a declaration,
3000 * on the other hand, can have a major impact on semantics, and redeclarations
3001 * of a particular entity should all have the same semantic context.
3002 *
3003 * In the example above, both declarations of \c C::f have \c C as their
3004 * semantic context, while the lexical context of the first \c C::f is \c C
3005 * and the lexical context of the second \c C::f is the translation unit.
Douglas Gregor7ecd19e2010-12-21 07:55:45 +00003006 *
3007 * For declarations written in the global scope, the lexical parent is
3008 * the translation unit.
Douglas Gregor0576ce72010-09-22 21:22:29 +00003009 */
3010CINDEX_LINKAGE CXCursor clang_getCursorLexicalParent(CXCursor cursor);
Douglas Gregor99a26af2010-10-01 20:25:15 +00003011
3012/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003013 * Determine the set of methods that are overridden by the given
Douglas Gregor99a26af2010-10-01 20:25:15 +00003014 * method.
3015 *
3016 * In both Objective-C and C++, a method (aka virtual member function,
3017 * in C++) can override a virtual method in a base class. For
3018 * Objective-C, a method is said to override any method in the class's
Argyrios Kyrtzidisbfb24252012-03-08 00:20:03 +00003019 * base class, its protocols, or its categories' protocols, that has the same
3020 * selector and is of the same kind (class or instance).
3021 * If no such method exists, the search continues to the class's superclass,
3022 * its protocols, and its categories, and so on. A method from an Objective-C
3023 * implementation is considered to override the same methods as its
3024 * corresponding method in the interface.
Douglas Gregor99a26af2010-10-01 20:25:15 +00003025 *
3026 * For C++, a virtual member function overrides any virtual member
3027 * function with the same signature that occurs in its base
3028 * classes. With multiple inheritance, a virtual member function can
3029 * override several virtual member functions coming from different
3030 * base classes.
3031 *
3032 * In all cases, this function determines the immediate overridden
3033 * method, rather than all of the overridden methods. For example, if
3034 * a method is originally declared in a class A, then overridden in B
3035 * (which in inherits from A) and also in C (which inherited from B),
3036 * then the only overridden method returned from this function when
3037 * invoked on C's method will be B's method. The client may then
3038 * invoke this function again, given the previously-found overridden
3039 * methods, to map out the complete method-override set.
3040 *
3041 * \param cursor A cursor representing an Objective-C or C++
3042 * method. This routine will compute the set of methods that this
3043 * method overrides.
3044 *
3045 * \param overridden A pointer whose pointee will be replaced with a
3046 * pointer to an array of cursors, representing the set of overridden
3047 * methods. If there are no overridden methods, the pointee will be
3048 * set to NULL. The pointee must be freed via a call to
3049 * \c clang_disposeOverriddenCursors().
3050 *
3051 * \param num_overridden A pointer to the number of overridden
3052 * functions, will be set to the number of overridden functions in the
3053 * array pointed to by \p overridden.
3054 */
3055CINDEX_LINKAGE void clang_getOverriddenCursors(CXCursor cursor,
3056 CXCursor **overridden,
3057 unsigned *num_overridden);
3058
3059/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003060 * Free the set of overridden cursors returned by \c
Douglas Gregor99a26af2010-10-01 20:25:15 +00003061 * clang_getOverriddenCursors().
3062 */
3063CINDEX_LINKAGE void clang_disposeOverriddenCursors(CXCursor *overridden);
3064
Ted Kremenek4ed29252010-04-12 21:22:16 +00003065/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003066 * Retrieve the file that is included by the given inclusion directive
Douglas Gregor796d76a2010-10-20 22:00:55 +00003067 * cursor.
3068 */
3069CINDEX_LINKAGE CXFile clang_getIncludedFile(CXCursor cursor);
3070
3071/**
Douglas Gregor6007cf22010-01-22 22:29:16 +00003072 * @}
3073 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003074
Douglas Gregor6007cf22010-01-22 22:29:16 +00003075/**
3076 * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code
3077 *
3078 * Cursors represent a location within the Abstract Syntax Tree (AST). These
3079 * routines help map between cursors and the physical locations where the
3080 * described entities occur in the source code. The mapping is provided in
3081 * both directions, so one can map from source code to the AST and back.
3082 *
3083 * @{
Steve Naroffa1c72842009-08-28 15:28:48 +00003084 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003085
Steve Naroff20bad0b2009-10-21 13:56:23 +00003086/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003087 * Map a source location to the cursor that describes the entity at that
Douglas Gregor816fd362010-01-22 21:44:22 +00003088 * location in the source code.
3089 *
3090 * clang_getCursor() maps an arbitrary source location within a translation
3091 * unit down to the most specific cursor that describes the entity at that
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003092 * location. For example, given an expression \c x + y, invoking
Douglas Gregor816fd362010-01-22 21:44:22 +00003093 * clang_getCursor() with a source location pointing to "x" will return the
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003094 * cursor for "x"; similarly for "y". If the cursor points anywhere between
Douglas Gregor816fd362010-01-22 21:44:22 +00003095 * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor()
3096 * will return a cursor referring to the "+" expression.
3097 *
3098 * \returns a cursor representing the entity at the given source location, or
3099 * a NULL cursor if no such entity can be found.
Steve Naroff20bad0b2009-10-21 13:56:23 +00003100 */
Douglas Gregor816fd362010-01-22 21:44:22 +00003101CINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, CXSourceLocation);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003102
Douglas Gregor66a58812010-01-18 22:46:11 +00003103/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003104 * Retrieve the physical location of the source constructor referenced
Douglas Gregor66a58812010-01-18 22:46:11 +00003105 * by the given cursor.
3106 *
3107 * The location of a declaration is typically the location of the name of that
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003108 * declaration, where the name of that declaration would occur if it is
3109 * unnamed, or some keyword that introduces that particular declaration.
3110 * The location of a reference is where that reference occurs within the
Douglas Gregor66a58812010-01-18 22:46:11 +00003111 * source code.
3112 */
3113CINDEX_LINKAGE CXSourceLocation clang_getCursorLocation(CXCursor);
Douglas Gregor6007cf22010-01-22 22:29:16 +00003114
Douglas Gregor6b8232f2010-01-19 19:34:47 +00003115/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003116 * Retrieve the physical extent of the source construct referenced by
Douglas Gregor33c34ac2010-01-19 00:34:46 +00003117 * the given cursor.
3118 *
3119 * The extent of a cursor starts with the file/line/column pointing at the
3120 * first character within the source construct that the cursor refers to and
Nico Weber7deebef2014-04-24 03:17:47 +00003121 * ends with the last character within that source construct. For a
Douglas Gregor33c34ac2010-01-19 00:34:46 +00003122 * declaration, the extent covers the declaration itself. For a reference,
3123 * the extent covers the location of the reference (e.g., where the referenced
3124 * entity was actually used).
3125 */
3126CINDEX_LINKAGE CXSourceRange clang_getCursorExtent(CXCursor);
Douglas Gregorad27e8b2010-01-19 01:20:04 +00003127
Douglas Gregor6007cf22010-01-22 22:29:16 +00003128/**
3129 * @}
3130 */
Ted Kremeneka5940822010-08-26 01:42:22 +00003131
Douglas Gregor6007cf22010-01-22 22:29:16 +00003132/**
Ted Kremenek6bca9842010-05-14 21:29:26 +00003133 * \defgroup CINDEX_TYPES Type information for CXCursors
3134 *
3135 * @{
3136 */
3137
3138/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003139 * Describes the kind of type
Ted Kremenek6bca9842010-05-14 21:29:26 +00003140 */
3141enum CXTypeKind {
3142 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003143 * Represents an invalid type (e.g., where no type is available).
Ted Kremenek6bca9842010-05-14 21:29:26 +00003144 */
3145 CXType_Invalid = 0,
3146
3147 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003148 * A type whose specific kind is not exposed via this
Ted Kremenek6bca9842010-05-14 21:29:26 +00003149 * interface.
3150 */
3151 CXType_Unexposed = 1,
3152
3153 /* Builtin types */
3154 CXType_Void = 2,
3155 CXType_Bool = 3,
3156 CXType_Char_U = 4,
3157 CXType_UChar = 5,
3158 CXType_Char16 = 6,
3159 CXType_Char32 = 7,
3160 CXType_UShort = 8,
3161 CXType_UInt = 9,
3162 CXType_ULong = 10,
3163 CXType_ULongLong = 11,
3164 CXType_UInt128 = 12,
3165 CXType_Char_S = 13,
3166 CXType_SChar = 14,
3167 CXType_WChar = 15,
3168 CXType_Short = 16,
3169 CXType_Int = 17,
3170 CXType_Long = 18,
3171 CXType_LongLong = 19,
3172 CXType_Int128 = 20,
3173 CXType_Float = 21,
3174 CXType_Double = 22,
3175 CXType_LongDouble = 23,
3176 CXType_NullPtr = 24,
3177 CXType_Overload = 25,
3178 CXType_Dependent = 26,
3179 CXType_ObjCId = 27,
3180 CXType_ObjCClass = 28,
3181 CXType_ObjCSel = 29,
Nemanja Ivanovicbb1ea2d2016-05-09 08:52:33 +00003182 CXType_Float128 = 30,
Joey Gouly6ea21852017-02-10 15:51:11 +00003183 CXType_Half = 31,
Sjoerd Meijercc623ad2017-09-08 15:15:00 +00003184 CXType_Float16 = 32,
Ted Kremenek6bca9842010-05-14 21:29:26 +00003185 CXType_FirstBuiltin = CXType_Void,
Sjoerd Meijercc623ad2017-09-08 15:15:00 +00003186 CXType_LastBuiltin = CXType_Float16,
Ted Kremenek6bca9842010-05-14 21:29:26 +00003187
3188 CXType_Complex = 100,
3189 CXType_Pointer = 101,
3190 CXType_BlockPointer = 102,
3191 CXType_LValueReference = 103,
3192 CXType_RValueReference = 104,
3193 CXType_Record = 105,
3194 CXType_Enum = 106,
3195 CXType_Typedef = 107,
3196 CXType_ObjCInterface = 108,
Ted Kremenekc1508872010-06-21 20:15:39 +00003197 CXType_ObjCObjectPointer = 109,
3198 CXType_FunctionNoProto = 110,
Argyrios Kyrtzidis2b0cf602011-09-27 17:44:34 +00003199 CXType_FunctionProto = 111,
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003200 CXType_ConstantArray = 112,
Argyrios Kyrtzidis0661a712013-07-23 17:36:21 +00003201 CXType_Vector = 113,
3202 CXType_IncompleteArray = 114,
3203 CXType_VariableArray = 115,
Argyrios Kyrtzidis7a4253b2013-10-03 16:19:23 +00003204 CXType_DependentSizedArray = 116,
Sergey Kalinichevc0151202015-11-15 13:10:10 +00003205 CXType_MemberPointer = 117,
Sergey Kalinichev69770ae2016-05-03 06:58:29 +00003206 CXType_Auto = 118,
3207
3208 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003209 * Represents a type that was referred to using an elaborated type keyword.
Sergey Kalinichev69770ae2016-05-03 06:58:29 +00003210 *
3211 * E.g., struct S, or via a qualified name, e.g., N::M::type, or both.
3212 */
Sven van Haastregtcc4f1e42017-05-23 10:36:43 +00003213 CXType_Elaborated = 119,
3214
3215 /* OpenCL PipeType. */
3216 CXType_Pipe = 120,
3217
3218 /* OpenCL builtin types. */
3219 CXType_OCLImage1dRO = 121,
3220 CXType_OCLImage1dArrayRO = 122,
3221 CXType_OCLImage1dBufferRO = 123,
3222 CXType_OCLImage2dRO = 124,
3223 CXType_OCLImage2dArrayRO = 125,
3224 CXType_OCLImage2dDepthRO = 126,
3225 CXType_OCLImage2dArrayDepthRO = 127,
3226 CXType_OCLImage2dMSAARO = 128,
3227 CXType_OCLImage2dArrayMSAARO = 129,
3228 CXType_OCLImage2dMSAADepthRO = 130,
3229 CXType_OCLImage2dArrayMSAADepthRO = 131,
3230 CXType_OCLImage3dRO = 132,
3231 CXType_OCLImage1dWO = 133,
3232 CXType_OCLImage1dArrayWO = 134,
3233 CXType_OCLImage1dBufferWO = 135,
3234 CXType_OCLImage2dWO = 136,
3235 CXType_OCLImage2dArrayWO = 137,
3236 CXType_OCLImage2dDepthWO = 138,
3237 CXType_OCLImage2dArrayDepthWO = 139,
3238 CXType_OCLImage2dMSAAWO = 140,
3239 CXType_OCLImage2dArrayMSAAWO = 141,
3240 CXType_OCLImage2dMSAADepthWO = 142,
3241 CXType_OCLImage2dArrayMSAADepthWO = 143,
3242 CXType_OCLImage3dWO = 144,
3243 CXType_OCLImage1dRW = 145,
3244 CXType_OCLImage1dArrayRW = 146,
3245 CXType_OCLImage1dBufferRW = 147,
3246 CXType_OCLImage2dRW = 148,
3247 CXType_OCLImage2dArrayRW = 149,
3248 CXType_OCLImage2dDepthRW = 150,
3249 CXType_OCLImage2dArrayDepthRW = 151,
3250 CXType_OCLImage2dMSAARW = 152,
3251 CXType_OCLImage2dArrayMSAARW = 153,
3252 CXType_OCLImage2dMSAADepthRW = 154,
3253 CXType_OCLImage2dArrayMSAADepthRW = 155,
3254 CXType_OCLImage3dRW = 156,
3255 CXType_OCLSampler = 157,
3256 CXType_OCLEvent = 158,
3257 CXType_OCLQueue = 159,
3258 CXType_OCLReserveID = 160
Ted Kremenek6bca9842010-05-14 21:29:26 +00003259};
3260
3261/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003262 * Describes the calling convention of a function type
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003263 */
3264enum CXCallingConv {
3265 CXCallingConv_Default = 0,
3266 CXCallingConv_C = 1,
3267 CXCallingConv_X86StdCall = 2,
3268 CXCallingConv_X86FastCall = 3,
3269 CXCallingConv_X86ThisCall = 4,
3270 CXCallingConv_X86Pascal = 5,
3271 CXCallingConv_AAPCS = 6,
3272 CXCallingConv_AAPCS_VFP = 7,
Erich Keane757d3172016-11-02 18:29:35 +00003273 CXCallingConv_X86RegCall = 8,
Guy Benyeif0a014b2012-12-25 08:53:55 +00003274 CXCallingConv_IntelOclBicc = 9,
Martin Storsjo022e7822017-07-17 20:49:45 +00003275 CXCallingConv_Win64 = 10,
Nikolai Bozhenovce25d412017-08-08 14:13:50 +00003276 /* Alias for compatibility with older versions of API. */
3277 CXCallingConv_X86_64Win64 = CXCallingConv_Win64,
Charles Davisb5a214e2013-08-30 04:39:01 +00003278 CXCallingConv_X86_64SysV = 11,
Reid Klecknerd7857f02014-10-24 17:42:17 +00003279 CXCallingConv_X86VectorCall = 12,
John McCall477f2bb2016-03-03 06:39:32 +00003280 CXCallingConv_Swift = 13,
Roman Levenstein35aa5ce2016-03-16 18:00:46 +00003281 CXCallingConv_PreserveMost = 14,
3282 CXCallingConv_PreserveAll = 15,
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003283
3284 CXCallingConv_Invalid = 100,
3285 CXCallingConv_Unexposed = 200
3286};
3287
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003288/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003289 * The type of an element in the abstract syntax tree.
Ted Kremenek6bca9842010-05-14 21:29:26 +00003290 *
3291 */
3292typedef struct {
3293 enum CXTypeKind kind;
3294 void *data[2];
3295} CXType;
3296
3297/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003298 * Retrieve the type of a CXCursor (if any).
Ted Kremenek6bca9842010-05-14 21:29:26 +00003299 */
3300CINDEX_LINKAGE CXType clang_getCursorType(CXCursor C);
3301
3302/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003303 * Pretty-print the underlying type using the rules of the
Dmitri Gribenko00353722013-02-15 21:15:49 +00003304 * language of the translation unit from which it came.
3305 *
3306 * If the type is invalid, an empty string is returned.
3307 */
3308CINDEX_LINKAGE CXString clang_getTypeSpelling(CXType CT);
3309
3310/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003311 * Retrieve the underlying type of a typedef declaration.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003312 *
3313 * If the cursor does not reference a typedef declaration, an invalid type is
3314 * returned.
3315 */
3316CINDEX_LINKAGE CXType clang_getTypedefDeclUnderlyingType(CXCursor C);
3317
3318/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003319 * Retrieve the integer type of an enum declaration.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003320 *
3321 * If the cursor does not reference an enum declaration, an invalid type is
3322 * returned.
3323 */
3324CINDEX_LINKAGE CXType clang_getEnumDeclIntegerType(CXCursor C);
3325
3326/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003327 * Retrieve the integer value of an enum constant declaration as a signed
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003328 * long long.
3329 *
3330 * If the cursor does not reference an enum constant declaration, LLONG_MIN is returned.
3331 * Since this is also potentially a valid constant value, the kind of the cursor
3332 * must be verified before calling this function.
3333 */
3334CINDEX_LINKAGE long long clang_getEnumConstantDeclValue(CXCursor C);
3335
3336/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003337 * Retrieve the integer value of an enum constant declaration as an unsigned
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003338 * long long.
3339 *
3340 * If the cursor does not reference an enum constant declaration, ULLONG_MAX is returned.
3341 * Since this is also potentially a valid constant value, the kind of the cursor
3342 * must be verified before calling this function.
3343 */
3344CINDEX_LINKAGE unsigned long long clang_getEnumConstantDeclUnsignedValue(CXCursor C);
3345
3346/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003347 * Retrieve the bit width of a bit field declaration as an integer.
Dmitri Gribenkob506ba12012-12-04 15:13:46 +00003348 *
3349 * If a cursor that is not a bit field declaration is passed in, -1 is returned.
3350 */
3351CINDEX_LINKAGE int clang_getFieldDeclBitWidth(CXCursor C);
3352
3353/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003354 * Retrieve the number of non-variadic arguments associated with a given
Argyrios Kyrtzidis0c27e4b2012-04-11 19:32:19 +00003355 * cursor.
3356 *
Argyrios Kyrtzidisb2792972013-04-01 17:38:59 +00003357 * The number of arguments can be determined for calls as well as for
3358 * declarations of functions or methods. For other cursors -1 is returned.
Argyrios Kyrtzidis0c27e4b2012-04-11 19:32:19 +00003359 */
3360CINDEX_LINKAGE int clang_Cursor_getNumArguments(CXCursor C);
3361
3362/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003363 * Retrieve the argument cursor of a function or method.
Argyrios Kyrtzidis0c27e4b2012-04-11 19:32:19 +00003364 *
Argyrios Kyrtzidisb2792972013-04-01 17:38:59 +00003365 * The argument cursor can be determined for calls as well as for declarations
3366 * of functions or methods. For other cursors and for invalid indices, an
3367 * invalid cursor is returned.
Argyrios Kyrtzidis0c27e4b2012-04-11 19:32:19 +00003368 */
3369CINDEX_LINKAGE CXCursor clang_Cursor_getArgument(CXCursor C, unsigned i);
3370
3371/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003372 * Describes the kind of a template argument.
Eli Benderskyc27a0c42014-10-10 20:01:05 +00003373 *
3374 * See the definition of llvm::clang::TemplateArgument::ArgKind for full
3375 * element descriptions.
3376 */
3377enum CXTemplateArgumentKind {
3378 CXTemplateArgumentKind_Null,
3379 CXTemplateArgumentKind_Type,
3380 CXTemplateArgumentKind_Declaration,
3381 CXTemplateArgumentKind_NullPtr,
3382 CXTemplateArgumentKind_Integral,
3383 CXTemplateArgumentKind_Template,
3384 CXTemplateArgumentKind_TemplateExpansion,
3385 CXTemplateArgumentKind_Expression,
3386 CXTemplateArgumentKind_Pack,
3387 /* Indicates an error case, preventing the kind from being deduced. */
3388 CXTemplateArgumentKind_Invalid
3389};
3390
3391/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003392 *Returns the number of template args of a function decl representing a
Eli Benderskyc27a0c42014-10-10 20:01:05 +00003393 * template specialization.
3394 *
3395 * If the argument cursor cannot be converted into a template function
3396 * declaration, -1 is returned.
3397 *
3398 * For example, for the following declaration and specialization:
3399 * template <typename T, int kInt, bool kBool>
3400 * void foo() { ... }
3401 *
3402 * template <>
3403 * void foo<float, -7, true>();
3404 *
3405 * The value 3 would be returned from this call.
3406 */
3407CINDEX_LINKAGE int clang_Cursor_getNumTemplateArguments(CXCursor C);
3408
3409/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003410 * Retrieve the kind of the I'th template argument of the CXCursor C.
Eli Benderskyc27a0c42014-10-10 20:01:05 +00003411 *
3412 * If the argument CXCursor does not represent a FunctionDecl, an invalid
3413 * template argument kind is returned.
3414 *
3415 * For example, for the following declaration and specialization:
3416 * template <typename T, int kInt, bool kBool>
3417 * void foo() { ... }
3418 *
3419 * template <>
3420 * void foo<float, -7, true>();
3421 *
3422 * For I = 0, 1, and 2, Type, Integral, and Integral will be returned,
3423 * respectively.
3424 */
3425CINDEX_LINKAGE enum CXTemplateArgumentKind clang_Cursor_getTemplateArgumentKind(
3426 CXCursor C, unsigned I);
3427
3428/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003429 * Retrieve a CXType representing the type of a TemplateArgument of a
Eli Benderskyc27a0c42014-10-10 20:01:05 +00003430 * function decl representing a template specialization.
3431 *
3432 * If the argument CXCursor does not represent a FunctionDecl whose I'th
3433 * template argument has a kind of CXTemplateArgKind_Integral, an invalid type
3434 * is returned.
3435 *
3436 * For example, for the following declaration and specialization:
3437 * template <typename T, int kInt, bool kBool>
3438 * void foo() { ... }
3439 *
3440 * template <>
3441 * void foo<float, -7, true>();
3442 *
3443 * If called with I = 0, "float", will be returned.
3444 * Invalid types will be returned for I == 1 or 2.
3445 */
3446CINDEX_LINKAGE CXType clang_Cursor_getTemplateArgumentType(CXCursor C,
3447 unsigned I);
3448
3449/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003450 * Retrieve the value of an Integral TemplateArgument (of a function
Eli Benderskyc27a0c42014-10-10 20:01:05 +00003451 * decl representing a template specialization) as a signed long long.
3452 *
3453 * It is undefined to call this function on a CXCursor that does not represent a
3454 * FunctionDecl or whose I'th template argument is not an integral value.
3455 *
3456 * For example, for the following declaration and specialization:
3457 * template <typename T, int kInt, bool kBool>
3458 * void foo() { ... }
3459 *
3460 * template <>
3461 * void foo<float, -7, true>();
3462 *
3463 * If called with I = 1 or 2, -7 or true will be returned, respectively.
3464 * For I == 0, this function's behavior is undefined.
3465 */
3466CINDEX_LINKAGE long long clang_Cursor_getTemplateArgumentValue(CXCursor C,
3467 unsigned I);
3468
3469/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003470 * Retrieve the value of an Integral TemplateArgument (of a function
Eli Benderskyc27a0c42014-10-10 20:01:05 +00003471 * decl representing a template specialization) as an unsigned long long.
3472 *
3473 * It is undefined to call this function on a CXCursor that does not represent a
3474 * FunctionDecl or whose I'th template argument is not an integral value.
3475 *
3476 * For example, for the following declaration and specialization:
3477 * template <typename T, int kInt, bool kBool>
3478 * void foo() { ... }
3479 *
3480 * template <>
3481 * void foo<float, 2147483649, true>();
3482 *
3483 * If called with I = 1 or 2, 2147483649 or true will be returned, respectively.
3484 * For I == 0, this function's behavior is undefined.
3485 */
3486CINDEX_LINKAGE unsigned long long clang_Cursor_getTemplateArgumentUnsignedValue(
3487 CXCursor C, unsigned I);
3488
3489/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003490 * Determine whether two CXTypes represent the same type.
Ted Kremenek6bca9842010-05-14 21:29:26 +00003491 *
James Dennett574cb4c2012-06-15 05:41:51 +00003492 * \returns non-zero if the CXTypes represent the same type and
3493 * zero otherwise.
Ted Kremenek6bca9842010-05-14 21:29:26 +00003494 */
3495CINDEX_LINKAGE unsigned clang_equalTypes(CXType A, CXType B);
3496
3497/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003498 * Return the canonical type for a CXType.
Ted Kremenek6bca9842010-05-14 21:29:26 +00003499 *
3500 * Clang's type system explicitly models typedefs and all the ways
3501 * a specific type can be represented. The canonical type is the underlying
3502 * type with all the "sugar" removed. For example, if 'T' is a typedef
3503 * for 'int', the canonical type for 'T' would be 'int'.
3504 */
3505CINDEX_LINKAGE CXType clang_getCanonicalType(CXType T);
3506
3507/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003508 * Determine whether a CXType has the "const" qualifier set,
James Dennett574cb4c2012-06-15 05:41:51 +00003509 * without looking through typedefs that may have added "const" at a
3510 * different level.
Douglas Gregor56a63802011-01-27 16:27:11 +00003511 */
3512CINDEX_LINKAGE unsigned clang_isConstQualifiedType(CXType T);
3513
3514/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003515 * Determine whether a CXCursor that is a macro, is
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00003516 * function like.
3517 */
3518CINDEX_LINKAGE unsigned clang_Cursor_isMacroFunctionLike(CXCursor C);
3519
3520/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003521 * Determine whether a CXCursor that is a macro, is a
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00003522 * builtin one.
3523 */
3524CINDEX_LINKAGE unsigned clang_Cursor_isMacroBuiltin(CXCursor C);
3525
3526/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003527 * Determine whether a CXCursor that is a function declaration, is an
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00003528 * inline declaration.
3529 */
3530CINDEX_LINKAGE unsigned clang_Cursor_isFunctionInlined(CXCursor C);
3531
3532/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003533 * Determine whether a CXType has the "volatile" qualifier set,
James Dennett574cb4c2012-06-15 05:41:51 +00003534 * without looking through typedefs that may have added "volatile" at
3535 * a different level.
Douglas Gregor56a63802011-01-27 16:27:11 +00003536 */
3537CINDEX_LINKAGE unsigned clang_isVolatileQualifiedType(CXType T);
3538
3539/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003540 * Determine whether a CXType has the "restrict" qualifier set,
James Dennett574cb4c2012-06-15 05:41:51 +00003541 * without looking through typedefs that may have added "restrict" at a
3542 * different level.
Douglas Gregor56a63802011-01-27 16:27:11 +00003543 */
3544CINDEX_LINKAGE unsigned clang_isRestrictQualifiedType(CXType T);
3545
3546/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003547 * Returns the address space of the given type.
Sven van Haastregte8910422017-06-08 14:22:04 +00003548 */
3549CINDEX_LINKAGE unsigned clang_getAddressSpace(CXType T);
3550
3551/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003552 * Returns the typedef name of the given type.
Sven van Haastregte8910422017-06-08 14:22:04 +00003553 */
3554CINDEX_LINKAGE CXString clang_getTypedefName(CXType CT);
3555
3556/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003557 * For pointer types, returns the type of the pointee.
Ted Kremenek6bca9842010-05-14 21:29:26 +00003558 */
3559CINDEX_LINKAGE CXType clang_getPointeeType(CXType T);
3560
3561/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003562 * Return the cursor for the declaration of the given type.
Ted Kremenek6bca9842010-05-14 21:29:26 +00003563 */
3564CINDEX_LINKAGE CXCursor clang_getTypeDeclaration(CXType T);
3565
David Chisnall50e4eba2010-12-30 14:05:53 +00003566/**
3567 * Returns the Objective-C type encoding for the specified declaration.
3568 */
3569CINDEX_LINKAGE CXString clang_getDeclObjCTypeEncoding(CXCursor C);
Ted Kremenek6bca9842010-05-14 21:29:26 +00003570
3571/**
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00003572 * Returns the Objective-C type encoding for the specified CXType.
3573 */
3574CINDEX_LINKAGE CXString clang_Type_getObjCEncoding(CXType type);
3575
3576/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003577 * Retrieve the spelling of a given CXTypeKind.
Ted Kremenek6bca9842010-05-14 21:29:26 +00003578 */
3579CINDEX_LINKAGE CXString clang_getTypeKindSpelling(enum CXTypeKind K);
3580
3581/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003582 * Retrieve the calling convention associated with a function type.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003583 *
3584 * If a non-function type is passed in, CXCallingConv_Invalid is returned.
3585 */
3586CINDEX_LINKAGE enum CXCallingConv clang_getFunctionTypeCallingConv(CXType T);
3587
3588/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003589 * Retrieve the return type associated with a function type.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003590 *
3591 * If a non-function type is passed in, an invalid type is returned.
Ted Kremenekc1508872010-06-21 20:15:39 +00003592 */
3593CINDEX_LINKAGE CXType clang_getResultType(CXType T);
3594
3595/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003596 * Retrieve the exception specification type associated with a function type.
Richard Smitheedb0c92018-05-11 19:46:31 +00003597 * This is a value of type CXCursor_ExceptionSpecificationKind.
Jonathan Coe0a5b03b2017-06-27 22:54:56 +00003598 *
3599 * If a non-function type is passed in, an error code of -1 is returned.
3600 */
3601CINDEX_LINKAGE int clang_getExceptionSpecificationType(CXType T);
3602
3603/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003604 * Retrieve the number of non-variadic parameters associated with a
James Dennett574cb4c2012-06-15 05:41:51 +00003605 * function type.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003606 *
Argyrios Kyrtzidis0c27e4b2012-04-11 19:32:19 +00003607 * If a non-function type is passed in, -1 is returned.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003608 */
Argyrios Kyrtzidis0c27e4b2012-04-11 19:32:19 +00003609CINDEX_LINKAGE int clang_getNumArgTypes(CXType T);
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003610
3611/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003612 * Retrieve the type of a parameter of a function type.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003613 *
James Dennett574cb4c2012-06-15 05:41:51 +00003614 * If a non-function type is passed in or the function does not have enough
3615 * parameters, an invalid type is returned.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003616 */
3617CINDEX_LINKAGE CXType clang_getArgType(CXType T, unsigned i);
3618
3619/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003620 * Return 1 if the CXType is a variadic function type, and 0 otherwise.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003621 */
3622CINDEX_LINKAGE unsigned clang_isFunctionTypeVariadic(CXType T);
3623
3624/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003625 * Retrieve the return type associated with a given cursor.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003626 *
3627 * This only returns a valid type if the cursor refers to a function or method.
Ted Kremenekc62ab8d2010-06-21 20:48:56 +00003628 */
3629CINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C);
3630
3631/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003632 * Retrieve the exception specification type associated with a given cursor.
Richard Smitheedb0c92018-05-11 19:46:31 +00003633 * This is a value of type CXCursor_ExceptionSpecificationKind.
Jonathan Coe0a5b03b2017-06-27 22:54:56 +00003634 *
3635 * This only returns a valid result if the cursor refers to a function or method.
3636 */
3637CINDEX_LINKAGE int clang_getCursorExceptionSpecificationType(CXCursor C);
3638
3639/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003640 * Return 1 if the CXType is a POD (plain old data) type, and 0
Ted Kremenek0c7476a2010-07-30 00:14:11 +00003641 * otherwise.
3642 */
3643CINDEX_LINKAGE unsigned clang_isPODType(CXType T);
3644
3645/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003646 * Return the element type of an array, complex, or vector type.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003647 *
3648 * If a type is passed in that is not an array, complex, or vector type,
3649 * an invalid type is returned.
3650 */
3651CINDEX_LINKAGE CXType clang_getElementType(CXType T);
3652
3653/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003654 * Return the number of elements of an array or vector type.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003655 *
3656 * If a type is passed in that is not an array or vector type,
3657 * -1 is returned.
3658 */
3659CINDEX_LINKAGE long long clang_getNumElements(CXType T);
3660
3661/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003662 * Return the element type of an array type.
Argyrios Kyrtzidis2b0cf602011-09-27 17:44:34 +00003663 *
3664 * If a non-array type is passed in, an invalid type is returned.
3665 */
3666CINDEX_LINKAGE CXType clang_getArrayElementType(CXType T);
3667
3668/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003669 * Return the array size of a constant array.
Argyrios Kyrtzidis2b0cf602011-09-27 17:44:34 +00003670 *
3671 * If a non-array type is passed in, -1 is returned.
3672 */
3673CINDEX_LINKAGE long long clang_getArraySize(CXType T);
3674
3675/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003676 * Retrieve the type named by the qualified-id.
Sergey Kalinichev69770ae2016-05-03 06:58:29 +00003677 *
3678 * If a non-elaborated type is passed in, an invalid type is returned.
3679 */
3680CINDEX_LINKAGE CXType clang_Type_getNamedType(CXType T);
3681
3682/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003683 * Determine if a typedef is 'transparent' tag.
Argyrios Kyrtzidis3b25c912017-03-21 16:56:02 +00003684 *
3685 * A typedef is considered 'transparent' if it shares a name and spelling
3686 * location with its underlying tag type, as is the case with the NS_ENUM macro.
3687 *
3688 * \returns non-zero if transparent and zero otherwise.
3689 */
3690CINDEX_LINKAGE unsigned clang_Type_isTransparentTagTypedef(CXType T);
3691
3692/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003693 * List the possible error codes for \c clang_Type_getSizeOf,
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003694 * \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf and
3695 * \c clang_Cursor_getOffsetOf.
3696 *
3697 * A value of this enumeration type can be returned if the target type is not
3698 * a valid argument to sizeof, alignof or offsetof.
3699 */
3700enum CXTypeLayoutError {
3701 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003702 * Type is of kind CXType_Invalid.
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003703 */
3704 CXTypeLayoutError_Invalid = -1,
3705 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003706 * The type is an incomplete Type.
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003707 */
3708 CXTypeLayoutError_Incomplete = -2,
3709 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003710 * The type is a dependent Type.
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003711 */
3712 CXTypeLayoutError_Dependent = -3,
3713 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003714 * The type is not a constant size type.
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003715 */
3716 CXTypeLayoutError_NotConstantSize = -4,
3717 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003718 * The Field name is not valid for this record.
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003719 */
3720 CXTypeLayoutError_InvalidFieldName = -5
3721};
3722
3723/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003724 * Return the alignment of a type in bytes as per C++[expr.alignof]
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003725 * standard.
3726 *
3727 * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
3728 * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
3729 * is returned.
3730 * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
3731 * returned.
3732 * If the type declaration is not a constant size type,
3733 * CXTypeLayoutError_NotConstantSize is returned.
3734 */
3735CINDEX_LINKAGE long long clang_Type_getAlignOf(CXType T);
3736
3737/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003738 * Return the class type of an member pointer type.
Argyrios Kyrtzidis7a4253b2013-10-03 16:19:23 +00003739 *
3740 * If a non-member-pointer type is passed in, an invalid type is returned.
3741 */
3742CINDEX_LINKAGE CXType clang_Type_getClassType(CXType T);
3743
3744/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003745 * Return the size of a type in bytes as per C++[expr.sizeof] standard.
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003746 *
3747 * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
3748 * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
3749 * is returned.
3750 * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
3751 * returned.
3752 */
3753CINDEX_LINKAGE long long clang_Type_getSizeOf(CXType T);
3754
3755/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003756 * Return the offset of a field named S in a record of type T in bits
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003757 * as it would be returned by __offsetof__ as per C++11[18.2p4]
3758 *
3759 * If the cursor is not a record field declaration, CXTypeLayoutError_Invalid
3760 * is returned.
3761 * If the field's type declaration is an incomplete type,
3762 * CXTypeLayoutError_Incomplete is returned.
3763 * If the field's type declaration is a dependent type,
3764 * CXTypeLayoutError_Dependent is returned.
3765 * If the field's name S is not found,
3766 * CXTypeLayoutError_InvalidFieldName is returned.
3767 */
3768CINDEX_LINKAGE long long clang_Type_getOffsetOf(CXType T, const char *S);
3769
Argyrios Kyrtzidis2bff5162015-04-13 16:55:04 +00003770/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003771 * Return the offset of the field represented by the Cursor.
Argyrios Kyrtzidis2bff5162015-04-13 16:55:04 +00003772 *
3773 * If the cursor is not a field declaration, -1 is returned.
3774 * If the cursor semantic parent is not a record field declaration,
3775 * CXTypeLayoutError_Invalid is returned.
3776 * If the field's type declaration is an incomplete type,
3777 * CXTypeLayoutError_Incomplete is returned.
3778 * If the field's type declaration is a dependent type,
3779 * CXTypeLayoutError_Dependent is returned.
3780 * If the field's name S is not found,
3781 * CXTypeLayoutError_InvalidFieldName is returned.
3782 */
3783CINDEX_LINKAGE long long clang_Cursor_getOffsetOfField(CXCursor C);
3784
3785/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003786 * Determine whether the given cursor represents an anonymous record
Argyrios Kyrtzidis2bff5162015-04-13 16:55:04 +00003787 * declaration.
3788 */
3789CINDEX_LINKAGE unsigned clang_Cursor_isAnonymous(CXCursor C);
3790
Argyrios Kyrtzidisadff3ae2013-10-11 19:58:38 +00003791enum CXRefQualifierKind {
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003792 /** No ref-qualifier was provided. */
Argyrios Kyrtzidisadff3ae2013-10-11 19:58:38 +00003793 CXRefQualifier_None = 0,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003794 /** An lvalue ref-qualifier was provided (\c &). */
Argyrios Kyrtzidisadff3ae2013-10-11 19:58:38 +00003795 CXRefQualifier_LValue,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003796 /** An rvalue ref-qualifier was provided (\c &&). */
Argyrios Kyrtzidisadff3ae2013-10-11 19:58:38 +00003797 CXRefQualifier_RValue
3798};
3799
3800/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003801 * Returns the number of template arguments for given template
Argyrios Kyrtzidis35f5aab2016-11-15 20:51:46 +00003802 * specialization, or -1 if type \c T is not a template specialization.
Dmitri Gribenko6ede6ab2014-02-27 16:05:05 +00003803 */
3804CINDEX_LINKAGE int clang_Type_getNumTemplateArguments(CXType T);
3805
3806/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003807 * Returns the type template argument of a template class specialization
Dmitri Gribenko6ede6ab2014-02-27 16:05:05 +00003808 * at given index.
3809 *
3810 * This function only returns template type arguments and does not handle
3811 * template template arguments or variadic packs.
3812 */
3813CINDEX_LINKAGE CXType clang_Type_getTemplateArgumentAsType(CXType T, unsigned i);
3814
3815/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003816 * Retrieve the ref-qualifier kind of a function or method.
Argyrios Kyrtzidisadff3ae2013-10-11 19:58:38 +00003817 *
3818 * The ref-qualifier is returned for C++ functions or methods. For other types
3819 * or non-C++ declarations, CXRefQualifier_None is returned.
3820 */
3821CINDEX_LINKAGE enum CXRefQualifierKind clang_Type_getCXXRefQualifier(CXType T);
3822
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003823/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003824 * Returns non-zero if the cursor specifies a Record member that is a
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003825 * bitfield.
3826 */
3827CINDEX_LINKAGE unsigned clang_Cursor_isBitField(CXCursor C);
3828
3829/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003830 * Returns 1 if the base class specified by the cursor with kind
Ted Kremenekae9e2212010-08-27 21:34:58 +00003831 * CX_CXXBaseSpecifier is virtual.
3832 */
3833CINDEX_LINKAGE unsigned clang_isVirtualBase(CXCursor);
3834
3835/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003836 * Represents the C++ access control level to a base class for a
Ted Kremenekae9e2212010-08-27 21:34:58 +00003837 * cursor with kind CX_CXXBaseSpecifier.
3838 */
3839enum CX_CXXAccessSpecifier {
3840 CX_CXXInvalidAccessSpecifier,
3841 CX_CXXPublic,
3842 CX_CXXProtected,
3843 CX_CXXPrivate
3844};
3845
3846/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003847 * Returns the access control level for the referenced object.
Argyrios Kyrtzidisf6464082013-04-11 17:31:13 +00003848 *
Argyrios Kyrtzidis1ab09cc2013-04-11 17:02:10 +00003849 * If the cursor refers to a C++ declaration, its access control level within its
3850 * parent scope is returned. Otherwise, if the cursor refers to a base specifier or
3851 * access specifier, the specifier itself is returned.
Ted Kremenekae9e2212010-08-27 21:34:58 +00003852 */
3853CINDEX_LINKAGE enum CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor);
3854
3855/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003856 * Represents the storage classes as declared in the source. CX_SC_Invalid
Chad Rosierdb1cc7f2014-12-05 15:50:44 +00003857 * was added for the case that the passed cursor in not a declaration.
Argyrios Kyrtzidis4e0854f2014-10-15 17:05:31 +00003858 */
3859enum CX_StorageClass {
3860 CX_SC_Invalid,
3861 CX_SC_None,
3862 CX_SC_Extern,
3863 CX_SC_Static,
3864 CX_SC_PrivateExtern,
3865 CX_SC_OpenCLWorkGroupLocal,
3866 CX_SC_Auto,
3867 CX_SC_Register
3868};
3869
3870/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003871 * Returns the storage class for a function or variable declaration.
Argyrios Kyrtzidis4e0854f2014-10-15 17:05:31 +00003872 *
3873 * If the passed in Cursor is not a function or variable declaration,
3874 * CX_SC_Invalid is returned else the storage class.
3875 */
3876CINDEX_LINKAGE enum CX_StorageClass clang_Cursor_getStorageClass(CXCursor);
3877
3878/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003879 * Determine the number of overloaded declarations referenced by a
Douglas Gregor16a2bdd2010-09-13 22:52:57 +00003880 * \c CXCursor_OverloadedDeclRef cursor.
3881 *
3882 * \param cursor The cursor whose overloaded declarations are being queried.
3883 *
3884 * \returns The number of overloaded declarations referenced by \c cursor. If it
3885 * is not a \c CXCursor_OverloadedDeclRef cursor, returns 0.
3886 */
3887CINDEX_LINKAGE unsigned clang_getNumOverloadedDecls(CXCursor cursor);
3888
3889/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003890 * Retrieve a cursor for one of the overloaded declarations referenced
Douglas Gregor16a2bdd2010-09-13 22:52:57 +00003891 * by a \c CXCursor_OverloadedDeclRef cursor.
3892 *
3893 * \param cursor The cursor whose overloaded declarations are being queried.
3894 *
3895 * \param index The zero-based index into the set of overloaded declarations in
3896 * the cursor.
3897 *
3898 * \returns A cursor representing the declaration referenced by the given
3899 * \c cursor at the specified \c index. If the cursor does not have an
3900 * associated set of overloaded declarations, or if the index is out of bounds,
3901 * returns \c clang_getNullCursor();
3902 */
3903CINDEX_LINKAGE CXCursor clang_getOverloadedDecl(CXCursor cursor,
3904 unsigned index);
3905
3906/**
Ted Kremenek6bca9842010-05-14 21:29:26 +00003907 * @}
3908 */
Ted Kremeneka5940822010-08-26 01:42:22 +00003909
3910/**
Ted Kremenek2c2c5f32010-08-27 21:34:51 +00003911 * \defgroup CINDEX_ATTRIBUTES Information for attributes
Ted Kremeneka5940822010-08-26 01:42:22 +00003912 *
3913 * @{
3914 */
3915
Ted Kremeneka5940822010-08-26 01:42:22 +00003916/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003917 * For cursors representing an iboutletcollection attribute,
Ted Kremeneka5940822010-08-26 01:42:22 +00003918 * this function returns the collection element type.
3919 *
3920 */
3921CINDEX_LINKAGE CXType clang_getIBOutletCollectionType(CXCursor);
3922
3923/**
3924 * @}
3925 */
Ted Kremenek6bca9842010-05-14 21:29:26 +00003926
3927/**
Douglas Gregor6007cf22010-01-22 22:29:16 +00003928 * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors
3929 *
3930 * These routines provide the ability to traverse the abstract syntax tree
3931 * using cursors.
3932 *
3933 * @{
3934 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003935
Douglas Gregor6007cf22010-01-22 22:29:16 +00003936/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003937 * Describes how the traversal of the children of a particular
Douglas Gregor6007cf22010-01-22 22:29:16 +00003938 * cursor should proceed after visiting a particular child cursor.
3939 *
3940 * A value of this enumeration type should be returned by each
3941 * \c CXCursorVisitor to indicate how clang_visitChildren() proceed.
3942 */
3943enum CXChildVisitResult {
3944 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003945 * Terminates the cursor traversal.
Douglas Gregor6007cf22010-01-22 22:29:16 +00003946 */
3947 CXChildVisit_Break,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003948 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003949 * Continues the cursor traversal with the next sibling of
Douglas Gregor6007cf22010-01-22 22:29:16 +00003950 * the cursor just visited, without visiting its children.
3951 */
3952 CXChildVisit_Continue,
3953 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003954 * Recursively traverse the children of this cursor, using
Douglas Gregor6007cf22010-01-22 22:29:16 +00003955 * the same visitor and client data.
3956 */
3957 CXChildVisit_Recurse
3958};
3959
3960/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003961 * Visitor invoked for each cursor found by a traversal.
Douglas Gregor6007cf22010-01-22 22:29:16 +00003962 *
3963 * This visitor function will be invoked for each cursor found by
3964 * clang_visitCursorChildren(). Its first argument is the cursor being
3965 * visited, its second argument is the parent visitor for that cursor,
3966 * and its third argument is the client data provided to
3967 * clang_visitCursorChildren().
3968 *
3969 * The visitor should return one of the \c CXChildVisitResult values
3970 * to direct clang_visitCursorChildren().
3971 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003972typedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor,
3973 CXCursor parent,
Douglas Gregor6007cf22010-01-22 22:29:16 +00003974 CXClientData client_data);
3975
3976/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003977 * Visit the children of a particular cursor.
Douglas Gregor6007cf22010-01-22 22:29:16 +00003978 *
3979 * This function visits all the direct children of the given cursor,
3980 * invoking the given \p visitor function with the cursors of each
3981 * visited child. The traversal may be recursive, if the visitor returns
3982 * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if
3983 * the visitor returns \c CXChildVisit_Break.
3984 *
Douglas Gregor6007cf22010-01-22 22:29:16 +00003985 * \param parent the cursor whose child may be visited. All kinds of
Daniel Dunbarb9999fd2010-01-24 04:10:31 +00003986 * cursors can be visited, including invalid cursors (which, by
Douglas Gregor6007cf22010-01-22 22:29:16 +00003987 * definition, have no children).
3988 *
3989 * \param visitor the visitor function that will be invoked for each
3990 * child of \p parent.
3991 *
3992 * \param client_data pointer data supplied by the client, which will
3993 * be passed to the visitor each time it is invoked.
3994 *
3995 * \returns a non-zero value if the traversal was terminated
3996 * prematurely by the visitor returning \c CXChildVisit_Break.
3997 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003998CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent,
Douglas Gregor6007cf22010-01-22 22:29:16 +00003999 CXCursorVisitor visitor,
4000 CXClientData client_data);
David Chisnallb2aa0ef2010-11-03 14:12:26 +00004001#ifdef __has_feature
4002# if __has_feature(blocks)
4003/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004004 * Visitor invoked for each cursor found by a traversal.
David Chisnallb2aa0ef2010-11-03 14:12:26 +00004005 *
4006 * This visitor block will be invoked for each cursor found by
4007 * clang_visitChildrenWithBlock(). Its first argument is the cursor being
4008 * visited, its second argument is the parent visitor for that cursor.
4009 *
4010 * The visitor should return one of the \c CXChildVisitResult values
4011 * to direct clang_visitChildrenWithBlock().
4012 */
4013typedef enum CXChildVisitResult
4014 (^CXCursorVisitorBlock)(CXCursor cursor, CXCursor parent);
4015
4016/**
4017 * Visits the children of a cursor using the specified block. Behaves
4018 * identically to clang_visitChildren() in all other respects.
4019 */
Argyrios Kyrtzidisa0a35d72016-02-07 18:21:28 +00004020CINDEX_LINKAGE unsigned clang_visitChildrenWithBlock(CXCursor parent,
4021 CXCursorVisitorBlock block);
David Chisnallb2aa0ef2010-11-03 14:12:26 +00004022# endif
4023#endif
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004024
Douglas Gregor6007cf22010-01-22 22:29:16 +00004025/**
4026 * @}
4027 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004028
Douglas Gregor6007cf22010-01-22 22:29:16 +00004029/**
4030 * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST
4031 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004032 * These routines provide the ability to determine references within and
Douglas Gregor6007cf22010-01-22 22:29:16 +00004033 * across translation units, by providing the names of the entities referenced
4034 * by cursors, follow reference cursors to the declarations they reference,
4035 * and associate declarations with their definitions.
4036 *
4037 * @{
4038 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004039
Douglas Gregor6007cf22010-01-22 22:29:16 +00004040/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004041 * Retrieve a Unified Symbol Resolution (USR) for the entity referenced
Douglas Gregor6007cf22010-01-22 22:29:16 +00004042 * by the given cursor.
4043 *
4044 * A Unified Symbol Resolution (USR) is a string that identifies a particular
4045 * entity (function, class, variable, etc.) within a program. USRs can be
4046 * compared across translation units to determine, e.g., when references in
4047 * one translation refer to an entity defined in another translation unit.
4048 */
4049CINDEX_LINKAGE CXString clang_getCursorUSR(CXCursor);
4050
4051/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004052 * Construct a USR for a specified Objective-C class.
Ted Kremenekd071c602010-03-13 02:50:34 +00004053 */
4054CINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name);
4055
4056/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004057 * Construct a USR for a specified Objective-C category.
Ted Kremenekd071c602010-03-13 02:50:34 +00004058 */
4059CINDEX_LINKAGE CXString
Ted Kremenekbc1a67b2010-03-15 17:38:58 +00004060 clang_constructUSR_ObjCCategory(const char *class_name,
Ted Kremenekd071c602010-03-13 02:50:34 +00004061 const char *category_name);
4062
4063/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004064 * Construct a USR for a specified Objective-C protocol.
Ted Kremenekd071c602010-03-13 02:50:34 +00004065 */
4066CINDEX_LINKAGE CXString
4067 clang_constructUSR_ObjCProtocol(const char *protocol_name);
4068
Ted Kremenekd071c602010-03-13 02:50:34 +00004069/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004070 * Construct a USR for a specified Objective-C instance variable and
Ted Kremenekd071c602010-03-13 02:50:34 +00004071 * the USR for its containing class.
4072 */
4073CINDEX_LINKAGE CXString clang_constructUSR_ObjCIvar(const char *name,
4074 CXString classUSR);
4075
4076/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004077 * Construct a USR for a specified Objective-C method and
Ted Kremenekd071c602010-03-13 02:50:34 +00004078 * the USR for its containing class.
4079 */
4080CINDEX_LINKAGE CXString clang_constructUSR_ObjCMethod(const char *name,
4081 unsigned isInstanceMethod,
4082 CXString classUSR);
4083
4084/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004085 * Construct a USR for a specified Objective-C property and the USR
Ted Kremenekd071c602010-03-13 02:50:34 +00004086 * for its containing class.
4087 */
4088CINDEX_LINKAGE CXString clang_constructUSR_ObjCProperty(const char *property,
4089 CXString classUSR);
4090
4091/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004092 * Retrieve a name for the entity referenced by this cursor.
Douglas Gregor6007cf22010-01-22 22:29:16 +00004093 */
4094CINDEX_LINKAGE CXString clang_getCursorSpelling(CXCursor);
4095
Douglas Gregor97c75712010-10-02 22:49:11 +00004096/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004097 * Retrieve a range for a piece that forms the cursors spelling name.
Argyrios Kyrtzidis191a6a82012-03-30 20:58:35 +00004098 * Most of the times there is only one range for the complete spelling but for
Nico Weber7deebef2014-04-24 03:17:47 +00004099 * Objective-C methods and Objective-C message expressions, there are multiple
4100 * pieces for each selector identifier.
Argyrios Kyrtzidis191a6a82012-03-30 20:58:35 +00004101 *
4102 * \param pieceIndex the index of the spelling name piece. If this is greater
4103 * than the actual number of pieces, it will return a NULL (invalid) range.
4104 *
4105 * \param options Reserved.
4106 */
4107CINDEX_LINKAGE CXSourceRange clang_Cursor_getSpellingNameRange(CXCursor,
4108 unsigned pieceIndex,
4109 unsigned options);
4110
4111/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004112 * Opaque pointer representing a policy that controls pretty printing
Jonathan Coe45ef5032018-01-16 10:19:56 +00004113 * for \c clang_getCursorPrettyPrinted.
4114 */
4115typedef void *CXPrintingPolicy;
4116
4117/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004118 * Properties for the printing policy.
Jonathan Coe45ef5032018-01-16 10:19:56 +00004119 *
4120 * See \c clang::PrintingPolicy for more information.
4121 */
4122enum CXPrintingPolicyProperty {
4123 CXPrintingPolicy_Indentation,
4124 CXPrintingPolicy_SuppressSpecifiers,
4125 CXPrintingPolicy_SuppressTagKeyword,
4126 CXPrintingPolicy_IncludeTagDefinition,
4127 CXPrintingPolicy_SuppressScope,
4128 CXPrintingPolicy_SuppressUnwrittenScope,
4129 CXPrintingPolicy_SuppressInitializers,
4130 CXPrintingPolicy_ConstantArraySizeAsWritten,
4131 CXPrintingPolicy_AnonymousTagLocations,
4132 CXPrintingPolicy_SuppressStrongLifetime,
4133 CXPrintingPolicy_SuppressLifetimeQualifiers,
4134 CXPrintingPolicy_SuppressTemplateArgsInCXXConstructors,
4135 CXPrintingPolicy_Bool,
4136 CXPrintingPolicy_Restrict,
4137 CXPrintingPolicy_Alignof,
4138 CXPrintingPolicy_UnderscoreAlignof,
4139 CXPrintingPolicy_UseVoidForZeroParams,
4140 CXPrintingPolicy_TerseOutput,
4141 CXPrintingPolicy_PolishForDeclaration,
4142 CXPrintingPolicy_Half,
4143 CXPrintingPolicy_MSWChar,
4144 CXPrintingPolicy_IncludeNewlines,
4145 CXPrintingPolicy_MSVCFormatting,
4146 CXPrintingPolicy_ConstantsAsWritten,
4147 CXPrintingPolicy_SuppressImplicitBase,
4148 CXPrintingPolicy_FullyQualifiedName,
4149
4150 CXPrintingPolicy_LastProperty = CXPrintingPolicy_FullyQualifiedName
4151};
4152
4153/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004154 * Get a property value for the given printing policy.
Jonathan Coe45ef5032018-01-16 10:19:56 +00004155 */
Ivan Donchevskii4cab0fe2018-01-16 12:11:59 +00004156CINDEX_LINKAGE unsigned
Jonathan Coe45ef5032018-01-16 10:19:56 +00004157clang_PrintingPolicy_getProperty(CXPrintingPolicy Policy,
4158 enum CXPrintingPolicyProperty Property);
4159
4160/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004161 * Set a property value for the given printing policy.
Jonathan Coe45ef5032018-01-16 10:19:56 +00004162 */
Ivan Donchevskii4cab0fe2018-01-16 12:11:59 +00004163CINDEX_LINKAGE void clang_PrintingPolicy_setProperty(CXPrintingPolicy Policy,
4164 enum CXPrintingPolicyProperty Property,
4165 unsigned Value);
Jonathan Coe45ef5032018-01-16 10:19:56 +00004166
4167/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004168 * Retrieve the default policy for the cursor.
Jonathan Coe45ef5032018-01-16 10:19:56 +00004169 *
4170 * The policy should be released after use with \c
4171 * clang_PrintingPolicy_dispose.
4172 */
4173CINDEX_LINKAGE CXPrintingPolicy clang_getCursorPrintingPolicy(CXCursor);
4174
4175/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004176 * Release a printing policy.
Jonathan Coe45ef5032018-01-16 10:19:56 +00004177 */
4178CINDEX_LINKAGE void clang_PrintingPolicy_dispose(CXPrintingPolicy Policy);
4179
4180/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004181 * Pretty print declarations.
Jonathan Coe45ef5032018-01-16 10:19:56 +00004182 *
4183 * \param Cursor The cursor representing a declaration.
4184 *
4185 * \param Policy The policy to control the entities being printed. If
4186 * NULL, a default policy is used.
4187 *
4188 * \returns The pretty printed declaration or the empty string for
4189 * other cursors.
4190 */
4191CINDEX_LINKAGE CXString clang_getCursorPrettyPrinted(CXCursor Cursor,
4192 CXPrintingPolicy Policy);
4193
4194/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004195 * Retrieve the display name for the entity referenced by this cursor.
Douglas Gregor97c75712010-10-02 22:49:11 +00004196 *
4197 * The display name contains extra information that helps identify the cursor,
4198 * such as the parameters of a function or template or the arguments of a
4199 * class template specialization.
4200 */
4201CINDEX_LINKAGE CXString clang_getCursorDisplayName(CXCursor);
4202
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004203/** For a cursor that is a reference, retrieve a cursor representing the
Douglas Gregorad27e8b2010-01-19 01:20:04 +00004204 * entity that it references.
4205 *
4206 * Reference cursors refer to other entities in the AST. For example, an
4207 * Objective-C superclass reference cursor refers to an Objective-C class.
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004208 * This function produces the cursor for the Objective-C class from the
Douglas Gregorad27e8b2010-01-19 01:20:04 +00004209 * cursor for the superclass reference. If the input cursor is a declaration or
4210 * definition, it returns that declaration or definition unchanged.
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004211 * Otherwise, returns the NULL cursor.
Douglas Gregorad27e8b2010-01-19 01:20:04 +00004212 */
4213CINDEX_LINKAGE CXCursor clang_getCursorReferenced(CXCursor);
Douglas Gregor6b8232f2010-01-19 19:34:47 +00004214
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004215/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004216 * For a cursor that is either a reference to or a declaration
Douglas Gregor6b8232f2010-01-19 19:34:47 +00004217 * of some entity, retrieve a cursor that describes the definition of
4218 * that entity.
4219 *
4220 * Some entities can be declared multiple times within a translation
4221 * unit, but only one of those declarations can also be a
4222 * definition. For example, given:
4223 *
4224 * \code
4225 * int f(int, int);
4226 * int g(int x, int y) { return f(x, y); }
4227 * int f(int a, int b) { return a + b; }
4228 * int f(int, int);
4229 * \endcode
4230 *
4231 * there are three declarations of the function "f", but only the
4232 * second one is a definition. The clang_getCursorDefinition()
4233 * function will take any cursor pointing to a declaration of "f"
4234 * (the first or fourth lines of the example) or a cursor referenced
4235 * that uses "f" (the call to "f' inside "g") and will return a
4236 * declaration cursor pointing to the definition (the second "f"
4237 * declaration).
4238 *
4239 * If given a cursor for which there is no corresponding definition,
4240 * e.g., because there is no definition of that entity within this
4241 * translation unit, returns a NULL cursor.
4242 */
4243CINDEX_LINKAGE CXCursor clang_getCursorDefinition(CXCursor);
4244
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004245/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004246 * Determine whether the declaration pointed to by this cursor
Douglas Gregor6b8232f2010-01-19 19:34:47 +00004247 * is also a definition of that entity.
4248 */
4249CINDEX_LINKAGE unsigned clang_isCursorDefinition(CXCursor);
4250
Douglas Gregor6007cf22010-01-22 22:29:16 +00004251/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004252 * Retrieve the canonical cursor corresponding to the given cursor.
Douglas Gregorfec4dc92010-11-19 23:44:15 +00004253 *
4254 * In the C family of languages, many kinds of entities can be declared several
4255 * times within a single translation unit. For example, a structure type can
4256 * be forward-declared (possibly multiple times) and later defined:
4257 *
4258 * \code
4259 * struct X;
4260 * struct X;
4261 * struct X {
4262 * int member;
4263 * };
4264 * \endcode
4265 *
4266 * The declarations and the definition of \c X are represented by three
4267 * different cursors, all of which are declarations of the same underlying
4268 * entity. One of these cursor is considered the "canonical" cursor, which
4269 * is effectively the representative for the underlying entity. One can
4270 * determine if two cursors are declarations of the same underlying entity by
4271 * comparing their canonical cursors.
4272 *
4273 * \returns The canonical cursor for the entity referred to by the given cursor.
4274 */
4275CINDEX_LINKAGE CXCursor clang_getCanonicalCursor(CXCursor);
4276
Argyrios Kyrtzidis210f29f2012-03-30 22:15:48 +00004277/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004278 * If the cursor points to a selector identifier in an Objective-C
Nico Weber7deebef2014-04-24 03:17:47 +00004279 * method or message expression, this returns the selector index.
Argyrios Kyrtzidis210f29f2012-03-30 22:15:48 +00004280 *
James Dennett574cb4c2012-06-15 05:41:51 +00004281 * After getting a cursor with #clang_getCursor, this can be called to
Argyrios Kyrtzidis210f29f2012-03-30 22:15:48 +00004282 * determine if the location points to a selector identifier.
4283 *
Nico Weber7deebef2014-04-24 03:17:47 +00004284 * \returns The selector index if the cursor is an Objective-C method or message
Argyrios Kyrtzidis210f29f2012-03-30 22:15:48 +00004285 * expression and the cursor is pointing to a selector identifier, or -1
4286 * otherwise.
4287 */
4288CINDEX_LINKAGE int clang_Cursor_getObjCSelectorIndex(CXCursor);
4289
Douglas Gregorfec4dc92010-11-19 23:44:15 +00004290/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004291 * Given a cursor pointing to a C++ method call or an Objective-C
Nico Weber7deebef2014-04-24 03:17:47 +00004292 * message, returns non-zero if the method/message is "dynamic", meaning:
Argyrios Kyrtzidisb6df68212012-07-02 23:54:36 +00004293 *
4294 * For a C++ method: the call is virtual.
Nico Weber7deebef2014-04-24 03:17:47 +00004295 * For an Objective-C message: the receiver is an object instance, not 'super'
4296 * or a specific class.
Argyrios Kyrtzidisb6df68212012-07-02 23:54:36 +00004297 *
4298 * If the method/message is "static" or the cursor does not point to a
4299 * method/message, it will return zero.
4300 */
4301CINDEX_LINKAGE int clang_Cursor_isDynamicCall(CXCursor C);
4302
4303/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004304 * Given a cursor pointing to an Objective-C message or property
Argyrios Kyrtzidis2a684862017-04-27 17:23:04 +00004305 * reference, or C++ method call, returns the CXType of the receiver.
Argyrios Kyrtzidisb26a24c2012-11-01 02:01:34 +00004306 */
4307CINDEX_LINKAGE CXType clang_Cursor_getReceiverType(CXCursor C);
4308
4309/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004310 * Property attributes for a \c CXCursor_ObjCPropertyDecl.
Argyrios Kyrtzidis9adfd8a2013-04-18 22:15:49 +00004311 */
4312typedef enum {
4313 CXObjCPropertyAttr_noattr = 0x00,
4314 CXObjCPropertyAttr_readonly = 0x01,
4315 CXObjCPropertyAttr_getter = 0x02,
4316 CXObjCPropertyAttr_assign = 0x04,
4317 CXObjCPropertyAttr_readwrite = 0x08,
4318 CXObjCPropertyAttr_retain = 0x10,
4319 CXObjCPropertyAttr_copy = 0x20,
4320 CXObjCPropertyAttr_nonatomic = 0x40,
4321 CXObjCPropertyAttr_setter = 0x80,
4322 CXObjCPropertyAttr_atomic = 0x100,
4323 CXObjCPropertyAttr_weak = 0x200,
4324 CXObjCPropertyAttr_strong = 0x400,
Manman Ren04fd4d82016-05-31 23:22:04 +00004325 CXObjCPropertyAttr_unsafe_unretained = 0x800,
Manman Ren400e4c32016-06-03 23:11:41 +00004326 CXObjCPropertyAttr_class = 0x1000
Argyrios Kyrtzidis9adfd8a2013-04-18 22:15:49 +00004327} CXObjCPropertyAttrKind;
4328
4329/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004330 * Given a cursor that represents a property declaration, return the
Argyrios Kyrtzidis9adfd8a2013-04-18 22:15:49 +00004331 * associated property attributes. The bits are formed from
4332 * \c CXObjCPropertyAttrKind.
4333 *
4334 * \param reserved Reserved for future use, pass 0.
4335 */
4336CINDEX_LINKAGE unsigned clang_Cursor_getObjCPropertyAttributes(CXCursor C,
4337 unsigned reserved);
4338
4339/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004340 * 'Qualifiers' written next to the return and parameter types in
Nico Weber7deebef2014-04-24 03:17:47 +00004341 * Objective-C method declarations.
Argyrios Kyrtzidis9d9bc012013-04-18 23:29:12 +00004342 */
4343typedef enum {
4344 CXObjCDeclQualifier_None = 0x0,
4345 CXObjCDeclQualifier_In = 0x1,
4346 CXObjCDeclQualifier_Inout = 0x2,
4347 CXObjCDeclQualifier_Out = 0x4,
4348 CXObjCDeclQualifier_Bycopy = 0x8,
4349 CXObjCDeclQualifier_Byref = 0x10,
4350 CXObjCDeclQualifier_Oneway = 0x20
4351} CXObjCDeclQualifierKind;
4352
4353/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004354 * Given a cursor that represents an Objective-C method or parameter
Nico Weber7deebef2014-04-24 03:17:47 +00004355 * declaration, return the associated Objective-C qualifiers for the return
4356 * type or the parameter respectively. The bits are formed from
4357 * CXObjCDeclQualifierKind.
Argyrios Kyrtzidis9d9bc012013-04-18 23:29:12 +00004358 */
4359CINDEX_LINKAGE unsigned clang_Cursor_getObjCDeclQualifiers(CXCursor C);
4360
4361/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004362 * Given a cursor that represents an Objective-C method or property
Alex Lorenz6c2898a2017-04-06 14:03:25 +00004363 * declaration, return non-zero if the declaration was affected by "\@optional".
4364 * Returns zero if the cursor is not such a declaration or it is "\@required".
Argyrios Kyrtzidis7b50fc52013-07-05 20:44:37 +00004365 */
4366CINDEX_LINKAGE unsigned clang_Cursor_isObjCOptional(CXCursor C);
4367
4368/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004369 * Returns non-zero if the given cursor is a variadic function or method.
Argyrios Kyrtzidis23814e42013-04-18 23:53:05 +00004370 */
4371CINDEX_LINKAGE unsigned clang_Cursor_isVariadic(CXCursor C);
4372
4373/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004374 * Returns non-zero if the given cursor points to a symbol marked with
Argyrios Kyrtzidis0381cc72017-05-10 15:10:36 +00004375 * external_source_symbol attribute.
4376 *
4377 * \param language If non-NULL, and the attribute is present, will be set to
4378 * the 'language' string from the attribute.
4379 *
4380 * \param definedIn If non-NULL, and the attribute is present, will be set to
4381 * the 'definedIn' string from the attribute.
4382 *
4383 * \param isGenerated If non-NULL, and the attribute is present, will be set to
Argyrios Kyrtzidis8b337c02017-05-10 15:48:16 +00004384 * non-zero if the 'generated_declaration' is set in the attribute.
Argyrios Kyrtzidis0381cc72017-05-10 15:10:36 +00004385 */
4386CINDEX_LINKAGE unsigned clang_Cursor_isExternalSymbol(CXCursor C,
4387 CXString *language, CXString *definedIn,
4388 unsigned *isGenerated);
4389
4390/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004391 * Given a cursor that represents a declaration, return the associated
Dmitri Gribenkoaab83832012-06-20 00:34:58 +00004392 * comment's source range. The range may include multiple consecutive comments
4393 * with whitespace in between.
4394 */
4395CINDEX_LINKAGE CXSourceRange clang_Cursor_getCommentRange(CXCursor C);
4396
4397/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004398 * Given a cursor that represents a declaration, return the associated
Dmitri Gribenkoaab83832012-06-20 00:34:58 +00004399 * comment text, including comment markers.
4400 */
4401CINDEX_LINKAGE CXString clang_Cursor_getRawCommentText(CXCursor C);
4402
4403/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004404 * Given a cursor that represents a documentable entity (e.g.,
4405 * declaration), return the associated \paragraph; otherwise return the
Dmitri Gribenko5e4fe002012-07-20 21:34:34 +00004406 * first paragraph.
Dmitri Gribenko5188c4b2012-06-26 20:39:18 +00004407 */
4408CINDEX_LINKAGE CXString clang_Cursor_getBriefCommentText(CXCursor C);
4409
4410/**
Dmitri Gribenko5e4fe002012-07-20 21:34:34 +00004411 * @}
4412 */
4413
Eli Bendersky44a206f2014-07-31 18:04:56 +00004414/** \defgroup CINDEX_MANGLE Name Mangling API Functions
4415 *
4416 * @{
4417 */
4418
4419/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004420 * Retrieve the CXString representing the mangled name of the cursor.
Eli Bendersky44a206f2014-07-31 18:04:56 +00004421 */
4422CINDEX_LINKAGE CXString clang_Cursor_getMangling(CXCursor);
4423
4424/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004425 * Retrieve the CXStrings representing the mangled symbols of the C++
Saleem Abdulrasool60034432015-11-12 03:57:22 +00004426 * constructor or destructor at the cursor.
4427 */
4428CINDEX_LINKAGE CXStringSet *clang_Cursor_getCXXManglings(CXCursor);
4429
4430/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004431 * Retrieve the CXStrings representing the mangled symbols of the ObjC
Dave Lee1a532c92017-09-22 16:58:57 +00004432 * class interface or implementation at the cursor.
4433 */
4434CINDEX_LINKAGE CXStringSet *clang_Cursor_getObjCManglings(CXCursor);
4435
4436/**
Eli Bendersky44a206f2014-07-31 18:04:56 +00004437 * @}
4438 */
4439
Dmitri Gribenko5e4fe002012-07-20 21:34:34 +00004440/**
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004441 * \defgroup CINDEX_MODULE Module introspection
4442 *
4443 * The functions in this group provide access to information about modules.
4444 *
4445 * @{
4446 */
4447
4448typedef void *CXModule;
4449
4450/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004451 * Given a CXCursor_ModuleImportDecl cursor, return the associated module.
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004452 */
4453CINDEX_LINKAGE CXModule clang_Cursor_getModule(CXCursor C);
4454
4455/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004456 * Given a CXFile header file, return the module that contains it, if one
Argyrios Kyrtzidisf6d49c32014-05-14 23:14:37 +00004457 * exists.
4458 */
4459CINDEX_LINKAGE CXModule clang_getModuleForFile(CXTranslationUnit, CXFile);
4460
4461/**
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004462 * \param Module a module object.
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004463 *
Argyrios Kyrtzidis12fdb9e2013-04-26 22:47:49 +00004464 * \returns the module file where the provided module object came from.
4465 */
4466CINDEX_LINKAGE CXFile clang_Module_getASTFile(CXModule Module);
4467
4468/**
4469 * \param Module a module object.
4470 *
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004471 * \returns the parent of a sub-module or NULL if the given module is top-level,
4472 * e.g. for 'std.vector' it will return the 'std' module.
4473 */
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004474CINDEX_LINKAGE CXModule clang_Module_getParent(CXModule Module);
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004475
4476/**
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004477 * \param Module a module object.
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004478 *
4479 * \returns the name of the module, e.g. for the 'std.vector' sub-module it
4480 * will return "vector".
4481 */
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004482CINDEX_LINKAGE CXString clang_Module_getName(CXModule Module);
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004483
4484/**
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004485 * \param Module a module object.
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004486 *
4487 * \returns the full name of the module, e.g. "std.vector".
4488 */
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004489CINDEX_LINKAGE CXString clang_Module_getFullName(CXModule Module);
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004490
4491/**
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004492 * \param Module a module object.
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004493 *
Argyrios Kyrtzidis884337f2014-05-15 04:44:25 +00004494 * \returns non-zero if the module is a system one.
4495 */
4496CINDEX_LINKAGE int clang_Module_isSystem(CXModule Module);
4497
4498/**
4499 * \param Module a module object.
4500 *
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004501 * \returns the number of top level headers associated with this module.
4502 */
Argyrios Kyrtzidis3c5305c2013-03-13 21:13:43 +00004503CINDEX_LINKAGE unsigned clang_Module_getNumTopLevelHeaders(CXTranslationUnit,
4504 CXModule Module);
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004505
4506/**
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004507 * \param Module a module object.
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004508 *
4509 * \param Index top level header index (zero-based).
4510 *
4511 * \returns the specified top level header associated with the module.
4512 */
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004513CINDEX_LINKAGE
Argyrios Kyrtzidis3c5305c2013-03-13 21:13:43 +00004514CXFile clang_Module_getTopLevelHeader(CXTranslationUnit,
4515 CXModule Module, unsigned Index);
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004516
4517/**
4518 * @}
4519 */
4520
4521/**
Ted Kremenek9cfe9e62010-05-17 20:06:56 +00004522 * \defgroup CINDEX_CPP C++ AST introspection
4523 *
4524 * The routines in this group provide access information in the ASTs specific
4525 * to C++ language features.
4526 *
4527 * @{
4528 */
4529
4530/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004531 * Determine if a C++ constructor is a converting constructor.
Jonathan Coe29565352016-04-27 12:48:25 +00004532 */
4533CINDEX_LINKAGE unsigned clang_CXXConstructor_isConvertingConstructor(CXCursor C);
4534
4535/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004536 * Determine if a C++ constructor is a copy constructor.
Jonathan Coe29565352016-04-27 12:48:25 +00004537 */
4538CINDEX_LINKAGE unsigned clang_CXXConstructor_isCopyConstructor(CXCursor C);
4539
4540/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004541 * Determine if a C++ constructor is the default constructor.
Jonathan Coe29565352016-04-27 12:48:25 +00004542 */
4543CINDEX_LINKAGE unsigned clang_CXXConstructor_isDefaultConstructor(CXCursor C);
4544
4545/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004546 * Determine if a C++ constructor is a move constructor.
Jonathan Coe29565352016-04-27 12:48:25 +00004547 */
4548CINDEX_LINKAGE unsigned clang_CXXConstructor_isMoveConstructor(CXCursor C);
4549
4550/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004551 * Determine if a C++ field is declared 'mutable'.
Saleem Abdulrasool6ea75db2015-10-27 15:50:22 +00004552 */
4553CINDEX_LINKAGE unsigned clang_CXXField_isMutable(CXCursor C);
4554
4555/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004556 * Determine if a C++ method is declared '= default'.
Jonathan Coe29565352016-04-27 12:48:25 +00004557 */
4558CINDEX_LINKAGE unsigned clang_CXXMethod_isDefaulted(CXCursor C);
4559
4560/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004561 * Determine if a C++ member function or member function template is
Dmitri Gribenko62770be2013-05-17 18:38:35 +00004562 * pure virtual.
4563 */
4564CINDEX_LINKAGE unsigned clang_CXXMethod_isPureVirtual(CXCursor C);
4565
4566/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004567 * Determine if a C++ member function or member function template is
Douglas Gregorf11309e2010-08-31 22:12:17 +00004568 * declared 'static'.
Ted Kremenek9cfe9e62010-05-17 20:06:56 +00004569 */
4570CINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C);
4571
4572/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004573 * Determine if a C++ member function or member function template is
Douglas Gregor9519d922011-05-12 15:17:24 +00004574 * explicitly declared 'virtual' or if it overrides a virtual method from
4575 * one of the base classes.
4576 */
4577CINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual(CXCursor C);
4578
4579/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004580 * Determine if a C++ record is abstract, i.e. whether a class or struct
Alex Lorenz34ccadc2017-12-14 22:01:50 +00004581 * has a pure virtual member function.
4582 */
4583CINDEX_LINKAGE unsigned clang_CXXRecord_isAbstract(CXCursor C);
4584
4585/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004586 * Determine if an enum declaration refers to a scoped enum.
Alex Lorenzff7f42e2017-07-12 11:35:11 +00004587 */
4588CINDEX_LINKAGE unsigned clang_EnumDecl_isScoped(CXCursor C);
4589
4590/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004591 * Determine if a C++ member function or member function template is
Dmitri Gribenkoe570ede2014-04-07 14:59:13 +00004592 * declared 'const'.
4593 */
4594CINDEX_LINKAGE unsigned clang_CXXMethod_isConst(CXCursor C);
4595
4596/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004597 * Given a cursor that represents a template, determine
Douglas Gregorf11309e2010-08-31 22:12:17 +00004598 * the cursor kind of the specializations would be generated by instantiating
4599 * the template.
4600 *
4601 * This routine can be used to determine what flavor of function template,
4602 * class template, or class template partial specialization is stored in the
4603 * cursor. For example, it can describe whether a class template cursor is
4604 * declared with "struct", "class" or "union".
4605 *
4606 * \param C The cursor to query. This cursor should represent a template
4607 * declaration.
4608 *
4609 * \returns The cursor kind of the specializations that would be generated
4610 * by instantiating the template \p C. If \p C is not a template, returns
4611 * \c CXCursor_NoDeclFound.
4612 */
4613CINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind(CXCursor C);
4614
4615/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004616 * Given a cursor that may represent a specialization or instantiation
Douglas Gregord3f48bd2010-09-02 00:07:54 +00004617 * of a template, retrieve the cursor that represents the template that it
4618 * specializes or from which it was instantiated.
4619 *
4620 * This routine determines the template involved both for explicit
4621 * specializations of templates and for implicit instantiations of the template,
4622 * both of which are referred to as "specializations". For a class template
4623 * specialization (e.g., \c std::vector<bool>), this routine will return
4624 * either the primary template (\c std::vector) or, if the specialization was
4625 * instantiated from a class template partial specialization, the class template
4626 * partial specialization. For a class template partial specialization and a
4627 * function template specialization (including instantiations), this
4628 * this routine will return the specialized template.
4629 *
4630 * For members of a class template (e.g., member functions, member classes, or
4631 * static data members), returns the specialized or instantiated member.
4632 * Although not strictly "templates" in the C++ language, members of class
4633 * templates have the same notions of specializations and instantiations that
4634 * templates do, so this routine treats them similarly.
4635 *
4636 * \param C A cursor that may be a specialization of a template or a member
4637 * of a template.
4638 *
4639 * \returns If the given cursor is a specialization or instantiation of a
4640 * template or a member thereof, the template or member that it specializes or
4641 * from which it was instantiated. Otherwise, returns a NULL cursor.
4642 */
4643CINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate(CXCursor C);
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004644
4645/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004646 * Given a cursor that references something else, return the source range
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004647 * covering that reference.
4648 *
4649 * \param C A cursor pointing to a member reference, a declaration reference, or
4650 * an operator call.
4651 * \param NameFlags A bitset with three independent flags:
4652 * CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and
4653 * CXNameRange_WantSinglePiece.
4654 * \param PieceIndex For contiguous names or when passing the flag
4655 * CXNameRange_WantSinglePiece, only one piece with index 0 is
4656 * available. When the CXNameRange_WantSinglePiece flag is not passed for a
Benjamin Kramer474261a2012-06-02 10:20:41 +00004657 * non-contiguous names, this index can be used to retrieve the individual
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004658 * pieces of the name. See also CXNameRange_WantSinglePiece.
4659 *
4660 * \returns The piece of the name pointed to by the given cursor. If there is no
4661 * name, or if the PieceIndex is out-of-range, a null-cursor will be returned.
4662 */
Francois Pichetece689f2011-07-25 22:00:44 +00004663CINDEX_LINKAGE CXSourceRange clang_getCursorReferenceNameRange(CXCursor C,
4664 unsigned NameFlags,
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004665 unsigned PieceIndex);
4666
4667enum CXNameRefFlags {
4668 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004669 * Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004670 * range.
4671 */
4672 CXNameRange_WantQualifier = 0x1,
4673
4674 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004675 * Include the explicit template arguments, e.g. \<int> in x.f<int>,
James Dennett574cb4c2012-06-15 05:41:51 +00004676 * in the range.
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004677 */
4678 CXNameRange_WantTemplateArgs = 0x2,
4679
4680 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004681 * If the name is non-contiguous, return the full spanning range.
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004682 *
4683 * Non-contiguous names occur in Objective-C when a selector with two or more
4684 * parameters is used, or in C++ when using an operator:
4685 * \code
Nico Weber7deebef2014-04-24 03:17:47 +00004686 * [object doSomething:here withValue:there]; // Objective-C
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004687 * return some_vector[1]; // C++
4688 * \endcode
4689 */
4690 CXNameRange_WantSinglePiece = 0x4
4691};
Douglas Gregord3f48bd2010-09-02 00:07:54 +00004692
4693/**
Ted Kremenek9cfe9e62010-05-17 20:06:56 +00004694 * @}
4695 */
4696
4697/**
Douglas Gregor61656112010-01-26 18:31:56 +00004698 * \defgroup CINDEX_LEX Token extraction and manipulation
4699 *
4700 * The routines in this group provide access to the tokens within a
4701 * translation unit, along with a semantic mapping of those tokens to
4702 * their corresponding cursors.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004703 *
4704 * @{
4705 */
4706
4707/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004708 * Describes a kind of token.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004709 */
4710typedef enum CXTokenKind {
4711 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004712 * A token that contains some kind of punctuation.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004713 */
4714 CXToken_Punctuation,
Ted Kremenekd071c602010-03-13 02:50:34 +00004715
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004716 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004717 * A language keyword.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004718 */
4719 CXToken_Keyword,
Ted Kremenekd071c602010-03-13 02:50:34 +00004720
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004721 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004722 * An identifier (that is not a keyword).
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004723 */
4724 CXToken_Identifier,
Ted Kremenekd071c602010-03-13 02:50:34 +00004725
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004726 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004727 * A numeric, string, or character literal.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004728 */
4729 CXToken_Literal,
Ted Kremenekd071c602010-03-13 02:50:34 +00004730
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004731 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004732 * A comment.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004733 */
4734 CXToken_Comment
4735} CXTokenKind;
4736
4737/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004738 * Describes a single preprocessing token.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004739 */
4740typedef struct {
4741 unsigned int_data[4];
4742 void *ptr_data;
4743} CXToken;
4744
4745/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004746 * Determine the kind of the given token.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004747 */
4748CINDEX_LINKAGE CXTokenKind clang_getTokenKind(CXToken);
Ted Kremenekd071c602010-03-13 02:50:34 +00004749
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004750/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004751 * Determine the spelling of the given token.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004752 *
4753 * The spelling of a token is the textual representation of that token, e.g.,
4754 * the text of an identifier or keyword.
4755 */
4756CINDEX_LINKAGE CXString clang_getTokenSpelling(CXTranslationUnit, CXToken);
Ted Kremenekd071c602010-03-13 02:50:34 +00004757
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004758/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004759 * Retrieve the source location of the given token.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004760 */
Ted Kremenekd071c602010-03-13 02:50:34 +00004761CINDEX_LINKAGE CXSourceLocation clang_getTokenLocation(CXTranslationUnit,
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004762 CXToken);
Ted Kremenekd071c602010-03-13 02:50:34 +00004763
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004764/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004765 * Retrieve a source range that covers the given token.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004766 */
4767CINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken);
4768
4769/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004770 * Tokenize the source code described by the given range into raw
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004771 * lexical tokens.
4772 *
4773 * \param TU the translation unit whose text is being tokenized.
4774 *
4775 * \param Range the source range in which text should be tokenized. All of the
4776 * tokens produced by tokenization will fall within this source range,
4777 *
4778 * \param Tokens this pointer will be set to point to the array of tokens
4779 * that occur within the given source range. The returned pointer must be
4780 * freed with clang_disposeTokens() before the translation unit is destroyed.
4781 *
4782 * \param NumTokens will be set to the number of tokens in the \c *Tokens
4783 * array.
4784 *
4785 */
4786CINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
4787 CXToken **Tokens, unsigned *NumTokens);
Ted Kremenekd071c602010-03-13 02:50:34 +00004788
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004789/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004790 * Annotate the given set of tokens by providing cursors for each token
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004791 * that can be mapped to a specific entity within the abstract syntax tree.
4792 *
Douglas Gregor61656112010-01-26 18:31:56 +00004793 * This token-annotation routine is equivalent to invoking
4794 * clang_getCursor() for the source locations of each of the
4795 * tokens. The cursors provided are filtered, so that only those
4796 * cursors that have a direct correspondence to the token are
4797 * accepted. For example, given a function call \c f(x),
4798 * clang_getCursor() would provide the following cursors:
4799 *
4800 * * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'.
4801 * * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'.
4802 * * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'.
4803 *
4804 * Only the first and last of these cursors will occur within the
4805 * annotate, since the tokens "f" and "x' directly refer to a function
4806 * and a variable, respectively, but the parentheses are just a small
4807 * part of the full syntax of the function call expression, which is
4808 * not provided as an annotation.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004809 *
4810 * \param TU the translation unit that owns the given tokens.
4811 *
4812 * \param Tokens the set of tokens to annotate.
4813 *
4814 * \param NumTokens the number of tokens in \p Tokens.
4815 *
4816 * \param Cursors an array of \p NumTokens cursors, whose contents will be
4817 * replaced with the cursors corresponding to each token.
4818 */
4819CINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU,
4820 CXToken *Tokens, unsigned NumTokens,
4821 CXCursor *Cursors);
Ted Kremenekd071c602010-03-13 02:50:34 +00004822
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004823/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004824 * Free the given set of tokens.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004825 */
Ted Kremenekd071c602010-03-13 02:50:34 +00004826CINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU,
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004827 CXToken *Tokens, unsigned NumTokens);
Ted Kremenekd071c602010-03-13 02:50:34 +00004828
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004829/**
4830 * @}
4831 */
Ted Kremenekd071c602010-03-13 02:50:34 +00004832
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004833/**
Douglas Gregor6007cf22010-01-22 22:29:16 +00004834 * \defgroup CINDEX_DEBUG Debugging facilities
4835 *
4836 * These routines are used for testing and debugging, only, and should not
4837 * be relied upon.
4838 *
4839 * @{
4840 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004841
Steve Naroff76b8f132009-09-23 17:52:52 +00004842/* for debug/testing */
Ted Kremenek29004672010-02-17 00:41:32 +00004843CINDEX_LINKAGE CXString clang_getCursorKindSpelling(enum CXCursorKind Kind);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004844CINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(CXCursor,
4845 const char **startBuf,
Steve Naroff76b8f132009-09-23 17:52:52 +00004846 const char **endBuf,
4847 unsigned *startLine,
4848 unsigned *startColumn,
4849 unsigned *endLine,
4850 unsigned *endColumn);
Douglas Gregor1e21cc72010-02-18 23:07:20 +00004851CINDEX_LINKAGE void clang_enableStackTraces(void);
Daniel Dunbar23420652010-11-04 01:26:29 +00004852CINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void*), void *user_data,
4853 unsigned stack_size);
4854
Douglas Gregor9eb77012009-11-07 00:00:49 +00004855/**
Douglas Gregor6007cf22010-01-22 22:29:16 +00004856 * @}
4857 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004858
Douglas Gregor6007cf22010-01-22 22:29:16 +00004859/**
4860 * \defgroup CINDEX_CODE_COMPLET Code completion
4861 *
4862 * Code completion involves taking an (incomplete) source file, along with
4863 * knowledge of where the user is actively editing that file, and suggesting
4864 * syntactically- and semantically-valid constructs that the user might want to
4865 * use at that particular point in the source code. These data structures and
4866 * routines provide support for code completion.
4867 *
4868 * @{
4869 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004870
Douglas Gregor6007cf22010-01-22 22:29:16 +00004871/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004872 * A semantic string that describes a code-completion result.
Douglas Gregor9eb77012009-11-07 00:00:49 +00004873 *
4874 * A semantic string that describes the formatting of a code-completion
4875 * result as a single "template" of text that should be inserted into the
4876 * source buffer when a particular code-completion result is selected.
4877 * Each semantic string is made up of some number of "chunks", each of which
4878 * contains some text along with a description of what that text means, e.g.,
4879 * the name of the entity being referenced, whether the text chunk is part of
4880 * the template, or whether it is a "placeholder" that the user should replace
4881 * with actual code,of a specific kind. See \c CXCompletionChunkKind for a
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004882 * description of the different kinds of chunks.
Douglas Gregor9eb77012009-11-07 00:00:49 +00004883 */
4884typedef void *CXCompletionString;
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004885
Douglas Gregor9eb77012009-11-07 00:00:49 +00004886/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004887 * A single result of code completion.
Douglas Gregor9eb77012009-11-07 00:00:49 +00004888 */
4889typedef struct {
4890 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004891 * The kind of entity that this completion refers to.
Douglas Gregor9eb77012009-11-07 00:00:49 +00004892 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004893 * The cursor kind will be a macro, keyword, or a declaration (one of the
Douglas Gregor9eb77012009-11-07 00:00:49 +00004894 * *Decl cursor kinds), describing the entity that the completion is
4895 * referring to.
4896 *
4897 * \todo In the future, we would like to provide a full cursor, to allow
4898 * the client to extract additional information from declaration.
4899 */
4900 enum CXCursorKind CursorKind;
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004901
4902 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004903 * The code-completion string that describes how to insert this
Douglas Gregor9eb77012009-11-07 00:00:49 +00004904 * code-completion result into the editing buffer.
4905 */
4906 CXCompletionString CompletionString;
4907} CXCompletionResult;
4908
4909/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004910 * Describes a single piece of text within a code-completion string.
Douglas Gregor9eb77012009-11-07 00:00:49 +00004911 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004912 * Each "chunk" within a code-completion string (\c CXCompletionString) is
4913 * either a piece of text with a specific "kind" that describes how that text
Douglas Gregor9eb77012009-11-07 00:00:49 +00004914 * should be interpreted by the client or is another completion string.
4915 */
4916enum CXCompletionChunkKind {
4917 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004918 * A code-completion string that describes "optional" text that
Douglas Gregor9eb77012009-11-07 00:00:49 +00004919 * could be a part of the template (but is not required).
4920 *
4921 * The Optional chunk is the only kind of chunk that has a code-completion
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004922 * string for its representation, which is accessible via
Douglas Gregor9eb77012009-11-07 00:00:49 +00004923 * \c clang_getCompletionChunkCompletionString(). The code-completion string
4924 * describes an additional part of the template that is completely optional.
4925 * For example, optional chunks can be used to describe the placeholders for
4926 * arguments that match up with defaulted function parameters, e.g. given:
4927 *
4928 * \code
4929 * void f(int x, float y = 3.14, double z = 2.71828);
4930 * \endcode
4931 *
4932 * The code-completion string for this function would contain:
4933 * - a TypedText chunk for "f".
4934 * - a LeftParen chunk for "(".
4935 * - a Placeholder chunk for "int x"
4936 * - an Optional chunk containing the remaining defaulted arguments, e.g.,
4937 * - a Comma chunk for ","
Daniel Dunbar4053fae2010-02-17 08:07:44 +00004938 * - a Placeholder chunk for "float y"
Douglas Gregor9eb77012009-11-07 00:00:49 +00004939 * - an Optional chunk containing the last defaulted argument:
4940 * - a Comma chunk for ","
4941 * - a Placeholder chunk for "double z"
4942 * - a RightParen chunk for ")"
4943 *
Daniel Dunbar4053fae2010-02-17 08:07:44 +00004944 * There are many ways to handle Optional chunks. Two simple approaches are:
Douglas Gregor9eb77012009-11-07 00:00:49 +00004945 * - Completely ignore optional chunks, in which case the template for the
4946 * function "f" would only include the first parameter ("int x").
4947 * - Fully expand all optional chunks, in which case the template for the
4948 * function "f" would have all of the parameters.
4949 */
4950 CXCompletionChunk_Optional,
4951 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004952 * Text that a user would be expected to type to get this
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004953 * code-completion result.
Douglas Gregor9eb77012009-11-07 00:00:49 +00004954 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004955 * There will be exactly one "typed text" chunk in a semantic string, which
4956 * will typically provide the spelling of a keyword or the name of a
Douglas Gregor9eb77012009-11-07 00:00:49 +00004957 * declaration that could be used at the current code point. Clients are
4958 * expected to filter the code-completion results based on the text in this
4959 * chunk.
4960 */
4961 CXCompletionChunk_TypedText,
4962 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004963 * Text that should be inserted as part of a code-completion result.
Douglas Gregor9eb77012009-11-07 00:00:49 +00004964 *
4965 * A "text" chunk represents text that is part of the template to be
4966 * inserted into user code should this particular code-completion result
4967 * be selected.
4968 */
4969 CXCompletionChunk_Text,
4970 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004971 * Placeholder text that should be replaced by the user.
Douglas Gregor9eb77012009-11-07 00:00:49 +00004972 *
4973 * A "placeholder" chunk marks a place where the user should insert text
4974 * into the code-completion template. For example, placeholders might mark
4975 * the function parameters for a function declaration, to indicate that the
4976 * user should provide arguments for each of those parameters. The actual
4977 * text in a placeholder is a suggestion for the text to display before
4978 * the user replaces the placeholder with real code.
4979 */
4980 CXCompletionChunk_Placeholder,
4981 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004982 * Informative text that should be displayed but never inserted as
Douglas Gregor9eb77012009-11-07 00:00:49 +00004983 * part of the template.
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004984 *
Douglas Gregor9eb77012009-11-07 00:00:49 +00004985 * An "informative" chunk contains annotations that can be displayed to
4986 * help the user decide whether a particular code-completion result is the
4987 * right option, but which is not part of the actual template to be inserted
4988 * by code completion.
4989 */
4990 CXCompletionChunk_Informative,
4991 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004992 * Text that describes the current parameter when code-completion is
Douglas Gregor9eb77012009-11-07 00:00:49 +00004993 * referring to function call, message send, or template specialization.
4994 *
4995 * A "current parameter" chunk occurs when code-completion is providing
4996 * information about a parameter corresponding to the argument at the
4997 * code-completion point. For example, given a function
4998 *
4999 * \code
5000 * int add(int x, int y);
5001 * \endcode
5002 *
5003 * and the source code \c add(, where the code-completion point is after the
5004 * "(", the code-completion string will contain a "current parameter" chunk
5005 * for "int x", indicating that the current argument will initialize that
5006 * parameter. After typing further, to \c add(17, (where the code-completion
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005007 * point is after the ","), the code-completion string will contain a
Alexander Kornienko2a8c18d2018-04-06 15:14:32 +00005008 * "current parameter" chunk to "int y".
Douglas Gregor9eb77012009-11-07 00:00:49 +00005009 */
5010 CXCompletionChunk_CurrentParameter,
5011 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005012 * A left parenthesis ('('), used to initiate a function call or
Douglas Gregor9eb77012009-11-07 00:00:49 +00005013 * signal the beginning of a function parameter list.
5014 */
5015 CXCompletionChunk_LeftParen,
5016 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005017 * A right parenthesis (')'), used to finish a function call or
Douglas Gregor9eb77012009-11-07 00:00:49 +00005018 * signal the end of a function parameter list.
5019 */
5020 CXCompletionChunk_RightParen,
5021 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005022 * A left bracket ('[').
Douglas Gregor9eb77012009-11-07 00:00:49 +00005023 */
5024 CXCompletionChunk_LeftBracket,
5025 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005026 * A right bracket (']').
Douglas Gregor9eb77012009-11-07 00:00:49 +00005027 */
5028 CXCompletionChunk_RightBracket,
5029 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005030 * A left brace ('{').
Douglas Gregor9eb77012009-11-07 00:00:49 +00005031 */
5032 CXCompletionChunk_LeftBrace,
5033 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005034 * A right brace ('}').
Douglas Gregor9eb77012009-11-07 00:00:49 +00005035 */
5036 CXCompletionChunk_RightBrace,
5037 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005038 * A left angle bracket ('<').
Douglas Gregor9eb77012009-11-07 00:00:49 +00005039 */
5040 CXCompletionChunk_LeftAngle,
5041 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005042 * A right angle bracket ('>').
Douglas Gregor9eb77012009-11-07 00:00:49 +00005043 */
5044 CXCompletionChunk_RightAngle,
5045 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005046 * A comma separator (',').
Douglas Gregor9eb77012009-11-07 00:00:49 +00005047 */
Douglas Gregorb3fa9192009-12-18 18:53:37 +00005048 CXCompletionChunk_Comma,
5049 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005050 * Text that specifies the result type of a given result.
Douglas Gregorb3fa9192009-12-18 18:53:37 +00005051 *
5052 * This special kind of informative chunk is not meant to be inserted into
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005053 * the text buffer. Rather, it is meant to illustrate the type that an
Douglas Gregorb3fa9192009-12-18 18:53:37 +00005054 * expression using the given completion string would have.
5055 */
Douglas Gregor504a6ae2010-01-10 23:08:15 +00005056 CXCompletionChunk_ResultType,
5057 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005058 * A colon (':').
Douglas Gregor504a6ae2010-01-10 23:08:15 +00005059 */
5060 CXCompletionChunk_Colon,
5061 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005062 * A semicolon (';').
Douglas Gregor504a6ae2010-01-10 23:08:15 +00005063 */
5064 CXCompletionChunk_SemiColon,
5065 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005066 * An '=' sign.
Douglas Gregor504a6ae2010-01-10 23:08:15 +00005067 */
5068 CXCompletionChunk_Equal,
5069 /**
5070 * Horizontal space (' ').
5071 */
5072 CXCompletionChunk_HorizontalSpace,
5073 /**
Alex Lorenz6c2898a2017-04-06 14:03:25 +00005074 * Vertical space ('\\n'), after which it is generally a good idea to
Douglas Gregor504a6ae2010-01-10 23:08:15 +00005075 * perform indentation.
5076 */
5077 CXCompletionChunk_VerticalSpace
Douglas Gregor9eb77012009-11-07 00:00:49 +00005078};
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005079
Douglas Gregor9eb77012009-11-07 00:00:49 +00005080/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005081 * Determine the kind of a particular chunk within a completion string.
Douglas Gregor9eb77012009-11-07 00:00:49 +00005082 *
5083 * \param completion_string the completion string to query.
5084 *
5085 * \param chunk_number the 0-based index of the chunk in the completion string.
5086 *
5087 * \returns the kind of the chunk at the index \c chunk_number.
5088 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005089CINDEX_LINKAGE enum CXCompletionChunkKind
Douglas Gregor9eb77012009-11-07 00:00:49 +00005090clang_getCompletionChunkKind(CXCompletionString completion_string,
5091 unsigned chunk_number);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005092
Douglas Gregor9eb77012009-11-07 00:00:49 +00005093/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005094 * Retrieve the text associated with a particular chunk within a
Douglas Gregor9eb77012009-11-07 00:00:49 +00005095 * completion string.
5096 *
5097 * \param completion_string the completion string to query.
5098 *
5099 * \param chunk_number the 0-based index of the chunk in the completion string.
5100 *
5101 * \returns the text associated with the chunk at index \c chunk_number.
5102 */
Ted Kremenekf602f962010-02-17 01:42:24 +00005103CINDEX_LINKAGE CXString
Douglas Gregor9eb77012009-11-07 00:00:49 +00005104clang_getCompletionChunkText(CXCompletionString completion_string,
5105 unsigned chunk_number);
5106
5107/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005108 * Retrieve the completion string associated with a particular chunk
Douglas Gregor9eb77012009-11-07 00:00:49 +00005109 * within a completion string.
5110 *
5111 * \param completion_string the completion string to query.
5112 *
5113 * \param chunk_number the 0-based index of the chunk in the completion string.
5114 *
5115 * \returns the completion string associated with the chunk at index
Erik Verbruggen98ea7f62011-10-14 15:31:08 +00005116 * \c chunk_number.
Douglas Gregor9eb77012009-11-07 00:00:49 +00005117 */
5118CINDEX_LINKAGE CXCompletionString
5119clang_getCompletionChunkCompletionString(CXCompletionString completion_string,
5120 unsigned chunk_number);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005121
Douglas Gregor9eb77012009-11-07 00:00:49 +00005122/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005123 * Retrieve the number of chunks in the given code-completion string.
Douglas Gregor9eb77012009-11-07 00:00:49 +00005124 */
5125CINDEX_LINKAGE unsigned
5126clang_getNumCompletionChunks(CXCompletionString completion_string);
5127
5128/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005129 * Determine the priority of this code completion.
Douglas Gregora2db7932010-05-26 22:00:08 +00005130 *
5131 * The priority of a code completion indicates how likely it is that this
5132 * particular completion is the completion that the user will select. The
5133 * priority is selected by various internal heuristics.
5134 *
5135 * \param completion_string The completion string to query.
5136 *
5137 * \returns The priority of this completion string. Smaller values indicate
5138 * higher-priority (more likely) completions.
5139 */
5140CINDEX_LINKAGE unsigned
5141clang_getCompletionPriority(CXCompletionString completion_string);
5142
5143/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005144 * Determine the availability of the entity that this code-completion
Douglas Gregorf757a122010-08-23 23:00:57 +00005145 * string refers to.
5146 *
5147 * \param completion_string The completion string to query.
5148 *
5149 * \returns The availability of the completion string.
5150 */
5151CINDEX_LINKAGE enum CXAvailabilityKind
5152clang_getCompletionAvailability(CXCompletionString completion_string);
5153
5154/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005155 * Retrieve the number of annotations associated with the given
Erik Verbruggen98ea7f62011-10-14 15:31:08 +00005156 * completion string.
5157 *
5158 * \param completion_string the completion string to query.
5159 *
5160 * \returns the number of annotations associated with the given completion
5161 * string.
5162 */
5163CINDEX_LINKAGE unsigned
5164clang_getCompletionNumAnnotations(CXCompletionString completion_string);
5165
5166/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005167 * Retrieve the annotation associated with the given completion string.
Erik Verbruggen98ea7f62011-10-14 15:31:08 +00005168 *
5169 * \param completion_string the completion string to query.
5170 *
5171 * \param annotation_number the 0-based index of the annotation of the
5172 * completion string.
5173 *
5174 * \returns annotation string associated with the completion at index
5175 * \c annotation_number, or a NULL string if that annotation is not available.
5176 */
5177CINDEX_LINKAGE CXString
5178clang_getCompletionAnnotation(CXCompletionString completion_string,
5179 unsigned annotation_number);
5180
5181/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005182 * Retrieve the parent context of the given completion string.
Douglas Gregor78254c82012-03-27 23:34:16 +00005183 *
5184 * The parent context of a completion string is the semantic parent of
5185 * the declaration (if any) that the code completion represents. For example,
5186 * a code completion for an Objective-C method would have the method's class
5187 * or protocol as its context.
5188 *
5189 * \param completion_string The code completion string whose parent is
5190 * being queried.
5191 *
Argyrios Kyrtzidis9ae39562012-09-26 16:39:56 +00005192 * \param kind DEPRECATED: always set to CXCursor_NotImplemented if non-NULL.
Douglas Gregor78254c82012-03-27 23:34:16 +00005193 *
James Dennett574cb4c2012-06-15 05:41:51 +00005194 * \returns The name of the completion parent, e.g., "NSObject" if
Douglas Gregor78254c82012-03-27 23:34:16 +00005195 * the completion string represents a method in the NSObject class.
5196 */
5197CINDEX_LINKAGE CXString
5198clang_getCompletionParent(CXCompletionString completion_string,
5199 enum CXCursorKind *kind);
Dmitri Gribenko3292d062012-07-02 17:35:10 +00005200
5201/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005202 * Retrieve the brief documentation comment attached to the declaration
Dmitri Gribenko3292d062012-07-02 17:35:10 +00005203 * that corresponds to the given completion string.
5204 */
5205CINDEX_LINKAGE CXString
5206clang_getCompletionBriefComment(CXCompletionString completion_string);
5207
Douglas Gregor78254c82012-03-27 23:34:16 +00005208/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005209 * Retrieve a completion string for an arbitrary declaration or macro
Douglas Gregor3f35bb22011-08-04 20:04:59 +00005210 * definition cursor.
5211 *
5212 * \param cursor The cursor to query.
5213 *
5214 * \returns A non-context-sensitive completion string for declaration and macro
5215 * definition cursors, or NULL for other kinds of cursors.
5216 */
5217CINDEX_LINKAGE CXCompletionString
5218clang_getCursorCompletionString(CXCursor cursor);
5219
5220/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005221 * Contains the results of code-completion.
Douglas Gregorf72b6ac2009-12-18 16:20:58 +00005222 *
5223 * This data structure contains the results of code completion, as
Douglas Gregor6a9580282010-10-11 21:51:20 +00005224 * produced by \c clang_codeCompleteAt(). Its contents must be freed by
Douglas Gregorf72b6ac2009-12-18 16:20:58 +00005225 * \c clang_disposeCodeCompleteResults.
5226 */
5227typedef struct {
5228 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005229 * The code-completion results.
Douglas Gregorf72b6ac2009-12-18 16:20:58 +00005230 */
5231 CXCompletionResult *Results;
5232
5233 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005234 * The number of code-completion results stored in the
Douglas Gregorf72b6ac2009-12-18 16:20:58 +00005235 * \c Results array.
5236 */
5237 unsigned NumResults;
5238} CXCodeCompleteResults;
5239
5240/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005241 * Flags that can be passed to \c clang_codeCompleteAt() to
Douglas Gregorb68bc592010-08-05 09:09:23 +00005242 * modify its behavior.
5243 *
5244 * The enumerators in this enumeration can be bitwise-OR'd together to
5245 * provide multiple options to \c clang_codeCompleteAt().
5246 */
5247enum CXCodeComplete_Flags {
5248 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005249 * Whether to include macros within the set of code
Douglas Gregorb68bc592010-08-05 09:09:23 +00005250 * completions returned.
5251 */
5252 CXCodeComplete_IncludeMacros = 0x01,
5253
5254 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005255 * Whether to include code patterns for language constructs
Douglas Gregorb68bc592010-08-05 09:09:23 +00005256 * within the set of code completions, e.g., for loops.
5257 */
Dmitri Gribenko3292d062012-07-02 17:35:10 +00005258 CXCodeComplete_IncludeCodePatterns = 0x02,
5259
5260 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005261 * Whether to include brief documentation within the set of code
Dmitri Gribenko3292d062012-07-02 17:35:10 +00005262 * completions returned.
5263 */
Sam McCallbb2cf632018-01-12 14:51:47 +00005264 CXCodeComplete_IncludeBriefComments = 0x04,
5265
5266 /**
Sam McCallabdcc612018-01-24 17:50:20 +00005267 * Whether to speed up completion by omitting top- or namespace-level entities
5268 * defined in the preamble. There's no guarantee any particular entity is
5269 * omitted. This may be useful if the headers are indexed externally.
Sam McCallbb2cf632018-01-12 14:51:47 +00005270 */
5271 CXCodeComplete_SkipPreamble = 0x08
Douglas Gregorb68bc592010-08-05 09:09:23 +00005272};
5273
5274/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005275 * Bits that represent the context under which completion is occurring.
Douglas Gregor21325842011-07-07 16:03:39 +00005276 *
5277 * The enumerators in this enumeration may be bitwise-OR'd together if multiple
5278 * contexts are occurring simultaneously.
5279 */
5280enum CXCompletionContext {
5281 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005282 * The context for completions is unexposed, as only Clang results
Douglas Gregor21325842011-07-07 16:03:39 +00005283 * should be included. (This is equivalent to having no context bits set.)
5284 */
5285 CXCompletionContext_Unexposed = 0,
5286
5287 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005288 * Completions for any possible type should be included in the results.
Douglas Gregor21325842011-07-07 16:03:39 +00005289 */
5290 CXCompletionContext_AnyType = 1 << 0,
5291
5292 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005293 * Completions for any possible value (variables, function calls, etc.)
Douglas Gregor21325842011-07-07 16:03:39 +00005294 * should be included in the results.
5295 */
5296 CXCompletionContext_AnyValue = 1 << 1,
5297 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005298 * Completions for values that resolve to an Objective-C object should
Douglas Gregor21325842011-07-07 16:03:39 +00005299 * be included in the results.
5300 */
5301 CXCompletionContext_ObjCObjectValue = 1 << 2,
5302 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005303 * Completions for values that resolve to an Objective-C selector
Douglas Gregor21325842011-07-07 16:03:39 +00005304 * should be included in the results.
5305 */
5306 CXCompletionContext_ObjCSelectorValue = 1 << 3,
5307 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005308 * Completions for values that resolve to a C++ class type should be
Douglas Gregor21325842011-07-07 16:03:39 +00005309 * included in the results.
5310 */
5311 CXCompletionContext_CXXClassTypeValue = 1 << 4,
5312
5313 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005314 * Completions for fields of the member being accessed using the dot
Douglas Gregor21325842011-07-07 16:03:39 +00005315 * operator should be included in the results.
5316 */
5317 CXCompletionContext_DotMemberAccess = 1 << 5,
5318 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005319 * Completions for fields of the member being accessed using the arrow
Douglas Gregor21325842011-07-07 16:03:39 +00005320 * operator should be included in the results.
5321 */
5322 CXCompletionContext_ArrowMemberAccess = 1 << 6,
5323 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005324 * Completions for properties of the Objective-C object being accessed
Douglas Gregor21325842011-07-07 16:03:39 +00005325 * using the dot operator should be included in the results.
5326 */
5327 CXCompletionContext_ObjCPropertyAccess = 1 << 7,
5328
5329 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005330 * Completions for enum tags should be included in the results.
Douglas Gregor21325842011-07-07 16:03:39 +00005331 */
5332 CXCompletionContext_EnumTag = 1 << 8,
5333 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005334 * Completions for union tags should be included in the results.
Douglas Gregor21325842011-07-07 16:03:39 +00005335 */
5336 CXCompletionContext_UnionTag = 1 << 9,
5337 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005338 * Completions for struct tags should be included in the results.
Douglas Gregor21325842011-07-07 16:03:39 +00005339 */
5340 CXCompletionContext_StructTag = 1 << 10,
5341
5342 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005343 * Completions for C++ class names should be included in the results.
Douglas Gregor21325842011-07-07 16:03:39 +00005344 */
5345 CXCompletionContext_ClassTag = 1 << 11,
5346 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005347 * Completions for C++ namespaces and namespace aliases should be
Douglas Gregor21325842011-07-07 16:03:39 +00005348 * included in the results.
5349 */
5350 CXCompletionContext_Namespace = 1 << 12,
5351 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005352 * Completions for C++ nested name specifiers should be included in
Douglas Gregor21325842011-07-07 16:03:39 +00005353 * the results.
5354 */
5355 CXCompletionContext_NestedNameSpecifier = 1 << 13,
5356
5357 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005358 * Completions for Objective-C interfaces (classes) should be included
Douglas Gregor21325842011-07-07 16:03:39 +00005359 * in the results.
5360 */
5361 CXCompletionContext_ObjCInterface = 1 << 14,
5362 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005363 * Completions for Objective-C protocols should be included in
Douglas Gregor21325842011-07-07 16:03:39 +00005364 * the results.
5365 */
5366 CXCompletionContext_ObjCProtocol = 1 << 15,
5367 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005368 * Completions for Objective-C categories should be included in
Douglas Gregor21325842011-07-07 16:03:39 +00005369 * the results.
5370 */
5371 CXCompletionContext_ObjCCategory = 1 << 16,
5372 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005373 * Completions for Objective-C instance messages should be included
Douglas Gregor21325842011-07-07 16:03:39 +00005374 * in the results.
5375 */
5376 CXCompletionContext_ObjCInstanceMessage = 1 << 17,
5377 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005378 * Completions for Objective-C class messages should be included in
Douglas Gregor21325842011-07-07 16:03:39 +00005379 * the results.
5380 */
5381 CXCompletionContext_ObjCClassMessage = 1 << 18,
5382 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005383 * Completions for Objective-C selector names should be included in
Douglas Gregor21325842011-07-07 16:03:39 +00005384 * the results.
5385 */
5386 CXCompletionContext_ObjCSelectorName = 1 << 19,
5387
5388 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005389 * Completions for preprocessor macro names should be included in
Douglas Gregor21325842011-07-07 16:03:39 +00005390 * the results.
5391 */
5392 CXCompletionContext_MacroName = 1 << 20,
5393
5394 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005395 * Natural language completions should be included in the results.
Douglas Gregor21325842011-07-07 16:03:39 +00005396 */
5397 CXCompletionContext_NaturalLanguage = 1 << 21,
5398
5399 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005400 * The current context is unknown, so set all contexts.
Douglas Gregor21325842011-07-07 16:03:39 +00005401 */
5402 CXCompletionContext_Unknown = ((1 << 22) - 1)
5403};
5404
5405/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005406 * Returns a default set of code-completion options that can be
Douglas Gregorb68bc592010-08-05 09:09:23 +00005407 * passed to\c clang_codeCompleteAt().
5408 */
5409CINDEX_LINKAGE unsigned clang_defaultCodeCompleteOptions(void);
5410
5411/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005412 * Perform code completion at a given location in a translation unit.
Douglas Gregor8e984da2010-08-04 16:47:14 +00005413 *
5414 * This function performs code completion at a particular file, line, and
5415 * column within source code, providing results that suggest potential
5416 * code snippets based on the context of the completion. The basic model
5417 * for code completion is that Clang will parse a complete source file,
5418 * performing syntax checking up to the location where code-completion has
5419 * been requested. At that point, a special code-completion token is passed
5420 * to the parser, which recognizes this token and determines, based on the
5421 * current location in the C/Objective-C/C++ grammar and the state of
5422 * semantic analysis, what completions to provide. These completions are
5423 * returned via a new \c CXCodeCompleteResults structure.
5424 *
5425 * Code completion itself is meant to be triggered by the client when the
5426 * user types punctuation characters or whitespace, at which point the
5427 * code-completion location will coincide with the cursor. For example, if \c p
5428 * is a pointer, code-completion might be triggered after the "-" and then
Alexander Kornienko2a8c18d2018-04-06 15:14:32 +00005429 * after the ">" in \c p->. When the code-completion location is after the ">",
Douglas Gregor8e984da2010-08-04 16:47:14 +00005430 * the completion results will provide, e.g., the members of the struct that
5431 * "p" points to. The client is responsible for placing the cursor at the
5432 * beginning of the token currently being typed, then filtering the results
5433 * based on the contents of the token. For example, when code-completing for
5434 * the expression \c p->get, the client should provide the location just after
5435 * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the
5436 * client can filter the results based on the current token text ("get"), only
5437 * showing those results that start with "get". The intent of this interface
5438 * is to separate the relatively high-latency acquisition of code-completion
5439 * results from the filtering of results on a per-character basis, which must
5440 * have a lower latency.
5441 *
5442 * \param TU The translation unit in which code-completion should
5443 * occur. The source files for this translation unit need not be
5444 * completely up-to-date (and the contents of those source files may
5445 * be overridden via \p unsaved_files). Cursors referring into the
5446 * translation unit may be invalidated by this invocation.
5447 *
5448 * \param complete_filename The name of the source file where code
5449 * completion should be performed. This filename may be any file
5450 * included in the translation unit.
5451 *
5452 * \param complete_line The line at which code-completion should occur.
5453 *
5454 * \param complete_column The column at which code-completion should occur.
5455 * Note that the column should point just after the syntactic construct that
5456 * initiated code completion, and not in the middle of a lexical token.
5457 *
Vedant Kumarcbfe7bb2016-03-23 23:51:36 +00005458 * \param unsaved_files the Files that have not yet been saved to disk
Douglas Gregor8e984da2010-08-04 16:47:14 +00005459 * but may be required for parsing or code completion, including the
5460 * contents of those files. The contents and name of these files (as
5461 * specified by CXUnsavedFile) are copied when necessary, so the
5462 * client only needs to guarantee their validity until the call to
5463 * this function returns.
5464 *
5465 * \param num_unsaved_files The number of unsaved file entries in \p
5466 * unsaved_files.
5467 *
Douglas Gregorb68bc592010-08-05 09:09:23 +00005468 * \param options Extra options that control the behavior of code
5469 * completion, expressed as a bitwise OR of the enumerators of the
5470 * CXCodeComplete_Flags enumeration. The
5471 * \c clang_defaultCodeCompleteOptions() function returns a default set
5472 * of code-completion options.
5473 *
Douglas Gregor8e984da2010-08-04 16:47:14 +00005474 * \returns If successful, a new \c CXCodeCompleteResults structure
5475 * containing code-completion results, which should eventually be
5476 * freed with \c clang_disposeCodeCompleteResults(). If code
5477 * completion fails, returns NULL.
5478 */
5479CINDEX_LINKAGE
5480CXCodeCompleteResults *clang_codeCompleteAt(CXTranslationUnit TU,
5481 const char *complete_filename,
5482 unsigned complete_line,
5483 unsigned complete_column,
5484 struct CXUnsavedFile *unsaved_files,
Douglas Gregorb68bc592010-08-05 09:09:23 +00005485 unsigned num_unsaved_files,
5486 unsigned options);
Douglas Gregor8e984da2010-08-04 16:47:14 +00005487
5488/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005489 * Sort the code-completion results in case-insensitive alphabetical
Douglas Gregor49f67ce2010-08-26 13:48:20 +00005490 * order.
5491 *
5492 * \param Results The set of results to sort.
5493 * \param NumResults The number of results in \p Results.
5494 */
5495CINDEX_LINKAGE
5496void clang_sortCodeCompletionResults(CXCompletionResult *Results,
5497 unsigned NumResults);
5498
5499/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005500 * Free the given set of code-completion results.
Douglas Gregorf72b6ac2009-12-18 16:20:58 +00005501 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005502CINDEX_LINKAGE
Douglas Gregorf72b6ac2009-12-18 16:20:58 +00005503void clang_disposeCodeCompleteResults(CXCodeCompleteResults *Results);
Douglas Gregorf757a122010-08-23 23:00:57 +00005504
Douglas Gregor52606ff2010-01-20 01:10:47 +00005505/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005506 * Determine the number of diagnostics produced prior to the
Douglas Gregor33cdd812010-02-18 18:08:43 +00005507 * location where code completion was performed.
5508 */
Ted Kremenekd071c602010-03-13 02:50:34 +00005509CINDEX_LINKAGE
Douglas Gregor33cdd812010-02-18 18:08:43 +00005510unsigned clang_codeCompleteGetNumDiagnostics(CXCodeCompleteResults *Results);
5511
5512/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005513 * Retrieve a diagnostic associated with the given code completion.
Douglas Gregor33cdd812010-02-18 18:08:43 +00005514 *
James Dennett574cb4c2012-06-15 05:41:51 +00005515 * \param Results the code completion results to query.
Douglas Gregor33cdd812010-02-18 18:08:43 +00005516 * \param Index the zero-based diagnostic number to retrieve.
5517 *
5518 * \returns the requested diagnostic. This diagnostic must be freed
5519 * via a call to \c clang_disposeDiagnostic().
5520 */
Ted Kremenekd071c602010-03-13 02:50:34 +00005521CINDEX_LINKAGE
Douglas Gregor33cdd812010-02-18 18:08:43 +00005522CXDiagnostic clang_codeCompleteGetDiagnostic(CXCodeCompleteResults *Results,
5523 unsigned Index);
5524
5525/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005526 * Determines what completions are appropriate for the context
Douglas Gregor21325842011-07-07 16:03:39 +00005527 * the given code completion.
5528 *
5529 * \param Results the code completion results to query
5530 *
5531 * \returns the kinds of completions that are appropriate for use
5532 * along with the given code completion results.
5533 */
5534CINDEX_LINKAGE
5535unsigned long long clang_codeCompleteGetContexts(
5536 CXCodeCompleteResults *Results);
Douglas Gregor63745d52011-07-21 01:05:26 +00005537
5538/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005539 * Returns the cursor kind for the container for the current code
Douglas Gregor63745d52011-07-21 01:05:26 +00005540 * completion context. The container is only guaranteed to be set for
5541 * contexts where a container exists (i.e. member accesses or Objective-C
5542 * message sends); if there is not a container, this function will return
5543 * CXCursor_InvalidCode.
5544 *
5545 * \param Results the code completion results to query
5546 *
5547 * \param IsIncomplete on return, this value will be false if Clang has complete
5548 * information about the container. If Clang does not have complete
5549 * information, this value will be true.
5550 *
5551 * \returns the container kind, or CXCursor_InvalidCode if there is not a
5552 * container
5553 */
5554CINDEX_LINKAGE
5555enum CXCursorKind clang_codeCompleteGetContainerKind(
5556 CXCodeCompleteResults *Results,
5557 unsigned *IsIncomplete);
5558
5559/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005560 * Returns the USR for the container for the current code completion
Douglas Gregor63745d52011-07-21 01:05:26 +00005561 * context. If there is not a container for the current context, this
5562 * function will return the empty string.
5563 *
5564 * \param Results the code completion results to query
5565 *
5566 * \returns the USR for the container
5567 */
5568CINDEX_LINKAGE
5569CXString clang_codeCompleteGetContainerUSR(CXCodeCompleteResults *Results);
NAKAMURA Takumiaa13f942015-12-09 07:52:46 +00005570
Douglas Gregorea777402011-07-26 15:24:30 +00005571/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005572 * Returns the currently-entered selector for an Objective-C message
Douglas Gregorea777402011-07-26 15:24:30 +00005573 * send, formatted like "initWithFoo:bar:". Only guaranteed to return a
5574 * non-empty string for CXCompletionContext_ObjCInstanceMessage and
5575 * CXCompletionContext_ObjCClassMessage.
5576 *
5577 * \param Results the code completion results to query
5578 *
5579 * \returns the selector (or partial selector) that has been entered thus far
5580 * for an Objective-C message send.
5581 */
5582CINDEX_LINKAGE
5583CXString clang_codeCompleteGetObjCSelector(CXCodeCompleteResults *Results);
5584
Douglas Gregor21325842011-07-07 16:03:39 +00005585/**
Douglas Gregor52606ff2010-01-20 01:10:47 +00005586 * @}
5587 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005588
Ted Kremenekc0f3f722010-01-22 22:44:15 +00005589/**
5590 * \defgroup CINDEX_MISC Miscellaneous utility functions
5591 *
5592 * @{
5593 */
Ted Kremenek3e315a22010-01-23 17:51:23 +00005594
5595/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005596 * Return a version string, suitable for showing to a user, but not
Ted Kremenek3e315a22010-01-23 17:51:23 +00005597 * intended to be parsed (the format is not guaranteed to be stable).
5598 */
NAKAMURA Takumieacd6672013-01-10 02:12:38 +00005599CINDEX_LINKAGE CXString clang_getClangVersion(void);
Ted Kremenekc0f3f722010-01-22 22:44:15 +00005600
Ted Kremenek1ec7b332011-03-18 23:05:39 +00005601/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005602 * Enable/disable crash recovery.
Ted Kremenek1ec7b332011-03-18 23:05:39 +00005603 *
James Dennett574cb4c2012-06-15 05:41:51 +00005604 * \param isEnabled Flag to indicate if crash recovery is enabled. A non-zero
5605 * value enables crash recovery, while 0 disables it.
Ted Kremenek1ec7b332011-03-18 23:05:39 +00005606 */
5607CINDEX_LINKAGE void clang_toggleCrashRecovery(unsigned isEnabled);
5608
Ted Kremenek0b86e3a2010-01-26 19:31:51 +00005609 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005610 * Visitor invoked for each file in a translation unit
Ted Kremenek0b86e3a2010-01-26 19:31:51 +00005611 * (used with clang_getInclusions()).
5612 *
5613 * This visitor function will be invoked by clang_getInclusions() for each
James Dennett574cb4c2012-06-15 05:41:51 +00005614 * file included (either at the top-level or by \#include directives) within
Ted Kremenek0b86e3a2010-01-26 19:31:51 +00005615 * a translation unit. The first argument is the file being included, and
5616 * the second and third arguments provide the inclusion stack. The
5617 * array is sorted in order of immediate inclusion. For example,
5618 * the first element refers to the location that included 'included_file'.
5619 */
5620typedef void (*CXInclusionVisitor)(CXFile included_file,
5621 CXSourceLocation* inclusion_stack,
5622 unsigned include_len,
5623 CXClientData client_data);
5624
5625/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005626 * Visit the set of preprocessor inclusions in a translation unit.
Ted Kremenek0b86e3a2010-01-26 19:31:51 +00005627 * The visitor function is called with the provided data for every included
5628 * file. This does not include headers included by the PCH file (unless one
5629 * is inspecting the inclusions in the PCH file itself).
5630 */
5631CINDEX_LINKAGE void clang_getInclusions(CXTranslationUnit tu,
5632 CXInclusionVisitor visitor,
5633 CXClientData client_data);
5634
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005635typedef enum {
5636 CXEval_Int = 1 ,
5637 CXEval_Float = 2,
5638 CXEval_ObjCStrLiteral = 3,
5639 CXEval_StrLiteral = 4,
5640 CXEval_CFStr = 5,
5641 CXEval_Other = 6,
5642
5643 CXEval_UnExposed = 0
5644
5645} CXEvalResultKind ;
5646
5647/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005648 * Evaluation result of a cursor
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005649 */
5650typedef void * CXEvalResult;
5651
5652/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005653 * If cursor is a statement declaration tries to evaluate the
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005654 * statement and if its variable, tries to evaluate its initializer,
5655 * into its corresponding type.
5656 */
5657CINDEX_LINKAGE CXEvalResult clang_Cursor_Evaluate(CXCursor C);
5658
5659/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005660 * Returns the kind of the evaluated result.
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005661 */
Argyrios Kyrtzidisa851d7e2016-01-16 03:01:20 +00005662CINDEX_LINKAGE CXEvalResultKind clang_EvalResult_getKind(CXEvalResult E);
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005663
5664/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005665 * Returns the evaluation result as integer if the
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005666 * kind is Int.
5667 */
Argyrios Kyrtzidisa851d7e2016-01-16 03:01:20 +00005668CINDEX_LINKAGE int clang_EvalResult_getAsInt(CXEvalResult E);
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005669
5670/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005671 * Returns the evaluation result as a long long integer if the
Argyrios Kyrtzidis5dda1122016-12-01 23:41:27 +00005672 * kind is Int. This prevents overflows that may happen if the result is
5673 * returned with clang_EvalResult_getAsInt.
5674 */
5675CINDEX_LINKAGE long long clang_EvalResult_getAsLongLong(CXEvalResult E);
5676
5677/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005678 * Returns a non-zero value if the kind is Int and the evaluation
Argyrios Kyrtzidis5dda1122016-12-01 23:41:27 +00005679 * result resulted in an unsigned integer.
5680 */
5681CINDEX_LINKAGE unsigned clang_EvalResult_isUnsignedInt(CXEvalResult E);
5682
5683/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005684 * Returns the evaluation result as an unsigned integer if
Argyrios Kyrtzidis5dda1122016-12-01 23:41:27 +00005685 * the kind is Int and clang_EvalResult_isUnsignedInt is non-zero.
5686 */
5687CINDEX_LINKAGE unsigned long long clang_EvalResult_getAsUnsigned(CXEvalResult E);
5688
5689/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005690 * Returns the evaluation result as double if the
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005691 * kind is double.
5692 */
Argyrios Kyrtzidisa851d7e2016-01-16 03:01:20 +00005693CINDEX_LINKAGE double clang_EvalResult_getAsDouble(CXEvalResult E);
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005694
5695/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005696 * Returns the evaluation result as a constant string if the
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005697 * kind is other than Int or float. User must not free this pointer,
5698 * instead call clang_EvalResult_dispose on the CXEvalResult returned
5699 * by clang_Cursor_Evaluate.
5700 */
Argyrios Kyrtzidisa851d7e2016-01-16 03:01:20 +00005701CINDEX_LINKAGE const char* clang_EvalResult_getAsStr(CXEvalResult E);
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005702
5703/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005704 * Disposes the created Eval memory.
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005705 */
Argyrios Kyrtzidisa851d7e2016-01-16 03:01:20 +00005706CINDEX_LINKAGE void clang_EvalResult_dispose(CXEvalResult E);
Ted Kremenek0b86e3a2010-01-26 19:31:51 +00005707/**
Ted Kremenekc0f3f722010-01-22 22:44:15 +00005708 * @}
5709 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005710
Argyrios Kyrtzidisf89cc692011-07-11 20:15:00 +00005711/** \defgroup CINDEX_REMAPPING Remapping functions
5712 *
5713 * @{
5714 */
5715
5716/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005717 * A remapping of original source files and their translated files.
Argyrios Kyrtzidisf89cc692011-07-11 20:15:00 +00005718 */
5719typedef void *CXRemapping;
5720
5721/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005722 * Retrieve a remapping.
Argyrios Kyrtzidisf89cc692011-07-11 20:15:00 +00005723 *
5724 * \param path the path that contains metadata about remappings.
5725 *
5726 * \returns the requested remapping. This remapping must be freed
5727 * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
5728 */
5729CINDEX_LINKAGE CXRemapping clang_getRemappings(const char *path);
5730
5731/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005732 * Retrieve a remapping.
Ted Kremenekf7639e12012-03-06 20:06:33 +00005733 *
5734 * \param filePaths pointer to an array of file paths containing remapping info.
5735 *
5736 * \param numFiles number of file paths.
5737 *
5738 * \returns the requested remapping. This remapping must be freed
5739 * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
5740 */
5741CINDEX_LINKAGE
5742CXRemapping clang_getRemappingsFromFileList(const char **filePaths,
5743 unsigned numFiles);
5744
5745/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005746 * Determine the number of remappings.
Argyrios Kyrtzidisf89cc692011-07-11 20:15:00 +00005747 */
5748CINDEX_LINKAGE unsigned clang_remap_getNumFiles(CXRemapping);
5749
5750/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005751 * Get the original and the associated filename from the remapping.
Argyrios Kyrtzidisf89cc692011-07-11 20:15:00 +00005752 *
5753 * \param original If non-NULL, will be set to the original filename.
5754 *
5755 * \param transformed If non-NULL, will be set to the filename that the original
5756 * is associated with.
5757 */
5758CINDEX_LINKAGE void clang_remap_getFilenames(CXRemapping, unsigned index,
5759 CXString *original, CXString *transformed);
5760
5761/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005762 * Dispose the remapping.
Argyrios Kyrtzidisf89cc692011-07-11 20:15:00 +00005763 */
5764CINDEX_LINKAGE void clang_remap_dispose(CXRemapping);
5765
5766/**
5767 * @}
5768 */
5769
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00005770/** \defgroup CINDEX_HIGH Higher level API functions
5771 *
5772 * @{
5773 */
5774
5775enum CXVisitorResult {
5776 CXVisit_Break,
5777 CXVisit_Continue
5778};
5779
Saleem Abdulrasoolec988b72016-05-24 01:23:24 +00005780typedef struct CXCursorAndRangeVisitor {
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00005781 void *context;
5782 enum CXVisitorResult (*visit)(void *context, CXCursor, CXSourceRange);
5783} CXCursorAndRangeVisitor;
5784
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00005785typedef enum {
5786 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005787 * Function returned successfully.
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00005788 */
5789 CXResult_Success = 0,
5790 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005791 * One of the parameters was invalid for the function.
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00005792 */
5793 CXResult_Invalid = 1,
5794 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005795 * The function was terminated by a callback (e.g. it returned
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00005796 * CXVisit_Break)
5797 */
5798 CXResult_VisitBreak = 2
5799
5800} CXResult;
5801
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00005802/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005803 * Find references of a declaration in a specific file.
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00005804 *
5805 * \param cursor pointing to a declaration or a reference of one.
5806 *
5807 * \param file to search for references.
5808 *
5809 * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
5810 * each reference found.
5811 * The CXSourceRange will point inside the file; if the reference is inside
5812 * a macro (and not a macro argument) the CXSourceRange will be invalid.
Argyrios Kyrtzidis951f61f2013-03-08 20:42:33 +00005813 *
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00005814 * \returns one of the CXResult enumerators.
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00005815 */
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00005816CINDEX_LINKAGE CXResult clang_findReferencesInFile(CXCursor cursor, CXFile file,
5817 CXCursorAndRangeVisitor visitor);
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00005818
Argyrios Kyrtzidis503c83a2013-03-08 02:32:34 +00005819/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005820 * Find #import/#include directives in a specific file.
Argyrios Kyrtzidis503c83a2013-03-08 02:32:34 +00005821 *
5822 * \param TU translation unit containing the file to query.
5823 *
5824 * \param file to search for #import/#include directives.
5825 *
5826 * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
5827 * each directive found.
Argyrios Kyrtzidis951f61f2013-03-08 20:42:33 +00005828 *
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00005829 * \returns one of the CXResult enumerators.
Argyrios Kyrtzidis503c83a2013-03-08 02:32:34 +00005830 */
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00005831CINDEX_LINKAGE CXResult clang_findIncludesInFile(CXTranslationUnit TU,
5832 CXFile file,
5833 CXCursorAndRangeVisitor visitor);
Argyrios Kyrtzidis503c83a2013-03-08 02:32:34 +00005834
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00005835#ifdef __has_feature
5836# if __has_feature(blocks)
5837
5838typedef enum CXVisitorResult
5839 (^CXCursorAndRangeVisitorBlock)(CXCursor, CXSourceRange);
5840
5841CINDEX_LINKAGE
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00005842CXResult clang_findReferencesInFileWithBlock(CXCursor, CXFile,
5843 CXCursorAndRangeVisitorBlock);
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00005844
Argyrios Kyrtzidis503c83a2013-03-08 02:32:34 +00005845CINDEX_LINKAGE
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00005846CXResult clang_findIncludesInFileWithBlock(CXTranslationUnit, CXFile,
5847 CXCursorAndRangeVisitorBlock);
Argyrios Kyrtzidis503c83a2013-03-08 02:32:34 +00005848
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00005849# endif
5850#endif
5851
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005852/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005853 * The client's data object that is associated with a CXFile.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005854 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005855typedef void *CXIdxClientFile;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005856
5857/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005858 * The client's data object that is associated with a semantic entity.
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00005859 */
5860typedef void *CXIdxClientEntity;
5861
5862/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005863 * The client's data object that is associated with a semantic container
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005864 * of entities.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005865 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005866typedef void *CXIdxClientContainer;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005867
5868/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005869 * The client's data object that is associated with an AST file (PCH
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005870 * or module).
5871 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005872typedef void *CXIdxClientASTFile;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005873
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005874/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005875 * Source location passed to index callbacks.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005876 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005877typedef struct {
5878 void *ptr_data[2];
5879 unsigned int_data;
5880} CXIdxLoc;
5881
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005882/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005883 * Data for ppIncludedFile callback.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005884 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005885typedef struct {
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005886 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005887 * Location of '#' in the \#include/\#import directive.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005888 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005889 CXIdxLoc hashLoc;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005890 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005891 * Filename as written in the \#include/\#import directive.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005892 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005893 const char *filename;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005894 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005895 * The actual file that the \#include/\#import directive resolved to.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005896 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005897 CXFile file;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005898 int isImport;
5899 int isAngled;
Argyrios Kyrtzidis5e2ec482012-10-18 00:17:05 +00005900 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005901 * Non-zero if the directive was automatically turned into a module
Argyrios Kyrtzidis5e2ec482012-10-18 00:17:05 +00005902 * import.
5903 */
5904 int isModuleImport;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005905} CXIdxIncludedFileInfo;
5906
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005907/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005908 * Data for IndexerCallbacks#importedASTFile.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005909 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005910typedef struct {
Argyrios Kyrtzidis472eda02012-10-02 16:10:38 +00005911 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005912 * Top level AST file containing the imported PCH, module or submodule.
Argyrios Kyrtzidis472eda02012-10-02 16:10:38 +00005913 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005914 CXFile file;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005915 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005916 * The imported module or NULL if the AST file is a PCH.
Argyrios Kyrtzidisdc78f3e2012-10-05 00:22:40 +00005917 */
5918 CXModule module;
5919 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005920 * Location where the file is imported. Applicable only for modules.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005921 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005922 CXIdxLoc loc;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005923 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005924 * Non-zero if an inclusion directive was automatically turned into
Argyrios Kyrtzidisdc78f3e2012-10-05 00:22:40 +00005925 * a module import. Applicable only for modules.
Argyrios Kyrtzidis472eda02012-10-02 16:10:38 +00005926 */
Argyrios Kyrtzidis184b1442012-10-03 21:05:44 +00005927 int isImplicit;
Argyrios Kyrtzidis472eda02012-10-02 16:10:38 +00005928
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005929} CXIdxImportedASTFileInfo;
5930
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005931typedef enum {
5932 CXIdxEntity_Unexposed = 0,
5933 CXIdxEntity_Typedef = 1,
5934 CXIdxEntity_Function = 2,
5935 CXIdxEntity_Variable = 3,
5936 CXIdxEntity_Field = 4,
5937 CXIdxEntity_EnumConstant = 5,
5938
5939 CXIdxEntity_ObjCClass = 6,
5940 CXIdxEntity_ObjCProtocol = 7,
5941 CXIdxEntity_ObjCCategory = 8,
5942
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00005943 CXIdxEntity_ObjCInstanceMethod = 9,
5944 CXIdxEntity_ObjCClassMethod = 10,
5945 CXIdxEntity_ObjCProperty = 11,
5946 CXIdxEntity_ObjCIvar = 12,
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005947
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00005948 CXIdxEntity_Enum = 13,
5949 CXIdxEntity_Struct = 14,
5950 CXIdxEntity_Union = 15,
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00005951
5952 CXIdxEntity_CXXClass = 16,
5953 CXIdxEntity_CXXNamespace = 17,
5954 CXIdxEntity_CXXNamespaceAlias = 18,
5955 CXIdxEntity_CXXStaticVariable = 19,
5956 CXIdxEntity_CXXStaticMethod = 20,
5957 CXIdxEntity_CXXInstanceMethod = 21,
Joao Matose9a3ed42012-08-31 22:18:20 +00005958 CXIdxEntity_CXXConstructor = 22,
5959 CXIdxEntity_CXXDestructor = 23,
5960 CXIdxEntity_CXXConversionFunction = 24,
5961 CXIdxEntity_CXXTypeAlias = 25,
5962 CXIdxEntity_CXXInterface = 26
5963
5964} CXIdxEntityKind;
5965
Argyrios Kyrtzidis52002882011-12-07 20:44:12 +00005966typedef enum {
5967 CXIdxEntityLang_None = 0,
5968 CXIdxEntityLang_C = 1,
5969 CXIdxEntityLang_ObjC = 2,
Argyrios Kyrtzidisb4b85f22017-04-24 14:52:00 +00005970 CXIdxEntityLang_CXX = 3,
5971 CXIdxEntityLang_Swift = 4
Argyrios Kyrtzidis52002882011-12-07 20:44:12 +00005972} CXIdxEntityLanguage;
5973
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00005974/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005975 * Extra C++ template information for an entity. This can apply to:
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00005976 * CXIdxEntity_Function
5977 * CXIdxEntity_CXXClass
5978 * CXIdxEntity_CXXStaticMethod
5979 * CXIdxEntity_CXXInstanceMethod
5980 * CXIdxEntity_CXXConstructor
5981 * CXIdxEntity_CXXConversionFunction
5982 * CXIdxEntity_CXXTypeAlias
5983 */
5984typedef enum {
5985 CXIdxEntity_NonTemplate = 0,
5986 CXIdxEntity_Template = 1,
5987 CXIdxEntity_TemplatePartialSpecialization = 2,
5988 CXIdxEntity_TemplateSpecialization = 3
5989} CXIdxEntityCXXTemplateKind;
5990
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00005991typedef enum {
5992 CXIdxAttr_Unexposed = 0,
5993 CXIdxAttr_IBAction = 1,
5994 CXIdxAttr_IBOutlet = 2,
5995 CXIdxAttr_IBOutletCollection = 3
5996} CXIdxAttrKind;
5997
5998typedef struct {
5999 CXIdxAttrKind kind;
6000 CXCursor cursor;
6001 CXIdxLoc loc;
6002} CXIdxAttrInfo;
6003
6004typedef struct {
Argyrios Kyrtzidis4d873b72011-12-15 00:05:00 +00006005 CXIdxEntityKind kind;
6006 CXIdxEntityCXXTemplateKind templateKind;
6007 CXIdxEntityLanguage lang;
6008 const char *name;
6009 const char *USR;
6010 CXCursor cursor;
6011 const CXIdxAttrInfo *const *attributes;
6012 unsigned numAttributes;
6013} CXIdxEntityInfo;
6014
6015typedef struct {
6016 CXCursor cursor;
6017} CXIdxContainerInfo;
6018
6019typedef struct {
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00006020 const CXIdxAttrInfo *attrInfo;
6021 const CXIdxEntityInfo *objcClass;
6022 CXCursor classCursor;
6023 CXIdxLoc classLoc;
6024} CXIdxIBOutletCollectionAttrInfo;
6025
Argyrios Kyrtzidis8b71bc72012-12-06 19:41:16 +00006026typedef enum {
6027 CXIdxDeclFlag_Skipped = 0x1
6028} CXIdxDeclInfoFlags;
6029
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006030typedef struct {
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006031 const CXIdxEntityInfo *entityInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006032 CXCursor cursor;
6033 CXIdxLoc loc;
Argyrios Kyrtzidis663c8ec2011-12-07 20:44:19 +00006034 const CXIdxContainerInfo *semanticContainer;
6035 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006036 * Generally same as #semanticContainer but can be different in
Argyrios Kyrtzidis663c8ec2011-12-07 20:44:19 +00006037 * cases like out-of-line C++ member functions.
6038 */
6039 const CXIdxContainerInfo *lexicalContainer;
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006040 int isRedeclaration;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006041 int isDefinition;
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00006042 int isContainer;
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006043 const CXIdxContainerInfo *declAsContainer;
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00006044 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006045 * Whether the declaration exists in code or was created implicitly
Nico Weber7deebef2014-04-24 03:17:47 +00006046 * by the compiler, e.g. implicit Objective-C methods for properties.
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00006047 */
6048 int isImplicit;
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00006049 const CXIdxAttrInfo *const *attributes;
6050 unsigned numAttributes;
Argyrios Kyrtzidis8b71bc72012-12-06 19:41:16 +00006051
6052 unsigned flags;
6053
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006054} CXIdxDeclInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006055
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006056typedef enum {
6057 CXIdxObjCContainer_ForwardRef = 0,
6058 CXIdxObjCContainer_Interface = 1,
6059 CXIdxObjCContainer_Implementation = 2
6060} CXIdxObjCContainerKind;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006061
6062typedef struct {
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006063 const CXIdxDeclInfo *declInfo;
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006064 CXIdxObjCContainerKind kind;
6065} CXIdxObjCContainerDeclInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006066
6067typedef struct {
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006068 const CXIdxEntityInfo *base;
6069 CXCursor cursor;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006070 CXIdxLoc loc;
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006071} CXIdxBaseClassInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006072
6073typedef struct {
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006074 const CXIdxEntityInfo *protocol;
6075 CXCursor cursor;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006076 CXIdxLoc loc;
6077} CXIdxObjCProtocolRefInfo;
6078
6079typedef struct {
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006080 const CXIdxObjCProtocolRefInfo *const *protocols;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006081 unsigned numProtocols;
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00006082} CXIdxObjCProtocolRefListInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006083
6084typedef struct {
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00006085 const CXIdxObjCContainerDeclInfo *containerInfo;
6086 const CXIdxBaseClassInfo *superInfo;
6087 const CXIdxObjCProtocolRefListInfo *protocols;
6088} CXIdxObjCInterfaceDeclInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006089
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006090typedef struct {
Argyrios Kyrtzidis9b9f7a92011-12-13 18:47:45 +00006091 const CXIdxObjCContainerDeclInfo *containerInfo;
6092 const CXIdxEntityInfo *objcClass;
6093 CXCursor classCursor;
6094 CXIdxLoc classLoc;
6095 const CXIdxObjCProtocolRefListInfo *protocols;
6096} CXIdxObjCCategoryDeclInfo;
6097
6098typedef struct {
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006099 const CXIdxDeclInfo *declInfo;
Argyrios Kyrtzidis93db2922012-02-28 17:50:33 +00006100 const CXIdxEntityInfo *getter;
6101 const CXIdxEntityInfo *setter;
6102} CXIdxObjCPropertyDeclInfo;
6103
6104typedef struct {
6105 const CXIdxDeclInfo *declInfo;
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006106 const CXIdxBaseClassInfo *const *bases;
6107 unsigned numBases;
6108} CXIdxCXXClassDeclInfo;
6109
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006110/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006111 * Data for IndexerCallbacks#indexEntityReference.
Fangrui Song31b97192018-02-12 17:42:09 +00006112 *
6113 * This may be deprecated in a future version as this duplicates
6114 * the \c CXSymbolRole_Implicit bit in \c CXSymbolRole.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006115 */
Argyrios Kyrtzidis0c7735e52011-10-18 15:50:50 +00006116typedef enum {
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006117 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006118 * The entity is referenced directly in user's code.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006119 */
Argyrios Kyrtzidis0c7735e52011-10-18 15:50:50 +00006120 CXIdxEntityRef_Direct = 1,
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006121 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006122 * An implicit reference, e.g. a reference of an Objective-C method
Nico Weber7deebef2014-04-24 03:17:47 +00006123 * via the dot syntax.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006124 */
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00006125 CXIdxEntityRef_Implicit = 2
Argyrios Kyrtzidis0c7735e52011-10-18 15:50:50 +00006126} CXIdxEntityRefKind;
6127
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006128/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006129 * Roles that are attributed to symbol occurrences.
Fangrui Song31b97192018-02-12 17:42:09 +00006130 *
6131 * Internal: this currently mirrors low 9 bits of clang::index::SymbolRole with
6132 * higher bits zeroed. These high bits may be exposed in the future.
6133 */
6134typedef enum {
6135 CXSymbolRole_None = 0,
6136 CXSymbolRole_Declaration = 1 << 0,
6137 CXSymbolRole_Definition = 1 << 1,
6138 CXSymbolRole_Reference = 1 << 2,
6139 CXSymbolRole_Read = 1 << 3,
6140 CXSymbolRole_Write = 1 << 4,
6141 CXSymbolRole_Call = 1 << 5,
6142 CXSymbolRole_Dynamic = 1 << 6,
6143 CXSymbolRole_AddressOf = 1 << 7,
6144 CXSymbolRole_Implicit = 1 << 8
6145} CXSymbolRole;
6146
6147/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006148 * Data for IndexerCallbacks#indexEntityReference.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006149 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006150typedef struct {
Argyrios Kyrtzidis663c8ec2011-12-07 20:44:19 +00006151 CXIdxEntityRefKind kind;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006152 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006153 * Reference cursor.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006154 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006155 CXCursor cursor;
6156 CXIdxLoc loc;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006157 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006158 * The entity that gets referenced.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006159 */
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006160 const CXIdxEntityInfo *referencedEntity;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006161 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006162 * Immediate "parent" of the reference. For example:
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006163 *
6164 * \code
6165 * Foo *var;
6166 * \endcode
6167 *
6168 * The parent of reference of type 'Foo' is the variable 'var'.
Argyrios Kyrtzidis25cb0ff2011-12-13 18:47:41 +00006169 * For references inside statement bodies of functions/methods,
6170 * the parentEntity will be the function/method.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006171 */
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006172 const CXIdxEntityInfo *parentEntity;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006173 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006174 * Lexical container context of the reference.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006175 */
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006176 const CXIdxContainerInfo *container;
Fangrui Song31b97192018-02-12 17:42:09 +00006177 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006178 * Sets of symbol roles of the reference.
Fangrui Song31b97192018-02-12 17:42:09 +00006179 */
6180 CXSymbolRole role;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006181} CXIdxEntityRefInfo;
6182
James Dennett574cb4c2012-06-15 05:41:51 +00006183/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006184 * A group of callbacks used by #clang_indexSourceFile and
James Dennett574cb4c2012-06-15 05:41:51 +00006185 * #clang_indexTranslationUnit.
6186 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006187typedef struct {
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006188 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006189 * Called periodically to check whether indexing should be aborted.
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006190 * Should return 0 to continue, and non-zero to abort.
6191 */
6192 int (*abortQuery)(CXClientData client_data, void *reserved);
6193
6194 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006195 * Called at the end of indexing; passes the complete diagnostic set.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006196 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006197 void (*diagnostic)(CXClientData client_data,
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00006198 CXDiagnosticSet, void *reserved);
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006199
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006200 CXIdxClientFile (*enteredMainFile)(CXClientData client_data,
James Dennett574cb4c2012-06-15 05:41:51 +00006201 CXFile mainFile, void *reserved);
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006202
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006203 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006204 * Called when a file gets \#included/\#imported.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006205 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006206 CXIdxClientFile (*ppIncludedFile)(CXClientData client_data,
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006207 const CXIdxIncludedFileInfo *);
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006208
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006209 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006210 * Called when a AST file (PCH or module) gets imported.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006211 *
6212 * AST files will not get indexed (there will not be callbacks to index all
6213 * the entities in an AST file). The recommended action is that, if the AST
Argyrios Kyrtzidis472eda02012-10-02 16:10:38 +00006214 * file is not already indexed, to initiate a new indexing job specific to
6215 * the AST file.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006216 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006217 CXIdxClientASTFile (*importedASTFile)(CXClientData client_data,
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006218 const CXIdxImportedASTFileInfo *);
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006219
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006220 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006221 * Called at the beginning of indexing a translation unit.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006222 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006223 CXIdxClientContainer (*startedTranslationUnit)(CXClientData client_data,
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006224 void *reserved);
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006225
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006226 void (*indexDeclaration)(CXClientData client_data,
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006227 const CXIdxDeclInfo *);
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006228
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006229 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006230 * Called to index a reference of an entity.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006231 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006232 void (*indexEntityReference)(CXClientData client_data,
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006233 const CXIdxEntityRefInfo *);
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006234
6235} IndexerCallbacks;
6236
NAKAMURA Takumiaacef7e2011-11-11 02:51:09 +00006237CINDEX_LINKAGE int clang_index_isEntityObjCContainerKind(CXIdxEntityKind);
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006238CINDEX_LINKAGE const CXIdxObjCContainerDeclInfo *
6239clang_index_getObjCContainerDeclInfo(const CXIdxDeclInfo *);
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006240
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006241CINDEX_LINKAGE const CXIdxObjCInterfaceDeclInfo *
6242clang_index_getObjCInterfaceDeclInfo(const CXIdxDeclInfo *);
6243
NAKAMURA Takumiaacef7e2011-11-11 02:51:09 +00006244CINDEX_LINKAGE
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006245const CXIdxObjCCategoryDeclInfo *
6246clang_index_getObjCCategoryDeclInfo(const CXIdxDeclInfo *);
6247
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00006248CINDEX_LINKAGE const CXIdxObjCProtocolRefListInfo *
6249clang_index_getObjCProtocolRefListInfo(const CXIdxDeclInfo *);
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006250
Argyrios Kyrtzidis93db2922012-02-28 17:50:33 +00006251CINDEX_LINKAGE const CXIdxObjCPropertyDeclInfo *
6252clang_index_getObjCPropertyDeclInfo(const CXIdxDeclInfo *);
6253
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00006254CINDEX_LINKAGE const CXIdxIBOutletCollectionAttrInfo *
6255clang_index_getIBOutletCollectionAttrInfo(const CXIdxAttrInfo *);
6256
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006257CINDEX_LINKAGE const CXIdxCXXClassDeclInfo *
6258clang_index_getCXXClassDeclInfo(const CXIdxDeclInfo *);
6259
6260/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006261 * For retrieving a custom CXIdxClientContainer attached to a
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006262 * container.
6263 */
6264CINDEX_LINKAGE CXIdxClientContainer
6265clang_index_getClientContainer(const CXIdxContainerInfo *);
6266
6267/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006268 * For setting a custom CXIdxClientContainer attached to a
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006269 * container.
6270 */
6271CINDEX_LINKAGE void
6272clang_index_setClientContainer(const CXIdxContainerInfo *,CXIdxClientContainer);
6273
6274/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006275 * For retrieving a custom CXIdxClientEntity attached to an entity.
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006276 */
6277CINDEX_LINKAGE CXIdxClientEntity
6278clang_index_getClientEntity(const CXIdxEntityInfo *);
6279
6280/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006281 * For setting a custom CXIdxClientEntity attached to an entity.
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006282 */
6283CINDEX_LINKAGE void
6284clang_index_setClientEntity(const CXIdxEntityInfo *, CXIdxClientEntity);
6285
6286/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006287 * An indexing action/session, to be applied to one or multiple
Argyrios Kyrtzidis8b71bc72012-12-06 19:41:16 +00006288 * translation units.
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006289 */
6290typedef void *CXIndexAction;
6291
6292/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006293 * An indexing action/session, to be applied to one or multiple
Argyrios Kyrtzidis8b71bc72012-12-06 19:41:16 +00006294 * translation units.
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006295 *
6296 * \param CIdx The index object with which the index action will be associated.
6297 */
6298CINDEX_LINKAGE CXIndexAction clang_IndexAction_create(CXIndex CIdx);
6299
6300/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006301 * Destroy the given index action.
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006302 *
6303 * The index action must not be destroyed until all of the translation units
6304 * created within that index action have been destroyed.
6305 */
6306CINDEX_LINKAGE void clang_IndexAction_dispose(CXIndexAction);
6307
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006308typedef enum {
6309 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006310 * Used to indicate that no special indexing options are needed.
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006311 */
6312 CXIndexOpt_None = 0x0,
6313
6314 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006315 * Used to indicate that IndexerCallbacks#indexEntityReference should
James Dennett574cb4c2012-06-15 05:41:51 +00006316 * be invoked for only one reference of an entity per source file that does
6317 * not also include a declaration/definition of the entity.
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006318 */
Argyrios Kyrtzidisfb7d1452012-01-14 00:11:49 +00006319 CXIndexOpt_SuppressRedundantRefs = 0x1,
6320
6321 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006322 * Function-local symbols should be indexed. If this is not set
Argyrios Kyrtzidisfb7d1452012-01-14 00:11:49 +00006323 * function-local symbols will be ignored.
6324 */
Argyrios Kyrtzidis7e747952012-02-14 22:23:11 +00006325 CXIndexOpt_IndexFunctionLocalSymbols = 0x2,
6326
6327 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006328 * Implicit function/class template instantiations should be indexed.
Argyrios Kyrtzidis7e747952012-02-14 22:23:11 +00006329 * If this is not set, implicit instantiations will be ignored.
6330 */
Argyrios Kyrtzidis6c9ed7d2012-03-27 21:38:03 +00006331 CXIndexOpt_IndexImplicitTemplateInstantiations = 0x4,
6332
6333 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006334 * Suppress all compiler warnings when parsing for indexing.
Argyrios Kyrtzidis6c9ed7d2012-03-27 21:38:03 +00006335 */
Argyrios Kyrtzidis8b71bc72012-12-06 19:41:16 +00006336 CXIndexOpt_SuppressWarnings = 0x8,
6337
6338 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006339 * Skip a function/method body that was already parsed during an
Nico Weber7deebef2014-04-24 03:17:47 +00006340 * indexing session associated with a \c CXIndexAction object.
Argyrios Kyrtzidis8b71bc72012-12-06 19:41:16 +00006341 * Bodies in system headers are always skipped.
6342 */
6343 CXIndexOpt_SkipParsedBodiesInSession = 0x10
6344
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006345} CXIndexOptFlags;
6346
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006347/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006348 * Index the given source file and the translation unit corresponding
James Dennett574cb4c2012-06-15 05:41:51 +00006349 * to that file via callbacks implemented through #IndexerCallbacks.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006350 *
6351 * \param client_data pointer data supplied by the client, which will
6352 * be passed to the invoked callbacks.
6353 *
6354 * \param index_callbacks Pointer to indexing callbacks that the client
6355 * implements.
6356 *
James Dennett574cb4c2012-06-15 05:41:51 +00006357 * \param index_callbacks_size Size of #IndexerCallbacks structure that gets
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006358 * passed in index_callbacks.
6359 *
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006360 * \param index_options A bitmask of options that affects how indexing is
6361 * performed. This should be a bitwise OR of the CXIndexOpt_XXX flags.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006362 *
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00006363 * \param[out] out_TU pointer to store a \c CXTranslationUnit that can be
6364 * reused after indexing is finished. Set to \c NULL if you do not require it.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006365 *
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00006366 * \returns 0 on success or if there were errors from which the compiler could
Eric Christopher2c4555a2015-06-19 01:52:53 +00006367 * recover. If there is a failure from which there is no recovery, returns
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00006368 * a non-zero \c CXErrorCode.
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006369 *
James Dennett574cb4c2012-06-15 05:41:51 +00006370 * The rest of the parameters are the same as #clang_parseTranslationUnit.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006371 */
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006372CINDEX_LINKAGE int clang_indexSourceFile(CXIndexAction,
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006373 CXClientData client_data,
6374 IndexerCallbacks *index_callbacks,
6375 unsigned index_callbacks_size,
6376 unsigned index_options,
6377 const char *source_filename,
6378 const char * const *command_line_args,
6379 int num_command_line_args,
6380 struct CXUnsavedFile *unsaved_files,
6381 unsigned num_unsaved_files,
6382 CXTranslationUnit *out_TU,
6383 unsigned TU_options);
6384
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006385/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006386 * Same as clang_indexSourceFile but requires a full command line
Benjamin Kramerc02670e2015-11-18 16:14:27 +00006387 * for \c command_line_args including argv[0]. This is useful if the standard
6388 * library paths are relative to the binary.
6389 */
6390CINDEX_LINKAGE int clang_indexSourceFileFullArgv(
6391 CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks,
6392 unsigned index_callbacks_size, unsigned index_options,
6393 const char *source_filename, const char *const *command_line_args,
6394 int num_command_line_args, struct CXUnsavedFile *unsaved_files,
6395 unsigned num_unsaved_files, CXTranslationUnit *out_TU, unsigned TU_options);
6396
6397/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006398 * Index the given translation unit via callbacks implemented through
James Dennett574cb4c2012-06-15 05:41:51 +00006399 * #IndexerCallbacks.
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006400 *
6401 * The order of callback invocations is not guaranteed to be the same as
6402 * when indexing a source file. The high level order will be:
6403 *
6404 * -Preprocessor callbacks invocations
6405 * -Declaration/reference callbacks invocations
6406 * -Diagnostic callback invocations
6407 *
James Dennett574cb4c2012-06-15 05:41:51 +00006408 * The parameters are the same as #clang_indexSourceFile.
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006409 *
Eric Christopher2c4555a2015-06-19 01:52:53 +00006410 * \returns If there is a failure from which there is no recovery, returns
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006411 * non-zero, otherwise returns 0.
6412 */
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006413CINDEX_LINKAGE int clang_indexTranslationUnit(CXIndexAction,
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006414 CXClientData client_data,
6415 IndexerCallbacks *index_callbacks,
6416 unsigned index_callbacks_size,
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006417 unsigned index_options,
6418 CXTranslationUnit);
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006419
6420/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006421 * Retrieve the CXIdxFile, file, line, column, and offset represented by
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006422 * the given CXIdxLoc.
6423 *
6424 * If the location refers into a macro expansion, retrieves the
6425 * location of the macro expansion and if it refers into a macro argument
6426 * retrieves the location of the argument.
6427 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006428CINDEX_LINKAGE void clang_indexLoc_getFileLocation(CXIdxLoc loc,
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006429 CXIdxClientFile *indexFile,
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006430 CXFile *file,
6431 unsigned *line,
6432 unsigned *column,
6433 unsigned *offset);
6434
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006435/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006436 * Retrieve the CXSourceLocation represented by the given CXIdxLoc.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006437 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006438CINDEX_LINKAGE
6439CXSourceLocation clang_indexLoc_getCXSourceLocation(CXIdxLoc loc);
6440
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00006441/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006442 * Visitor invoked for each field found by a traversal.
Argyrios Kyrtzidis2bff5162015-04-13 16:55:04 +00006443 *
6444 * This visitor function will be invoked for each field found by
6445 * \c clang_Type_visitFields. Its first argument is the cursor being
6446 * visited, its second argument is the client data provided to
6447 * \c clang_Type_visitFields.
6448 *
6449 * The visitor should return one of the \c CXVisitorResult values
6450 * to direct \c clang_Type_visitFields.
6451 */
6452typedef enum CXVisitorResult (*CXFieldVisitor)(CXCursor C,
6453 CXClientData client_data);
6454
6455/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006456 * Visit the fields of a particular type.
Argyrios Kyrtzidis2bff5162015-04-13 16:55:04 +00006457 *
6458 * This function visits all the direct fields of the given cursor,
6459 * invoking the given \p visitor function with the cursors of each
6460 * visited field. The traversal may be ended prematurely, if
6461 * the visitor returns \c CXFieldVisit_Break.
6462 *
6463 * \param T the record type whose field may be visited.
6464 *
6465 * \param visitor the visitor function that will be invoked for each
6466 * field of \p T.
6467 *
6468 * \param client_data pointer data supplied by the client, which will
6469 * be passed to the visitor each time it is invoked.
6470 *
6471 * \returns a non-zero value if the traversal was terminated
6472 * prematurely by the visitor returning \c CXFieldVisit_Break.
6473 */
6474CINDEX_LINKAGE unsigned clang_Type_visitFields(CXType T,
6475 CXFieldVisitor visitor,
6476 CXClientData client_data);
6477
Argyrios Kyrtzidis2bff5162015-04-13 16:55:04 +00006478/**
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00006479 * @}
6480 */
6481
Douglas Gregor6007cf22010-01-22 22:29:16 +00006482/**
6483 * @}
6484 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00006485
Ted Kremenekb60d87c2009-08-26 22:36:44 +00006486#ifdef __cplusplus
6487}
6488#endif
6489#endif