blob: aaacb8d79764733899dcf3364b95cfaf9730a173 [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
Michael Wu58d837d2018-08-03 05:55:40 +000035#define CINDEX_VERSION_MINOR 50
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
Fangrui Song6907ce22018-07-30 19:24:48 +0000163 * will be negative if no minor version number was provided, e.g., for
Douglas Gregord6225d32012-05-08 00:14:45 +0000164 * 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 {
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000181 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000182 * The cursor has no exception specification.
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000183 */
184 CXCursor_ExceptionSpecificationKind_None,
185
186 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000187 * The cursor has exception specification throw()
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000188 */
189 CXCursor_ExceptionSpecificationKind_DynamicNone,
190
191 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000192 * The cursor has exception specification throw(T1, T2)
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000193 */
194 CXCursor_ExceptionSpecificationKind_Dynamic,
195
196 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000197 * The cursor has exception specification throw(...).
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000198 */
199 CXCursor_ExceptionSpecificationKind_MSAny,
200
201 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000202 * The cursor has exception specification basic noexcept.
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000203 */
204 CXCursor_ExceptionSpecificationKind_BasicNoexcept,
205
206 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000207 * The cursor has exception specification computed noexcept.
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000208 */
209 CXCursor_ExceptionSpecificationKind_ComputedNoexcept,
210
211 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000212 * The exception specification has not yet been evaluated.
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000213 */
214 CXCursor_ExceptionSpecificationKind_Unevaluated,
215
216 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000217 * The exception specification has not yet been instantiated.
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000218 */
219 CXCursor_ExceptionSpecificationKind_Uninstantiated,
220
221 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000222 * The exception specification has not been parsed yet.
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000223 */
224 CXCursor_ExceptionSpecificationKind_Unparsed
225};
226
Douglas Gregor802f12f2010-01-20 22:28:27 +0000227/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000228 * Provides a shared context for creating translation units.
James Dennett574cb4c2012-06-15 05:41:51 +0000229 *
230 * It provides two options:
Steve Naroff531e2842009-10-20 14:46:24 +0000231 *
232 * - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local"
233 * declarations (when loading any new translation units). A "local" declaration
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000234 * is one that belongs in the translation unit itself and not in a precompiled
Steve Naroff531e2842009-10-20 14:46:24 +0000235 * header that was used by the translation unit. If zero, all declarations
236 * will be enumerated.
237 *
Steve Naroffbb4568a2009-10-20 16:36:34 +0000238 * Here is an example:
239 *
James Dennett574cb4c2012-06-15 05:41:51 +0000240 * \code
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000241 * // excludeDeclsFromPCH = 1, displayDiagnostics=1
242 * Idx = clang_createIndex(1, 1);
Steve Naroffbb4568a2009-10-20 16:36:34 +0000243 *
244 * // IndexTest.pch was produced with the following command:
245 * // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch"
246 * TU = clang_createTranslationUnit(Idx, "IndexTest.pch");
247 *
248 * // This will load all the symbols from 'IndexTest.pch'
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000249 * clang_visitChildren(clang_getTranslationUnitCursor(TU),
Douglas Gregor990b5762010-01-20 21:37:00 +0000250 * TranslationUnitVisitor, 0);
Steve Naroffbb4568a2009-10-20 16:36:34 +0000251 * clang_disposeTranslationUnit(TU);
252 *
253 * // This will load all the symbols from 'IndexTest.c', excluding symbols
254 * // from 'IndexTest.pch'.
Daniel Dunbard0159262010-01-25 00:43:14 +0000255 * char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" };
256 * TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args,
257 * 0, 0);
Douglas Gregorfed36b12010-01-20 23:57:43 +0000258 * clang_visitChildren(clang_getTranslationUnitCursor(TU),
259 * TranslationUnitVisitor, 0);
Steve Naroffbb4568a2009-10-20 16:36:34 +0000260 * clang_disposeTranslationUnit(TU);
James Dennett574cb4c2012-06-15 05:41:51 +0000261 * \endcode
Steve Naroffbb4568a2009-10-20 16:36:34 +0000262 *
263 * This process of creating the 'pch', loading it separately, and using it (via
264 * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks
265 * (which gives the indexer the same performance benefit as the compiler).
Steve Naroff531e2842009-10-20 14:46:24 +0000266 */
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000267CINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH,
268 int displayDiagnostics);
Ted Kremenekd071c602010-03-13 02:50:34 +0000269
Douglas Gregor408bb742010-02-08 23:03:06 +0000270/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000271 * Destroy the given index.
Douglas Gregor408bb742010-02-08 23:03:06 +0000272 *
273 * The index must not be destroyed until all of the translation units created
274 * within that index have been destroyed.
275 */
Daniel Dunbar11089662009-12-03 01:54:28 +0000276CINDEX_LINKAGE void clang_disposeIndex(CXIndex index);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000277
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000278typedef enum {
279 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000280 * Used to indicate that no special CXIndex options are needed.
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000281 */
282 CXGlobalOpt_None = 0x0,
283
284 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000285 * Used to indicate that threads that libclang creates for indexing
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000286 * purposes should use background priority.
James Dennett574cb4c2012-06-15 05:41:51 +0000287 *
288 * Affects #clang_indexSourceFile, #clang_indexTranslationUnit,
289 * #clang_parseTranslationUnit, #clang_saveTranslationUnit.
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000290 */
291 CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1,
292
293 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000294 * Used to indicate that threads that libclang creates for editing
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000295 * purposes should use background priority.
James Dennett574cb4c2012-06-15 05:41:51 +0000296 *
297 * Affects #clang_reparseTranslationUnit, #clang_codeCompleteAt,
298 * #clang_annotateTokens
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000299 */
300 CXGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2,
301
302 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000303 * Used to indicate that all threads that libclang creates should use
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000304 * background priority.
305 */
306 CXGlobalOpt_ThreadBackgroundPriorityForAll =
307 CXGlobalOpt_ThreadBackgroundPriorityForIndexing |
308 CXGlobalOpt_ThreadBackgroundPriorityForEditing
309
310} CXGlobalOptFlags;
311
312/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000313 * Sets general options associated with a CXIndex.
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000314 *
315 * For example:
316 * \code
317 * CXIndex idx = ...;
318 * clang_CXIndex_setGlobalOptions(idx,
319 * clang_CXIndex_getGlobalOptions(idx) |
320 * CXGlobalOpt_ThreadBackgroundPriorityForIndexing);
321 * \endcode
322 *
323 * \param options A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags.
324 */
325CINDEX_LINKAGE void clang_CXIndex_setGlobalOptions(CXIndex, unsigned options);
326
327/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000328 * Gets the general options associated with a CXIndex.
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000329 *
330 * \returns A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags that
331 * are associated with the given CXIndex object.
332 */
333CINDEX_LINKAGE unsigned clang_CXIndex_getGlobalOptions(CXIndex);
334
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000335/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000336 * Sets the invocation emission path option in a CXIndex.
Alex Lorenz08615792017-12-04 21:56:36 +0000337 *
338 * The invocation emission path specifies a path which will contain log
339 * files for certain libclang invocations. A null value (default) implies that
340 * libclang invocations are not logged..
341 */
342CINDEX_LINKAGE void
343clang_CXIndex_setInvocationEmissionPathOption(CXIndex, const char *Path);
344
345/**
Douglas Gregor6007cf22010-01-22 22:29:16 +0000346 * \defgroup CINDEX_FILES File manipulation routines
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000347 *
348 * @{
349 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000350
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000351/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000352 * A particular source file that is part of a translation unit.
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000353 */
354typedef void *CXFile;
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000355
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000356/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000357 * Retrieve the complete file and path name of the given file.
Steve Naroff6231f182009-10-27 14:35:18 +0000358 */
Ted Kremenekc560b682010-02-17 00:41:20 +0000359CINDEX_LINKAGE CXString clang_getFileName(CXFile SFile);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000360
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000361/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000362 * Retrieve the last modification time of the given file.
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000363 */
Douglas Gregor249c1212009-10-31 15:48:08 +0000364CINDEX_LINKAGE time_t clang_getFileTime(CXFile SFile);
Steve Naroff6231f182009-10-27 14:35:18 +0000365
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000366/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000367 * Uniquely identifies a CXFile, that refers to the same underlying file,
Argyrios Kyrtzidisac08b262013-01-26 04:52:52 +0000368 * across an indexing session.
369 */
370typedef struct {
371 unsigned long long data[3];
372} CXFileUniqueID;
373
374/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000375 * Retrieve the unique ID for the given \c file.
Argyrios Kyrtzidisac08b262013-01-26 04:52:52 +0000376 *
377 * \param file the file to get the ID for.
378 * \param outID stores the returned CXFileUniqueID.
379 * \returns If there was a failure getting the unique ID, returns non-zero,
380 * otherwise returns 0.
381*/
382CINDEX_LINKAGE int clang_getFileUniqueID(CXFile file, CXFileUniqueID *outID);
383
384/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000385 * Determine whether the given header is guarded against
Douglas Gregor37aa4932011-05-04 00:14:37 +0000386 * multiple inclusions, either with the conventional
James Dennett574cb4c2012-06-15 05:41:51 +0000387 * \#ifndef/\#define/\#endif macro guards or with \#pragma once.
Douglas Gregor37aa4932011-05-04 00:14:37 +0000388 */
Fangrui Song6907ce22018-07-30 19:24:48 +0000389CINDEX_LINKAGE unsigned
Douglas Gregor37aa4932011-05-04 00:14:37 +0000390clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu, CXFile file);
391
392/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000393 * Retrieve a file handle within the given translation unit.
Douglas Gregor816fd362010-01-22 21:44:22 +0000394 *
395 * \param tu the translation unit
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000396 *
Samuel Antao4c8035b2016-12-12 18:00:20 +0000397 * \param file_name the name of the file.
Douglas Gregor816fd362010-01-22 21:44:22 +0000398 *
399 * \returns the file handle for the named file in the translation unit \p tu,
400 * or a NULL file handle if the file was not a part of this translation unit.
401 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000402CINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu,
Douglas Gregor816fd362010-01-22 21:44:22 +0000403 const char *file_name);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000404
Douglas Gregor816fd362010-01-22 21:44:22 +0000405/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000406 * Retrieve the buffer associated with the given file.
Erik Verbruggen3afa3ce2017-12-06 09:02:52 +0000407 *
408 * \param tu the translation unit
409 *
410 * \param file the file for which to retrieve the buffer.
411 *
412 * \param size [out] if non-NULL, will be set to the size of the buffer.
413 *
414 * \returns a pointer to the buffer in memory that holds the contents of
415 * \p file, or a NULL pointer when the file is not loaded.
416 */
417CINDEX_LINKAGE const char *clang_getFileContents(CXTranslationUnit tu,
418 CXFile file, size_t *size);
419
420/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000421 * Returns non-zero if the \c file1 and \c file2 point to the same file,
Argyrios Kyrtzidisac3997e2014-08-16 00:26:19 +0000422 * or they are both NULL.
423 */
424CINDEX_LINKAGE int clang_File_isEqual(CXFile file1, CXFile file2);
425
426/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000427 * Returns the real path name of \c file.
Fangrui Songe46ac5f2018-04-07 20:50:35 +0000428 *
429 * An empty string may be returned. Use \c clang_getFileName() in that case.
430 */
431CINDEX_LINKAGE CXString clang_File_tryGetRealPathName(CXFile file);
432
433/**
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000434 * @}
435 */
436
437/**
438 * \defgroup CINDEX_LOCATIONS Physical source locations
439 *
440 * Clang represents physical source locations in its abstract syntax tree in
441 * great detail, with file, line, and column information for the majority of
442 * the tokens parsed in the source code. These data types and functions are
443 * used to represent source location information, either for a particular
444 * point in the program or for a range of points in the program, and extract
445 * specific location information from those data types.
446 *
447 * @{
448 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000449
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000450/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000451 * Identifies a specific source location within a translation
Douglas Gregor4f46e782010-01-19 21:36:55 +0000452 * unit.
453 *
Chandler Carruth4aa01ef2011-08-31 16:53:37 +0000454 * Use clang_getExpansionLocation() or clang_getSpellingLocation()
Douglas Gregor229bebd2010-11-09 06:24:54 +0000455 * to map a source location to a particular file, line, and column.
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000456 */
457typedef struct {
Argyrios Kyrtzidis49d9d0292013-01-11 22:29:47 +0000458 const void *ptr_data[2];
Douglas Gregor4f46e782010-01-19 21:36:55 +0000459 unsigned int_data;
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000460} CXSourceLocation;
Ted Kremeneka44d99c2010-01-05 23:18:49 +0000461
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000462/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000463 * Identifies a half-open character range in the source code.
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000464 *
Douglas Gregor4f46e782010-01-19 21:36:55 +0000465 * Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the
466 * starting and end locations from a source range, respectively.
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000467 */
468typedef struct {
Argyrios Kyrtzidis49d9d0292013-01-11 22:29:47 +0000469 const void *ptr_data[2];
Douglas Gregor4f46e782010-01-19 21:36:55 +0000470 unsigned begin_int_data;
471 unsigned end_int_data;
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000472} CXSourceRange;
Ted Kremeneka44d99c2010-01-05 23:18:49 +0000473
Douglas Gregor4f46e782010-01-19 21:36:55 +0000474/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000475 * Retrieve a NULL (invalid) source location.
Douglas Gregor816fd362010-01-22 21:44:22 +0000476 */
NAKAMURA Takumieacd6672013-01-10 02:12:38 +0000477CINDEX_LINKAGE CXSourceLocation clang_getNullLocation(void);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000478
Douglas Gregor816fd362010-01-22 21:44:22 +0000479/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000480 * Determine whether two source locations, which must refer into
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000481 * the same translation unit, refer to exactly the same point in the source
Douglas Gregor816fd362010-01-22 21:44:22 +0000482 * code.
483 *
484 * \returns non-zero if the source locations refer to the same location, zero
485 * if they refer to different locations.
486 */
487CINDEX_LINKAGE unsigned clang_equalLocations(CXSourceLocation loc1,
488 CXSourceLocation loc2);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000489
Douglas Gregor816fd362010-01-22 21:44:22 +0000490/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000491 * Retrieves the source location associated with a given file/line/column
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000492 * in a particular translation unit.
Douglas Gregor816fd362010-01-22 21:44:22 +0000493 */
494CINDEX_LINKAGE CXSourceLocation clang_getLocation(CXTranslationUnit tu,
495 CXFile file,
496 unsigned line,
497 unsigned column);
David Chisnall2e16ac52010-10-15 17:07:39 +0000498/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000499 * Retrieves the source location associated with a given character offset
David Chisnall2e16ac52010-10-15 17:07:39 +0000500 * in a particular translation unit.
501 */
502CINDEX_LINKAGE CXSourceLocation clang_getLocationForOffset(CXTranslationUnit tu,
503 CXFile file,
504 unsigned offset);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000505
Douglas Gregor816fd362010-01-22 21:44:22 +0000506/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000507 * Returns non-zero if the given source location is in a system header.
Argyrios Kyrtzidis25f7af12013-04-12 17:06:51 +0000508 */
509CINDEX_LINKAGE int clang_Location_isInSystemHeader(CXSourceLocation location);
510
511/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000512 * Returns non-zero if the given source location is in the main file of
Stefanus Du Toitdb51c632013-08-08 17:48:14 +0000513 * the corresponding translation unit.
514 */
515CINDEX_LINKAGE int clang_Location_isFromMainFile(CXSourceLocation location);
516
517/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000518 * Retrieve a NULL (invalid) source range.
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000519 */
NAKAMURA Takumieacd6672013-01-10 02:12:38 +0000520CINDEX_LINKAGE CXSourceRange clang_getNullRange(void);
Ted Kremenekd071c602010-03-13 02:50:34 +0000521
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000522/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000523 * Retrieve a source range given the beginning and ending source
Douglas Gregor816fd362010-01-22 21:44:22 +0000524 * locations.
525 */
526CINDEX_LINKAGE CXSourceRange clang_getRange(CXSourceLocation begin,
527 CXSourceLocation end);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000528
Douglas Gregor816fd362010-01-22 21:44:22 +0000529/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000530 * Determine whether two ranges are equivalent.
Douglas Gregor757e38b2011-07-23 19:35:14 +0000531 *
532 * \returns non-zero if the ranges are the same, zero if they differ.
533 */
534CINDEX_LINKAGE unsigned clang_equalRanges(CXSourceRange range1,
535 CXSourceRange range2);
536
537/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000538 * Returns non-zero if \p range is null.
Argyrios Kyrtzidise7e42912011-09-28 18:14:21 +0000539 */
Erik Verbruggend610b0f2011-10-06 12:11:57 +0000540CINDEX_LINKAGE int clang_Range_isNull(CXSourceRange range);
Argyrios Kyrtzidise7e42912011-09-28 18:14:21 +0000541
542/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000543 * Retrieve the file, line, column, and offset represented by
Douglas Gregor9bd6db52010-01-26 19:19:08 +0000544 * the given source location.
Douglas Gregor4f46e782010-01-19 21:36:55 +0000545 *
Chandler Carruth4aa01ef2011-08-31 16:53:37 +0000546 * If the location refers into a macro expansion, retrieves the
547 * location of the macro expansion.
Douglas Gregor229bebd2010-11-09 06:24:54 +0000548 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000549 * \param location the location within a source file that will be decomposed
550 * into its parts.
Douglas Gregor4f46e782010-01-19 21:36:55 +0000551 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000552 * \param file [out] if non-NULL, will be set to the file to which the given
Douglas Gregor4f46e782010-01-19 21:36:55 +0000553 * source location points.
554 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000555 * \param line [out] if non-NULL, will be set to the line to which the given
Douglas Gregor4f46e782010-01-19 21:36:55 +0000556 * source location points.
557 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000558 * \param column [out] if non-NULL, will be set to the column to which the given
559 * source location points.
Douglas Gregor9bd6db52010-01-26 19:19:08 +0000560 *
561 * \param offset [out] if non-NULL, will be set to the offset into the
562 * buffer to which the given source location points.
Douglas Gregor4f46e782010-01-19 21:36:55 +0000563 */
Chandler Carruth4aa01ef2011-08-31 16:53:37 +0000564CINDEX_LINKAGE void clang_getExpansionLocation(CXSourceLocation location,
565 CXFile *file,
566 unsigned *line,
567 unsigned *column,
568 unsigned *offset);
569
570/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000571 * Retrieve the file, line and column represented by the given source
Vassil Vassilev4b8e29d2017-04-06 10:05:46 +0000572 * location, as specified in a # line directive.
Argyrios Kyrtzidis91672b32011-09-13 21:49:08 +0000573 *
574 * Example: given the following source code in a file somefile.c
575 *
James Dennett574cb4c2012-06-15 05:41:51 +0000576 * \code
Argyrios Kyrtzidis91672b32011-09-13 21:49:08 +0000577 * #123 "dummy.c" 1
578 *
579 * static int func(void)
580 * {
581 * return 0;
582 * }
James Dennett574cb4c2012-06-15 05:41:51 +0000583 * \endcode
Argyrios Kyrtzidis91672b32011-09-13 21:49:08 +0000584 *
585 * the location information returned by this function would be
586 *
587 * File: dummy.c Line: 124 Column: 12
588 *
589 * whereas clang_getExpansionLocation would have returned
590 *
591 * File: somefile.c Line: 3 Column: 12
592 *
593 * \param location the location within a source file that will be decomposed
594 * into its parts.
595 *
596 * \param filename [out] if non-NULL, will be set to the filename of the
597 * source location. Note that filenames returned will be for "virtual" files,
598 * which don't necessarily exist on the machine running clang - e.g. when
599 * parsing preprocessed output obtained from a different environment. If
600 * a non-NULL value is passed in, remember to dispose of the returned value
601 * using \c clang_disposeString() once you've finished with it. For an invalid
602 * source location, an empty string is returned.
603 *
604 * \param line [out] if non-NULL, will be set to the line number of the
605 * source location. For an invalid source location, zero is returned.
606 *
607 * \param column [out] if non-NULL, will be set to the column number of the
608 * source location. For an invalid source location, zero is returned.
609 */
610CINDEX_LINKAGE void clang_getPresumedLocation(CXSourceLocation location,
611 CXString *filename,
612 unsigned *line,
613 unsigned *column);
614
615/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000616 * Legacy API to retrieve the file, line, column, and offset represented
Chandler Carruth4aa01ef2011-08-31 16:53:37 +0000617 * by the given source location.
618 *
619 * This interface has been replaced by the newer interface
James Dennett574cb4c2012-06-15 05:41:51 +0000620 * #clang_getExpansionLocation(). See that interface's documentation for
Chandler Carruth4aa01ef2011-08-31 16:53:37 +0000621 * details.
622 */
Douglas Gregor4f46e782010-01-19 21:36:55 +0000623CINDEX_LINKAGE void clang_getInstantiationLocation(CXSourceLocation location,
624 CXFile *file,
625 unsigned *line,
Douglas Gregor9bd6db52010-01-26 19:19:08 +0000626 unsigned *column,
627 unsigned *offset);
Douglas Gregor47751d62010-01-26 03:07:15 +0000628
629/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000630 * Retrieve the file, line, column, and offset represented by
Douglas Gregor229bebd2010-11-09 06:24:54 +0000631 * the given source location.
632 *
633 * If the location refers into a macro instantiation, return where the
634 * location was originally spelled in the source file.
635 *
636 * \param location the location within a source file that will be decomposed
637 * into its parts.
638 *
639 * \param file [out] if non-NULL, will be set to the file to which the given
640 * source location points.
641 *
642 * \param line [out] if non-NULL, will be set to the line to which the given
643 * source location points.
644 *
645 * \param column [out] if non-NULL, will be set to the column to which the given
646 * source location points.
647 *
648 * \param offset [out] if non-NULL, will be set to the offset into the
649 * buffer to which the given source location points.
650 */
651CINDEX_LINKAGE void clang_getSpellingLocation(CXSourceLocation location,
652 CXFile *file,
653 unsigned *line,
654 unsigned *column,
655 unsigned *offset);
656
657/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000658 * Retrieve the file, line, column, and offset represented by
Argyrios Kyrtzidis56be7162013-01-04 18:30:13 +0000659 * the given source location.
660 *
661 * If the location refers into a macro expansion, return where the macro was
662 * expanded or where the macro argument was written, if the location points at
663 * a macro argument.
664 *
665 * \param location the location within a source file that will be decomposed
666 * into its parts.
667 *
668 * \param file [out] if non-NULL, will be set to the file to which the given
669 * source location points.
670 *
671 * \param line [out] if non-NULL, will be set to the line to which the given
672 * source location points.
673 *
674 * \param column [out] if non-NULL, will be set to the column to which the given
675 * source location points.
676 *
677 * \param offset [out] if non-NULL, will be set to the offset into the
678 * buffer to which the given source location points.
679 */
680CINDEX_LINKAGE void clang_getFileLocation(CXSourceLocation location,
681 CXFile *file,
682 unsigned *line,
683 unsigned *column,
684 unsigned *offset);
685
686/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000687 * Retrieve a source location representing the first character within a
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000688 * source range.
Douglas Gregor4f46e782010-01-19 21:36:55 +0000689 */
690CINDEX_LINKAGE CXSourceLocation clang_getRangeStart(CXSourceRange range);
691
692/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000693 * Retrieve a source location representing the last character within a
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000694 * source range.
Douglas Gregor4f46e782010-01-19 21:36:55 +0000695 */
696CINDEX_LINKAGE CXSourceLocation clang_getRangeEnd(CXSourceRange range);
697
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000698/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000699 * Identifies an array of ranges.
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000700 */
701typedef struct {
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000702 /** The number of ranges in the \c ranges array. */
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000703 unsigned count;
704 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000705 * An array of \c CXSourceRanges.
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000706 */
707 CXSourceRange *ranges;
Argyrios Kyrtzidis0e282ef2013-12-06 18:55:45 +0000708} CXSourceRangeList;
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000709
710/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000711 * Retrieve all ranges that were skipped by the preprocessor.
Argyrios Kyrtzidis0e282ef2013-12-06 18:55:45 +0000712 *
713 * The preprocessor will skip lines when they are surrounded by an
714 * if/ifdef/ifndef directive whose condition does not evaluate to true.
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000715 */
Argyrios Kyrtzidis0e282ef2013-12-06 18:55:45 +0000716CINDEX_LINKAGE CXSourceRangeList *clang_getSkippedRanges(CXTranslationUnit tu,
717 CXFile file);
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000718
719/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000720 * Retrieve all ranges from all files that were skipped by the
Cameron Desrochersd8091282016-08-18 15:43:55 +0000721 * preprocessor.
722 *
723 * The preprocessor will skip lines when they are surrounded by an
724 * if/ifdef/ifndef directive whose condition does not evaluate to true.
725 */
726CINDEX_LINKAGE CXSourceRangeList *clang_getAllSkippedRanges(CXTranslationUnit tu);
727
728/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000729 * Destroy the given \c CXSourceRangeList.
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000730 */
Argyrios Kyrtzidis0e282ef2013-12-06 18:55:45 +0000731CINDEX_LINKAGE void clang_disposeSourceRangeList(CXSourceRangeList *ranges);
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000732
733/**
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000734 * @}
735 */
Douglas Gregor6007cf22010-01-22 22:29:16 +0000736
737/**
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000738 * \defgroup CINDEX_DIAG Diagnostic reporting
739 *
740 * @{
741 */
742
743/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000744 * Describes the severity of a particular diagnostic.
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000745 */
746enum CXDiagnosticSeverity {
747 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000748 * A diagnostic that has been suppressed, e.g., by a command-line
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000749 * option.
750 */
751 CXDiagnostic_Ignored = 0,
Ted Kremenekd071c602010-03-13 02:50:34 +0000752
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000753 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000754 * This diagnostic is a note that should be attached to the
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000755 * previous (non-note) diagnostic.
756 */
757 CXDiagnostic_Note = 1,
758
759 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000760 * This diagnostic indicates suspicious code that may not be
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000761 * wrong.
762 */
763 CXDiagnostic_Warning = 2,
764
765 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000766 * This diagnostic indicates that the code is ill-formed.
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000767 */
768 CXDiagnostic_Error = 3,
769
770 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000771 * This diagnostic indicates that the code is ill-formed such
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000772 * that future parser recovery is unlikely to produce useful
773 * results.
774 */
775 CXDiagnostic_Fatal = 4
776};
777
778/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000779 * A single diagnostic, containing the diagnostic's severity,
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000780 * location, text, source ranges, and fix-it hints.
781 */
782typedef void *CXDiagnostic;
783
784/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000785 * A group of CXDiagnostics.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000786 */
787typedef void *CXDiagnosticSet;
Fangrui Song6907ce22018-07-30 19:24:48 +0000788
Ted Kremenekd010ba42011-11-10 08:43:12 +0000789/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000790 * Determine the number of diagnostics in a CXDiagnosticSet.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000791 */
792CINDEX_LINKAGE unsigned clang_getNumDiagnosticsInSet(CXDiagnosticSet Diags);
793
794/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000795 * Retrieve a diagnostic associated with the given CXDiagnosticSet.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000796 *
James Dennett574cb4c2012-06-15 05:41:51 +0000797 * \param Diags the CXDiagnosticSet to query.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000798 * \param Index the zero-based diagnostic number to retrieve.
799 *
800 * \returns the requested diagnostic. This diagnostic must be freed
801 * via a call to \c clang_disposeDiagnostic().
802 */
803CINDEX_LINKAGE CXDiagnostic clang_getDiagnosticInSet(CXDiagnosticSet Diags,
Fangrui Song6907ce22018-07-30 19:24:48 +0000804 unsigned Index);
Ted Kremenekd010ba42011-11-10 08:43:12 +0000805
Ted Kremenekd010ba42011-11-10 08:43:12 +0000806/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000807 * Describes the kind of error that occurred (if any) in a call to
Ted Kremenekd010ba42011-11-10 08:43:12 +0000808 * \c clang_loadDiagnostics.
809 */
810enum CXLoadDiag_Error {
811 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000812 * Indicates that no error occurred.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000813 */
814 CXLoadDiag_None = 0,
Fangrui Song6907ce22018-07-30 19:24:48 +0000815
Ted Kremenekd010ba42011-11-10 08:43:12 +0000816 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000817 * Indicates that an unknown error occurred while attempting to
Ted Kremenekd010ba42011-11-10 08:43:12 +0000818 * deserialize diagnostics.
819 */
820 CXLoadDiag_Unknown = 1,
Fangrui Song6907ce22018-07-30 19:24:48 +0000821
Ted Kremenekd010ba42011-11-10 08:43:12 +0000822 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000823 * Indicates that the file containing the serialized diagnostics
Ted Kremenekd010ba42011-11-10 08:43:12 +0000824 * could not be opened.
825 */
826 CXLoadDiag_CannotLoad = 2,
Fangrui Song6907ce22018-07-30 19:24:48 +0000827
Ted Kremenekd010ba42011-11-10 08:43:12 +0000828 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000829 * Indicates that the serialized diagnostics file is invalid or
James Dennett574cb4c2012-06-15 05:41:51 +0000830 * corrupt.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000831 */
832 CXLoadDiag_InvalidFile = 3
833};
Fangrui Song6907ce22018-07-30 19:24:48 +0000834
Ted Kremenekd010ba42011-11-10 08:43:12 +0000835/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000836 * Deserialize a set of diagnostics from a Clang diagnostics bitcode
James Dennett574cb4c2012-06-15 05:41:51 +0000837 * file.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000838 *
James Dennett574cb4c2012-06-15 05:41:51 +0000839 * \param file The name of the file to deserialize.
840 * \param error A pointer to a enum value recording if there was a problem
Ted Kremenekd010ba42011-11-10 08:43:12 +0000841 * deserializing the diagnostics.
James Dennett574cb4c2012-06-15 05:41:51 +0000842 * \param errorString A pointer to a CXString for recording the error string
Ted Kremenekd010ba42011-11-10 08:43:12 +0000843 * if the file was not successfully loaded.
844 *
845 * \returns A loaded CXDiagnosticSet if successful, and NULL otherwise. These
James Dennett574cb4c2012-06-15 05:41:51 +0000846 * diagnostics should be released using clang_disposeDiagnosticSet().
Ted Kremenekd010ba42011-11-10 08:43:12 +0000847 */
848CINDEX_LINKAGE CXDiagnosticSet clang_loadDiagnostics(const char *file,
849 enum CXLoadDiag_Error *error,
850 CXString *errorString);
851
852/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000853 * Release a CXDiagnosticSet and all of its contained diagnostics.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000854 */
855CINDEX_LINKAGE void clang_disposeDiagnosticSet(CXDiagnosticSet Diags);
856
857/**
Fangrui Song6907ce22018-07-30 19:24:48 +0000858 * Retrieve the child diagnostics of a CXDiagnostic.
James Dennett574cb4c2012-06-15 05:41:51 +0000859 *
860 * This CXDiagnosticSet does not need to be released by
Sylvestre Ledrud29d97c2013-11-17 09:46:45 +0000861 * clang_disposeDiagnosticSet.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000862 */
863CINDEX_LINKAGE CXDiagnosticSet clang_getChildDiagnostics(CXDiagnostic D);
864
865/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000866 * Determine the number of diagnostics produced for the given
Douglas Gregor33cdd812010-02-18 18:08:43 +0000867 * translation unit.
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000868 */
Douglas Gregor33cdd812010-02-18 18:08:43 +0000869CINDEX_LINKAGE unsigned clang_getNumDiagnostics(CXTranslationUnit Unit);
870
871/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000872 * Retrieve a diagnostic associated with the given translation unit.
Douglas Gregor33cdd812010-02-18 18:08:43 +0000873 *
874 * \param Unit the translation unit to query.
875 * \param Index the zero-based diagnostic number to retrieve.
876 *
877 * \returns the requested diagnostic. This diagnostic must be freed
878 * via a call to \c clang_disposeDiagnostic().
879 */
880CINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit,
881 unsigned Index);
882
883/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000884 * Retrieve the complete set of diagnostics associated with a
Ted Kremenekb4a8b052011-12-09 22:28:32 +0000885 * translation unit.
886 *
887 * \param Unit the translation unit to query.
888 */
889CINDEX_LINKAGE CXDiagnosticSet
Fangrui Song6907ce22018-07-30 19:24:48 +0000890 clang_getDiagnosticSetFromTU(CXTranslationUnit Unit);
Ted Kremenekb4a8b052011-12-09 22:28:32 +0000891
892/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000893 * Destroy a diagnostic.
Douglas Gregor33cdd812010-02-18 18:08:43 +0000894 */
895CINDEX_LINKAGE void clang_disposeDiagnostic(CXDiagnostic Diagnostic);
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000896
897/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000898 * Options to control the display of diagnostics.
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000899 *
900 * The values in this enum are meant to be combined to customize the
Sylvestre Ledrud29d97c2013-11-17 09:46:45 +0000901 * behavior of \c clang_formatDiagnostic().
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000902 */
903enum CXDiagnosticDisplayOptions {
904 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000905 * Display the source-location information where the
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000906 * diagnostic was located.
907 *
908 * When set, diagnostics will be prefixed by the file, line, and
909 * (optionally) column to which the diagnostic refers. For example,
910 *
911 * \code
912 * test.c:28: warning: extra tokens at end of #endif directive
913 * \endcode
914 *
915 * This option corresponds to the clang flag \c -fshow-source-location.
916 */
917 CXDiagnostic_DisplaySourceLocation = 0x01,
918
919 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000920 * If displaying the source-location information of the
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000921 * diagnostic, also include the column number.
922 *
923 * This option corresponds to the clang flag \c -fshow-column.
924 */
925 CXDiagnostic_DisplayColumn = 0x02,
926
927 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000928 * If displaying the source-location information of the
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000929 * diagnostic, also include information about source ranges in a
930 * machine-parsable format.
931 *
Ted Kremenekd071c602010-03-13 02:50:34 +0000932 * This option corresponds to the clang flag
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000933 * \c -fdiagnostics-print-source-range-info.
934 */
Douglas Gregora750e8e2010-11-19 16:18:16 +0000935 CXDiagnostic_DisplaySourceRanges = 0x04,
Fangrui Song6907ce22018-07-30 19:24:48 +0000936
Douglas Gregora750e8e2010-11-19 16:18:16 +0000937 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000938 * Display the option name associated with this diagnostic, if any.
Douglas Gregora750e8e2010-11-19 16:18:16 +0000939 *
940 * The option name displayed (e.g., -Wconversion) will be placed in brackets
941 * after the diagnostic text. This option corresponds to the clang flag
942 * \c -fdiagnostics-show-option.
943 */
944 CXDiagnostic_DisplayOption = 0x08,
Fangrui Song6907ce22018-07-30 19:24:48 +0000945
Douglas Gregora750e8e2010-11-19 16:18:16 +0000946 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000947 * Display the category number associated with this diagnostic, if any.
Douglas Gregora750e8e2010-11-19 16:18:16 +0000948 *
949 * The category number is displayed within brackets after the diagnostic text.
Fangrui Song6907ce22018-07-30 19:24:48 +0000950 * This option corresponds to the clang flag
Douglas Gregora750e8e2010-11-19 16:18:16 +0000951 * \c -fdiagnostics-show-category=id.
952 */
953 CXDiagnostic_DisplayCategoryId = 0x10,
954
955 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000956 * Display the category name associated with this diagnostic, if any.
Douglas Gregora750e8e2010-11-19 16:18:16 +0000957 *
958 * The category name is displayed within brackets after the diagnostic text.
Fangrui Song6907ce22018-07-30 19:24:48 +0000959 * This option corresponds to the clang flag
Douglas Gregora750e8e2010-11-19 16:18:16 +0000960 * \c -fdiagnostics-show-category=name.
961 */
962 CXDiagnostic_DisplayCategoryName = 0x20
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000963};
964
965/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000966 * Format the given diagnostic in a manner that is suitable for display.
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000967 *
Douglas Gregord770f732010-02-22 23:17:23 +0000968 * This routine will format the given diagnostic to a string, rendering
Ted Kremenekd071c602010-03-13 02:50:34 +0000969 * the diagnostic according to the various options given. The
970 * \c clang_defaultDiagnosticDisplayOptions() function returns the set of
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000971 * options that most closely mimics the behavior of the clang compiler.
972 *
973 * \param Diagnostic The diagnostic to print.
974 *
Ted Kremenekd071c602010-03-13 02:50:34 +0000975 * \param Options A set of options that control the diagnostic display,
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000976 * created by combining \c CXDiagnosticDisplayOptions values.
Douglas Gregord770f732010-02-22 23:17:23 +0000977 *
978 * \returns A new string containing for formatted diagnostic.
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000979 */
Douglas Gregord770f732010-02-22 23:17:23 +0000980CINDEX_LINKAGE CXString clang_formatDiagnostic(CXDiagnostic Diagnostic,
981 unsigned Options);
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000982
983/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000984 * Retrieve the set of display options most similar to the
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000985 * default behavior of the clang compiler.
986 *
987 * \returns A set of display options suitable for use with \c
Sylvestre Ledrud29d97c2013-11-17 09:46:45 +0000988 * clang_formatDiagnostic().
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000989 */
990CINDEX_LINKAGE unsigned clang_defaultDiagnosticDisplayOptions(void);
991
992/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000993 * Determine the severity of the given diagnostic.
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000994 */
Ted Kremenekd071c602010-03-13 02:50:34 +0000995CINDEX_LINKAGE enum CXDiagnosticSeverity
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000996clang_getDiagnosticSeverity(CXDiagnostic);
997
998/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000999 * Retrieve the source location of the given diagnostic.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001000 *
1001 * This location is where Clang would print the caret ('^') when
1002 * displaying the diagnostic on the command line.
1003 */
1004CINDEX_LINKAGE CXSourceLocation clang_getDiagnosticLocation(CXDiagnostic);
1005
1006/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001007 * Retrieve the text of the given diagnostic.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001008 */
1009CINDEX_LINKAGE CXString clang_getDiagnosticSpelling(CXDiagnostic);
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +00001010
1011/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001012 * Retrieve the name of the command-line option that enabled this
Douglas Gregora750e8e2010-11-19 16:18:16 +00001013 * diagnostic.
1014 *
1015 * \param Diag The diagnostic to be queried.
1016 *
1017 * \param Disable If non-NULL, will be set to the option that disables this
1018 * diagnostic (if any).
1019 *
1020 * \returns A string that contains the command-line option used to enable this
Fangrui Song6907ce22018-07-30 19:24:48 +00001021 * warning, such as "-Wconversion" or "-pedantic".
Douglas Gregora750e8e2010-11-19 16:18:16 +00001022 */
1023CINDEX_LINKAGE CXString clang_getDiagnosticOption(CXDiagnostic Diag,
1024 CXString *Disable);
1025
1026/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001027 * Retrieve the category number for this diagnostic.
Douglas Gregora750e8e2010-11-19 16:18:16 +00001028 *
1029 * Diagnostics can be categorized into groups along with other, related
Fangrui Song6907ce22018-07-30 19:24:48 +00001030 * diagnostics (e.g., diagnostics under the same warning flag). This routine
Douglas Gregora750e8e2010-11-19 16:18:16 +00001031 * retrieves the category number for the given diagnostic.
1032 *
1033 * \returns The number of the category that contains this diagnostic, or zero
1034 * if this diagnostic is uncategorized.
1035 */
1036CINDEX_LINKAGE unsigned clang_getDiagnosticCategory(CXDiagnostic);
1037
1038/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001039 * Retrieve the name of a particular diagnostic category. This
Ted Kremenek26a6d492012-04-12 00:03:31 +00001040 * is now deprecated. Use clang_getDiagnosticCategoryText()
1041 * instead.
Douglas Gregora750e8e2010-11-19 16:18:16 +00001042 *
Fangrui Song6907ce22018-07-30 19:24:48 +00001043 * \param Category A diagnostic category number, as returned by
Douglas Gregora750e8e2010-11-19 16:18:16 +00001044 * \c clang_getDiagnosticCategory().
1045 *
1046 * \returns The name of the given diagnostic category.
1047 */
Ted Kremenek26a6d492012-04-12 00:03:31 +00001048CINDEX_DEPRECATED CINDEX_LINKAGE
1049CXString clang_getDiagnosticCategoryName(unsigned Category);
1050
1051/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001052 * Retrieve the diagnostic category text for a given diagnostic.
Ted Kremenek26a6d492012-04-12 00:03:31 +00001053 *
Ted Kremenek26a6d492012-04-12 00:03:31 +00001054 * \returns The text of the given diagnostic category.
1055 */
1056CINDEX_LINKAGE CXString clang_getDiagnosticCategoryText(CXDiagnostic);
Fangrui Song6907ce22018-07-30 19:24:48 +00001057
Douglas Gregora750e8e2010-11-19 16:18:16 +00001058/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001059 * Determine the number of source ranges associated with the given
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +00001060 * diagnostic.
1061 */
1062CINDEX_LINKAGE unsigned clang_getDiagnosticNumRanges(CXDiagnostic);
Ted Kremenekd071c602010-03-13 02:50:34 +00001063
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001064/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001065 * Retrieve a source range associated with the diagnostic.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001066 *
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +00001067 * A diagnostic's source ranges highlight important elements in the source
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001068 * code. On the command line, Clang displays source ranges by
Ted Kremenekd071c602010-03-13 02:50:34 +00001069 * underlining them with '~' characters.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001070 *
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +00001071 * \param Diagnostic the diagnostic whose range is being extracted.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001072 *
Ted Kremenekd071c602010-03-13 02:50:34 +00001073 * \param Range the zero-based index specifying which range to
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001074 *
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +00001075 * \returns the requested source range.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001076 */
Ted Kremenekd071c602010-03-13 02:50:34 +00001077CINDEX_LINKAGE CXSourceRange clang_getDiagnosticRange(CXDiagnostic Diagnostic,
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +00001078 unsigned Range);
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001079
1080/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001081 * Determine the number of fix-it hints associated with the
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001082 * given diagnostic.
1083 */
1084CINDEX_LINKAGE unsigned clang_getDiagnosticNumFixIts(CXDiagnostic Diagnostic);
1085
1086/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001087 * Retrieve the replacement information for a given fix-it.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001088 *
Douglas Gregor836ec942010-02-19 18:16:06 +00001089 * Fix-its are described in terms of a source range whose contents
1090 * should be replaced by a string. This approach generalizes over
1091 * three kinds of operations: removal of source code (the range covers
1092 * the code to be removed and the replacement string is empty),
1093 * replacement of source code (the range covers the code to be
1094 * replaced and the replacement string provides the new code), and
1095 * insertion (both the start and end of the range point at the
1096 * insertion location, and the replacement string provides the text to
1097 * insert).
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001098 *
Douglas Gregor836ec942010-02-19 18:16:06 +00001099 * \param Diagnostic The diagnostic whose fix-its are being queried.
1100 *
1101 * \param FixIt The zero-based index of the fix-it.
1102 *
1103 * \param ReplacementRange The source range whose contents will be
1104 * replaced with the returned replacement string. Note that source
1105 * ranges are half-open ranges [a, b), so the source code should be
1106 * replaced from a and up to (but not including) b.
1107 *
1108 * \returns A string containing text that should be replace the source
1109 * code indicated by the \c ReplacementRange.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001110 */
Ted Kremenekd071c602010-03-13 02:50:34 +00001111CINDEX_LINKAGE CXString clang_getDiagnosticFixIt(CXDiagnostic Diagnostic,
Douglas Gregor836ec942010-02-19 18:16:06 +00001112 unsigned FixIt,
1113 CXSourceRange *ReplacementRange);
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001114
1115/**
1116 * @}
1117 */
1118
1119/**
1120 * \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation
1121 *
1122 * The routines in this group provide the ability to create and destroy
1123 * translation units from files, either by parsing the contents of the files or
1124 * by reading in a serialized representation of a translation unit.
1125 *
1126 * @{
1127 */
Ted Kremenekd071c602010-03-13 02:50:34 +00001128
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001129/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001130 * Get the original translation unit source file name.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001131 */
1132CINDEX_LINKAGE CXString
1133clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit);
1134
1135/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001136 * Return the CXTranslationUnit for a given source file and the provided
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001137 * command line arguments one would pass to the compiler.
1138 *
1139 * Note: The 'source_filename' argument is optional. If the caller provides a
1140 * NULL pointer, the name of the source file is expected to reside in the
1141 * specified command line arguments.
1142 *
1143 * Note: When encountered in 'clang_command_line_args', the following options
1144 * are ignored:
1145 *
1146 * '-c'
1147 * '-emit-ast'
1148 * '-fsyntax-only'
James Dennett574cb4c2012-06-15 05:41:51 +00001149 * '-o \<output file>' (both '-o' and '\<output file>' are ignored)
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001150 *
Ted Kremenekbd4972442010-11-08 04:28:51 +00001151 * \param CIdx The index object with which the translation unit will be
1152 * associated.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001153 *
James Dennett574cb4c2012-06-15 05:41:51 +00001154 * \param source_filename The name of the source file to load, or NULL if the
Ted Kremenekbd4972442010-11-08 04:28:51 +00001155 * source file is included in \p clang_command_line_args.
1156 *
1157 * \param num_clang_command_line_args The number of command-line arguments in
1158 * \p clang_command_line_args.
1159 *
1160 * \param clang_command_line_args The command-line arguments that would be
1161 * passed to the \c clang executable if it were being invoked out-of-process.
1162 * These command-line options will be parsed and will affect how the translation
1163 * unit is parsed. Note that the following options are ignored: '-c',
James Dennett574cb4c2012-06-15 05:41:51 +00001164 * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001165 *
1166 * \param num_unsaved_files the number of unsaved file entries in \p
1167 * unsaved_files.
1168 *
1169 * \param unsaved_files the files that have not yet been saved to disk
1170 * but may be required for code completion, including the contents of
Ted Kremenekde24a942010-04-12 18:47:26 +00001171 * those files. The contents and name of these files (as specified by
1172 * CXUnsavedFile) are copied when necessary, so the client only needs to
1173 * guarantee their validity until the call to this function returns.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001174 */
1175CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnitFromSourceFile(
1176 CXIndex CIdx,
1177 const char *source_filename,
1178 int num_clang_command_line_args,
Douglas Gregor57879fa2010-09-01 16:43:19 +00001179 const char * const *clang_command_line_args,
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001180 unsigned num_unsaved_files,
Douglas Gregor33cdd812010-02-18 18:08:43 +00001181 struct CXUnsavedFile *unsaved_files);
Ted Kremenekd071c602010-03-13 02:50:34 +00001182
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001183/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001184 * Same as \c clang_createTranslationUnit2, but returns
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001185 * the \c CXTranslationUnit instead of an error code. In case of an error this
1186 * routine returns a \c NULL \c CXTranslationUnit, without further detailed
1187 * error codes.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001188 */
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001189CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnit(
1190 CXIndex CIdx,
1191 const char *ast_filename);
1192
1193/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001194 * Create a translation unit from an AST file (\c -emit-ast).
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001195 *
1196 * \param[out] out_TU A non-NULL pointer to store the created
1197 * \c CXTranslationUnit.
1198 *
1199 * \returns Zero on success, otherwise returns an error code.
1200 */
1201CINDEX_LINKAGE enum CXErrorCode clang_createTranslationUnit2(
1202 CXIndex CIdx,
1203 const char *ast_filename,
1204 CXTranslationUnit *out_TU);
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001205
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001206/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001207 * Flags that control the creation of translation units.
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001208 *
1209 * The enumerators in this enumeration type are meant to be bitwise
1210 * ORed together to specify which options should be used when
1211 * constructing the translation unit.
1212 */
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001213enum CXTranslationUnit_Flags {
1214 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001215 * Used to indicate that no special translation-unit options are
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001216 * needed.
1217 */
1218 CXTranslationUnit_None = 0x0,
1219
1220 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001221 * Used to indicate that the parser should construct a "detailed"
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001222 * preprocessing record, including all macro definitions and instantiations.
1223 *
1224 * Constructing a detailed preprocessing record requires more memory
1225 * and time to parse, since the information contained in the record
1226 * is usually not retained. However, it can be useful for
1227 * applications that require more detailed information about the
1228 * behavior of the preprocessor.
1229 */
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001230 CXTranslationUnit_DetailedPreprocessingRecord = 0x01,
1231
1232 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001233 * Used to indicate that the translation unit is incomplete.
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001234 *
Douglas Gregor4a47bca2010-08-09 22:28:58 +00001235 * When a translation unit is considered "incomplete", semantic
1236 * analysis that is typically performed at the end of the
1237 * translation unit will be suppressed. For example, this suppresses
1238 * the completion of tentative declarations in C and of
1239 * instantiation of implicitly-instantiation function templates in
1240 * C++. This option is typically used when parsing a header with the
1241 * intent of producing a precompiled header.
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001242 */
Douglas Gregor4a47bca2010-08-09 22:28:58 +00001243 CXTranslationUnit_Incomplete = 0x02,
Fangrui Song6907ce22018-07-30 19:24:48 +00001244
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001245 /**
Fangrui Song6907ce22018-07-30 19:24:48 +00001246 * Used to indicate that the translation unit should be built with an
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001247 * implicit precompiled header for the preamble.
1248 *
1249 * An implicit precompiled header is used as an optimization when a
1250 * particular translation unit is likely to be reparsed many times
1251 * when the sources aren't changing that often. In this case, an
1252 * implicit precompiled header will be built containing all of the
1253 * initial includes at the top of the main file (what we refer to as
1254 * the "preamble" of the file). In subsequent parses, if the
1255 * preamble or the files in it have not changed, \c
1256 * clang_reparseTranslationUnit() will re-use the implicit
1257 * precompiled header to improve parsing performance.
1258 */
Douglas Gregorde051182010-08-11 15:58:42 +00001259 CXTranslationUnit_PrecompiledPreamble = 0x04,
Fangrui Song6907ce22018-07-30 19:24:48 +00001260
Douglas Gregorde051182010-08-11 15:58:42 +00001261 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001262 * Used to indicate that the translation unit should cache some
Douglas Gregorde051182010-08-11 15:58:42 +00001263 * code-completion results with each reparse of the source file.
1264 *
1265 * Caching of code-completion results is a performance optimization that
1266 * introduces some overhead to reparsing but improves the performance of
1267 * code-completion operations.
1268 */
Douglas Gregorf5a18542010-10-27 17:24:53 +00001269 CXTranslationUnit_CacheCompletionResults = 0x08,
Argyrios Kyrtzidis0db720f2012-10-11 16:05:00 +00001270
Douglas Gregorf5a18542010-10-27 17:24:53 +00001271 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001272 * Used to indicate that the translation unit will be serialized with
Argyrios Kyrtzidis0db720f2012-10-11 16:05:00 +00001273 * \c clang_saveTranslationUnit.
Douglas Gregorf5a18542010-10-27 17:24:53 +00001274 *
Argyrios Kyrtzidis0db720f2012-10-11 16:05:00 +00001275 * This option is typically used when parsing a header with the intent of
1276 * producing a precompiled header.
Douglas Gregorf5a18542010-10-27 17:24:53 +00001277 */
Argyrios Kyrtzidis0db720f2012-10-11 16:05:00 +00001278 CXTranslationUnit_ForSerialization = 0x10,
Douglas Gregorf5a18542010-10-27 17:24:53 +00001279
1280 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001281 * DEPRECATED: Enabled chained precompiled preambles in C++.
Douglas Gregorf5a18542010-10-27 17:24:53 +00001282 *
1283 * Note: this is a *temporary* option that is available only while
Douglas Gregor2ed0ee12011-08-25 22:54:01 +00001284 * we are testing C++ precompiled preamble support. It is deprecated.
Douglas Gregorf5a18542010-10-27 17:24:53 +00001285 */
Erik Verbruggen6e922512012-04-12 10:11:59 +00001286 CXTranslationUnit_CXXChainedPCH = 0x20,
1287
1288 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001289 * Used to indicate that function/method bodies should be skipped while
Erik Verbruggen6e922512012-04-12 10:11:59 +00001290 * parsing.
1291 *
1292 * This option can be used to search for declarations/definitions while
1293 * ignoring the usages.
1294 */
Dmitri Gribenko3292d062012-07-02 17:35:10 +00001295 CXTranslationUnit_SkipFunctionBodies = 0x40,
1296
1297 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001298 * Used to indicate that brief documentation comments should be
Dmitri Gribenko3292d062012-07-02 17:35:10 +00001299 * included into the set of code completions returned from this translation
1300 * unit.
1301 */
Benjamin Kramer5c248d82015-12-15 09:30:31 +00001302 CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 0x80,
1303
1304 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001305 * Used to indicate that the precompiled preamble should be created on
Benjamin Kramer5c248d82015-12-15 09:30:31 +00001306 * the first parse. Otherwise it will be created on the first reparse. This
1307 * trades runtime on the first parse (serializing the preamble takes time) for
1308 * reduced runtime on the second parse (can now reuse the preamble).
1309 */
Manuel Klimek016c0242016-03-01 10:56:19 +00001310 CXTranslationUnit_CreatePreambleOnFirstParse = 0x100,
1311
1312 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001313 * Do not stop processing when fatal errors are encountered.
Manuel Klimek016c0242016-03-01 10:56:19 +00001314 *
1315 * When fatal errors are encountered while parsing a translation unit,
1316 * semantic analysis is typically stopped early when compiling code. A common
1317 * source for fatal errors are unresolvable include files. For the
1318 * purposes of an IDE, this is undesirable behavior and as much information
1319 * as possible should be reported. Use this flag to enable this behavior.
1320 */
Argyrios Kyrtzidis735e92c2017-06-09 01:20:48 +00001321 CXTranslationUnit_KeepGoing = 0x200,
1322
Ivan Donchevskiif70d28b2018-05-17 09:15:22 +00001323 /**
1324 * Sets the preprocessor in a mode for parsing a single file only.
1325 */
Ivan Donchevskii6e895282018-05-17 09:24:37 +00001326 CXTranslationUnit_SingleFileParse = 0x400,
1327
1328 /**
Ivan Donchevskii3957e482018-06-13 12:37:08 +00001329 * Used in combination with CXTranslationUnit_SkipFunctionBodies to
Ivan Donchevskii6e895282018-05-17 09:24:37 +00001330 * constrain the skipping of function bodies to the preamble.
1331 *
1332 * The function bodies of the main file are not skipped.
1333 */
Michael Wu153085d2018-08-03 04:21:25 +00001334 CXTranslationUnit_LimitSkipFunctionBodiesToPreamble = 0x800,
1335
1336 /**
1337 * Used to indicate that attributed types should be included in CXType.
1338 */
Michael Wu40ff1052018-08-03 05:20:23 +00001339 CXTranslationUnit_IncludeAttributedTypes = 0x1000,
1340
1341 /**
1342 * Used to indicate that implicit attributes should be visited.
1343 */
1344 CXTranslationUnit_VisitImplicitAttributes = 0x2000
Ivan Donchevskiif70d28b2018-05-17 09:15:22 +00001345};
1346
1347/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001348 * Returns the set of flags that is suitable for parsing a translation
Douglas Gregor4a47bca2010-08-09 22:28:58 +00001349 * unit that is being edited.
1350 *
1351 * The set of flags returned provide options for \c clang_parseTranslationUnit()
1352 * to indicate that the translation unit is likely to be reparsed many times,
1353 * either explicitly (via \c clang_reparseTranslationUnit()) or implicitly
1354 * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag
Fangrui Song6907ce22018-07-30 19:24:48 +00001355 * set contains an unspecified set of optimizations (e.g., the precompiled
Douglas Gregor4a47bca2010-08-09 22:28:58 +00001356 * preamble) geared toward improving the performance of these routines. The
1357 * set of optimizations enabled may change from one version to the next.
1358 */
Douglas Gregorde051182010-08-11 15:58:42 +00001359CINDEX_LINKAGE unsigned clang_defaultEditingTranslationUnitOptions(void);
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001360
1361/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001362 * Same as \c clang_parseTranslationUnit2, but returns
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001363 * the \c CXTranslationUnit instead of an error code. In case of an error this
1364 * routine returns a \c NULL \c CXTranslationUnit, without further detailed
1365 * error codes.
1366 */
1367CINDEX_LINKAGE CXTranslationUnit
1368clang_parseTranslationUnit(CXIndex CIdx,
1369 const char *source_filename,
1370 const char *const *command_line_args,
1371 int num_command_line_args,
1372 struct CXUnsavedFile *unsaved_files,
1373 unsigned num_unsaved_files,
1374 unsigned options);
1375
Douglas Gregor4a47bca2010-08-09 22:28:58 +00001376/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001377 * Parse the given source file and the translation unit corresponding
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001378 * to that file.
1379 *
1380 * This routine is the main entry point for the Clang C API, providing the
1381 * ability to parse a source file into a translation unit that can then be
1382 * queried by other functions in the API. This routine accepts a set of
1383 * command-line arguments so that the compilation can be configured in the same
1384 * way that the compiler is configured on the command line.
1385 *
Fangrui Song6907ce22018-07-30 19:24:48 +00001386 * \param CIdx The index object with which the translation unit will be
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001387 * associated.
1388 *
1389 * \param source_filename The name of the source file to load, or NULL if the
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001390 * source file is included in \c command_line_args.
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001391 *
1392 * \param command_line_args The command-line arguments that would be
1393 * passed to the \c clang executable if it were being invoked out-of-process.
1394 * These command-line options will be parsed and will affect how the translation
Fangrui Song6907ce22018-07-30 19:24:48 +00001395 * unit is parsed. Note that the following options are ignored: '-c',
James Dennett574cb4c2012-06-15 05:41:51 +00001396 * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001397 *
1398 * \param num_command_line_args The number of command-line arguments in
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001399 * \c command_line_args.
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001400 *
1401 * \param unsaved_files the files that have not yet been saved to disk
Douglas Gregor8e984da2010-08-04 16:47:14 +00001402 * but may be required for parsing, including the contents of
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001403 * those files. The contents and name of these files (as specified by
1404 * CXUnsavedFile) are copied when necessary, so the client only needs to
1405 * guarantee their validity until the call to this function returns.
1406 *
1407 * \param num_unsaved_files the number of unsaved file entries in \p
1408 * unsaved_files.
1409 *
1410 * \param options A bitmask of options that affects how the translation unit
1411 * is managed but not its compilation. This should be a bitwise OR of the
1412 * CXTranslationUnit_XXX flags.
1413 *
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001414 * \param[out] out_TU A non-NULL pointer to store the created
1415 * \c CXTranslationUnit, describing the parsed code and containing any
1416 * diagnostics produced by the compiler.
1417 *
1418 * \returns Zero on success, otherwise returns an error code.
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001419 */
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001420CINDEX_LINKAGE enum CXErrorCode
1421clang_parseTranslationUnit2(CXIndex CIdx,
1422 const char *source_filename,
1423 const char *const *command_line_args,
1424 int num_command_line_args,
1425 struct CXUnsavedFile *unsaved_files,
1426 unsigned num_unsaved_files,
1427 unsigned options,
1428 CXTranslationUnit *out_TU);
1429
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001430/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001431 * Same as clang_parseTranslationUnit2 but requires a full command line
Benjamin Kramerc02670e2015-11-18 16:14:27 +00001432 * for \c command_line_args including argv[0]. This is useful if the standard
1433 * library paths are relative to the binary.
1434 */
1435CINDEX_LINKAGE enum CXErrorCode clang_parseTranslationUnit2FullArgv(
1436 CXIndex CIdx, const char *source_filename,
1437 const char *const *command_line_args, int num_command_line_args,
1438 struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files,
1439 unsigned options, CXTranslationUnit *out_TU);
1440
1441/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001442 * Flags that control how translation units are saved.
Douglas Gregor6bb92ec2010-08-13 15:35:05 +00001443 *
1444 * The enumerators in this enumeration type are meant to be bitwise
1445 * ORed together to specify which options should be used when
1446 * saving the translation unit.
1447 */
1448enum CXSaveTranslationUnit_Flags {
1449 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001450 * Used to indicate that no special saving options are needed.
Douglas Gregor6bb92ec2010-08-13 15:35:05 +00001451 */
1452 CXSaveTranslationUnit_None = 0x0
1453};
1454
1455/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001456 * Returns the set of flags that is suitable for saving a translation
Douglas Gregor6bb92ec2010-08-13 15:35:05 +00001457 * unit.
1458 *
1459 * The set of flags returned provide options for
1460 * \c clang_saveTranslationUnit() by default. The returned flag
1461 * set contains an unspecified set of options that save translation units with
1462 * the most commonly-requested data.
1463 */
1464CINDEX_LINKAGE unsigned clang_defaultSaveOptions(CXTranslationUnit TU);
1465
1466/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001467 * Describes the kind of error that occurred (if any) in a call to
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001468 * \c clang_saveTranslationUnit().
1469 */
1470enum CXSaveError {
1471 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001472 * Indicates that no error occurred while saving a translation unit.
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001473 */
1474 CXSaveError_None = 0,
Fangrui Song6907ce22018-07-30 19:24:48 +00001475
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001476 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001477 * Indicates that an unknown error occurred while attempting to save
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001478 * the file.
1479 *
Fangrui Song6907ce22018-07-30 19:24:48 +00001480 * This error typically indicates that file I/O failed when attempting to
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001481 * write the file.
1482 */
1483 CXSaveError_Unknown = 1,
Fangrui Song6907ce22018-07-30 19:24:48 +00001484
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001485 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001486 * Indicates that errors during translation prevented this attempt
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001487 * to save the translation unit.
Fangrui Song6907ce22018-07-30 19:24:48 +00001488 *
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001489 * Errors that prevent the translation unit from being saved can be
1490 * extracted using \c clang_getNumDiagnostics() and \c clang_getDiagnostic().
1491 */
1492 CXSaveError_TranslationErrors = 2,
Fangrui Song6907ce22018-07-30 19:24:48 +00001493
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001494 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001495 * Indicates that the translation unit to be saved was somehow
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001496 * invalid (e.g., NULL).
1497 */
1498 CXSaveError_InvalidTU = 3
1499};
Fangrui Song6907ce22018-07-30 19:24:48 +00001500
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001501/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001502 * Saves a translation unit into a serialized representation of
Douglas Gregore9386682010-08-13 05:36:37 +00001503 * that translation unit on disk.
1504 *
1505 * Any translation unit that was parsed without error can be saved
1506 * into a file. The translation unit can then be deserialized into a
1507 * new \c CXTranslationUnit with \c clang_createTranslationUnit() or,
1508 * if it is an incomplete translation unit that corresponds to a
1509 * header, used as a precompiled header when parsing other translation
1510 * units.
1511 *
1512 * \param TU The translation unit to save.
Douglas Gregor6bb92ec2010-08-13 15:35:05 +00001513 *
Douglas Gregore9386682010-08-13 05:36:37 +00001514 * \param FileName The file to which the translation unit will be saved.
1515 *
Douglas Gregor6bb92ec2010-08-13 15:35:05 +00001516 * \param options A bitmask of options that affects how the translation unit
1517 * is saved. This should be a bitwise OR of the
1518 * CXSaveTranslationUnit_XXX flags.
1519 *
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001520 * \returns A value that will match one of the enumerators of the CXSaveError
Fangrui Song6907ce22018-07-30 19:24:48 +00001521 * enumeration. Zero (CXSaveError_None) indicates that the translation unit was
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001522 * saved successfully, while a non-zero value indicates that a problem occurred.
Douglas Gregore9386682010-08-13 05:36:37 +00001523 */
1524CINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU,
Douglas Gregor6bb92ec2010-08-13 15:35:05 +00001525 const char *FileName,
1526 unsigned options);
Douglas Gregore9386682010-08-13 05:36:37 +00001527
1528/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001529 * Suspend a translation unit in order to free memory associated with it.
Erik Verbruggen346066b2017-05-30 14:25:54 +00001530 *
1531 * A suspended translation unit uses significantly less memory but on the other
1532 * side does not support any other calls than \c clang_reparseTranslationUnit
1533 * to resume it or \c clang_disposeTranslationUnit to dispose it completely.
1534 */
1535CINDEX_LINKAGE unsigned clang_suspendTranslationUnit(CXTranslationUnit);
1536
1537/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001538 * Destroy the specified CXTranslationUnit object.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001539 */
1540CINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit);
Ted Kremenekd071c602010-03-13 02:50:34 +00001541
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001542/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001543 * Flags that control the reparsing of translation units.
Douglas Gregorde051182010-08-11 15:58:42 +00001544 *
1545 * The enumerators in this enumeration type are meant to be bitwise
1546 * ORed together to specify which options should be used when
1547 * reparsing the translation unit.
1548 */
1549enum CXReparse_Flags {
1550 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001551 * Used to indicate that no special reparsing options are needed.
Douglas Gregorde051182010-08-11 15:58:42 +00001552 */
1553 CXReparse_None = 0x0
1554};
Fangrui Song6907ce22018-07-30 19:24:48 +00001555
Douglas Gregorde051182010-08-11 15:58:42 +00001556/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001557 * Returns the set of flags that is suitable for reparsing a translation
Douglas Gregorde051182010-08-11 15:58:42 +00001558 * unit.
1559 *
1560 * The set of flags returned provide options for
1561 * \c clang_reparseTranslationUnit() by default. The returned flag
1562 * set contains an unspecified set of optimizations geared toward common uses
Fangrui Song6907ce22018-07-30 19:24:48 +00001563 * of reparsing. The set of optimizations enabled may change from one version
Douglas Gregorde051182010-08-11 15:58:42 +00001564 * to the next.
1565 */
1566CINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU);
1567
1568/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001569 * Reparse the source files that produced this translation unit.
Douglas Gregoraa21cc42010-07-19 21:46:24 +00001570 *
1571 * This routine can be used to re-parse the source files that originally
1572 * created the given translation unit, for example because those source files
1573 * have changed (either on disk or as passed via \p unsaved_files). The
1574 * source code will be reparsed with the same command-line options as it
Fangrui Song6907ce22018-07-30 19:24:48 +00001575 * was originally parsed.
Douglas Gregoraa21cc42010-07-19 21:46:24 +00001576 *
1577 * Reparsing a translation unit invalidates all cursors and source locations
1578 * that refer into that translation unit. This makes reparsing a translation
1579 * unit semantically equivalent to destroying the translation unit and then
1580 * creating a new translation unit with the same command-line arguments.
Fangrui Song6907ce22018-07-30 19:24:48 +00001581 * However, it may be more efficient to reparse a translation
Douglas Gregoraa21cc42010-07-19 21:46:24 +00001582 * unit using this routine.
1583 *
1584 * \param TU The translation unit whose contents will be re-parsed. The
Fangrui Song6907ce22018-07-30 19:24:48 +00001585 * translation unit must originally have been built with
Douglas Gregoraa21cc42010-07-19 21:46:24 +00001586 * \c clang_createTranslationUnitFromSourceFile().
1587 *
1588 * \param num_unsaved_files The number of unsaved file entries in \p
1589 * unsaved_files.
1590 *
1591 * \param unsaved_files The files that have not yet been saved to disk
1592 * but may be required for parsing, including the contents of
1593 * those files. The contents and name of these files (as specified by
1594 * CXUnsavedFile) are copied when necessary, so the client only needs to
1595 * guarantee their validity until the call to this function returns.
Fangrui Song6907ce22018-07-30 19:24:48 +00001596 *
Douglas Gregorde051182010-08-11 15:58:42 +00001597 * \param options A bitset of options composed of the flags in CXReparse_Flags.
1598 * The function \c clang_defaultReparseOptions() produces a default set of
1599 * options recommended for most uses, based on the translation unit.
1600 *
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001601 * \returns 0 if the sources could be reparsed. A non-zero error code will be
Douglas Gregoraa21cc42010-07-19 21:46:24 +00001602 * returned if reparsing was impossible, such that the translation unit is
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001603 * invalid. In such cases, the only valid call for \c TU is
1604 * \c clang_disposeTranslationUnit(TU). The error codes returned by this
1605 * routine are described by the \c CXErrorCode enum.
Douglas Gregoraa21cc42010-07-19 21:46:24 +00001606 */
1607CINDEX_LINKAGE int clang_reparseTranslationUnit(CXTranslationUnit TU,
1608 unsigned num_unsaved_files,
Douglas Gregorde051182010-08-11 15:58:42 +00001609 struct CXUnsavedFile *unsaved_files,
1610 unsigned options);
Ted Kremenek83f642e2011-04-18 22:47:10 +00001611
1612/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001613 * Categorizes how memory is being used by a translation unit.
Ted Kremenek83f642e2011-04-18 22:47:10 +00001614 */
Ted Kremenek23324122011-04-20 16:41:07 +00001615enum CXTUResourceUsageKind {
1616 CXTUResourceUsage_AST = 1,
1617 CXTUResourceUsage_Identifiers = 2,
1618 CXTUResourceUsage_Selectors = 3,
1619 CXTUResourceUsage_GlobalCompletionResults = 4,
Ted Kremenek21735e62011-04-28 04:10:31 +00001620 CXTUResourceUsage_SourceManagerContentCache = 5,
Ted Kremenekf5df0ce2011-04-28 04:53:38 +00001621 CXTUResourceUsage_AST_SideTables = 6,
Ted Kremenek8d587902011-04-28 20:36:42 +00001622 CXTUResourceUsage_SourceManager_Membuffer_Malloc = 7,
Ted Kremenek5e1ed7b2011-04-28 23:46:20 +00001623 CXTUResourceUsage_SourceManager_Membuffer_MMap = 8,
Fangrui Song6907ce22018-07-30 19:24:48 +00001624 CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc = 9,
1625 CXTUResourceUsage_ExternalASTSource_Membuffer_MMap = 10,
Ted Kremenek2160a0d2011-05-04 01:38:46 +00001626 CXTUResourceUsage_Preprocessor = 11,
1627 CXTUResourceUsage_PreprocessingRecord = 12,
Ted Kremenek120992a2011-07-26 23:46:06 +00001628 CXTUResourceUsage_SourceManager_DataStructures = 13,
Ted Kremenekfbcce6f2011-07-26 23:46:11 +00001629 CXTUResourceUsage_Preprocessor_HeaderSearch = 14,
Ted Kremenek23324122011-04-20 16:41:07 +00001630 CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST,
1631 CXTUResourceUsage_MEMORY_IN_BYTES_END =
Ted Kremenekfbcce6f2011-07-26 23:46:11 +00001632 CXTUResourceUsage_Preprocessor_HeaderSearch,
Ted Kremenek23324122011-04-20 16:41:07 +00001633
1634 CXTUResourceUsage_First = CXTUResourceUsage_AST,
Ted Kremenekfbcce6f2011-07-26 23:46:11 +00001635 CXTUResourceUsage_Last = CXTUResourceUsage_Preprocessor_HeaderSearch
Ted Kremenek83f642e2011-04-18 22:47:10 +00001636};
1637
1638/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001639 * Returns the human-readable null-terminated C string that represents
Ted Kremenek23324122011-04-20 16:41:07 +00001640 * the name of the memory category. This string should never be freed.
Ted Kremenek83f642e2011-04-18 22:47:10 +00001641 */
1642CINDEX_LINKAGE
Ted Kremenek23324122011-04-20 16:41:07 +00001643const char *clang_getTUResourceUsageName(enum CXTUResourceUsageKind kind);
Ted Kremenek83f642e2011-04-18 22:47:10 +00001644
Ted Kremenek23324122011-04-20 16:41:07 +00001645typedef struct CXTUResourceUsageEntry {
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001646 /* The memory usage category. */
Fangrui Song6907ce22018-07-30 19:24:48 +00001647 enum CXTUResourceUsageKind kind;
1648 /* Amount of resources used.
Ted Kremenek23324122011-04-20 16:41:07 +00001649 The units will depend on the resource kind. */
Ted Kremenek83f642e2011-04-18 22:47:10 +00001650 unsigned long amount;
Ted Kremenek23324122011-04-20 16:41:07 +00001651} CXTUResourceUsageEntry;
Ted Kremenek83f642e2011-04-18 22:47:10 +00001652
1653/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001654 * The memory usage of a CXTranslationUnit, broken into categories.
Ted Kremenek83f642e2011-04-18 22:47:10 +00001655 */
Ted Kremenek23324122011-04-20 16:41:07 +00001656typedef struct CXTUResourceUsage {
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001657 /* Private data member, used for queries. */
Ted Kremenek83f642e2011-04-18 22:47:10 +00001658 void *data;
1659
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001660 /* The number of entries in the 'entries' array. */
Ted Kremenek83f642e2011-04-18 22:47:10 +00001661 unsigned numEntries;
1662
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001663 /* An array of key-value pairs, representing the breakdown of memory
Ted Kremenek83f642e2011-04-18 22:47:10 +00001664 usage. */
Ted Kremenek23324122011-04-20 16:41:07 +00001665 CXTUResourceUsageEntry *entries;
Ted Kremenek83f642e2011-04-18 22:47:10 +00001666
Ted Kremenek23324122011-04-20 16:41:07 +00001667} CXTUResourceUsage;
Ted Kremenek83f642e2011-04-18 22:47:10 +00001668
1669/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001670 * Return the memory usage of a translation unit. This object
Ted Kremenek23324122011-04-20 16:41:07 +00001671 * should be released with clang_disposeCXTUResourceUsage().
Ted Kremenek83f642e2011-04-18 22:47:10 +00001672 */
Ted Kremenek23324122011-04-20 16:41:07 +00001673CINDEX_LINKAGE CXTUResourceUsage clang_getCXTUResourceUsage(CXTranslationUnit TU);
Ted Kremenek83f642e2011-04-18 22:47:10 +00001674
Ted Kremenek23324122011-04-20 16:41:07 +00001675CINDEX_LINKAGE void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage);
Ted Kremenek83f642e2011-04-18 22:47:10 +00001676
Douglas Gregoraa21cc42010-07-19 21:46:24 +00001677/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001678 * Get target information for this translation unit.
Emilio Cobos Alvarez485ad422017-04-28 15:56:39 +00001679 *
1680 * The CXTargetInfo object cannot outlive the CXTranslationUnit object.
1681 */
1682CINDEX_LINKAGE CXTargetInfo
1683clang_getTranslationUnitTargetInfo(CXTranslationUnit CTUnit);
1684
1685/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001686 * Destroy the CXTargetInfo object.
Emilio Cobos Alvarez485ad422017-04-28 15:56:39 +00001687 */
1688CINDEX_LINKAGE void
1689clang_TargetInfo_dispose(CXTargetInfo Info);
1690
1691/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001692 * Get the normalized target triple as a string.
Emilio Cobos Alvarez485ad422017-04-28 15:56:39 +00001693 *
1694 * Returns the empty string in case of any error.
1695 */
1696CINDEX_LINKAGE CXString
1697clang_TargetInfo_getTriple(CXTargetInfo Info);
1698
1699/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001700 * Get the pointer width of the target in bits.
Emilio Cobos Alvarez485ad422017-04-28 15:56:39 +00001701 *
1702 * Returns -1 in case of error.
1703 */
1704CINDEX_LINKAGE int
1705clang_TargetInfo_getPointerWidth(CXTargetInfo Info);
1706
1707/**
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001708 * @}
1709 */
Ted Kremenekd071c602010-03-13 02:50:34 +00001710
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001711/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001712 * Describes the kind of entity that a cursor refers to.
Douglas Gregor6007cf22010-01-22 22:29:16 +00001713 */
1714enum CXCursorKind {
1715 /* Declarations */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001716 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001717 * A declaration whose specific kind is not exposed via this
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001718 * interface.
Douglas Gregor6007cf22010-01-22 22:29:16 +00001719 *
1720 * Unexposed declarations have the same operations as any other kind
1721 * of declaration; one can extract their location information,
1722 * spelling, find their definitions, etc. However, the specific kind
1723 * of the declaration is not reported.
1724 */
1725 CXCursor_UnexposedDecl = 1,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001726 /** A C or C++ struct. */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001727 CXCursor_StructDecl = 2,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001728 /** A C or C++ union. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001729 CXCursor_UnionDecl = 3,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001730 /** A C++ class. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001731 CXCursor_ClassDecl = 4,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001732 /** An enumeration. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001733 CXCursor_EnumDecl = 5,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001734 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001735 * A field (in C) or non-static data member (in C++) in a
Douglas Gregor6007cf22010-01-22 22:29:16 +00001736 * struct, union, or C++ class.
1737 */
1738 CXCursor_FieldDecl = 6,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001739 /** An enumerator constant. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001740 CXCursor_EnumConstantDecl = 7,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001741 /** A function. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001742 CXCursor_FunctionDecl = 8,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001743 /** A variable. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001744 CXCursor_VarDecl = 9,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001745 /** A function or method parameter. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001746 CXCursor_ParmDecl = 10,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001747 /** An Objective-C \@interface. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001748 CXCursor_ObjCInterfaceDecl = 11,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001749 /** An Objective-C \@interface for a category. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001750 CXCursor_ObjCCategoryDecl = 12,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001751 /** An Objective-C \@protocol declaration. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001752 CXCursor_ObjCProtocolDecl = 13,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001753 /** An Objective-C \@property declaration. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001754 CXCursor_ObjCPropertyDecl = 14,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001755 /** An Objective-C instance variable. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001756 CXCursor_ObjCIvarDecl = 15,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001757 /** An Objective-C instance method. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001758 CXCursor_ObjCInstanceMethodDecl = 16,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001759 /** An Objective-C class method. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001760 CXCursor_ObjCClassMethodDecl = 17,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001761 /** An Objective-C \@implementation. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001762 CXCursor_ObjCImplementationDecl = 18,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001763 /** An Objective-C \@implementation for a category. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001764 CXCursor_ObjCCategoryImplDecl = 19,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001765 /** A typedef. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001766 CXCursor_TypedefDecl = 20,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001767 /** A C++ class method. */
Ted Kremenek225b8e32010-04-13 23:39:06 +00001768 CXCursor_CXXMethod = 21,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001769 /** A C++ namespace. */
Ted Kremenekbd67fb22010-05-06 23:38:21 +00001770 CXCursor_Namespace = 22,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001771 /** A linkage specification, e.g. 'extern "C"'. */
Ted Kremenekb80cba52010-05-07 01:04:29 +00001772 CXCursor_LinkageSpec = 23,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001773 /** A C++ constructor. */
Douglas Gregor12bca222010-08-31 14:41:23 +00001774 CXCursor_Constructor = 24,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001775 /** A C++ destructor. */
Douglas Gregor12bca222010-08-31 14:41:23 +00001776 CXCursor_Destructor = 25,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001777 /** A C++ conversion function. */
Douglas Gregor12bca222010-08-31 14:41:23 +00001778 CXCursor_ConversionFunction = 26,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001779 /** A C++ template type parameter. */
Douglas Gregor713602b2010-08-31 17:01:39 +00001780 CXCursor_TemplateTypeParameter = 27,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001781 /** A C++ non-type template parameter. */
Douglas Gregor713602b2010-08-31 17:01:39 +00001782 CXCursor_NonTypeTemplateParameter = 28,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001783 /** A C++ template template parameter. */
Douglas Gregor713602b2010-08-31 17:01:39 +00001784 CXCursor_TemplateTemplateParameter = 29,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001785 /** A C++ function template. */
Douglas Gregor713602b2010-08-31 17:01:39 +00001786 CXCursor_FunctionTemplate = 30,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001787 /** A C++ class template. */
Douglas Gregor1fbaeb12010-08-31 19:02:00 +00001788 CXCursor_ClassTemplate = 31,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001789 /** A C++ class template partial specialization. */
Douglas Gregorf96abb22010-08-31 19:31:58 +00001790 CXCursor_ClassTemplatePartialSpecialization = 32,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001791 /** A C++ namespace alias declaration. */
Douglas Gregora89314e2010-08-31 23:48:11 +00001792 CXCursor_NamespaceAlias = 33,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001793 /** A C++ using directive. */
Douglas Gregor01a430132010-09-01 03:07:18 +00001794 CXCursor_UsingDirective = 34,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001795 /** A C++ using declaration. */
Douglas Gregora9aa29c2010-09-01 19:52:22 +00001796 CXCursor_UsingDeclaration = 35,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001797 /** A C++ alias declaration */
Richard Smithdda56e42011-04-15 14:24:37 +00001798 CXCursor_TypeAliasDecl = 36,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001799 /** An Objective-C \@synthesize definition. */
Douglas Gregor4cd65962011-06-03 23:08:58 +00001800 CXCursor_ObjCSynthesizeDecl = 37,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001801 /** An Objective-C \@dynamic definition. */
Douglas Gregor4cd65962011-06-03 23:08:58 +00001802 CXCursor_ObjCDynamicDecl = 38,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001803 /** An access specifier. */
Argyrios Kyrtzidis12afd702011-09-30 17:58:23 +00001804 CXCursor_CXXAccessSpecifier = 39,
Douglas Gregor4c362d52011-10-05 19:00:14 +00001805
Ted Kremenek08de5c12010-05-19 21:51:10 +00001806 CXCursor_FirstDecl = CXCursor_UnexposedDecl,
Argyrios Kyrtzidis12afd702011-09-30 17:58:23 +00001807 CXCursor_LastDecl = CXCursor_CXXAccessSpecifier,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001808
Douglas Gregor6007cf22010-01-22 22:29:16 +00001809 /* References */
1810 CXCursor_FirstRef = 40, /* Decl references */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001811 CXCursor_ObjCSuperClassRef = 40,
Douglas Gregor6007cf22010-01-22 22:29:16 +00001812 CXCursor_ObjCProtocolRef = 41,
1813 CXCursor_ObjCClassRef = 42,
1814 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001815 * A reference to a type declaration.
Douglas Gregor6007cf22010-01-22 22:29:16 +00001816 *
1817 * A type reference occurs anywhere where a type is named but not
1818 * declared. For example, given:
1819 *
1820 * \code
1821 * typedef unsigned size_type;
1822 * size_type size;
1823 * \endcode
1824 *
1825 * The typedef is a declaration of size_type (CXCursor_TypedefDecl),
1826 * while the type of the variable "size" is referenced. The cursor
1827 * referenced by the type of size is the typedef for size_type.
1828 */
1829 CXCursor_TypeRef = 43,
Ted Kremenekae9e2212010-08-27 21:34:58 +00001830 CXCursor_CXXBaseSpecifier = 44,
Fangrui Song6907ce22018-07-30 19:24:48 +00001831 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001832 * A reference to a class template, function template, template
Douglas Gregorf3af3112010-09-09 21:42:20 +00001833 * template parameter, or class template partial specialization.
Douglas Gregora23e8f72010-08-31 20:37:03 +00001834 */
1835 CXCursor_TemplateRef = 45,
Douglas Gregora89314e2010-08-31 23:48:11 +00001836 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001837 * A reference to a namespace or namespace alias.
Douglas Gregora89314e2010-08-31 23:48:11 +00001838 */
1839 CXCursor_NamespaceRef = 46,
Douglas Gregorf3af3112010-09-09 21:42:20 +00001840 /**
Fangrui Song6907ce22018-07-30 19:24:48 +00001841 * A reference to a member of a struct, union, or class that occurs in
Douglas Gregora93ab662010-09-10 00:22:18 +00001842 * some non-expression context, e.g., a designated initializer.
Douglas Gregorf3af3112010-09-09 21:42:20 +00001843 */
1844 CXCursor_MemberRef = 47,
Douglas Gregora93ab662010-09-10 00:22:18 +00001845 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001846 * A reference to a labeled statement.
Douglas Gregora93ab662010-09-10 00:22:18 +00001847 *
Fangrui Song6907ce22018-07-30 19:24:48 +00001848 * This cursor kind is used to describe the jump to "start_over" in the
Douglas Gregora93ab662010-09-10 00:22:18 +00001849 * goto statement in the following example:
1850 *
1851 * \code
1852 * start_over:
1853 * ++counter;
1854 *
1855 * goto start_over;
1856 * \endcode
1857 *
1858 * A label reference cursor refers to a label statement.
1859 */
1860 CXCursor_LabelRef = 48,
Fangrui Song6907ce22018-07-30 19:24:48 +00001861
Douglas Gregor16a2bdd2010-09-13 22:52:57 +00001862 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001863 * A reference to a set of overloaded functions or function templates
Douglas Gregor16a2bdd2010-09-13 22:52:57 +00001864 * that has not yet been resolved to a specific function or function template.
1865 *
1866 * An overloaded declaration reference cursor occurs in C++ templates where
1867 * a dependent name refers to a function. For example:
1868 *
1869 * \code
1870 * template<typename T> void swap(T&, T&);
1871 *
1872 * struct X { ... };
1873 * void swap(X&, X&);
1874 *
1875 * template<typename T>
1876 * void reverse(T* first, T* last) {
1877 * while (first < last - 1) {
1878 * swap(*first, *--last);
1879 * ++first;
1880 * }
1881 * }
1882 *
1883 * struct Y { };
1884 * void swap(Y&, Y&);
1885 * \endcode
1886 *
1887 * Here, the identifier "swap" is associated with an overloaded declaration
1888 * reference. In the template definition, "swap" refers to either of the two
1889 * "swap" functions declared above, so both results will be available. At
1890 * instantiation time, "swap" may also refer to other functions found via
1891 * argument-dependent lookup (e.g., the "swap" function at the end of the
1892 * example).
1893 *
Fangrui Song6907ce22018-07-30 19:24:48 +00001894 * The functions \c clang_getNumOverloadedDecls() and
Douglas Gregor16a2bdd2010-09-13 22:52:57 +00001895 * \c clang_getOverloadedDecl() can be used to retrieve the definitions
1896 * referenced by this cursor.
1897 */
1898 CXCursor_OverloadedDeclRef = 49,
Fangrui Song6907ce22018-07-30 19:24:48 +00001899
Douglas Gregor30093832012-02-15 00:54:55 +00001900 /**
Fangrui Song6907ce22018-07-30 19:24:48 +00001901 * A reference to a variable that occurs in some non-expression
Douglas Gregor30093832012-02-15 00:54:55 +00001902 * context, e.g., a C++ lambda capture list.
1903 */
1904 CXCursor_VariableRef = 50,
Fangrui Song6907ce22018-07-30 19:24:48 +00001905
Douglas Gregor30093832012-02-15 00:54:55 +00001906 CXCursor_LastRef = CXCursor_VariableRef,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001907
Douglas Gregor6007cf22010-01-22 22:29:16 +00001908 /* Error conditions */
1909 CXCursor_FirstInvalid = 70,
1910 CXCursor_InvalidFile = 70,
1911 CXCursor_NoDeclFound = 71,
1912 CXCursor_NotImplemented = 72,
Ted Kremeneke184ac52010-03-19 20:39:03 +00001913 CXCursor_InvalidCode = 73,
1914 CXCursor_LastInvalid = CXCursor_InvalidCode,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001915
Douglas Gregor6007cf22010-01-22 22:29:16 +00001916 /* Expressions */
1917 CXCursor_FirstExpr = 100,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001918
Douglas Gregor6007cf22010-01-22 22:29:16 +00001919 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001920 * An expression whose specific kind is not exposed via this
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001921 * interface.
Douglas Gregor6007cf22010-01-22 22:29:16 +00001922 *
1923 * Unexposed expressions have the same operations as any other kind
1924 * of expression; one can extract their location information,
1925 * spelling, children, etc. However, the specific kind of the
1926 * expression is not reported.
1927 */
1928 CXCursor_UnexposedExpr = 100,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001929
Douglas Gregor6007cf22010-01-22 22:29:16 +00001930 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001931 * An expression that refers to some value declaration, such
Nico Weber7deebef2014-04-24 03:17:47 +00001932 * as a function, variable, or enumerator.
Douglas Gregor6007cf22010-01-22 22:29:16 +00001933 */
1934 CXCursor_DeclRefExpr = 101,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001935
Douglas Gregor6007cf22010-01-22 22:29:16 +00001936 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001937 * An expression that refers to a member of a struct, union,
Douglas Gregor6007cf22010-01-22 22:29:16 +00001938 * class, Objective-C class, etc.
1939 */
1940 CXCursor_MemberRefExpr = 102,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001941
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001942 /** An expression that calls a function. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001943 CXCursor_CallExpr = 103,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001944
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001945 /** An expression that sends a message to an Objective-C
Douglas Gregor6007cf22010-01-22 22:29:16 +00001946 object or class. */
1947 CXCursor_ObjCMessageExpr = 104,
Ted Kremenek33b9a422010-04-11 21:47:37 +00001948
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001949 /** An expression that represents a block literal. */
Ted Kremenek33b9a422010-04-11 21:47:37 +00001950 CXCursor_BlockExpr = 105,
1951
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001952 /** An integer literal.
Douglas Gregor4c362d52011-10-05 19:00:14 +00001953 */
1954 CXCursor_IntegerLiteral = 106,
1955
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001956 /** A floating point number literal.
Douglas Gregor4c362d52011-10-05 19:00:14 +00001957 */
1958 CXCursor_FloatingLiteral = 107,
1959
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001960 /** An imaginary number literal.
Douglas Gregor4c362d52011-10-05 19:00:14 +00001961 */
1962 CXCursor_ImaginaryLiteral = 108,
1963
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001964 /** A string literal.
Douglas Gregor4c362d52011-10-05 19:00:14 +00001965 */
1966 CXCursor_StringLiteral = 109,
1967
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001968 /** A character literal.
Douglas Gregor4c362d52011-10-05 19:00:14 +00001969 */
1970 CXCursor_CharacterLiteral = 110,
1971
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001972 /** A parenthesized expression, e.g. "(1)".
Douglas Gregor4c362d52011-10-05 19:00:14 +00001973 *
1974 * This AST node is only formed if full location information is requested.
1975 */
1976 CXCursor_ParenExpr = 111,
1977
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001978 /** This represents the unary-expression's (except sizeof and
Douglas Gregor4c362d52011-10-05 19:00:14 +00001979 * alignof).
1980 */
1981 CXCursor_UnaryOperator = 112,
1982
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001983 /** [C99 6.5.2.1] Array Subscripting.
Douglas Gregor4c362d52011-10-05 19:00:14 +00001984 */
1985 CXCursor_ArraySubscriptExpr = 113,
1986
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001987 /** A builtin binary operation expression such as "x + y" or
Douglas Gregor4c362d52011-10-05 19:00:14 +00001988 * "x <= y".
1989 */
1990 CXCursor_BinaryOperator = 114,
1991
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001992 /** Compound assignment such as "+=".
Douglas Gregor4c362d52011-10-05 19:00:14 +00001993 */
1994 CXCursor_CompoundAssignOperator = 115,
1995
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001996 /** The ?: ternary operator.
Douglas Gregor4c362d52011-10-05 19:00:14 +00001997 */
1998 CXCursor_ConditionalOperator = 116,
1999
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002000 /** An explicit cast in C (C99 6.5.4) or a C-style cast in C++
Douglas Gregor4c362d52011-10-05 19:00:14 +00002001 * (C++ [expr.cast]), which uses the syntax (Type)expr.
2002 *
2003 * For example: (int)f.
2004 */
2005 CXCursor_CStyleCastExpr = 117,
2006
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002007 /** [C99 6.5.2.5]
Douglas Gregor4c362d52011-10-05 19:00:14 +00002008 */
2009 CXCursor_CompoundLiteralExpr = 118,
2010
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002011 /** Describes an C or C++ initializer list.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002012 */
2013 CXCursor_InitListExpr = 119,
2014
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002015 /** The GNU address of label extension, representing &&label.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002016 */
2017 CXCursor_AddrLabelExpr = 120,
2018
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002019 /** This is the GNU Statement Expression extension: ({int X=4; X;})
Douglas Gregor4c362d52011-10-05 19:00:14 +00002020 */
2021 CXCursor_StmtExpr = 121,
2022
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002023 /** Represents a C11 generic selection.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002024 */
2025 CXCursor_GenericSelectionExpr = 122,
2026
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002027 /** Implements the GNU __null extension, which is a name for a null
Douglas Gregor4c362d52011-10-05 19:00:14 +00002028 * pointer constant that has integral type (e.g., int or long) and is the same
2029 * size and alignment as a pointer.
2030 *
2031 * The __null extension is typically only used by system headers, which define
2032 * NULL as __null in C++ rather than using 0 (which is an integer that may not
2033 * match the size of a pointer).
2034 */
2035 CXCursor_GNUNullExpr = 123,
2036
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002037 /** C++'s static_cast<> expression.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002038 */
2039 CXCursor_CXXStaticCastExpr = 124,
2040
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002041 /** C++'s dynamic_cast<> expression.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002042 */
2043 CXCursor_CXXDynamicCastExpr = 125,
2044
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002045 /** C++'s reinterpret_cast<> expression.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002046 */
2047 CXCursor_CXXReinterpretCastExpr = 126,
2048
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002049 /** C++'s const_cast<> expression.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002050 */
2051 CXCursor_CXXConstCastExpr = 127,
2052
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002053 /** Represents an explicit C++ type conversion that uses "functional"
Douglas Gregor4c362d52011-10-05 19:00:14 +00002054 * notion (C++ [expr.type.conv]).
2055 *
2056 * Example:
2057 * \code
2058 * x = int(0.5);
2059 * \endcode
2060 */
2061 CXCursor_CXXFunctionalCastExpr = 128,
2062
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002063 /** A C++ typeid expression (C++ [expr.typeid]).
Douglas Gregor4c362d52011-10-05 19:00:14 +00002064 */
2065 CXCursor_CXXTypeidExpr = 129,
2066
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002067 /** [C++ 2.13.5] C++ Boolean Literal.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002068 */
2069 CXCursor_CXXBoolLiteralExpr = 130,
2070
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002071 /** [C++0x 2.14.7] C++ Pointer Literal.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002072 */
2073 CXCursor_CXXNullPtrLiteralExpr = 131,
2074
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002075 /** Represents the "this" expression in C++
Douglas Gregor4c362d52011-10-05 19:00:14 +00002076 */
2077 CXCursor_CXXThisExpr = 132,
2078
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002079 /** [C++ 15] C++ Throw Expression.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002080 *
2081 * This handles 'throw' and 'throw' assignment-expression. When
2082 * assignment-expression isn't present, Op will be null.
2083 */
2084 CXCursor_CXXThrowExpr = 133,
2085
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002086 /** A new expression for memory allocation and constructor calls, e.g:
Douglas Gregor4c362d52011-10-05 19:00:14 +00002087 * "new CXXNewExpr(foo)".
2088 */
2089 CXCursor_CXXNewExpr = 134,
2090
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002091 /** A delete expression for memory deallocation and destructor calls,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002092 * e.g. "delete[] pArray".
2093 */
2094 CXCursor_CXXDeleteExpr = 135,
2095
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002096 /** A unary expression. (noexcept, sizeof, or other traits)
Douglas Gregor4c362d52011-10-05 19:00:14 +00002097 */
2098 CXCursor_UnaryExpr = 136,
2099
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002100 /** An Objective-C string literal i.e. @"foo".
Douglas Gregor4c362d52011-10-05 19:00:14 +00002101 */
2102 CXCursor_ObjCStringLiteral = 137,
2103
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002104 /** An Objective-C \@encode expression.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002105 */
2106 CXCursor_ObjCEncodeExpr = 138,
2107
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002108 /** An Objective-C \@selector expression.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002109 */
2110 CXCursor_ObjCSelectorExpr = 139,
2111
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002112 /** An Objective-C \@protocol expression.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002113 */
2114 CXCursor_ObjCProtocolExpr = 140,
2115
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002116 /** An Objective-C "bridged" cast expression, which casts between
Douglas Gregor4c362d52011-10-05 19:00:14 +00002117 * Objective-C pointers and C pointers, transferring ownership in the process.
2118 *
2119 * \code
2120 * NSString *str = (__bridge_transfer NSString *)CFCreateString();
2121 * \endcode
2122 */
2123 CXCursor_ObjCBridgedCastExpr = 141,
2124
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002125 /** Represents a C++0x pack expansion that produces a sequence of
Douglas Gregor4c362d52011-10-05 19:00:14 +00002126 * expressions.
2127 *
2128 * A pack expansion expression contains a pattern (which itself is an
2129 * expression) followed by an ellipsis. For example:
2130 *
2131 * \code
2132 * template<typename F, typename ...Types>
2133 * void forward(F f, Types &&...args) {
2134 * f(static_cast<Types&&>(args)...);
2135 * }
2136 * \endcode
2137 */
2138 CXCursor_PackExpansionExpr = 142,
2139
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002140 /** Represents an expression that computes the length of a parameter
Douglas Gregor4c362d52011-10-05 19:00:14 +00002141 * pack.
2142 *
2143 * \code
2144 * template<typename ...Types>
2145 * struct count {
2146 * static const unsigned value = sizeof...(Types);
2147 * };
2148 * \endcode
2149 */
2150 CXCursor_SizeOfPackExpr = 143,
2151
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002152 /* Represents a C++ lambda expression that produces a local function
Douglas Gregor30093832012-02-15 00:54:55 +00002153 * object.
2154 *
2155 * \code
2156 * void abssort(float *x, unsigned N) {
2157 * std::sort(x, x + N,
2158 * [](float a, float b) {
2159 * return std::abs(a) < std::abs(b);
2160 * });
2161 * }
2162 * \endcode
2163 */
2164 CXCursor_LambdaExpr = 144,
Fangrui Song6907ce22018-07-30 19:24:48 +00002165
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002166 /** Objective-c Boolean Literal.
Ted Kremenek77006f62012-03-06 20:06:06 +00002167 */
2168 CXCursor_ObjCBoolLiteralExpr = 145,
2169
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002170 /** Represents the "self" expression in an Objective-C method.
Argyrios Kyrtzidisc2233be2013-04-23 17:57:17 +00002171 */
2172 CXCursor_ObjCSelfExpr = 146,
2173
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002174 /** OpenMP 4.0 [2.4, Array Section].
Alexey Bataev1a3320e2015-08-25 14:24:04 +00002175 */
2176 CXCursor_OMPArraySectionExpr = 147,
2177
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002178 /** Represents an @available(...) check.
Erik Pilkington29099de2016-07-16 00:35:23 +00002179 */
2180 CXCursor_ObjCAvailabilityCheckExpr = 148,
2181
Leonard Chandb01c3a2018-06-20 17:19:40 +00002182 /**
2183 * Fixed point literal
2184 */
2185 CXCursor_FixedPointLiteral = 149,
2186
2187 CXCursor_LastExpr = CXCursor_FixedPointLiteral,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002188
Douglas Gregor6007cf22010-01-22 22:29:16 +00002189 /* Statements */
2190 CXCursor_FirstStmt = 200,
2191 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002192 * A statement whose specific kind is not exposed via this
Douglas Gregor6007cf22010-01-22 22:29:16 +00002193 * interface.
2194 *
2195 * Unexposed statements have the same operations as any other kind of
2196 * statement; one can extract their location information, spelling,
2197 * children, etc. However, the specific kind of the statement is not
2198 * reported.
2199 */
2200 CXCursor_UnexposedStmt = 200,
Fangrui Song6907ce22018-07-30 19:24:48 +00002201
2202 /** A labelled statement in a function.
Douglas Gregora93ab662010-09-10 00:22:18 +00002203 *
Fangrui Song6907ce22018-07-30 19:24:48 +00002204 * This cursor kind is used to describe the "start_over:" label statement in
Douglas Gregora93ab662010-09-10 00:22:18 +00002205 * the following example:
2206 *
2207 * \code
2208 * start_over:
2209 * ++counter;
2210 * \endcode
2211 *
2212 */
2213 CXCursor_LabelStmt = 201,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002214
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002215 /** A group of statements like { stmt stmt }.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002216 *
2217 * This cursor kind is used to describe compound statements, e.g. function
2218 * bodies.
2219 */
2220 CXCursor_CompoundStmt = 202,
2221
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002222 /** A case statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002223 */
2224 CXCursor_CaseStmt = 203,
2225
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002226 /** A default statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002227 */
2228 CXCursor_DefaultStmt = 204,
2229
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002230 /** An if statement
Douglas Gregor4c362d52011-10-05 19:00:14 +00002231 */
2232 CXCursor_IfStmt = 205,
2233
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002234 /** A switch statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002235 */
2236 CXCursor_SwitchStmt = 206,
2237
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002238 /** A while statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002239 */
2240 CXCursor_WhileStmt = 207,
2241
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002242 /** A do statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002243 */
2244 CXCursor_DoStmt = 208,
2245
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002246 /** A for statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002247 */
2248 CXCursor_ForStmt = 209,
2249
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002250 /** A goto statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002251 */
2252 CXCursor_GotoStmt = 210,
2253
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002254 /** An indirect goto statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002255 */
2256 CXCursor_IndirectGotoStmt = 211,
2257
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002258 /** A continue statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002259 */
2260 CXCursor_ContinueStmt = 212,
2261
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002262 /** A break statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002263 */
2264 CXCursor_BreakStmt = 213,
2265
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002266 /** A return statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002267 */
2268 CXCursor_ReturnStmt = 214,
2269
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002270 /** A GCC inline assembly statement extension.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002271 */
Chad Rosierde70e0e2012-08-25 00:11:56 +00002272 CXCursor_GCCAsmStmt = 215,
Argyrios Kyrtzidis5eae0732012-09-24 19:27:20 +00002273 CXCursor_AsmStmt = CXCursor_GCCAsmStmt,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002274
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002275 /** Objective-C's overall \@try-\@catch-\@finally statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002276 */
2277 CXCursor_ObjCAtTryStmt = 216,
2278
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002279 /** Objective-C's \@catch statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002280 */
2281 CXCursor_ObjCAtCatchStmt = 217,
2282
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002283 /** Objective-C's \@finally statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002284 */
2285 CXCursor_ObjCAtFinallyStmt = 218,
2286
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002287 /** Objective-C's \@throw statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002288 */
2289 CXCursor_ObjCAtThrowStmt = 219,
2290
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002291 /** Objective-C's \@synchronized statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002292 */
2293 CXCursor_ObjCAtSynchronizedStmt = 220,
2294
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002295 /** Objective-C's autorelease pool statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002296 */
2297 CXCursor_ObjCAutoreleasePoolStmt = 221,
2298
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002299 /** Objective-C's collection statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002300 */
2301 CXCursor_ObjCForCollectionStmt = 222,
2302
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002303 /** C++'s catch statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002304 */
2305 CXCursor_CXXCatchStmt = 223,
2306
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002307 /** C++'s try statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002308 */
2309 CXCursor_CXXTryStmt = 224,
2310
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002311 /** C++'s for (* : *) statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002312 */
2313 CXCursor_CXXForRangeStmt = 225,
2314
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002315 /** Windows Structured Exception Handling's try statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002316 */
2317 CXCursor_SEHTryStmt = 226,
2318
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002319 /** Windows Structured Exception Handling's except statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002320 */
2321 CXCursor_SEHExceptStmt = 227,
2322
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002323 /** Windows Structured Exception Handling's finally statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002324 */
2325 CXCursor_SEHFinallyStmt = 228,
2326
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002327 /** A MS inline assembly statement extension.
Chad Rosier32503022012-06-11 20:47:18 +00002328 */
2329 CXCursor_MSAsmStmt = 229,
2330
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002331 /** The null statement ";": C99 6.8.3p3.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002332 *
2333 * This cursor kind is used to describe the null statement.
2334 */
2335 CXCursor_NullStmt = 230,
2336
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002337 /** Adaptor class for mixing declarations with statements and
Douglas Gregor4c362d52011-10-05 19:00:14 +00002338 * expressions.
2339 */
2340 CXCursor_DeclStmt = 231,
2341
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002342 /** OpenMP parallel directive.
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002343 */
2344 CXCursor_OMPParallelDirective = 232,
2345
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002346 /** OpenMP SIMD directive.
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002347 */
2348 CXCursor_OMPSimdDirective = 233,
2349
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002350 /** OpenMP for directive.
Alexey Bataevf29276e2014-06-18 04:14:57 +00002351 */
2352 CXCursor_OMPForDirective = 234,
2353
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002354 /** OpenMP sections directive.
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002355 */
2356 CXCursor_OMPSectionsDirective = 235,
2357
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002358 /** OpenMP section directive.
Alexey Bataev1e0498a2014-06-26 08:21:58 +00002359 */
2360 CXCursor_OMPSectionDirective = 236,
2361
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002362 /** OpenMP single directive.
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00002363 */
2364 CXCursor_OMPSingleDirective = 237,
2365
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002366 /** OpenMP parallel for directive.
Alexey Bataev4acb8592014-07-07 13:01:15 +00002367 */
2368 CXCursor_OMPParallelForDirective = 238,
2369
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002370 /** OpenMP parallel sections directive.
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002371 */
2372 CXCursor_OMPParallelSectionsDirective = 239,
2373
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002374 /** OpenMP task directive.
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002375 */
2376 CXCursor_OMPTaskDirective = 240,
2377
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002378 /** OpenMP master directive.
Alexander Musman80c22892014-07-17 08:54:58 +00002379 */
2380 CXCursor_OMPMasterDirective = 241,
2381
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002382 /** OpenMP critical directive.
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002383 */
2384 CXCursor_OMPCriticalDirective = 242,
2385
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002386 /** OpenMP taskyield directive.
Alexey Bataev68446b72014-07-18 07:47:19 +00002387 */
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002388 CXCursor_OMPTaskyieldDirective = 243,
Alexey Bataev68446b72014-07-18 07:47:19 +00002389
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002390 /** OpenMP barrier directive.
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00002391 */
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002392 CXCursor_OMPBarrierDirective = 244,
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00002393
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002394 /** OpenMP taskwait directive.
Alexey Bataev2df347a2014-07-18 10:17:07 +00002395 */
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002396 CXCursor_OMPTaskwaitDirective = 245,
Alexey Bataev2df347a2014-07-18 10:17:07 +00002397
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002398 /** OpenMP flush directive.
Alexey Bataev6125da92014-07-21 11:26:11 +00002399 */
2400 CXCursor_OMPFlushDirective = 246,
Alexey Bataev0162e452014-07-22 10:10:35 +00002401
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002402 /** Windows Structured Exception Handling's leave statement.
Reid Klecknerba764482014-07-24 18:22:15 +00002403 */
2404 CXCursor_SEHLeaveStmt = 247,
2405
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002406 /** OpenMP ordered directive.
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002407 */
Reid Klecknerba764482014-07-24 18:22:15 +00002408 CXCursor_OMPOrderedDirective = 248,
Alexey Bataev6125da92014-07-21 11:26:11 +00002409
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002410 /** OpenMP atomic directive.
Alexey Bataev0162e452014-07-22 10:10:35 +00002411 */
Reid Klecknerba764482014-07-24 18:22:15 +00002412 CXCursor_OMPAtomicDirective = 249,
Alexey Bataev0162e452014-07-22 10:10:35 +00002413
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002414 /** OpenMP for SIMD directive.
Alexander Musmanf82886e2014-09-18 05:12:34 +00002415 */
2416 CXCursor_OMPForSimdDirective = 250,
2417
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002418 /** OpenMP parallel for SIMD directive.
Alexander Musmane4e893b2014-09-23 09:33:00 +00002419 */
2420 CXCursor_OMPParallelForSimdDirective = 251,
2421
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002422 /** OpenMP target directive.
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002423 */
Alexander Musmane4e893b2014-09-23 09:33:00 +00002424 CXCursor_OMPTargetDirective = 252,
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002425
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002426 /** OpenMP teams directive.
Alexey Bataev13314bf2014-10-09 04:18:56 +00002427 */
2428 CXCursor_OMPTeamsDirective = 253,
2429
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002430 /** OpenMP taskgroup directive.
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002431 */
Michael Wong65f367f2015-07-21 13:44:28 +00002432 CXCursor_OMPTaskgroupDirective = 254,
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002433
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002434 /** OpenMP cancellation point directive.
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002435 */
Michael Wong65f367f2015-07-21 13:44:28 +00002436 CXCursor_OMPCancellationPointDirective = 255,
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002437
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002438 /** OpenMP cancel directive.
Alexey Bataev80909872015-07-02 11:25:17 +00002439 */
Michael Wong65f367f2015-07-21 13:44:28 +00002440 CXCursor_OMPCancelDirective = 256,
Alexey Bataev80909872015-07-02 11:25:17 +00002441
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002442 /** OpenMP target data directive.
Michael Wong65f367f2015-07-21 13:44:28 +00002443 */
2444 CXCursor_OMPTargetDataDirective = 257,
2445
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002446 /** OpenMP taskloop directive.
Alexey Bataev49f6e782015-12-01 04:18:41 +00002447 */
2448 CXCursor_OMPTaskLoopDirective = 258,
2449
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002450 /** OpenMP taskloop simd directive.
Alexey Bataev0a6ed842015-12-03 09:40:15 +00002451 */
2452 CXCursor_OMPTaskLoopSimdDirective = 259,
2453
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002454 /** OpenMP distribute directive.
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00002455 */
2456 CXCursor_OMPDistributeDirective = 260,
2457
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002458 /** OpenMP target enter data directive.
Samuel Antaodf67fc42016-01-19 19:15:56 +00002459 */
2460 CXCursor_OMPTargetEnterDataDirective = 261,
2461
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002462 /** OpenMP target exit data directive.
Samuel Antao72590762016-01-19 20:04:50 +00002463 */
2464 CXCursor_OMPTargetExitDataDirective = 262,
2465
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002466 /** OpenMP target parallel directive.
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002467 */
2468 CXCursor_OMPTargetParallelDirective = 263,
2469
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002470 /** OpenMP target parallel for directive.
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00002471 */
2472 CXCursor_OMPTargetParallelForDirective = 264,
2473
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002474 /** OpenMP target update directive.
Samuel Antao686c70c2016-05-26 17:30:50 +00002475 */
2476 CXCursor_OMPTargetUpdateDirective = 265,
2477
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002478 /** OpenMP distribute parallel for directive.
Carlo Bertolli9925f152016-06-27 14:55:37 +00002479 */
2480 CXCursor_OMPDistributeParallelForDirective = 266,
2481
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002482 /** OpenMP distribute parallel for simd directive.
Kelvin Li4a39add2016-07-05 05:00:15 +00002483 */
2484 CXCursor_OMPDistributeParallelForSimdDirective = 267,
2485
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002486 /** OpenMP distribute simd directive.
Kelvin Li787f3fc2016-07-06 04:45:38 +00002487 */
2488 CXCursor_OMPDistributeSimdDirective = 268,
2489
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002490 /** OpenMP target parallel for simd directive.
Kelvin Lia579b912016-07-14 02:54:56 +00002491 */
2492 CXCursor_OMPTargetParallelForSimdDirective = 269,
2493
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002494 /** OpenMP target simd directive.
Kelvin Li986330c2016-07-20 22:57:10 +00002495 */
2496 CXCursor_OMPTargetSimdDirective = 270,
2497
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002498 /** OpenMP teams distribute directive.
Kelvin Li02532872016-08-05 14:37:37 +00002499 */
2500 CXCursor_OMPTeamsDistributeDirective = 271,
2501
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002502 /** OpenMP teams distribute simd directive.
Kelvin Li4e325f72016-10-25 12:50:55 +00002503 */
2504 CXCursor_OMPTeamsDistributeSimdDirective = 272,
2505
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002506 /** OpenMP teams distribute parallel for simd directive.
Kelvin Li579e41c2016-11-30 23:51:03 +00002507 */
2508 CXCursor_OMPTeamsDistributeParallelForSimdDirective = 273,
2509
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002510 /** OpenMP teams distribute parallel for directive.
Kelvin Li7ade93f2016-12-09 03:24:30 +00002511 */
2512 CXCursor_OMPTeamsDistributeParallelForDirective = 274,
2513
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002514 /** OpenMP target teams directive.
Kelvin Libf594a52016-12-17 05:48:59 +00002515 */
2516 CXCursor_OMPTargetTeamsDirective = 275,
2517
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002518 /** OpenMP target teams distribute directive.
Kelvin Li83c451e2016-12-25 04:52:54 +00002519 */
2520 CXCursor_OMPTargetTeamsDistributeDirective = 276,
2521
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002522 /** OpenMP target teams distribute parallel for directive.
Kelvin Li80e8f562016-12-29 22:16:30 +00002523 */
2524 CXCursor_OMPTargetTeamsDistributeParallelForDirective = 277,
2525
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002526 /** OpenMP target teams distribute parallel for simd directive.
Kelvin Li1851df52017-01-03 05:23:48 +00002527 */
2528 CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective = 278,
2529
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002530 /** OpenMP target teams distribute simd directive.
Kelvin Lida681182017-01-10 18:08:18 +00002531 */
2532 CXCursor_OMPTargetTeamsDistributeSimdDirective = 279,
2533
2534 CXCursor_LastStmt = CXCursor_OMPTargetTeamsDistributeSimdDirective,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002535
Douglas Gregor6007cf22010-01-22 22:29:16 +00002536 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002537 * Cursor that represents the translation unit itself.
Douglas Gregor6007cf22010-01-22 22:29:16 +00002538 *
2539 * The translation unit cursor exists primarily to act as the root
2540 * cursor for traversing the contents of a translation unit.
2541 */
Ted Kremenekbff31432010-02-18 03:09:07 +00002542 CXCursor_TranslationUnit = 300,
2543
Bill Wendling44426052012-12-20 19:22:21 +00002544 /* Attributes */
Ted Kremenekbff31432010-02-18 03:09:07 +00002545 CXCursor_FirstAttr = 400,
2546 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002547 * An attribute whose specific kind is not exposed via this
Ted Kremenekbff31432010-02-18 03:09:07 +00002548 * interface.
2549 */
2550 CXCursor_UnexposedAttr = 400,
2551
2552 CXCursor_IBActionAttr = 401,
2553 CXCursor_IBOutletAttr = 402,
Ted Kremenek26bde772010-05-19 17:38:06 +00002554 CXCursor_IBOutletCollectionAttr = 403,
Argyrios Kyrtzidis2cb4e3c2011-09-13 17:39:31 +00002555 CXCursor_CXXFinalAttr = 404,
2556 CXCursor_CXXOverrideAttr = 405,
Erik Verbruggenca98f2a2011-10-13 09:41:32 +00002557 CXCursor_AnnotateAttr = 406,
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00002558 CXCursor_AsmLabelAttr = 407,
Argyrios Kyrtzidis16834f12013-09-25 00:14:38 +00002559 CXCursor_PackedAttr = 408,
Joey Gouly81228382014-05-01 15:41:58 +00002560 CXCursor_PureAttr = 409,
2561 CXCursor_ConstAttr = 410,
2562 CXCursor_NoDuplicateAttr = 411,
Eli Bendersky2581e662014-05-28 19:29:58 +00002563 CXCursor_CUDAConstantAttr = 412,
2564 CXCursor_CUDADeviceAttr = 413,
2565 CXCursor_CUDAGlobalAttr = 414,
2566 CXCursor_CUDAHostAttr = 415,
Eli Bendersky9b071472014-08-08 14:59:00 +00002567 CXCursor_CUDASharedAttr = 416,
Saleem Abdulrasool79c69712015-09-05 18:53:43 +00002568 CXCursor_VisibilityAttr = 417,
Saleem Abdulrasool8aa0b802015-12-10 18:45:18 +00002569 CXCursor_DLLExport = 418,
2570 CXCursor_DLLImport = 419,
Michael Wud092d0b2018-08-03 05:03:22 +00002571 CXCursor_NSReturnsRetained = 420,
2572 CXCursor_NSReturnsNotRetained = 421,
2573 CXCursor_NSReturnsAutoreleased = 422,
2574 CXCursor_NSConsumesSelf = 423,
2575 CXCursor_NSConsumed = 424,
2576 CXCursor_ObjCException = 425,
2577 CXCursor_ObjCNSObject = 426,
2578 CXCursor_ObjCIndependentClass = 427,
2579 CXCursor_ObjCPreciseLifetime = 428,
2580 CXCursor_ObjCReturnsInnerPointer = 429,
2581 CXCursor_ObjCRequiresSuper = 430,
2582 CXCursor_ObjCRootClass = 431,
2583 CXCursor_ObjCSubclassingRestricted = 432,
2584 CXCursor_ObjCExplicitProtocolImpl = 433,
2585 CXCursor_ObjCDesignatedInitializer = 434,
2586 CXCursor_ObjCRuntimeVisible = 435,
2587 CXCursor_ObjCBoxable = 436,
Michael Wu58d837d2018-08-03 05:55:40 +00002588 CXCursor_FlagEnum = 437,
2589 CXCursor_LastAttr = CXCursor_FlagEnum,
Eli Bendersky2581e662014-05-28 19:29:58 +00002590
Douglas Gregor92a524f2010-03-18 00:42:48 +00002591 /* Preprocessing */
2592 CXCursor_PreprocessingDirective = 500,
Douglas Gregor06d6d322010-03-18 18:04:21 +00002593 CXCursor_MacroDefinition = 501,
Chandler Carruth9e4704a2011-07-14 08:41:15 +00002594 CXCursor_MacroExpansion = 502,
2595 CXCursor_MacroInstantiation = CXCursor_MacroExpansion,
Douglas Gregor796d76a2010-10-20 22:00:55 +00002596 CXCursor_InclusionDirective = 503,
Douglas Gregor92a524f2010-03-18 00:42:48 +00002597 CXCursor_FirstPreprocessing = CXCursor_PreprocessingDirective,
Argyrios Kyrtzidis50e5b1d2012-10-05 00:22:24 +00002598 CXCursor_LastPreprocessing = CXCursor_InclusionDirective,
2599
2600 /* Extra Declarations */
2601 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002602 * A module import declaration.
Argyrios Kyrtzidis50e5b1d2012-10-05 00:22:24 +00002603 */
2604 CXCursor_ModuleImportDecl = 600,
Sergey Kalinichev8f3b1872015-11-15 13:48:32 +00002605 CXCursor_TypeAliasTemplateDecl = 601,
Olivier Goffart81978012016-06-09 16:15:55 +00002606 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002607 * A static_assert or _Static_assert node
Olivier Goffart81978012016-06-09 16:15:55 +00002608 */
2609 CXCursor_StaticAssert = 602,
Olivier Goffartd211c642016-11-04 06:29:27 +00002610 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002611 * a friend declaration.
Olivier Goffartd211c642016-11-04 06:29:27 +00002612 */
2613 CXCursor_FriendDecl = 603,
Argyrios Kyrtzidis50e5b1d2012-10-05 00:22:24 +00002614 CXCursor_FirstExtraDecl = CXCursor_ModuleImportDecl,
Olivier Goffartd211c642016-11-04 06:29:27 +00002615 CXCursor_LastExtraDecl = CXCursor_FriendDecl,
Francisco Lopes da Silva975a9f62015-01-21 16:24:11 +00002616
2617 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002618 * A code completion overload candidate.
Francisco Lopes da Silva975a9f62015-01-21 16:24:11 +00002619 */
2620 CXCursor_OverloadCandidate = 700
Douglas Gregor6007cf22010-01-22 22:29:16 +00002621};
2622
2623/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002624 * A cursor representing some element in the abstract syntax tree for
Douglas Gregor6007cf22010-01-22 22:29:16 +00002625 * a translation unit.
2626 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002627 * The cursor abstraction unifies the different kinds of entities in a
Douglas Gregor6007cf22010-01-22 22:29:16 +00002628 * program--declaration, statements, expressions, references to declarations,
2629 * etc.--under a single "cursor" abstraction with a common set of operations.
2630 * Common operation for a cursor include: getting the physical location in
2631 * a source file where the cursor points, getting the name associated with a
2632 * cursor, and retrieving cursors for any child nodes of a particular cursor.
2633 *
2634 * Cursors can be produced in two specific ways.
2635 * clang_getTranslationUnitCursor() produces a cursor for a translation unit,
2636 * from which one can use clang_visitChildren() to explore the rest of the
2637 * translation unit. clang_getCursor() maps from a physical source location
2638 * to the entity that resides at that location, allowing one to map from the
2639 * source code into the AST.
2640 */
2641typedef struct {
2642 enum CXCursorKind kind;
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00002643 int xdata;
Dmitri Gribenkoba2f7462013-01-11 21:01:49 +00002644 const void *data[3];
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002645} CXCursor;
Douglas Gregor6007cf22010-01-22 22:29:16 +00002646
2647/**
2648 * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations
2649 *
2650 * @{
2651 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002652
Douglas Gregor6007cf22010-01-22 22:29:16 +00002653/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002654 * Retrieve the NULL cursor, which represents no entity.
Douglas Gregor6007cf22010-01-22 22:29:16 +00002655 */
2656CINDEX_LINKAGE CXCursor clang_getNullCursor(void);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002657
Douglas Gregor6007cf22010-01-22 22:29:16 +00002658/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002659 * Retrieve the cursor that represents the given translation unit.
Douglas Gregor6007cf22010-01-22 22:29:16 +00002660 *
2661 * The translation unit cursor can be used to start traversing the
2662 * various declarations within the given translation unit.
2663 */
2664CINDEX_LINKAGE CXCursor clang_getTranslationUnitCursor(CXTranslationUnit);
2665
2666/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002667 * Determine whether two cursors are equivalent.
Douglas Gregor6007cf22010-01-22 22:29:16 +00002668 */
2669CINDEX_LINKAGE unsigned clang_equalCursors(CXCursor, CXCursor);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002670
Douglas Gregor6007cf22010-01-22 22:29:16 +00002671/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002672 * Returns non-zero if \p cursor is null.
Argyrios Kyrtzidisd6e9fa52011-09-27 00:30:30 +00002673 */
Dmitri Gribenko8994e0c2012-09-13 13:11:20 +00002674CINDEX_LINKAGE int clang_Cursor_isNull(CXCursor cursor);
Argyrios Kyrtzidisd6e9fa52011-09-27 00:30:30 +00002675
2676/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002677 * Compute a hash value for the given cursor.
Douglas Gregor06a3f302010-11-20 00:09:34 +00002678 */
2679CINDEX_LINKAGE unsigned clang_hashCursor(CXCursor);
Fangrui Song6907ce22018-07-30 19:24:48 +00002680
Douglas Gregor06a3f302010-11-20 00:09:34 +00002681/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002682 * Retrieve the kind of the given cursor.
Douglas Gregor6007cf22010-01-22 22:29:16 +00002683 */
2684CINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor);
2685
2686/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002687 * Determine whether the given cursor kind represents a declaration.
Ivan Donchevskii65c766e2018-01-03 10:40:11 +00002688 */
2689CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind);
2690
2691/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002692 * Determine whether the given declaration is invalid.
Ivan Donchevskii08ff9102018-01-04 10:59:50 +00002693 *
2694 * A declaration is invalid if it could not be parsed successfully.
2695 *
2696 * \returns non-zero if the cursor represents a declaration and it is
2697 * invalid, otherwise NULL.
2698 */
2699CINDEX_LINKAGE unsigned clang_isInvalidDeclaration(CXCursor);
2700
2701/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002702 * Determine whether the given cursor kind represents a simple
Ivan Donchevskii65c766e2018-01-03 10:40:11 +00002703 * reference.
Douglas Gregor6007cf22010-01-22 22:29:16 +00002704 *
2705 * Note that other kinds of cursors (such as expressions) can also refer to
2706 * other cursors. Use clang_getCursorReferenced() to determine whether a
2707 * particular cursor refers to another entity.
2708 */
2709CINDEX_LINKAGE unsigned clang_isReference(enum CXCursorKind);
2710
2711/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002712 * Determine whether the given cursor kind represents an expression.
Douglas Gregor6007cf22010-01-22 22:29:16 +00002713 */
2714CINDEX_LINKAGE unsigned clang_isExpression(enum CXCursorKind);
2715
2716/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002717 * Determine whether the given cursor kind represents a statement.
Douglas Gregor6007cf22010-01-22 22:29:16 +00002718 */
2719CINDEX_LINKAGE unsigned clang_isStatement(enum CXCursorKind);
2720
2721/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002722 * Determine whether the given cursor kind represents an attribute.
Douglas Gregora98034a2011-07-06 03:00:34 +00002723 */
2724CINDEX_LINKAGE unsigned clang_isAttribute(enum CXCursorKind);
2725
2726/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002727 * Determine whether the given cursor has any attributes.
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00002728 */
2729CINDEX_LINKAGE unsigned clang_Cursor_hasAttrs(CXCursor C);
2730
2731/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002732 * Determine whether the given cursor kind represents an invalid
Douglas Gregor6007cf22010-01-22 22:29:16 +00002733 * cursor.
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002734 */
Douglas Gregor6007cf22010-01-22 22:29:16 +00002735CINDEX_LINKAGE unsigned clang_isInvalid(enum CXCursorKind);
2736
2737/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002738 * Determine whether the given cursor kind represents a translation
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002739 * unit.
Douglas Gregor6007cf22010-01-22 22:29:16 +00002740 */
2741CINDEX_LINKAGE unsigned clang_isTranslationUnit(enum CXCursorKind);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002742
Ted Kremenekff9021b2010-03-08 21:17:29 +00002743/***
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002744 * Determine whether the given cursor represents a preprocessing
Douglas Gregor92a524f2010-03-18 00:42:48 +00002745 * element, such as a preprocessor directive or macro instantiation.
2746 */
2747CINDEX_LINKAGE unsigned clang_isPreprocessing(enum CXCursorKind);
Fangrui Song6907ce22018-07-30 19:24:48 +00002748
Douglas Gregor92a524f2010-03-18 00:42:48 +00002749/***
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002750 * Determine whether the given cursor represents a currently
Ted Kremenekff9021b2010-03-08 21:17:29 +00002751 * unexposed piece of the AST (e.g., CXCursor_UnexposedStmt).
2752 */
2753CINDEX_LINKAGE unsigned clang_isUnexposed(enum CXCursorKind);
2754
Douglas Gregor6007cf22010-01-22 22:29:16 +00002755/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002756 * Describe the linkage of the entity referred to by a cursor.
Ted Kremenekfb4961d2010-03-03 06:36:57 +00002757 */
2758enum CXLinkageKind {
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002759 /** This value indicates that no linkage information is available
Ted Kremenekfb4961d2010-03-03 06:36:57 +00002760 * for a provided CXCursor. */
2761 CXLinkage_Invalid,
2762 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002763 * This is the linkage for variables, parameters, and so on that
Ted Kremenekfb4961d2010-03-03 06:36:57 +00002764 * have automatic storage. This covers normal (non-extern) local variables.
2765 */
2766 CXLinkage_NoLinkage,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002767 /** This is the linkage for static variables and static functions. */
Ted Kremenekfb4961d2010-03-03 06:36:57 +00002768 CXLinkage_Internal,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002769 /** This is the linkage for entities with external linkage that live
Ted Kremenekfb4961d2010-03-03 06:36:57 +00002770 * in C++ anonymous namespaces.*/
2771 CXLinkage_UniqueExternal,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002772 /** This is the linkage for entities with true, external linkage. */
Ted Kremenekfb4961d2010-03-03 06:36:57 +00002773 CXLinkage_External
2774};
2775
2776/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002777 * Determine the linkage of the entity referred to by a given cursor.
Ted Kremenekfb4961d2010-03-03 06:36:57 +00002778 */
2779CINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor);
2780
Ehsan Akhgarib743de72016-05-31 15:55:51 +00002781enum CXVisibilityKind {
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002782 /** This value indicates that no visibility information is available
Ehsan Akhgarib743de72016-05-31 15:55:51 +00002783 * for a provided CXCursor. */
2784 CXVisibility_Invalid,
2785
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002786 /** Symbol not seen by the linker. */
Ehsan Akhgarib743de72016-05-31 15:55:51 +00002787 CXVisibility_Hidden,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002788 /** Symbol seen by the linker but resolves to a symbol inside this object. */
Ehsan Akhgarib743de72016-05-31 15:55:51 +00002789 CXVisibility_Protected,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002790 /** Symbol seen by the linker and acts like a normal symbol. */
Ehsan Akhgarib743de72016-05-31 15:55:51 +00002791 CXVisibility_Default
2792};
2793
2794/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002795 * Describe the visibility of the entity referred to by a cursor.
Ehsan Akhgarib743de72016-05-31 15:55:51 +00002796 *
2797 * This returns the default visibility if not explicitly specified by
2798 * a visibility attribute. The default visibility may be changed by
2799 * commandline arguments.
2800 *
2801 * \param cursor The cursor to query.
2802 *
2803 * \returns The visibility of the cursor.
2804 */
2805CINDEX_LINKAGE enum CXVisibilityKind clang_getCursorVisibility(CXCursor cursor);
2806
Ehsan Akhgari93697fa2015-11-23 19:56:46 +00002807/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002808 * Determine the availability of the entity that this cursor refers to,
Douglas Gregord6225d32012-05-08 00:14:45 +00002809 * taking the current target platform into account.
Douglas Gregorf757a122010-08-23 23:00:57 +00002810 *
2811 * \param cursor The cursor to query.
2812 *
2813 * \returns The availability of the cursor.
2814 */
Fangrui Song6907ce22018-07-30 19:24:48 +00002815CINDEX_LINKAGE enum CXAvailabilityKind
Douglas Gregorf757a122010-08-23 23:00:57 +00002816clang_getCursorAvailability(CXCursor cursor);
2817
2818/**
Douglas Gregord6225d32012-05-08 00:14:45 +00002819 * Describes the availability of a given entity on a particular platform, e.g.,
2820 * a particular class might only be available on Mac OS 10.7 or newer.
2821 */
2822typedef struct CXPlatformAvailability {
2823 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002824 * A string that describes the platform for which this structure
Douglas Gregord6225d32012-05-08 00:14:45 +00002825 * provides availability information.
2826 *
Manman Renccf25bb2016-06-28 20:55:30 +00002827 * Possible values are "ios" or "macos".
Douglas Gregord6225d32012-05-08 00:14:45 +00002828 */
2829 CXString Platform;
2830 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002831 * The version number in which this entity was introduced.
Douglas Gregord6225d32012-05-08 00:14:45 +00002832 */
2833 CXVersion Introduced;
2834 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002835 * The version number in which this entity was deprecated (but is
Douglas Gregord6225d32012-05-08 00:14:45 +00002836 * still available).
2837 */
2838 CXVersion Deprecated;
2839 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002840 * The version number in which this entity was obsoleted, and therefore
Douglas Gregord6225d32012-05-08 00:14:45 +00002841 * is no longer available.
2842 */
2843 CXVersion Obsoleted;
2844 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002845 * Whether the entity is unconditionally unavailable on this platform.
Douglas Gregord6225d32012-05-08 00:14:45 +00002846 */
2847 int Unavailable;
2848 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002849 * An optional message to provide to a user of this API, e.g., to
Douglas Gregord6225d32012-05-08 00:14:45 +00002850 * suggest replacement APIs.
2851 */
2852 CXString Message;
2853} CXPlatformAvailability;
2854
2855/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002856 * Determine the availability of the entity that this cursor refers to
Douglas Gregord6225d32012-05-08 00:14:45 +00002857 * on any platforms for which availability information is known.
2858 *
2859 * \param cursor The cursor to query.
2860 *
Fangrui Song6907ce22018-07-30 19:24:48 +00002861 * \param always_deprecated If non-NULL, will be set to indicate whether the
Douglas Gregord6225d32012-05-08 00:14:45 +00002862 * entity is deprecated on all platforms.
2863 *
Fangrui Song6907ce22018-07-30 19:24:48 +00002864 * \param deprecated_message If non-NULL, will be set to the message text
Douglas Gregord6225d32012-05-08 00:14:45 +00002865 * provided along with the unconditional deprecation of this entity. The client
2866 * is responsible for deallocating this string.
2867 *
James Dennett574cb4c2012-06-15 05:41:51 +00002868 * \param always_unavailable If non-NULL, will be set to indicate whether the
Douglas Gregord6225d32012-05-08 00:14:45 +00002869 * entity is unavailable on all platforms.
2870 *
2871 * \param unavailable_message If non-NULL, will be set to the message text
Fangrui Song6907ce22018-07-30 19:24:48 +00002872 * provided along with the unconditional unavailability of this entity. The
Douglas Gregord6225d32012-05-08 00:14:45 +00002873 * client is responsible for deallocating this string.
2874 *
2875 * \param availability If non-NULL, an array of CXPlatformAvailability instances
2876 * that will be populated with platform availability information, up to either
2877 * the number of platforms for which availability information is available (as
2878 * returned by this function) or \c availability_size, whichever is smaller.
2879 *
Fangrui Song6907ce22018-07-30 19:24:48 +00002880 * \param availability_size The number of elements available in the
Douglas Gregord6225d32012-05-08 00:14:45 +00002881 * \c availability array.
2882 *
2883 * \returns The number of platforms (N) for which availability information is
2884 * available (which is unrelated to \c availability_size).
2885 *
Fangrui Song6907ce22018-07-30 19:24:48 +00002886 * Note that the client is responsible for calling
2887 * \c clang_disposeCXPlatformAvailability to free each of the
2888 * platform-availability structures returned. There are
Douglas Gregord6225d32012-05-08 00:14:45 +00002889 * \c min(N, availability_size) such structures.
2890 */
2891CINDEX_LINKAGE int
2892clang_getCursorPlatformAvailability(CXCursor cursor,
2893 int *always_deprecated,
2894 CXString *deprecated_message,
2895 int *always_unavailable,
2896 CXString *unavailable_message,
2897 CXPlatformAvailability *availability,
2898 int availability_size);
2899
2900/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002901 * Free the memory associated with a \c CXPlatformAvailability structure.
Douglas Gregord6225d32012-05-08 00:14:45 +00002902 */
2903CINDEX_LINKAGE void
2904clang_disposeCXPlatformAvailability(CXPlatformAvailability *availability);
Fangrui Song6907ce22018-07-30 19:24:48 +00002905
Douglas Gregord6225d32012-05-08 00:14:45 +00002906/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002907 * Describe the "language" of the entity referred to by a cursor.
Ted Kremenek4ed29252010-04-12 21:22:16 +00002908 */
Reid Kleckner9e3bc722013-12-30 17:48:49 +00002909enum CXLanguageKind {
Ted Kremenekee457512010-04-14 20:58:32 +00002910 CXLanguage_Invalid = 0,
Ted Kremenek4ed29252010-04-12 21:22:16 +00002911 CXLanguage_C,
2912 CXLanguage_ObjC,
Ted Kremenekee457512010-04-14 20:58:32 +00002913 CXLanguage_CPlusPlus
Ted Kremenek4ed29252010-04-12 21:22:16 +00002914};
2915
2916/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002917 * Determine the "language" of the entity referred to by a given cursor.
Ted Kremenek4ed29252010-04-12 21:22:16 +00002918 */
2919CINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor);
2920
Argyrios Kyrtzidisd6e9fa52011-09-27 00:30:30 +00002921/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002922 * Describe the "thread-local storage (TLS) kind" of the declaration
Saleem Abdulrasool50bc5652017-09-13 02:15:09 +00002923 * referred to by a cursor.
2924 */
2925enum CXTLSKind {
2926 CXTLS_None = 0,
2927 CXTLS_Dynamic,
2928 CXTLS_Static
2929};
2930
2931/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002932 * Determine the "thread-local storage (TLS) kind" of the declaration
Saleem Abdulrasool50bc5652017-09-13 02:15:09 +00002933 * referred to by a cursor.
2934 */
2935CINDEX_LINKAGE enum CXTLSKind clang_getCursorTLSKind(CXCursor cursor);
2936
2937/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002938 * Returns the translation unit that a cursor originated from.
Argyrios Kyrtzidisd6e9fa52011-09-27 00:30:30 +00002939 */
2940CINDEX_LINKAGE CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor);
2941
Ted Kremenekc0b98662013-04-24 07:17:12 +00002942/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002943 * A fast container representing a set of CXCursors.
Ted Kremenekc0b98662013-04-24 07:17:12 +00002944 */
2945typedef struct CXCursorSetImpl *CXCursorSet;
2946
2947/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002948 * Creates an empty CXCursorSet.
Ted Kremenekc0b98662013-04-24 07:17:12 +00002949 */
2950CINDEX_LINKAGE CXCursorSet clang_createCXCursorSet(void);
2951
2952/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002953 * Disposes a CXCursorSet and releases its associated memory.
Ted Kremenekc0b98662013-04-24 07:17:12 +00002954 */
2955CINDEX_LINKAGE void clang_disposeCXCursorSet(CXCursorSet cset);
2956
2957/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002958 * Queries a CXCursorSet to see if it contains a specific CXCursor.
Ted Kremenekc0b98662013-04-24 07:17:12 +00002959 *
2960 * \returns non-zero if the set contains the specified cursor.
2961*/
2962CINDEX_LINKAGE unsigned clang_CXCursorSet_contains(CXCursorSet cset,
2963 CXCursor cursor);
2964
2965/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002966 * Inserts a CXCursor into a CXCursorSet.
Ted Kremenekc0b98662013-04-24 07:17:12 +00002967 *
2968 * \returns zero if the CXCursor was already in the set, and non-zero otherwise.
2969*/
2970CINDEX_LINKAGE unsigned clang_CXCursorSet_insert(CXCursorSet cset,
2971 CXCursor cursor);
2972
Douglas Gregor0576ce72010-09-22 21:22:29 +00002973/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002974 * Determine the semantic parent of the given cursor.
Douglas Gregor0576ce72010-09-22 21:22:29 +00002975 *
2976 * The semantic parent of a cursor is the cursor that semantically contains
2977 * the given \p cursor. For many declarations, the lexical and semantic parents
Fangrui Song6907ce22018-07-30 19:24:48 +00002978 * are equivalent (the lexical parent is returned by
Douglas Gregor0576ce72010-09-22 21:22:29 +00002979 * \c clang_getCursorLexicalParent()). They diverge when declarations or
2980 * definitions are provided out-of-line. For example:
2981 *
2982 * \code
2983 * class C {
2984 * void f();
2985 * };
2986 *
2987 * void C::f() { }
2988 * \endcode
2989 *
Nico Weber7deebef2014-04-24 03:17:47 +00002990 * In the out-of-line definition of \c C::f, the semantic parent is
Douglas Gregor0576ce72010-09-22 21:22:29 +00002991 * the class \c C, of which this function is a member. The lexical parent is
2992 * the place where the declaration actually occurs in the source code; in this
Nico Weber7deebef2014-04-24 03:17:47 +00002993 * case, the definition occurs in the translation unit. In general, the
Douglas Gregor0576ce72010-09-22 21:22:29 +00002994 * lexical parent for a given entity can change without affecting the semantics
2995 * of the program, and the lexical parent of different declarations of the
2996 * same entity may be different. Changing the semantic parent of a declaration,
2997 * on the other hand, can have a major impact on semantics, and redeclarations
2998 * of a particular entity should all have the same semantic context.
2999 *
3000 * In the example above, both declarations of \c C::f have \c C as their
3001 * semantic context, while the lexical context of the first \c C::f is \c C
3002 * and the lexical context of the second \c C::f is the translation unit.
Douglas Gregor7ecd19e2010-12-21 07:55:45 +00003003 *
3004 * For global declarations, the semantic parent is the translation unit.
Douglas Gregor0576ce72010-09-22 21:22:29 +00003005 */
3006CINDEX_LINKAGE CXCursor clang_getCursorSemanticParent(CXCursor cursor);
3007
3008/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003009 * Determine the lexical parent of the given cursor.
Douglas Gregor0576ce72010-09-22 21:22:29 +00003010 *
3011 * The lexical parent of a cursor is the cursor in which the given \p cursor
3012 * was actually written. For many declarations, the lexical and semantic parents
Fangrui Song6907ce22018-07-30 19:24:48 +00003013 * are equivalent (the semantic parent is returned by
Douglas Gregor0576ce72010-09-22 21:22:29 +00003014 * \c clang_getCursorSemanticParent()). They diverge when declarations or
3015 * definitions are provided out-of-line. For example:
3016 *
3017 * \code
3018 * class C {
3019 * void f();
3020 * };
3021 *
3022 * void C::f() { }
3023 * \endcode
3024 *
Nico Weber7deebef2014-04-24 03:17:47 +00003025 * In the out-of-line definition of \c C::f, the semantic parent is
Douglas Gregor0576ce72010-09-22 21:22:29 +00003026 * the class \c C, of which this function is a member. The lexical parent is
3027 * the place where the declaration actually occurs in the source code; in this
Nico Weber7deebef2014-04-24 03:17:47 +00003028 * case, the definition occurs in the translation unit. In general, the
Douglas Gregor0576ce72010-09-22 21:22:29 +00003029 * lexical parent for a given entity can change without affecting the semantics
3030 * of the program, and the lexical parent of different declarations of the
3031 * same entity may be different. Changing the semantic parent of a declaration,
3032 * on the other hand, can have a major impact on semantics, and redeclarations
3033 * of a particular entity should all have the same semantic context.
3034 *
3035 * In the example above, both declarations of \c C::f have \c C as their
3036 * semantic context, while the lexical context of the first \c C::f is \c C
3037 * and the lexical context of the second \c C::f is the translation unit.
Douglas Gregor7ecd19e2010-12-21 07:55:45 +00003038 *
3039 * For declarations written in the global scope, the lexical parent is
3040 * the translation unit.
Douglas Gregor0576ce72010-09-22 21:22:29 +00003041 */
3042CINDEX_LINKAGE CXCursor clang_getCursorLexicalParent(CXCursor cursor);
Douglas Gregor99a26af2010-10-01 20:25:15 +00003043
3044/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003045 * Determine the set of methods that are overridden by the given
Douglas Gregor99a26af2010-10-01 20:25:15 +00003046 * method.
3047 *
3048 * In both Objective-C and C++, a method (aka virtual member function,
3049 * in C++) can override a virtual method in a base class. For
3050 * Objective-C, a method is said to override any method in the class's
Argyrios Kyrtzidisbfb24252012-03-08 00:20:03 +00003051 * base class, its protocols, or its categories' protocols, that has the same
3052 * selector and is of the same kind (class or instance).
3053 * If no such method exists, the search continues to the class's superclass,
3054 * its protocols, and its categories, and so on. A method from an Objective-C
3055 * implementation is considered to override the same methods as its
3056 * corresponding method in the interface.
Douglas Gregor99a26af2010-10-01 20:25:15 +00003057 *
3058 * For C++, a virtual member function overrides any virtual member
3059 * function with the same signature that occurs in its base
3060 * classes. With multiple inheritance, a virtual member function can
3061 * override several virtual member functions coming from different
3062 * base classes.
3063 *
3064 * In all cases, this function determines the immediate overridden
3065 * method, rather than all of the overridden methods. For example, if
3066 * a method is originally declared in a class A, then overridden in B
3067 * (which in inherits from A) and also in C (which inherited from B),
3068 * then the only overridden method returned from this function when
3069 * invoked on C's method will be B's method. The client may then
3070 * invoke this function again, given the previously-found overridden
3071 * methods, to map out the complete method-override set.
3072 *
3073 * \param cursor A cursor representing an Objective-C or C++
3074 * method. This routine will compute the set of methods that this
3075 * method overrides.
Fangrui Song6907ce22018-07-30 19:24:48 +00003076 *
Douglas Gregor99a26af2010-10-01 20:25:15 +00003077 * \param overridden A pointer whose pointee will be replaced with a
3078 * pointer to an array of cursors, representing the set of overridden
3079 * methods. If there are no overridden methods, the pointee will be
Fangrui Song6907ce22018-07-30 19:24:48 +00003080 * set to NULL. The pointee must be freed via a call to
Douglas Gregor99a26af2010-10-01 20:25:15 +00003081 * \c clang_disposeOverriddenCursors().
3082 *
3083 * \param num_overridden A pointer to the number of overridden
3084 * functions, will be set to the number of overridden functions in the
3085 * array pointed to by \p overridden.
3086 */
Fangrui Song6907ce22018-07-30 19:24:48 +00003087CINDEX_LINKAGE void clang_getOverriddenCursors(CXCursor cursor,
Douglas Gregor99a26af2010-10-01 20:25:15 +00003088 CXCursor **overridden,
3089 unsigned *num_overridden);
3090
3091/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003092 * Free the set of overridden cursors returned by \c
Douglas Gregor99a26af2010-10-01 20:25:15 +00003093 * clang_getOverriddenCursors().
3094 */
3095CINDEX_LINKAGE void clang_disposeOverriddenCursors(CXCursor *overridden);
3096
Ted Kremenek4ed29252010-04-12 21:22:16 +00003097/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003098 * Retrieve the file that is included by the given inclusion directive
Douglas Gregor796d76a2010-10-20 22:00:55 +00003099 * cursor.
3100 */
3101CINDEX_LINKAGE CXFile clang_getIncludedFile(CXCursor cursor);
Fangrui Song6907ce22018-07-30 19:24:48 +00003102
Douglas Gregor796d76a2010-10-20 22:00:55 +00003103/**
Douglas Gregor6007cf22010-01-22 22:29:16 +00003104 * @}
3105 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003106
Douglas Gregor6007cf22010-01-22 22:29:16 +00003107/**
3108 * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code
3109 *
3110 * Cursors represent a location within the Abstract Syntax Tree (AST). These
3111 * routines help map between cursors and the physical locations where the
3112 * described entities occur in the source code. The mapping is provided in
3113 * both directions, so one can map from source code to the AST and back.
3114 *
3115 * @{
Steve Naroffa1c72842009-08-28 15:28:48 +00003116 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003117
Steve Naroff20bad0b2009-10-21 13:56:23 +00003118/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003119 * Map a source location to the cursor that describes the entity at that
Douglas Gregor816fd362010-01-22 21:44:22 +00003120 * location in the source code.
3121 *
3122 * clang_getCursor() maps an arbitrary source location within a translation
3123 * unit down to the most specific cursor that describes the entity at that
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003124 * location. For example, given an expression \c x + y, invoking
Douglas Gregor816fd362010-01-22 21:44:22 +00003125 * clang_getCursor() with a source location pointing to "x" will return the
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003126 * cursor for "x"; similarly for "y". If the cursor points anywhere between
Douglas Gregor816fd362010-01-22 21:44:22 +00003127 * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor()
3128 * will return a cursor referring to the "+" expression.
3129 *
3130 * \returns a cursor representing the entity at the given source location, or
3131 * a NULL cursor if no such entity can be found.
Steve Naroff20bad0b2009-10-21 13:56:23 +00003132 */
Douglas Gregor816fd362010-01-22 21:44:22 +00003133CINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, CXSourceLocation);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003134
Douglas Gregor66a58812010-01-18 22:46:11 +00003135/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003136 * Retrieve the physical location of the source constructor referenced
Douglas Gregor66a58812010-01-18 22:46:11 +00003137 * by the given cursor.
3138 *
3139 * The location of a declaration is typically the location of the name of that
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003140 * declaration, where the name of that declaration would occur if it is
3141 * unnamed, or some keyword that introduces that particular declaration.
3142 * The location of a reference is where that reference occurs within the
Douglas Gregor66a58812010-01-18 22:46:11 +00003143 * source code.
3144 */
3145CINDEX_LINKAGE CXSourceLocation clang_getCursorLocation(CXCursor);
Douglas Gregor6007cf22010-01-22 22:29:16 +00003146
Douglas Gregor6b8232f2010-01-19 19:34:47 +00003147/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003148 * Retrieve the physical extent of the source construct referenced by
Douglas Gregor33c34ac2010-01-19 00:34:46 +00003149 * the given cursor.
3150 *
3151 * The extent of a cursor starts with the file/line/column pointing at the
3152 * first character within the source construct that the cursor refers to and
Nico Weber7deebef2014-04-24 03:17:47 +00003153 * ends with the last character within that source construct. For a
Douglas Gregor33c34ac2010-01-19 00:34:46 +00003154 * declaration, the extent covers the declaration itself. For a reference,
3155 * the extent covers the location of the reference (e.g., where the referenced
3156 * entity was actually used).
3157 */
3158CINDEX_LINKAGE CXSourceRange clang_getCursorExtent(CXCursor);
Douglas Gregorad27e8b2010-01-19 01:20:04 +00003159
Douglas Gregor6007cf22010-01-22 22:29:16 +00003160/**
3161 * @}
3162 */
Fangrui Song6907ce22018-07-30 19:24:48 +00003163
Douglas Gregor6007cf22010-01-22 22:29:16 +00003164/**
Ted Kremenek6bca9842010-05-14 21:29:26 +00003165 * \defgroup CINDEX_TYPES Type information for CXCursors
3166 *
3167 * @{
3168 */
3169
3170/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003171 * Describes the kind of type
Ted Kremenek6bca9842010-05-14 21:29:26 +00003172 */
3173enum CXTypeKind {
3174 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003175 * Represents an invalid type (e.g., where no type is available).
Ted Kremenek6bca9842010-05-14 21:29:26 +00003176 */
3177 CXType_Invalid = 0,
3178
3179 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003180 * A type whose specific kind is not exposed via this
Ted Kremenek6bca9842010-05-14 21:29:26 +00003181 * interface.
3182 */
3183 CXType_Unexposed = 1,
3184
3185 /* Builtin types */
3186 CXType_Void = 2,
3187 CXType_Bool = 3,
3188 CXType_Char_U = 4,
3189 CXType_UChar = 5,
3190 CXType_Char16 = 6,
3191 CXType_Char32 = 7,
3192 CXType_UShort = 8,
3193 CXType_UInt = 9,
3194 CXType_ULong = 10,
3195 CXType_ULongLong = 11,
3196 CXType_UInt128 = 12,
3197 CXType_Char_S = 13,
3198 CXType_SChar = 14,
3199 CXType_WChar = 15,
3200 CXType_Short = 16,
3201 CXType_Int = 17,
3202 CXType_Long = 18,
3203 CXType_LongLong = 19,
3204 CXType_Int128 = 20,
3205 CXType_Float = 21,
3206 CXType_Double = 22,
3207 CXType_LongDouble = 23,
3208 CXType_NullPtr = 24,
3209 CXType_Overload = 25,
3210 CXType_Dependent = 26,
3211 CXType_ObjCId = 27,
3212 CXType_ObjCClass = 28,
3213 CXType_ObjCSel = 29,
Nemanja Ivanovicbb1ea2d2016-05-09 08:52:33 +00003214 CXType_Float128 = 30,
Joey Gouly6ea21852017-02-10 15:51:11 +00003215 CXType_Half = 31,
Sjoerd Meijercc623ad2017-09-08 15:15:00 +00003216 CXType_Float16 = 32,
Leonard Chanf921d852018-06-04 16:07:52 +00003217 CXType_ShortAccum = 33,
3218 CXType_Accum = 34,
3219 CXType_LongAccum = 35,
3220 CXType_UShortAccum = 36,
3221 CXType_UAccum = 37,
3222 CXType_ULongAccum = 38,
Ted Kremenek6bca9842010-05-14 21:29:26 +00003223 CXType_FirstBuiltin = CXType_Void,
Leonard Chanf921d852018-06-04 16:07:52 +00003224 CXType_LastBuiltin = CXType_ULongAccum,
Ted Kremenek6bca9842010-05-14 21:29:26 +00003225
3226 CXType_Complex = 100,
3227 CXType_Pointer = 101,
3228 CXType_BlockPointer = 102,
3229 CXType_LValueReference = 103,
3230 CXType_RValueReference = 104,
3231 CXType_Record = 105,
3232 CXType_Enum = 106,
3233 CXType_Typedef = 107,
3234 CXType_ObjCInterface = 108,
Ted Kremenekc1508872010-06-21 20:15:39 +00003235 CXType_ObjCObjectPointer = 109,
3236 CXType_FunctionNoProto = 110,
Argyrios Kyrtzidis2b0cf602011-09-27 17:44:34 +00003237 CXType_FunctionProto = 111,
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003238 CXType_ConstantArray = 112,
Argyrios Kyrtzidis0661a712013-07-23 17:36:21 +00003239 CXType_Vector = 113,
3240 CXType_IncompleteArray = 114,
3241 CXType_VariableArray = 115,
Argyrios Kyrtzidis7a4253b2013-10-03 16:19:23 +00003242 CXType_DependentSizedArray = 116,
Sergey Kalinichevc0151202015-11-15 13:10:10 +00003243 CXType_MemberPointer = 117,
Sergey Kalinichev69770ae2016-05-03 06:58:29 +00003244 CXType_Auto = 118,
3245
3246 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003247 * Represents a type that was referred to using an elaborated type keyword.
Sergey Kalinichev69770ae2016-05-03 06:58:29 +00003248 *
3249 * E.g., struct S, or via a qualified name, e.g., N::M::type, or both.
3250 */
Sven van Haastregtcc4f1e42017-05-23 10:36:43 +00003251 CXType_Elaborated = 119,
3252
3253 /* OpenCL PipeType. */
3254 CXType_Pipe = 120,
3255
3256 /* OpenCL builtin types. */
3257 CXType_OCLImage1dRO = 121,
3258 CXType_OCLImage1dArrayRO = 122,
3259 CXType_OCLImage1dBufferRO = 123,
3260 CXType_OCLImage2dRO = 124,
3261 CXType_OCLImage2dArrayRO = 125,
3262 CXType_OCLImage2dDepthRO = 126,
3263 CXType_OCLImage2dArrayDepthRO = 127,
3264 CXType_OCLImage2dMSAARO = 128,
3265 CXType_OCLImage2dArrayMSAARO = 129,
3266 CXType_OCLImage2dMSAADepthRO = 130,
3267 CXType_OCLImage2dArrayMSAADepthRO = 131,
3268 CXType_OCLImage3dRO = 132,
3269 CXType_OCLImage1dWO = 133,
3270 CXType_OCLImage1dArrayWO = 134,
3271 CXType_OCLImage1dBufferWO = 135,
3272 CXType_OCLImage2dWO = 136,
3273 CXType_OCLImage2dArrayWO = 137,
3274 CXType_OCLImage2dDepthWO = 138,
3275 CXType_OCLImage2dArrayDepthWO = 139,
3276 CXType_OCLImage2dMSAAWO = 140,
3277 CXType_OCLImage2dArrayMSAAWO = 141,
3278 CXType_OCLImage2dMSAADepthWO = 142,
3279 CXType_OCLImage2dArrayMSAADepthWO = 143,
3280 CXType_OCLImage3dWO = 144,
3281 CXType_OCLImage1dRW = 145,
3282 CXType_OCLImage1dArrayRW = 146,
3283 CXType_OCLImage1dBufferRW = 147,
3284 CXType_OCLImage2dRW = 148,
3285 CXType_OCLImage2dArrayRW = 149,
3286 CXType_OCLImage2dDepthRW = 150,
3287 CXType_OCLImage2dArrayDepthRW = 151,
3288 CXType_OCLImage2dMSAARW = 152,
3289 CXType_OCLImage2dArrayMSAARW = 153,
3290 CXType_OCLImage2dMSAADepthRW = 154,
3291 CXType_OCLImage2dArrayMSAADepthRW = 155,
3292 CXType_OCLImage3dRW = 156,
3293 CXType_OCLSampler = 157,
3294 CXType_OCLEvent = 158,
3295 CXType_OCLQueue = 159,
Michael Wu9c852612018-08-03 03:03:20 +00003296 CXType_OCLReserveID = 160,
3297
Michael Wuced99b92018-08-03 04:02:40 +00003298 CXType_ObjCObject = 161,
Michael Wu153085d2018-08-03 04:21:25 +00003299 CXType_ObjCTypeParam = 162,
Andrew Savonichev3fee3512018-11-08 11:25:41 +00003300 CXType_Attributed = 163,
3301
3302 CXType_OCLIntelSubgroupAVCMcePayload = 164,
3303 CXType_OCLIntelSubgroupAVCImePayload = 165,
3304 CXType_OCLIntelSubgroupAVCRefPayload = 166,
3305 CXType_OCLIntelSubgroupAVCSicPayload = 167,
3306 CXType_OCLIntelSubgroupAVCMceResult = 168,
3307 CXType_OCLIntelSubgroupAVCImeResult = 169,
3308 CXType_OCLIntelSubgroupAVCRefResult = 170,
3309 CXType_OCLIntelSubgroupAVCSicResult = 171,
3310 CXType_OCLIntelSubgroupAVCImeResultSingleRefStreamout = 172,
3311 CXType_OCLIntelSubgroupAVCImeResultDualRefStreamout = 173,
3312 CXType_OCLIntelSubgroupAVCImeSingleRefStreamin = 174,
3313
3314 CXType_OCLIntelSubgroupAVCImeDualRefStreamin = 175
Ted Kremenek6bca9842010-05-14 21:29:26 +00003315};
3316
3317/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003318 * Describes the calling convention of a function type
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003319 */
3320enum CXCallingConv {
3321 CXCallingConv_Default = 0,
3322 CXCallingConv_C = 1,
3323 CXCallingConv_X86StdCall = 2,
3324 CXCallingConv_X86FastCall = 3,
3325 CXCallingConv_X86ThisCall = 4,
3326 CXCallingConv_X86Pascal = 5,
3327 CXCallingConv_AAPCS = 6,
3328 CXCallingConv_AAPCS_VFP = 7,
Erich Keane757d3172016-11-02 18:29:35 +00003329 CXCallingConv_X86RegCall = 8,
Guy Benyeif0a014b2012-12-25 08:53:55 +00003330 CXCallingConv_IntelOclBicc = 9,
Martin Storsjo022e7822017-07-17 20:49:45 +00003331 CXCallingConv_Win64 = 10,
Nikolai Bozhenovce25d412017-08-08 14:13:50 +00003332 /* Alias for compatibility with older versions of API. */
3333 CXCallingConv_X86_64Win64 = CXCallingConv_Win64,
Charles Davisb5a214e2013-08-30 04:39:01 +00003334 CXCallingConv_X86_64SysV = 11,
Reid Klecknerd7857f02014-10-24 17:42:17 +00003335 CXCallingConv_X86VectorCall = 12,
John McCall477f2bb2016-03-03 06:39:32 +00003336 CXCallingConv_Swift = 13,
Roman Levenstein35aa5ce2016-03-16 18:00:46 +00003337 CXCallingConv_PreserveMost = 14,
3338 CXCallingConv_PreserveAll = 15,
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003339
3340 CXCallingConv_Invalid = 100,
3341 CXCallingConv_Unexposed = 200
3342};
3343
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003344/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003345 * The type of an element in the abstract syntax tree.
Ted Kremenek6bca9842010-05-14 21:29:26 +00003346 *
3347 */
3348typedef struct {
3349 enum CXTypeKind kind;
3350 void *data[2];
3351} CXType;
3352
3353/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003354 * Retrieve the type of a CXCursor (if any).
Ted Kremenek6bca9842010-05-14 21:29:26 +00003355 */
3356CINDEX_LINKAGE CXType clang_getCursorType(CXCursor C);
3357
3358/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003359 * Pretty-print the underlying type using the rules of the
Dmitri Gribenko00353722013-02-15 21:15:49 +00003360 * language of the translation unit from which it came.
3361 *
3362 * If the type is invalid, an empty string is returned.
3363 */
3364CINDEX_LINKAGE CXString clang_getTypeSpelling(CXType CT);
3365
3366/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003367 * Retrieve the underlying type of a typedef declaration.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003368 *
3369 * If the cursor does not reference a typedef declaration, an invalid type is
3370 * returned.
3371 */
3372CINDEX_LINKAGE CXType clang_getTypedefDeclUnderlyingType(CXCursor C);
3373
3374/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003375 * Retrieve the integer type of an enum declaration.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003376 *
3377 * If the cursor does not reference an enum declaration, an invalid type is
3378 * returned.
3379 */
3380CINDEX_LINKAGE CXType clang_getEnumDeclIntegerType(CXCursor C);
3381
3382/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003383 * Retrieve the integer value of an enum constant declaration as a signed
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003384 * long long.
3385 *
3386 * If the cursor does not reference an enum constant declaration, LLONG_MIN is returned.
3387 * Since this is also potentially a valid constant value, the kind of the cursor
3388 * must be verified before calling this function.
3389 */
3390CINDEX_LINKAGE long long clang_getEnumConstantDeclValue(CXCursor C);
3391
3392/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003393 * Retrieve the integer value of an enum constant declaration as an unsigned
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003394 * long long.
3395 *
3396 * If the cursor does not reference an enum constant declaration, ULLONG_MAX is returned.
3397 * Since this is also potentially a valid constant value, the kind of the cursor
3398 * must be verified before calling this function.
3399 */
3400CINDEX_LINKAGE unsigned long long clang_getEnumConstantDeclUnsignedValue(CXCursor C);
3401
3402/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003403 * Retrieve the bit width of a bit field declaration as an integer.
Dmitri Gribenkob506ba12012-12-04 15:13:46 +00003404 *
3405 * If a cursor that is not a bit field declaration is passed in, -1 is returned.
3406 */
3407CINDEX_LINKAGE int clang_getFieldDeclBitWidth(CXCursor C);
3408
3409/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003410 * Retrieve the number of non-variadic arguments associated with a given
Argyrios Kyrtzidis0c27e4b2012-04-11 19:32:19 +00003411 * cursor.
3412 *
Argyrios Kyrtzidisb2792972013-04-01 17:38:59 +00003413 * The number of arguments can be determined for calls as well as for
3414 * declarations of functions or methods. For other cursors -1 is returned.
Argyrios Kyrtzidis0c27e4b2012-04-11 19:32:19 +00003415 */
3416CINDEX_LINKAGE int clang_Cursor_getNumArguments(CXCursor C);
3417
3418/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003419 * Retrieve the argument cursor of a function or method.
Argyrios Kyrtzidis0c27e4b2012-04-11 19:32:19 +00003420 *
Argyrios Kyrtzidisb2792972013-04-01 17:38:59 +00003421 * The argument cursor can be determined for calls as well as for declarations
3422 * of functions or methods. For other cursors and for invalid indices, an
3423 * invalid cursor is returned.
Argyrios Kyrtzidis0c27e4b2012-04-11 19:32:19 +00003424 */
3425CINDEX_LINKAGE CXCursor clang_Cursor_getArgument(CXCursor C, unsigned i);
3426
3427/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003428 * Describes the kind of a template argument.
Eli Benderskyc27a0c42014-10-10 20:01:05 +00003429 *
3430 * See the definition of llvm::clang::TemplateArgument::ArgKind for full
3431 * element descriptions.
3432 */
3433enum CXTemplateArgumentKind {
3434 CXTemplateArgumentKind_Null,
3435 CXTemplateArgumentKind_Type,
3436 CXTemplateArgumentKind_Declaration,
3437 CXTemplateArgumentKind_NullPtr,
3438 CXTemplateArgumentKind_Integral,
3439 CXTemplateArgumentKind_Template,
3440 CXTemplateArgumentKind_TemplateExpansion,
3441 CXTemplateArgumentKind_Expression,
3442 CXTemplateArgumentKind_Pack,
3443 /* Indicates an error case, preventing the kind from being deduced. */
3444 CXTemplateArgumentKind_Invalid
3445};
3446
3447/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003448 *Returns the number of template args of a function decl representing a
Eli Benderskyc27a0c42014-10-10 20:01:05 +00003449 * template specialization.
3450 *
3451 * If the argument cursor cannot be converted into a template function
3452 * declaration, -1 is returned.
3453 *
3454 * For example, for the following declaration and specialization:
3455 * template <typename T, int kInt, bool kBool>
3456 * void foo() { ... }
3457 *
3458 * template <>
3459 * void foo<float, -7, true>();
3460 *
3461 * The value 3 would be returned from this call.
3462 */
3463CINDEX_LINKAGE int clang_Cursor_getNumTemplateArguments(CXCursor C);
3464
3465/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003466 * Retrieve the kind of the I'th template argument of the CXCursor C.
Eli Benderskyc27a0c42014-10-10 20:01:05 +00003467 *
3468 * If the argument CXCursor does not represent a FunctionDecl, an invalid
3469 * template argument kind is returned.
3470 *
3471 * For example, for the following declaration and specialization:
3472 * template <typename T, int kInt, bool kBool>
3473 * void foo() { ... }
3474 *
3475 * template <>
3476 * void foo<float, -7, true>();
3477 *
3478 * For I = 0, 1, and 2, Type, Integral, and Integral will be returned,
3479 * respectively.
3480 */
3481CINDEX_LINKAGE enum CXTemplateArgumentKind clang_Cursor_getTemplateArgumentKind(
3482 CXCursor C, unsigned I);
3483
3484/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003485 * Retrieve a CXType representing the type of a TemplateArgument of a
Eli Benderskyc27a0c42014-10-10 20:01:05 +00003486 * function decl representing a template specialization.
3487 *
3488 * If the argument CXCursor does not represent a FunctionDecl whose I'th
3489 * template argument has a kind of CXTemplateArgKind_Integral, an invalid type
3490 * is returned.
3491 *
3492 * For example, for the following declaration and specialization:
3493 * template <typename T, int kInt, bool kBool>
3494 * void foo() { ... }
3495 *
3496 * template <>
3497 * void foo<float, -7, true>();
3498 *
3499 * If called with I = 0, "float", will be returned.
3500 * Invalid types will be returned for I == 1 or 2.
3501 */
3502CINDEX_LINKAGE CXType clang_Cursor_getTemplateArgumentType(CXCursor C,
3503 unsigned I);
3504
3505/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003506 * Retrieve the value of an Integral TemplateArgument (of a function
Eli Benderskyc27a0c42014-10-10 20:01:05 +00003507 * decl representing a template specialization) as a signed long long.
3508 *
3509 * It is undefined to call this function on a CXCursor that does not represent a
3510 * FunctionDecl or whose I'th template argument is not an integral value.
3511 *
3512 * For example, for the following declaration and specialization:
3513 * template <typename T, int kInt, bool kBool>
3514 * void foo() { ... }
3515 *
3516 * template <>
3517 * void foo<float, -7, true>();
3518 *
3519 * If called with I = 1 or 2, -7 or true will be returned, respectively.
3520 * For I == 0, this function's behavior is undefined.
3521 */
3522CINDEX_LINKAGE long long clang_Cursor_getTemplateArgumentValue(CXCursor C,
3523 unsigned I);
3524
3525/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003526 * Retrieve the value of an Integral TemplateArgument (of a function
Eli Benderskyc27a0c42014-10-10 20:01:05 +00003527 * decl representing a template specialization) as an unsigned long long.
3528 *
3529 * It is undefined to call this function on a CXCursor that does not represent a
3530 * FunctionDecl or whose I'th template argument is not an integral value.
3531 *
3532 * For example, for the following declaration and specialization:
3533 * template <typename T, int kInt, bool kBool>
3534 * void foo() { ... }
3535 *
3536 * template <>
3537 * void foo<float, 2147483649, true>();
3538 *
3539 * If called with I = 1 or 2, 2147483649 or true will be returned, respectively.
3540 * For I == 0, this function's behavior is undefined.
3541 */
3542CINDEX_LINKAGE unsigned long long clang_Cursor_getTemplateArgumentUnsignedValue(
3543 CXCursor C, unsigned I);
3544
3545/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003546 * Determine whether two CXTypes represent the same type.
Ted Kremenek6bca9842010-05-14 21:29:26 +00003547 *
James Dennett574cb4c2012-06-15 05:41:51 +00003548 * \returns non-zero if the CXTypes represent the same type and
3549 * zero otherwise.
Ted Kremenek6bca9842010-05-14 21:29:26 +00003550 */
3551CINDEX_LINKAGE unsigned clang_equalTypes(CXType A, CXType B);
3552
3553/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003554 * Return the canonical type for a CXType.
Ted Kremenek6bca9842010-05-14 21:29:26 +00003555 *
3556 * Clang's type system explicitly models typedefs and all the ways
3557 * a specific type can be represented. The canonical type is the underlying
3558 * type with all the "sugar" removed. For example, if 'T' is a typedef
3559 * for 'int', the canonical type for 'T' would be 'int'.
3560 */
3561CINDEX_LINKAGE CXType clang_getCanonicalType(CXType T);
3562
3563/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003564 * Determine whether a CXType has the "const" qualifier set,
James Dennett574cb4c2012-06-15 05:41:51 +00003565 * without looking through typedefs that may have added "const" at a
3566 * different level.
Douglas Gregor56a63802011-01-27 16:27:11 +00003567 */
3568CINDEX_LINKAGE unsigned clang_isConstQualifiedType(CXType T);
3569
3570/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003571 * Determine whether a CXCursor that is a macro, is
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00003572 * function like.
3573 */
3574CINDEX_LINKAGE unsigned clang_Cursor_isMacroFunctionLike(CXCursor C);
3575
3576/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003577 * Determine whether a CXCursor that is a macro, is a
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00003578 * builtin one.
3579 */
3580CINDEX_LINKAGE unsigned clang_Cursor_isMacroBuiltin(CXCursor C);
3581
3582/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003583 * Determine whether a CXCursor that is a function declaration, is an
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00003584 * inline declaration.
3585 */
3586CINDEX_LINKAGE unsigned clang_Cursor_isFunctionInlined(CXCursor C);
3587
3588/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003589 * Determine whether a CXType has the "volatile" qualifier set,
James Dennett574cb4c2012-06-15 05:41:51 +00003590 * without looking through typedefs that may have added "volatile" at
3591 * a different level.
Douglas Gregor56a63802011-01-27 16:27:11 +00003592 */
3593CINDEX_LINKAGE unsigned clang_isVolatileQualifiedType(CXType T);
3594
3595/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003596 * Determine whether a CXType has the "restrict" qualifier set,
James Dennett574cb4c2012-06-15 05:41:51 +00003597 * without looking through typedefs that may have added "restrict" at a
3598 * different level.
Douglas Gregor56a63802011-01-27 16:27:11 +00003599 */
3600CINDEX_LINKAGE unsigned clang_isRestrictQualifiedType(CXType T);
3601
3602/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003603 * Returns the address space of the given type.
Sven van Haastregte8910422017-06-08 14:22:04 +00003604 */
3605CINDEX_LINKAGE unsigned clang_getAddressSpace(CXType T);
3606
3607/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003608 * Returns the typedef name of the given type.
Sven van Haastregte8910422017-06-08 14:22:04 +00003609 */
3610CINDEX_LINKAGE CXString clang_getTypedefName(CXType CT);
3611
3612/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003613 * For pointer types, returns the type of the pointee.
Ted Kremenek6bca9842010-05-14 21:29:26 +00003614 */
3615CINDEX_LINKAGE CXType clang_getPointeeType(CXType T);
3616
3617/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003618 * Return the cursor for the declaration of the given type.
Ted Kremenek6bca9842010-05-14 21:29:26 +00003619 */
3620CINDEX_LINKAGE CXCursor clang_getTypeDeclaration(CXType T);
3621
David Chisnall50e4eba2010-12-30 14:05:53 +00003622/**
3623 * Returns the Objective-C type encoding for the specified declaration.
3624 */
3625CINDEX_LINKAGE CXString clang_getDeclObjCTypeEncoding(CXCursor C);
Ted Kremenek6bca9842010-05-14 21:29:26 +00003626
3627/**
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00003628 * Returns the Objective-C type encoding for the specified CXType.
3629 */
Fangrui Song6907ce22018-07-30 19:24:48 +00003630CINDEX_LINKAGE CXString clang_Type_getObjCEncoding(CXType type);
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00003631
3632/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003633 * Retrieve the spelling of a given CXTypeKind.
Ted Kremenek6bca9842010-05-14 21:29:26 +00003634 */
3635CINDEX_LINKAGE CXString clang_getTypeKindSpelling(enum CXTypeKind K);
3636
3637/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003638 * Retrieve the calling convention associated with a function type.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003639 *
3640 * If a non-function type is passed in, CXCallingConv_Invalid is returned.
3641 */
3642CINDEX_LINKAGE enum CXCallingConv clang_getFunctionTypeCallingConv(CXType T);
3643
3644/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003645 * Retrieve the return type associated with a function type.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003646 *
3647 * If a non-function type is passed in, an invalid type is returned.
Ted Kremenekc1508872010-06-21 20:15:39 +00003648 */
3649CINDEX_LINKAGE CXType clang_getResultType(CXType T);
3650
3651/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003652 * Retrieve the exception specification type associated with a function type.
Richard Smitheedb0c92018-05-11 19:46:31 +00003653 * This is a value of type CXCursor_ExceptionSpecificationKind.
Jonathan Coe0a5b03b2017-06-27 22:54:56 +00003654 *
3655 * If a non-function type is passed in, an error code of -1 is returned.
3656 */
3657CINDEX_LINKAGE int clang_getExceptionSpecificationType(CXType T);
3658
3659/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003660 * Retrieve the number of non-variadic parameters associated with a
James Dennett574cb4c2012-06-15 05:41:51 +00003661 * function type.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003662 *
Argyrios Kyrtzidis0c27e4b2012-04-11 19:32:19 +00003663 * If a non-function type is passed in, -1 is returned.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003664 */
Argyrios Kyrtzidis0c27e4b2012-04-11 19:32:19 +00003665CINDEX_LINKAGE int clang_getNumArgTypes(CXType T);
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003666
3667/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003668 * Retrieve the type of a parameter of a function type.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003669 *
James Dennett574cb4c2012-06-15 05:41:51 +00003670 * If a non-function type is passed in or the function does not have enough
3671 * parameters, an invalid type is returned.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003672 */
3673CINDEX_LINKAGE CXType clang_getArgType(CXType T, unsigned i);
3674
3675/**
Michael Wu9c852612018-08-03 03:03:20 +00003676 * Retrieves the base type of the ObjCObjectType.
3677 *
3678 * If the type is not an ObjC object, an invalid type is returned.
3679 */
3680CINDEX_LINKAGE CXType clang_Type_getObjCObjectBaseType(CXType T);
3681
3682/**
3683 * Retrieve the number of protocol references associated with an ObjC object/id.
3684 *
3685 * If the type is not an ObjC object, 0 is returned.
3686 */
3687CINDEX_LINKAGE unsigned clang_Type_getNumObjCProtocolRefs(CXType T);
3688
3689/**
3690 * Retrieve the decl for a protocol reference for an ObjC object/id.
3691 *
3692 * If the type is not an ObjC object or there are not enough protocol
3693 * references, an invalid cursor is returned.
3694 */
3695CINDEX_LINKAGE CXCursor clang_Type_getObjCProtocolDecl(CXType T, unsigned i);
3696
3697/**
3698 * Retreive the number of type arguments associated with an ObjC object.
3699 *
3700 * If the type is not an ObjC object, 0 is returned.
3701 */
3702CINDEX_LINKAGE unsigned clang_Type_getNumObjCTypeArgs(CXType T);
3703
3704/**
3705 * Retrieve a type argument associated with an ObjC object.
3706 *
3707 * If the type is not an ObjC or the index is not valid,
3708 * an invalid type is returned.
3709 */
3710CINDEX_LINKAGE CXType clang_Type_getObjCTypeArg(CXType T, unsigned i);
3711
3712/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003713 * Return 1 if the CXType is a variadic function type, and 0 otherwise.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003714 */
3715CINDEX_LINKAGE unsigned clang_isFunctionTypeVariadic(CXType T);
3716
3717/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003718 * Retrieve the return type associated with a given cursor.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003719 *
3720 * This only returns a valid type if the cursor refers to a function or method.
Ted Kremenekc62ab8d2010-06-21 20:48:56 +00003721 */
3722CINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C);
3723
3724/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003725 * Retrieve the exception specification type associated with a given cursor.
Richard Smitheedb0c92018-05-11 19:46:31 +00003726 * This is a value of type CXCursor_ExceptionSpecificationKind.
Jonathan Coe0a5b03b2017-06-27 22:54:56 +00003727 *
3728 * This only returns a valid result if the cursor refers to a function or method.
3729 */
3730CINDEX_LINKAGE int clang_getCursorExceptionSpecificationType(CXCursor C);
3731
3732/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003733 * Return 1 if the CXType is a POD (plain old data) type, and 0
Ted Kremenek0c7476a2010-07-30 00:14:11 +00003734 * otherwise.
3735 */
3736CINDEX_LINKAGE unsigned clang_isPODType(CXType T);
3737
3738/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003739 * Return the element type of an array, complex, or vector type.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003740 *
3741 * If a type is passed in that is not an array, complex, or vector type,
3742 * an invalid type is returned.
3743 */
3744CINDEX_LINKAGE CXType clang_getElementType(CXType T);
3745
3746/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003747 * Return the number of elements of an array or vector type.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003748 *
3749 * If a type is passed in that is not an array or vector type,
3750 * -1 is returned.
3751 */
3752CINDEX_LINKAGE long long clang_getNumElements(CXType T);
3753
3754/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003755 * Return the element type of an array type.
Argyrios Kyrtzidis2b0cf602011-09-27 17:44:34 +00003756 *
3757 * If a non-array type is passed in, an invalid type is returned.
3758 */
3759CINDEX_LINKAGE CXType clang_getArrayElementType(CXType T);
3760
3761/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003762 * Return the array size of a constant array.
Argyrios Kyrtzidis2b0cf602011-09-27 17:44:34 +00003763 *
3764 * If a non-array type is passed in, -1 is returned.
3765 */
3766CINDEX_LINKAGE long long clang_getArraySize(CXType T);
3767
3768/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003769 * Retrieve the type named by the qualified-id.
Sergey Kalinichev69770ae2016-05-03 06:58:29 +00003770 *
3771 * If a non-elaborated type is passed in, an invalid type is returned.
3772 */
3773CINDEX_LINKAGE CXType clang_Type_getNamedType(CXType T);
3774
3775/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003776 * Determine if a typedef is 'transparent' tag.
Argyrios Kyrtzidis3b25c912017-03-21 16:56:02 +00003777 *
3778 * A typedef is considered 'transparent' if it shares a name and spelling
3779 * location with its underlying tag type, as is the case with the NS_ENUM macro.
3780 *
3781 * \returns non-zero if transparent and zero otherwise.
3782 */
3783CINDEX_LINKAGE unsigned clang_Type_isTransparentTagTypedef(CXType T);
3784
Michael Wu7649e622018-08-03 04:38:04 +00003785enum CXTypeNullabilityKind {
3786 /**
3787 * Values of this type can never be null.
3788 */
3789 CXTypeNullability_NonNull = 0,
3790 /**
3791 * Values of this type can be null.
3792 */
3793 CXTypeNullability_Nullable = 1,
3794 /**
3795 * Whether values of this type can be null is (explicitly)
3796 * unspecified. This captures a (fairly rare) case where we
3797 * can't conclude anything about the nullability of the type even
3798 * though it has been considered.
3799 */
3800 CXTypeNullability_Unspecified = 2,
3801 /**
3802 * Nullability is not applicable to this type.
3803 */
3804 CXTypeNullability_Invalid = 3
3805};
3806
3807/**
3808 * Retrieve the nullability kind of a pointer type.
3809 */
3810CINDEX_LINKAGE enum CXTypeNullabilityKind clang_Type_getNullability(CXType T);
3811
Argyrios Kyrtzidis3b25c912017-03-21 16:56:02 +00003812/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003813 * List the possible error codes for \c clang_Type_getSizeOf,
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003814 * \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf and
3815 * \c clang_Cursor_getOffsetOf.
3816 *
3817 * A value of this enumeration type can be returned if the target type is not
3818 * a valid argument to sizeof, alignof or offsetof.
3819 */
3820enum CXTypeLayoutError {
3821 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003822 * Type is of kind CXType_Invalid.
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003823 */
3824 CXTypeLayoutError_Invalid = -1,
3825 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003826 * The type is an incomplete Type.
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003827 */
3828 CXTypeLayoutError_Incomplete = -2,
3829 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003830 * The type is a dependent Type.
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003831 */
3832 CXTypeLayoutError_Dependent = -3,
3833 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003834 * The type is not a constant size type.
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003835 */
3836 CXTypeLayoutError_NotConstantSize = -4,
3837 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003838 * The Field name is not valid for this record.
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003839 */
3840 CXTypeLayoutError_InvalidFieldName = -5
3841};
3842
3843/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003844 * Return the alignment of a type in bytes as per C++[expr.alignof]
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003845 * standard.
3846 *
3847 * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
3848 * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
3849 * is returned.
3850 * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
3851 * returned.
3852 * If the type declaration is not a constant size type,
3853 * CXTypeLayoutError_NotConstantSize is returned.
3854 */
3855CINDEX_LINKAGE long long clang_Type_getAlignOf(CXType T);
3856
3857/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003858 * Return the class type of an member pointer type.
Argyrios Kyrtzidis7a4253b2013-10-03 16:19:23 +00003859 *
3860 * If a non-member-pointer type is passed in, an invalid type is returned.
3861 */
3862CINDEX_LINKAGE CXType clang_Type_getClassType(CXType T);
3863
3864/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003865 * Return the size of a type in bytes as per C++[expr.sizeof] standard.
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003866 *
3867 * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
3868 * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
3869 * is returned.
3870 * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
3871 * returned.
3872 */
3873CINDEX_LINKAGE long long clang_Type_getSizeOf(CXType T);
3874
3875/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003876 * Return the offset of a field named S in a record of type T in bits
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003877 * as it would be returned by __offsetof__ as per C++11[18.2p4]
3878 *
3879 * If the cursor is not a record field declaration, CXTypeLayoutError_Invalid
3880 * is returned.
3881 * If the field's type declaration is an incomplete type,
3882 * CXTypeLayoutError_Incomplete is returned.
3883 * If the field's type declaration is a dependent type,
3884 * CXTypeLayoutError_Dependent is returned.
3885 * If the field's name S is not found,
3886 * CXTypeLayoutError_InvalidFieldName is returned.
3887 */
3888CINDEX_LINKAGE long long clang_Type_getOffsetOf(CXType T, const char *S);
3889
Argyrios Kyrtzidis2bff5162015-04-13 16:55:04 +00003890/**
Michael Wu153085d2018-08-03 04:21:25 +00003891 * Return the type that was modified by this attributed type.
3892 *
3893 * If the type is not an attributed type, an invalid type is returned.
3894 */
3895CINDEX_LINKAGE CXType clang_Type_getModifiedType(CXType T);
3896
3897/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003898 * Return the offset of the field represented by the Cursor.
Argyrios Kyrtzidis2bff5162015-04-13 16:55:04 +00003899 *
3900 * If the cursor is not a field declaration, -1 is returned.
3901 * If the cursor semantic parent is not a record field declaration,
3902 * CXTypeLayoutError_Invalid is returned.
3903 * If the field's type declaration is an incomplete type,
3904 * CXTypeLayoutError_Incomplete is returned.
3905 * If the field's type declaration is a dependent type,
3906 * CXTypeLayoutError_Dependent is returned.
3907 * If the field's name S is not found,
3908 * CXTypeLayoutError_InvalidFieldName is returned.
3909 */
3910CINDEX_LINKAGE long long clang_Cursor_getOffsetOfField(CXCursor C);
3911
3912/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003913 * Determine whether the given cursor represents an anonymous record
Argyrios Kyrtzidis2bff5162015-04-13 16:55:04 +00003914 * declaration.
3915 */
3916CINDEX_LINKAGE unsigned clang_Cursor_isAnonymous(CXCursor C);
3917
Argyrios Kyrtzidisadff3ae2013-10-11 19:58:38 +00003918enum CXRefQualifierKind {
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003919 /** No ref-qualifier was provided. */
Argyrios Kyrtzidisadff3ae2013-10-11 19:58:38 +00003920 CXRefQualifier_None = 0,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003921 /** An lvalue ref-qualifier was provided (\c &). */
Argyrios Kyrtzidisadff3ae2013-10-11 19:58:38 +00003922 CXRefQualifier_LValue,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003923 /** An rvalue ref-qualifier was provided (\c &&). */
Argyrios Kyrtzidisadff3ae2013-10-11 19:58:38 +00003924 CXRefQualifier_RValue
3925};
3926
3927/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003928 * Returns the number of template arguments for given template
Argyrios Kyrtzidis35f5aab2016-11-15 20:51:46 +00003929 * specialization, or -1 if type \c T is not a template specialization.
Dmitri Gribenko6ede6ab2014-02-27 16:05:05 +00003930 */
3931CINDEX_LINKAGE int clang_Type_getNumTemplateArguments(CXType T);
3932
3933/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003934 * Returns the type template argument of a template class specialization
Dmitri Gribenko6ede6ab2014-02-27 16:05:05 +00003935 * at given index.
3936 *
3937 * This function only returns template type arguments and does not handle
3938 * template template arguments or variadic packs.
3939 */
3940CINDEX_LINKAGE CXType clang_Type_getTemplateArgumentAsType(CXType T, unsigned i);
3941
3942/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003943 * Retrieve the ref-qualifier kind of a function or method.
Argyrios Kyrtzidisadff3ae2013-10-11 19:58:38 +00003944 *
3945 * The ref-qualifier is returned for C++ functions or methods. For other types
3946 * or non-C++ declarations, CXRefQualifier_None is returned.
3947 */
3948CINDEX_LINKAGE enum CXRefQualifierKind clang_Type_getCXXRefQualifier(CXType T);
3949
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003950/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003951 * Returns non-zero if the cursor specifies a Record member that is a
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003952 * bitfield.
3953 */
3954CINDEX_LINKAGE unsigned clang_Cursor_isBitField(CXCursor C);
3955
3956/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003957 * Returns 1 if the base class specified by the cursor with kind
Ted Kremenekae9e2212010-08-27 21:34:58 +00003958 * CX_CXXBaseSpecifier is virtual.
3959 */
3960CINDEX_LINKAGE unsigned clang_isVirtualBase(CXCursor);
Fangrui Song6907ce22018-07-30 19:24:48 +00003961
Ted Kremenekae9e2212010-08-27 21:34:58 +00003962/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003963 * Represents the C++ access control level to a base class for a
Ted Kremenekae9e2212010-08-27 21:34:58 +00003964 * cursor with kind CX_CXXBaseSpecifier.
3965 */
3966enum CX_CXXAccessSpecifier {
3967 CX_CXXInvalidAccessSpecifier,
3968 CX_CXXPublic,
3969 CX_CXXProtected,
3970 CX_CXXPrivate
3971};
3972
3973/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003974 * Returns the access control level for the referenced object.
Argyrios Kyrtzidisf6464082013-04-11 17:31:13 +00003975 *
Argyrios Kyrtzidis1ab09cc2013-04-11 17:02:10 +00003976 * If the cursor refers to a C++ declaration, its access control level within its
3977 * parent scope is returned. Otherwise, if the cursor refers to a base specifier or
3978 * access specifier, the specifier itself is returned.
Ted Kremenekae9e2212010-08-27 21:34:58 +00003979 */
3980CINDEX_LINKAGE enum CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor);
3981
3982/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003983 * Represents the storage classes as declared in the source. CX_SC_Invalid
Chad Rosierdb1cc7f2014-12-05 15:50:44 +00003984 * was added for the case that the passed cursor in not a declaration.
Argyrios Kyrtzidis4e0854f2014-10-15 17:05:31 +00003985 */
3986enum CX_StorageClass {
3987 CX_SC_Invalid,
3988 CX_SC_None,
3989 CX_SC_Extern,
3990 CX_SC_Static,
3991 CX_SC_PrivateExtern,
3992 CX_SC_OpenCLWorkGroupLocal,
3993 CX_SC_Auto,
3994 CX_SC_Register
3995};
3996
3997/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003998 * Returns the storage class for a function or variable declaration.
Argyrios Kyrtzidis4e0854f2014-10-15 17:05:31 +00003999 *
4000 * If the passed in Cursor is not a function or variable declaration,
4001 * CX_SC_Invalid is returned else the storage class.
4002 */
4003CINDEX_LINKAGE enum CX_StorageClass clang_Cursor_getStorageClass(CXCursor);
4004
4005/**
Fangrui Song6907ce22018-07-30 19:24:48 +00004006 * Determine the number of overloaded declarations referenced by a
Douglas Gregor16a2bdd2010-09-13 22:52:57 +00004007 * \c CXCursor_OverloadedDeclRef cursor.
4008 *
4009 * \param cursor The cursor whose overloaded declarations are being queried.
4010 *
4011 * \returns The number of overloaded declarations referenced by \c cursor. If it
4012 * is not a \c CXCursor_OverloadedDeclRef cursor, returns 0.
4013 */
4014CINDEX_LINKAGE unsigned clang_getNumOverloadedDecls(CXCursor cursor);
4015
4016/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004017 * Retrieve a cursor for one of the overloaded declarations referenced
Douglas Gregor16a2bdd2010-09-13 22:52:57 +00004018 * by a \c CXCursor_OverloadedDeclRef cursor.
4019 *
4020 * \param cursor The cursor whose overloaded declarations are being queried.
4021 *
4022 * \param index The zero-based index into the set of overloaded declarations in
4023 * the cursor.
4024 *
Fangrui Song6907ce22018-07-30 19:24:48 +00004025 * \returns A cursor representing the declaration referenced by the given
4026 * \c cursor at the specified \c index. If the cursor does not have an
Douglas Gregor16a2bdd2010-09-13 22:52:57 +00004027 * associated set of overloaded declarations, or if the index is out of bounds,
4028 * returns \c clang_getNullCursor();
4029 */
Fangrui Song6907ce22018-07-30 19:24:48 +00004030CINDEX_LINKAGE CXCursor clang_getOverloadedDecl(CXCursor cursor,
Douglas Gregor16a2bdd2010-09-13 22:52:57 +00004031 unsigned index);
Fangrui Song6907ce22018-07-30 19:24:48 +00004032
Douglas Gregor16a2bdd2010-09-13 22:52:57 +00004033/**
Ted Kremenek6bca9842010-05-14 21:29:26 +00004034 * @}
4035 */
Fangrui Song6907ce22018-07-30 19:24:48 +00004036
Ted Kremeneka5940822010-08-26 01:42:22 +00004037/**
Ted Kremenek2c2c5f32010-08-27 21:34:51 +00004038 * \defgroup CINDEX_ATTRIBUTES Information for attributes
Ted Kremeneka5940822010-08-26 01:42:22 +00004039 *
4040 * @{
4041 */
4042
Ted Kremeneka5940822010-08-26 01:42:22 +00004043/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004044 * For cursors representing an iboutletcollection attribute,
Ted Kremeneka5940822010-08-26 01:42:22 +00004045 * this function returns the collection element type.
4046 *
4047 */
4048CINDEX_LINKAGE CXType clang_getIBOutletCollectionType(CXCursor);
4049
4050/**
4051 * @}
4052 */
Ted Kremenek6bca9842010-05-14 21:29:26 +00004053
4054/**
Douglas Gregor6007cf22010-01-22 22:29:16 +00004055 * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors
4056 *
4057 * These routines provide the ability to traverse the abstract syntax tree
4058 * using cursors.
4059 *
4060 * @{
4061 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004062
Douglas Gregor6007cf22010-01-22 22:29:16 +00004063/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004064 * Describes how the traversal of the children of a particular
Douglas Gregor6007cf22010-01-22 22:29:16 +00004065 * cursor should proceed after visiting a particular child cursor.
4066 *
4067 * A value of this enumeration type should be returned by each
4068 * \c CXCursorVisitor to indicate how clang_visitChildren() proceed.
4069 */
4070enum CXChildVisitResult {
4071 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004072 * Terminates the cursor traversal.
Douglas Gregor6007cf22010-01-22 22:29:16 +00004073 */
4074 CXChildVisit_Break,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004075 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004076 * Continues the cursor traversal with the next sibling of
Douglas Gregor6007cf22010-01-22 22:29:16 +00004077 * the cursor just visited, without visiting its children.
4078 */
4079 CXChildVisit_Continue,
4080 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004081 * Recursively traverse the children of this cursor, using
Douglas Gregor6007cf22010-01-22 22:29:16 +00004082 * the same visitor and client data.
4083 */
4084 CXChildVisit_Recurse
4085};
4086
4087/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004088 * Visitor invoked for each cursor found by a traversal.
Douglas Gregor6007cf22010-01-22 22:29:16 +00004089 *
4090 * This visitor function will be invoked for each cursor found by
4091 * clang_visitCursorChildren(). Its first argument is the cursor being
4092 * visited, its second argument is the parent visitor for that cursor,
4093 * and its third argument is the client data provided to
4094 * clang_visitCursorChildren().
4095 *
4096 * The visitor should return one of the \c CXChildVisitResult values
4097 * to direct clang_visitCursorChildren().
4098 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004099typedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor,
4100 CXCursor parent,
Douglas Gregor6007cf22010-01-22 22:29:16 +00004101 CXClientData client_data);
4102
4103/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004104 * Visit the children of a particular cursor.
Douglas Gregor6007cf22010-01-22 22:29:16 +00004105 *
4106 * This function visits all the direct children of the given cursor,
4107 * invoking the given \p visitor function with the cursors of each
4108 * visited child. The traversal may be recursive, if the visitor returns
4109 * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if
4110 * the visitor returns \c CXChildVisit_Break.
4111 *
Douglas Gregor6007cf22010-01-22 22:29:16 +00004112 * \param parent the cursor whose child may be visited. All kinds of
Daniel Dunbarb9999fd2010-01-24 04:10:31 +00004113 * cursors can be visited, including invalid cursors (which, by
Douglas Gregor6007cf22010-01-22 22:29:16 +00004114 * definition, have no children).
4115 *
4116 * \param visitor the visitor function that will be invoked for each
4117 * child of \p parent.
4118 *
4119 * \param client_data pointer data supplied by the client, which will
4120 * be passed to the visitor each time it is invoked.
4121 *
4122 * \returns a non-zero value if the traversal was terminated
4123 * prematurely by the visitor returning \c CXChildVisit_Break.
4124 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004125CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent,
Douglas Gregor6007cf22010-01-22 22:29:16 +00004126 CXCursorVisitor visitor,
4127 CXClientData client_data);
David Chisnallb2aa0ef2010-11-03 14:12:26 +00004128#ifdef __has_feature
4129# if __has_feature(blocks)
4130/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004131 * Visitor invoked for each cursor found by a traversal.
David Chisnallb2aa0ef2010-11-03 14:12:26 +00004132 *
4133 * This visitor block will be invoked for each cursor found by
4134 * clang_visitChildrenWithBlock(). Its first argument is the cursor being
4135 * visited, its second argument is the parent visitor for that cursor.
4136 *
4137 * The visitor should return one of the \c CXChildVisitResult values
4138 * to direct clang_visitChildrenWithBlock().
4139 */
Fangrui Song6907ce22018-07-30 19:24:48 +00004140typedef enum CXChildVisitResult
David Chisnallb2aa0ef2010-11-03 14:12:26 +00004141 (^CXCursorVisitorBlock)(CXCursor cursor, CXCursor parent);
4142
4143/**
4144 * Visits the children of a cursor using the specified block. Behaves
4145 * identically to clang_visitChildren() in all other respects.
4146 */
Argyrios Kyrtzidisa0a35d72016-02-07 18:21:28 +00004147CINDEX_LINKAGE unsigned clang_visitChildrenWithBlock(CXCursor parent,
4148 CXCursorVisitorBlock block);
David Chisnallb2aa0ef2010-11-03 14:12:26 +00004149# endif
4150#endif
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004151
Douglas Gregor6007cf22010-01-22 22:29:16 +00004152/**
4153 * @}
4154 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004155
Douglas Gregor6007cf22010-01-22 22:29:16 +00004156/**
4157 * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST
4158 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004159 * These routines provide the ability to determine references within and
Douglas Gregor6007cf22010-01-22 22:29:16 +00004160 * across translation units, by providing the names of the entities referenced
4161 * by cursors, follow reference cursors to the declarations they reference,
4162 * and associate declarations with their definitions.
4163 *
4164 * @{
4165 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004166
Douglas Gregor6007cf22010-01-22 22:29:16 +00004167/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004168 * Retrieve a Unified Symbol Resolution (USR) for the entity referenced
Douglas Gregor6007cf22010-01-22 22:29:16 +00004169 * by the given cursor.
4170 *
4171 * A Unified Symbol Resolution (USR) is a string that identifies a particular
4172 * entity (function, class, variable, etc.) within a program. USRs can be
4173 * compared across translation units to determine, e.g., when references in
4174 * one translation refer to an entity defined in another translation unit.
4175 */
4176CINDEX_LINKAGE CXString clang_getCursorUSR(CXCursor);
4177
4178/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004179 * Construct a USR for a specified Objective-C class.
Ted Kremenekd071c602010-03-13 02:50:34 +00004180 */
4181CINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name);
4182
4183/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004184 * Construct a USR for a specified Objective-C category.
Ted Kremenekd071c602010-03-13 02:50:34 +00004185 */
4186CINDEX_LINKAGE CXString
Ted Kremenekbc1a67b2010-03-15 17:38:58 +00004187 clang_constructUSR_ObjCCategory(const char *class_name,
Ted Kremenekd071c602010-03-13 02:50:34 +00004188 const char *category_name);
4189
4190/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004191 * Construct a USR for a specified Objective-C protocol.
Ted Kremenekd071c602010-03-13 02:50:34 +00004192 */
4193CINDEX_LINKAGE CXString
4194 clang_constructUSR_ObjCProtocol(const char *protocol_name);
4195
Ted Kremenekd071c602010-03-13 02:50:34 +00004196/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004197 * Construct a USR for a specified Objective-C instance variable and
Ted Kremenekd071c602010-03-13 02:50:34 +00004198 * the USR for its containing class.
4199 */
4200CINDEX_LINKAGE CXString clang_constructUSR_ObjCIvar(const char *name,
4201 CXString classUSR);
4202
4203/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004204 * Construct a USR for a specified Objective-C method and
Ted Kremenekd071c602010-03-13 02:50:34 +00004205 * the USR for its containing class.
4206 */
4207CINDEX_LINKAGE CXString clang_constructUSR_ObjCMethod(const char *name,
4208 unsigned isInstanceMethod,
4209 CXString classUSR);
4210
4211/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004212 * Construct a USR for a specified Objective-C property and the USR
Ted Kremenekd071c602010-03-13 02:50:34 +00004213 * for its containing class.
4214 */
4215CINDEX_LINKAGE CXString clang_constructUSR_ObjCProperty(const char *property,
4216 CXString classUSR);
4217
4218/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004219 * Retrieve a name for the entity referenced by this cursor.
Douglas Gregor6007cf22010-01-22 22:29:16 +00004220 */
4221CINDEX_LINKAGE CXString clang_getCursorSpelling(CXCursor);
4222
Douglas Gregor97c75712010-10-02 22:49:11 +00004223/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004224 * Retrieve a range for a piece that forms the cursors spelling name.
Argyrios Kyrtzidis191a6a82012-03-30 20:58:35 +00004225 * Most of the times there is only one range for the complete spelling but for
Nico Weber7deebef2014-04-24 03:17:47 +00004226 * Objective-C methods and Objective-C message expressions, there are multiple
4227 * pieces for each selector identifier.
Fangrui Song6907ce22018-07-30 19:24:48 +00004228 *
Argyrios Kyrtzidis191a6a82012-03-30 20:58:35 +00004229 * \param pieceIndex the index of the spelling name piece. If this is greater
4230 * than the actual number of pieces, it will return a NULL (invalid) range.
Fangrui Song6907ce22018-07-30 19:24:48 +00004231 *
Argyrios Kyrtzidis191a6a82012-03-30 20:58:35 +00004232 * \param options Reserved.
4233 */
4234CINDEX_LINKAGE CXSourceRange clang_Cursor_getSpellingNameRange(CXCursor,
4235 unsigned pieceIndex,
4236 unsigned options);
4237
4238/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004239 * Opaque pointer representing a policy that controls pretty printing
Jonathan Coe45ef5032018-01-16 10:19:56 +00004240 * for \c clang_getCursorPrettyPrinted.
4241 */
4242typedef void *CXPrintingPolicy;
4243
4244/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004245 * Properties for the printing policy.
Jonathan Coe45ef5032018-01-16 10:19:56 +00004246 *
4247 * See \c clang::PrintingPolicy for more information.
4248 */
4249enum CXPrintingPolicyProperty {
4250 CXPrintingPolicy_Indentation,
4251 CXPrintingPolicy_SuppressSpecifiers,
4252 CXPrintingPolicy_SuppressTagKeyword,
4253 CXPrintingPolicy_IncludeTagDefinition,
4254 CXPrintingPolicy_SuppressScope,
4255 CXPrintingPolicy_SuppressUnwrittenScope,
4256 CXPrintingPolicy_SuppressInitializers,
4257 CXPrintingPolicy_ConstantArraySizeAsWritten,
4258 CXPrintingPolicy_AnonymousTagLocations,
4259 CXPrintingPolicy_SuppressStrongLifetime,
4260 CXPrintingPolicy_SuppressLifetimeQualifiers,
4261 CXPrintingPolicy_SuppressTemplateArgsInCXXConstructors,
4262 CXPrintingPolicy_Bool,
4263 CXPrintingPolicy_Restrict,
4264 CXPrintingPolicy_Alignof,
4265 CXPrintingPolicy_UnderscoreAlignof,
4266 CXPrintingPolicy_UseVoidForZeroParams,
4267 CXPrintingPolicy_TerseOutput,
4268 CXPrintingPolicy_PolishForDeclaration,
4269 CXPrintingPolicy_Half,
4270 CXPrintingPolicy_MSWChar,
4271 CXPrintingPolicy_IncludeNewlines,
4272 CXPrintingPolicy_MSVCFormatting,
4273 CXPrintingPolicy_ConstantsAsWritten,
4274 CXPrintingPolicy_SuppressImplicitBase,
4275 CXPrintingPolicy_FullyQualifiedName,
4276
4277 CXPrintingPolicy_LastProperty = CXPrintingPolicy_FullyQualifiedName
4278};
4279
4280/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004281 * Get a property value for the given printing policy.
Jonathan Coe45ef5032018-01-16 10:19:56 +00004282 */
Ivan Donchevskii4cab0fe2018-01-16 12:11:59 +00004283CINDEX_LINKAGE unsigned
Jonathan Coe45ef5032018-01-16 10:19:56 +00004284clang_PrintingPolicy_getProperty(CXPrintingPolicy Policy,
4285 enum CXPrintingPolicyProperty Property);
4286
4287/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004288 * Set a property value for the given printing policy.
Jonathan Coe45ef5032018-01-16 10:19:56 +00004289 */
Ivan Donchevskii4cab0fe2018-01-16 12:11:59 +00004290CINDEX_LINKAGE void clang_PrintingPolicy_setProperty(CXPrintingPolicy Policy,
4291 enum CXPrintingPolicyProperty Property,
4292 unsigned Value);
Jonathan Coe45ef5032018-01-16 10:19:56 +00004293
4294/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004295 * Retrieve the default policy for the cursor.
Jonathan Coe45ef5032018-01-16 10:19:56 +00004296 *
4297 * The policy should be released after use with \c
4298 * clang_PrintingPolicy_dispose.
4299 */
4300CINDEX_LINKAGE CXPrintingPolicy clang_getCursorPrintingPolicy(CXCursor);
4301
4302/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004303 * Release a printing policy.
Jonathan Coe45ef5032018-01-16 10:19:56 +00004304 */
4305CINDEX_LINKAGE void clang_PrintingPolicy_dispose(CXPrintingPolicy Policy);
4306
4307/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004308 * Pretty print declarations.
Jonathan Coe45ef5032018-01-16 10:19:56 +00004309 *
4310 * \param Cursor The cursor representing a declaration.
4311 *
4312 * \param Policy The policy to control the entities being printed. If
4313 * NULL, a default policy is used.
4314 *
4315 * \returns The pretty printed declaration or the empty string for
4316 * other cursors.
4317 */
4318CINDEX_LINKAGE CXString clang_getCursorPrettyPrinted(CXCursor Cursor,
4319 CXPrintingPolicy Policy);
4320
4321/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004322 * Retrieve the display name for the entity referenced by this cursor.
Douglas Gregor97c75712010-10-02 22:49:11 +00004323 *
4324 * The display name contains extra information that helps identify the cursor,
Fangrui Song6907ce22018-07-30 19:24:48 +00004325 * such as the parameters of a function or template or the arguments of a
Douglas Gregor97c75712010-10-02 22:49:11 +00004326 * class template specialization.
4327 */
4328CINDEX_LINKAGE CXString clang_getCursorDisplayName(CXCursor);
Fangrui Song6907ce22018-07-30 19:24:48 +00004329
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004330/** For a cursor that is a reference, retrieve a cursor representing the
Douglas Gregorad27e8b2010-01-19 01:20:04 +00004331 * entity that it references.
4332 *
4333 * Reference cursors refer to other entities in the AST. For example, an
4334 * Objective-C superclass reference cursor refers to an Objective-C class.
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004335 * This function produces the cursor for the Objective-C class from the
Douglas Gregorad27e8b2010-01-19 01:20:04 +00004336 * cursor for the superclass reference. If the input cursor is a declaration or
4337 * definition, it returns that declaration or definition unchanged.
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004338 * Otherwise, returns the NULL cursor.
Douglas Gregorad27e8b2010-01-19 01:20:04 +00004339 */
4340CINDEX_LINKAGE CXCursor clang_getCursorReferenced(CXCursor);
Douglas Gregor6b8232f2010-01-19 19:34:47 +00004341
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004342/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004343 * For a cursor that is either a reference to or a declaration
Douglas Gregor6b8232f2010-01-19 19:34:47 +00004344 * of some entity, retrieve a cursor that describes the definition of
4345 * that entity.
4346 *
4347 * Some entities can be declared multiple times within a translation
4348 * unit, but only one of those declarations can also be a
4349 * definition. For example, given:
4350 *
4351 * \code
4352 * int f(int, int);
4353 * int g(int x, int y) { return f(x, y); }
4354 * int f(int a, int b) { return a + b; }
4355 * int f(int, int);
4356 * \endcode
4357 *
4358 * there are three declarations of the function "f", but only the
4359 * second one is a definition. The clang_getCursorDefinition()
4360 * function will take any cursor pointing to a declaration of "f"
4361 * (the first or fourth lines of the example) or a cursor referenced
4362 * that uses "f" (the call to "f' inside "g") and will return a
4363 * declaration cursor pointing to the definition (the second "f"
4364 * declaration).
4365 *
4366 * If given a cursor for which there is no corresponding definition,
4367 * e.g., because there is no definition of that entity within this
4368 * translation unit, returns a NULL cursor.
4369 */
4370CINDEX_LINKAGE CXCursor clang_getCursorDefinition(CXCursor);
4371
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004372/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004373 * Determine whether the declaration pointed to by this cursor
Douglas Gregor6b8232f2010-01-19 19:34:47 +00004374 * is also a definition of that entity.
4375 */
4376CINDEX_LINKAGE unsigned clang_isCursorDefinition(CXCursor);
4377
Douglas Gregor6007cf22010-01-22 22:29:16 +00004378/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004379 * Retrieve the canonical cursor corresponding to the given cursor.
Douglas Gregorfec4dc92010-11-19 23:44:15 +00004380 *
4381 * In the C family of languages, many kinds of entities can be declared several
4382 * times within a single translation unit. For example, a structure type can
4383 * be forward-declared (possibly multiple times) and later defined:
4384 *
4385 * \code
4386 * struct X;
4387 * struct X;
4388 * struct X {
4389 * int member;
4390 * };
4391 * \endcode
4392 *
Fangrui Song6907ce22018-07-30 19:24:48 +00004393 * The declarations and the definition of \c X are represented by three
4394 * different cursors, all of which are declarations of the same underlying
Douglas Gregorfec4dc92010-11-19 23:44:15 +00004395 * entity. One of these cursor is considered the "canonical" cursor, which
Fangrui Song6907ce22018-07-30 19:24:48 +00004396 * is effectively the representative for the underlying entity. One can
Douglas Gregorfec4dc92010-11-19 23:44:15 +00004397 * determine if two cursors are declarations of the same underlying entity by
4398 * comparing their canonical cursors.
4399 *
4400 * \returns The canonical cursor for the entity referred to by the given cursor.
4401 */
4402CINDEX_LINKAGE CXCursor clang_getCanonicalCursor(CXCursor);
4403
Argyrios Kyrtzidis210f29f2012-03-30 22:15:48 +00004404/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004405 * If the cursor points to a selector identifier in an Objective-C
Nico Weber7deebef2014-04-24 03:17:47 +00004406 * method or message expression, this returns the selector index.
Argyrios Kyrtzidis210f29f2012-03-30 22:15:48 +00004407 *
James Dennett574cb4c2012-06-15 05:41:51 +00004408 * After getting a cursor with #clang_getCursor, this can be called to
Argyrios Kyrtzidis210f29f2012-03-30 22:15:48 +00004409 * determine if the location points to a selector identifier.
4410 *
Nico Weber7deebef2014-04-24 03:17:47 +00004411 * \returns The selector index if the cursor is an Objective-C method or message
Argyrios Kyrtzidis210f29f2012-03-30 22:15:48 +00004412 * expression and the cursor is pointing to a selector identifier, or -1
4413 * otherwise.
4414 */
4415CINDEX_LINKAGE int clang_Cursor_getObjCSelectorIndex(CXCursor);
4416
Douglas Gregorfec4dc92010-11-19 23:44:15 +00004417/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004418 * Given a cursor pointing to a C++ method call or an Objective-C
Nico Weber7deebef2014-04-24 03:17:47 +00004419 * message, returns non-zero if the method/message is "dynamic", meaning:
Fangrui Song6907ce22018-07-30 19:24:48 +00004420 *
Argyrios Kyrtzidisb6df68212012-07-02 23:54:36 +00004421 * For a C++ method: the call is virtual.
Nico Weber7deebef2014-04-24 03:17:47 +00004422 * For an Objective-C message: the receiver is an object instance, not 'super'
4423 * or a specific class.
Fangrui Song6907ce22018-07-30 19:24:48 +00004424 *
Argyrios Kyrtzidisb6df68212012-07-02 23:54:36 +00004425 * If the method/message is "static" or the cursor does not point to a
4426 * method/message, it will return zero.
4427 */
4428CINDEX_LINKAGE int clang_Cursor_isDynamicCall(CXCursor C);
4429
4430/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004431 * Given a cursor pointing to an Objective-C message or property
Argyrios Kyrtzidis2a684862017-04-27 17:23:04 +00004432 * reference, or C++ method call, returns the CXType of the receiver.
Argyrios Kyrtzidisb26a24c2012-11-01 02:01:34 +00004433 */
4434CINDEX_LINKAGE CXType clang_Cursor_getReceiverType(CXCursor C);
4435
4436/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004437 * Property attributes for a \c CXCursor_ObjCPropertyDecl.
Argyrios Kyrtzidis9adfd8a2013-04-18 22:15:49 +00004438 */
4439typedef enum {
4440 CXObjCPropertyAttr_noattr = 0x00,
4441 CXObjCPropertyAttr_readonly = 0x01,
4442 CXObjCPropertyAttr_getter = 0x02,
4443 CXObjCPropertyAttr_assign = 0x04,
4444 CXObjCPropertyAttr_readwrite = 0x08,
4445 CXObjCPropertyAttr_retain = 0x10,
4446 CXObjCPropertyAttr_copy = 0x20,
4447 CXObjCPropertyAttr_nonatomic = 0x40,
4448 CXObjCPropertyAttr_setter = 0x80,
4449 CXObjCPropertyAttr_atomic = 0x100,
4450 CXObjCPropertyAttr_weak = 0x200,
4451 CXObjCPropertyAttr_strong = 0x400,
Manman Ren04fd4d82016-05-31 23:22:04 +00004452 CXObjCPropertyAttr_unsafe_unretained = 0x800,
Manman Ren400e4c32016-06-03 23:11:41 +00004453 CXObjCPropertyAttr_class = 0x1000
Argyrios Kyrtzidis9adfd8a2013-04-18 22:15:49 +00004454} CXObjCPropertyAttrKind;
4455
4456/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004457 * Given a cursor that represents a property declaration, return the
Argyrios Kyrtzidis9adfd8a2013-04-18 22:15:49 +00004458 * associated property attributes. The bits are formed from
4459 * \c CXObjCPropertyAttrKind.
4460 *
4461 * \param reserved Reserved for future use, pass 0.
4462 */
4463CINDEX_LINKAGE unsigned clang_Cursor_getObjCPropertyAttributes(CXCursor C,
4464 unsigned reserved);
4465
4466/**
Michael Wu6e88f532018-08-03 05:38:29 +00004467 * Given a cursor that represents a property declaration, return the
4468 * name of the method that implements the getter.
4469 */
4470CINDEX_LINKAGE CXString clang_Cursor_getObjCPropertyGetterName(CXCursor C);
4471
4472/**
4473 * Given a cursor that represents a property declaration, return the
4474 * name of the method that implements the setter, if any.
4475 */
4476CINDEX_LINKAGE CXString clang_Cursor_getObjCPropertySetterName(CXCursor C);
4477
4478/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004479 * 'Qualifiers' written next to the return and parameter types in
Nico Weber7deebef2014-04-24 03:17:47 +00004480 * Objective-C method declarations.
Argyrios Kyrtzidis9d9bc012013-04-18 23:29:12 +00004481 */
4482typedef enum {
4483 CXObjCDeclQualifier_None = 0x0,
4484 CXObjCDeclQualifier_In = 0x1,
4485 CXObjCDeclQualifier_Inout = 0x2,
4486 CXObjCDeclQualifier_Out = 0x4,
4487 CXObjCDeclQualifier_Bycopy = 0x8,
4488 CXObjCDeclQualifier_Byref = 0x10,
4489 CXObjCDeclQualifier_Oneway = 0x20
4490} CXObjCDeclQualifierKind;
4491
4492/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004493 * Given a cursor that represents an Objective-C method or parameter
Nico Weber7deebef2014-04-24 03:17:47 +00004494 * declaration, return the associated Objective-C qualifiers for the return
4495 * type or the parameter respectively. The bits are formed from
4496 * CXObjCDeclQualifierKind.
Argyrios Kyrtzidis9d9bc012013-04-18 23:29:12 +00004497 */
4498CINDEX_LINKAGE unsigned clang_Cursor_getObjCDeclQualifiers(CXCursor C);
4499
4500/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004501 * Given a cursor that represents an Objective-C method or property
Alex Lorenz6c2898a2017-04-06 14:03:25 +00004502 * declaration, return non-zero if the declaration was affected by "\@optional".
4503 * Returns zero if the cursor is not such a declaration or it is "\@required".
Argyrios Kyrtzidis7b50fc52013-07-05 20:44:37 +00004504 */
4505CINDEX_LINKAGE unsigned clang_Cursor_isObjCOptional(CXCursor C);
4506
4507/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004508 * Returns non-zero if the given cursor is a variadic function or method.
Argyrios Kyrtzidis23814e42013-04-18 23:53:05 +00004509 */
4510CINDEX_LINKAGE unsigned clang_Cursor_isVariadic(CXCursor C);
4511
4512/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004513 * Returns non-zero if the given cursor points to a symbol marked with
Argyrios Kyrtzidis0381cc72017-05-10 15:10:36 +00004514 * external_source_symbol attribute.
4515 *
4516 * \param language If non-NULL, and the attribute is present, will be set to
4517 * the 'language' string from the attribute.
4518 *
4519 * \param definedIn If non-NULL, and the attribute is present, will be set to
4520 * the 'definedIn' string from the attribute.
4521 *
4522 * \param isGenerated If non-NULL, and the attribute is present, will be set to
Argyrios Kyrtzidis8b337c02017-05-10 15:48:16 +00004523 * non-zero if the 'generated_declaration' is set in the attribute.
Argyrios Kyrtzidis0381cc72017-05-10 15:10:36 +00004524 */
4525CINDEX_LINKAGE unsigned clang_Cursor_isExternalSymbol(CXCursor C,
4526 CXString *language, CXString *definedIn,
4527 unsigned *isGenerated);
4528
4529/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004530 * Given a cursor that represents a declaration, return the associated
Dmitri Gribenkoaab83832012-06-20 00:34:58 +00004531 * comment's source range. The range may include multiple consecutive comments
4532 * with whitespace in between.
4533 */
4534CINDEX_LINKAGE CXSourceRange clang_Cursor_getCommentRange(CXCursor C);
4535
4536/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004537 * Given a cursor that represents a declaration, return the associated
Dmitri Gribenkoaab83832012-06-20 00:34:58 +00004538 * comment text, including comment markers.
4539 */
4540CINDEX_LINKAGE CXString clang_Cursor_getRawCommentText(CXCursor C);
4541
4542/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004543 * Given a cursor that represents a documentable entity (e.g.,
4544 * declaration), return the associated \paragraph; otherwise return the
Dmitri Gribenko5e4fe002012-07-20 21:34:34 +00004545 * first paragraph.
Dmitri Gribenko5188c4b2012-06-26 20:39:18 +00004546 */
4547CINDEX_LINKAGE CXString clang_Cursor_getBriefCommentText(CXCursor C);
4548
4549/**
Dmitri Gribenko5e4fe002012-07-20 21:34:34 +00004550 * @}
4551 */
4552
Eli Bendersky44a206f2014-07-31 18:04:56 +00004553/** \defgroup CINDEX_MANGLE Name Mangling API Functions
4554 *
4555 * @{
4556 */
4557
4558/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004559 * Retrieve the CXString representing the mangled name of the cursor.
Eli Bendersky44a206f2014-07-31 18:04:56 +00004560 */
4561CINDEX_LINKAGE CXString clang_Cursor_getMangling(CXCursor);
4562
4563/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004564 * Retrieve the CXStrings representing the mangled symbols of the C++
Saleem Abdulrasool60034432015-11-12 03:57:22 +00004565 * constructor or destructor at the cursor.
4566 */
4567CINDEX_LINKAGE CXStringSet *clang_Cursor_getCXXManglings(CXCursor);
4568
4569/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004570 * Retrieve the CXStrings representing the mangled symbols of the ObjC
Dave Lee1a532c92017-09-22 16:58:57 +00004571 * class interface or implementation at the cursor.
4572 */
4573CINDEX_LINKAGE CXStringSet *clang_Cursor_getObjCManglings(CXCursor);
4574
4575/**
Eli Bendersky44a206f2014-07-31 18:04:56 +00004576 * @}
4577 */
4578
Dmitri Gribenko5e4fe002012-07-20 21:34:34 +00004579/**
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004580 * \defgroup CINDEX_MODULE Module introspection
4581 *
4582 * The functions in this group provide access to information about modules.
4583 *
4584 * @{
4585 */
4586
4587typedef void *CXModule;
4588
4589/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004590 * Given a CXCursor_ModuleImportDecl cursor, return the associated module.
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004591 */
4592CINDEX_LINKAGE CXModule clang_Cursor_getModule(CXCursor C);
4593
4594/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004595 * Given a CXFile header file, return the module that contains it, if one
Argyrios Kyrtzidisf6d49c32014-05-14 23:14:37 +00004596 * exists.
4597 */
4598CINDEX_LINKAGE CXModule clang_getModuleForFile(CXTranslationUnit, CXFile);
4599
4600/**
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004601 * \param Module a module object.
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004602 *
Argyrios Kyrtzidis12fdb9e2013-04-26 22:47:49 +00004603 * \returns the module file where the provided module object came from.
4604 */
4605CINDEX_LINKAGE CXFile clang_Module_getASTFile(CXModule Module);
4606
4607/**
4608 * \param Module a module object.
4609 *
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004610 * \returns the parent of a sub-module or NULL if the given module is top-level,
4611 * e.g. for 'std.vector' it will return the 'std' module.
4612 */
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004613CINDEX_LINKAGE CXModule clang_Module_getParent(CXModule Module);
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004614
4615/**
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004616 * \param Module a module object.
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004617 *
4618 * \returns the name of the module, e.g. for the 'std.vector' sub-module it
4619 * will return "vector".
4620 */
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004621CINDEX_LINKAGE CXString clang_Module_getName(CXModule Module);
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004622
4623/**
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004624 * \param Module a module object.
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004625 *
4626 * \returns the full name of the module, e.g. "std.vector".
4627 */
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004628CINDEX_LINKAGE CXString clang_Module_getFullName(CXModule Module);
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004629
4630/**
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004631 * \param Module a module object.
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004632 *
Argyrios Kyrtzidis884337f2014-05-15 04:44:25 +00004633 * \returns non-zero if the module is a system one.
4634 */
4635CINDEX_LINKAGE int clang_Module_isSystem(CXModule Module);
4636
4637/**
4638 * \param Module a module object.
4639 *
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004640 * \returns the number of top level headers associated with this module.
4641 */
Argyrios Kyrtzidis3c5305c2013-03-13 21:13:43 +00004642CINDEX_LINKAGE unsigned clang_Module_getNumTopLevelHeaders(CXTranslationUnit,
4643 CXModule Module);
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004644
4645/**
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004646 * \param Module a module object.
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004647 *
4648 * \param Index top level header index (zero-based).
4649 *
4650 * \returns the specified top level header associated with the module.
4651 */
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004652CINDEX_LINKAGE
Argyrios Kyrtzidis3c5305c2013-03-13 21:13:43 +00004653CXFile clang_Module_getTopLevelHeader(CXTranslationUnit,
4654 CXModule Module, unsigned Index);
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004655
4656/**
4657 * @}
4658 */
4659
4660/**
Ted Kremenek9cfe9e62010-05-17 20:06:56 +00004661 * \defgroup CINDEX_CPP C++ AST introspection
4662 *
4663 * The routines in this group provide access information in the ASTs specific
4664 * to C++ language features.
4665 *
4666 * @{
4667 */
4668
4669/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004670 * Determine if a C++ constructor is a converting constructor.
Jonathan Coe29565352016-04-27 12:48:25 +00004671 */
4672CINDEX_LINKAGE unsigned clang_CXXConstructor_isConvertingConstructor(CXCursor C);
4673
4674/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004675 * Determine if a C++ constructor is a copy constructor.
Jonathan Coe29565352016-04-27 12:48:25 +00004676 */
4677CINDEX_LINKAGE unsigned clang_CXXConstructor_isCopyConstructor(CXCursor C);
4678
4679/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004680 * Determine if a C++ constructor is the default constructor.
Jonathan Coe29565352016-04-27 12:48:25 +00004681 */
4682CINDEX_LINKAGE unsigned clang_CXXConstructor_isDefaultConstructor(CXCursor C);
4683
4684/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004685 * Determine if a C++ constructor is a move constructor.
Jonathan Coe29565352016-04-27 12:48:25 +00004686 */
4687CINDEX_LINKAGE unsigned clang_CXXConstructor_isMoveConstructor(CXCursor C);
4688
4689/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004690 * Determine if a C++ field is declared 'mutable'.
Saleem Abdulrasool6ea75db2015-10-27 15:50:22 +00004691 */
4692CINDEX_LINKAGE unsigned clang_CXXField_isMutable(CXCursor C);
4693
4694/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004695 * Determine if a C++ method is declared '= default'.
Jonathan Coe29565352016-04-27 12:48:25 +00004696 */
4697CINDEX_LINKAGE unsigned clang_CXXMethod_isDefaulted(CXCursor C);
4698
4699/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004700 * Determine if a C++ member function or member function template is
Dmitri Gribenko62770be2013-05-17 18:38:35 +00004701 * pure virtual.
4702 */
4703CINDEX_LINKAGE unsigned clang_CXXMethod_isPureVirtual(CXCursor C);
4704
4705/**
Fangrui Song6907ce22018-07-30 19:24:48 +00004706 * Determine if a C++ member function or member function template is
Douglas Gregorf11309e2010-08-31 22:12:17 +00004707 * declared 'static'.
Ted Kremenek9cfe9e62010-05-17 20:06:56 +00004708 */
4709CINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C);
4710
4711/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004712 * Determine if a C++ member function or member function template is
Douglas Gregor9519d922011-05-12 15:17:24 +00004713 * explicitly declared 'virtual' or if it overrides a virtual method from
4714 * one of the base classes.
4715 */
4716CINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual(CXCursor C);
4717
4718/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004719 * Determine if a C++ record is abstract, i.e. whether a class or struct
Alex Lorenz34ccadc2017-12-14 22:01:50 +00004720 * has a pure virtual member function.
4721 */
4722CINDEX_LINKAGE unsigned clang_CXXRecord_isAbstract(CXCursor C);
4723
4724/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004725 * Determine if an enum declaration refers to a scoped enum.
Alex Lorenzff7f42e2017-07-12 11:35:11 +00004726 */
4727CINDEX_LINKAGE unsigned clang_EnumDecl_isScoped(CXCursor C);
4728
4729/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004730 * Determine if a C++ member function or member function template is
Dmitri Gribenkoe570ede2014-04-07 14:59:13 +00004731 * declared 'const'.
4732 */
4733CINDEX_LINKAGE unsigned clang_CXXMethod_isConst(CXCursor C);
4734
4735/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004736 * Given a cursor that represents a template, determine
Douglas Gregorf11309e2010-08-31 22:12:17 +00004737 * the cursor kind of the specializations would be generated by instantiating
4738 * the template.
4739 *
4740 * This routine can be used to determine what flavor of function template,
4741 * class template, or class template partial specialization is stored in the
4742 * cursor. For example, it can describe whether a class template cursor is
4743 * declared with "struct", "class" or "union".
4744 *
4745 * \param C The cursor to query. This cursor should represent a template
4746 * declaration.
4747 *
4748 * \returns The cursor kind of the specializations that would be generated
4749 * by instantiating the template \p C. If \p C is not a template, returns
4750 * \c CXCursor_NoDeclFound.
4751 */
4752CINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind(CXCursor C);
Fangrui Song6907ce22018-07-30 19:24:48 +00004753
Douglas Gregorf11309e2010-08-31 22:12:17 +00004754/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004755 * Given a cursor that may represent a specialization or instantiation
Douglas Gregord3f48bd2010-09-02 00:07:54 +00004756 * of a template, retrieve the cursor that represents the template that it
4757 * specializes or from which it was instantiated.
4758 *
Fangrui Song6907ce22018-07-30 19:24:48 +00004759 * This routine determines the template involved both for explicit
Douglas Gregord3f48bd2010-09-02 00:07:54 +00004760 * specializations of templates and for implicit instantiations of the template,
4761 * both of which are referred to as "specializations". For a class template
Fangrui Song6907ce22018-07-30 19:24:48 +00004762 * specialization (e.g., \c std::vector<bool>), this routine will return
Douglas Gregord3f48bd2010-09-02 00:07:54 +00004763 * either the primary template (\c std::vector) or, if the specialization was
4764 * instantiated from a class template partial specialization, the class template
4765 * partial specialization. For a class template partial specialization and a
4766 * function template specialization (including instantiations), this
4767 * this routine will return the specialized template.
4768 *
4769 * For members of a class template (e.g., member functions, member classes, or
Fangrui Song6907ce22018-07-30 19:24:48 +00004770 * static data members), returns the specialized or instantiated member.
Douglas Gregord3f48bd2010-09-02 00:07:54 +00004771 * Although not strictly "templates" in the C++ language, members of class
4772 * templates have the same notions of specializations and instantiations that
4773 * templates do, so this routine treats them similarly.
4774 *
4775 * \param C A cursor that may be a specialization of a template or a member
4776 * of a template.
4777 *
Fangrui Song6907ce22018-07-30 19:24:48 +00004778 * \returns If the given cursor is a specialization or instantiation of a
Douglas Gregord3f48bd2010-09-02 00:07:54 +00004779 * template or a member thereof, the template or member that it specializes or
4780 * from which it was instantiated. Otherwise, returns a NULL cursor.
4781 */
4782CINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate(CXCursor C);
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004783
4784/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004785 * Given a cursor that references something else, return the source range
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004786 * covering that reference.
4787 *
4788 * \param C A cursor pointing to a member reference, a declaration reference, or
4789 * an operator call.
Fangrui Song6907ce22018-07-30 19:24:48 +00004790 * \param NameFlags A bitset with three independent flags:
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004791 * CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and
4792 * CXNameRange_WantSinglePiece.
Fangrui Song6907ce22018-07-30 19:24:48 +00004793 * \param PieceIndex For contiguous names or when passing the flag
4794 * CXNameRange_WantSinglePiece, only one piece with index 0 is
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004795 * available. When the CXNameRange_WantSinglePiece flag is not passed for a
Benjamin Kramer474261a2012-06-02 10:20:41 +00004796 * non-contiguous names, this index can be used to retrieve the individual
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004797 * pieces of the name. See also CXNameRange_WantSinglePiece.
4798 *
4799 * \returns The piece of the name pointed to by the given cursor. If there is no
4800 * name, or if the PieceIndex is out-of-range, a null-cursor will be returned.
4801 */
Francois Pichetece689f2011-07-25 22:00:44 +00004802CINDEX_LINKAGE CXSourceRange clang_getCursorReferenceNameRange(CXCursor C,
Fangrui Song6907ce22018-07-30 19:24:48 +00004803 unsigned NameFlags,
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004804 unsigned PieceIndex);
4805
4806enum CXNameRefFlags {
4807 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004808 * Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004809 * range.
4810 */
4811 CXNameRange_WantQualifier = 0x1,
Fangrui Song6907ce22018-07-30 19:24:48 +00004812
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004813 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004814 * Include the explicit template arguments, e.g. \<int> in x.f<int>,
James Dennett574cb4c2012-06-15 05:41:51 +00004815 * in the range.
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004816 */
4817 CXNameRange_WantTemplateArgs = 0x2,
4818
4819 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004820 * If the name is non-contiguous, return the full spanning range.
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004821 *
4822 * Non-contiguous names occur in Objective-C when a selector with two or more
4823 * parameters is used, or in C++ when using an operator:
4824 * \code
Nico Weber7deebef2014-04-24 03:17:47 +00004825 * [object doSomething:here withValue:there]; // Objective-C
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004826 * return some_vector[1]; // C++
4827 * \endcode
4828 */
4829 CXNameRange_WantSinglePiece = 0x4
4830};
Fangrui Song6907ce22018-07-30 19:24:48 +00004831
Douglas Gregord3f48bd2010-09-02 00:07:54 +00004832/**
Ted Kremenek9cfe9e62010-05-17 20:06:56 +00004833 * @}
4834 */
4835
4836/**
Douglas Gregor61656112010-01-26 18:31:56 +00004837 * \defgroup CINDEX_LEX Token extraction and manipulation
4838 *
4839 * The routines in this group provide access to the tokens within a
4840 * translation unit, along with a semantic mapping of those tokens to
4841 * their corresponding cursors.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004842 *
4843 * @{
4844 */
4845
4846/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004847 * Describes a kind of token.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004848 */
4849typedef enum CXTokenKind {
4850 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004851 * A token that contains some kind of punctuation.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004852 */
4853 CXToken_Punctuation,
Ted Kremenekd071c602010-03-13 02:50:34 +00004854
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004855 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004856 * A language keyword.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004857 */
4858 CXToken_Keyword,
Ted Kremenekd071c602010-03-13 02:50:34 +00004859
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004860 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004861 * An identifier (that is not a keyword).
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004862 */
4863 CXToken_Identifier,
Ted Kremenekd071c602010-03-13 02:50:34 +00004864
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004865 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004866 * A numeric, string, or character literal.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004867 */
4868 CXToken_Literal,
Ted Kremenekd071c602010-03-13 02:50:34 +00004869
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004870 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004871 * A comment.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004872 */
4873 CXToken_Comment
4874} CXTokenKind;
4875
4876/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004877 * Describes a single preprocessing token.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004878 */
4879typedef struct {
4880 unsigned int_data[4];
4881 void *ptr_data;
4882} CXToken;
4883
4884/**
Ivan Donchevskii3957e482018-06-13 12:37:08 +00004885 * Get the raw lexical token starting with the given location.
4886 *
4887 * \param TU the translation unit whose text is being tokenized.
4888 *
4889 * \param Location the source location with which the token starts.
4890 *
4891 * \returns The token starting with the given location or NULL if no such token
4892 * exist. The returned pointer must be freed with clang_disposeTokens before the
4893 * translation unit is destroyed.
4894 */
4895CINDEX_LINKAGE CXToken *clang_getToken(CXTranslationUnit TU,
4896 CXSourceLocation Location);
4897
4898/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004899 * Determine the kind of the given token.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004900 */
4901CINDEX_LINKAGE CXTokenKind clang_getTokenKind(CXToken);
Ted Kremenekd071c602010-03-13 02:50:34 +00004902
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004903/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004904 * Determine the spelling of the given token.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004905 *
4906 * The spelling of a token is the textual representation of that token, e.g.,
4907 * the text of an identifier or keyword.
4908 */
4909CINDEX_LINKAGE CXString clang_getTokenSpelling(CXTranslationUnit, CXToken);
Ted Kremenekd071c602010-03-13 02:50:34 +00004910
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004911/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004912 * Retrieve the source location of the given token.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004913 */
Ted Kremenekd071c602010-03-13 02:50:34 +00004914CINDEX_LINKAGE CXSourceLocation clang_getTokenLocation(CXTranslationUnit,
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004915 CXToken);
Ted Kremenekd071c602010-03-13 02:50:34 +00004916
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004917/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004918 * Retrieve a source range that covers the given token.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004919 */
4920CINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken);
4921
4922/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004923 * Tokenize the source code described by the given range into raw
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004924 * lexical tokens.
4925 *
4926 * \param TU the translation unit whose text is being tokenized.
4927 *
4928 * \param Range the source range in which text should be tokenized. All of the
4929 * tokens produced by tokenization will fall within this source range,
4930 *
4931 * \param Tokens this pointer will be set to point to the array of tokens
4932 * that occur within the given source range. The returned pointer must be
4933 * freed with clang_disposeTokens() before the translation unit is destroyed.
4934 *
4935 * \param NumTokens will be set to the number of tokens in the \c *Tokens
4936 * array.
4937 *
4938 */
4939CINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
4940 CXToken **Tokens, unsigned *NumTokens);
Ted Kremenekd071c602010-03-13 02:50:34 +00004941
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004942/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004943 * Annotate the given set of tokens by providing cursors for each token
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004944 * that can be mapped to a specific entity within the abstract syntax tree.
4945 *
Douglas Gregor61656112010-01-26 18:31:56 +00004946 * This token-annotation routine is equivalent to invoking
4947 * clang_getCursor() for the source locations of each of the
4948 * tokens. The cursors provided are filtered, so that only those
4949 * cursors that have a direct correspondence to the token are
4950 * accepted. For example, given a function call \c f(x),
4951 * clang_getCursor() would provide the following cursors:
4952 *
4953 * * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'.
4954 * * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'.
4955 * * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'.
4956 *
4957 * Only the first and last of these cursors will occur within the
4958 * annotate, since the tokens "f" and "x' directly refer to a function
4959 * and a variable, respectively, but the parentheses are just a small
4960 * part of the full syntax of the function call expression, which is
4961 * not provided as an annotation.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004962 *
4963 * \param TU the translation unit that owns the given tokens.
4964 *
4965 * \param Tokens the set of tokens to annotate.
4966 *
4967 * \param NumTokens the number of tokens in \p Tokens.
4968 *
4969 * \param Cursors an array of \p NumTokens cursors, whose contents will be
4970 * replaced with the cursors corresponding to each token.
4971 */
4972CINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU,
4973 CXToken *Tokens, unsigned NumTokens,
4974 CXCursor *Cursors);
Ted Kremenekd071c602010-03-13 02:50:34 +00004975
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004976/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004977 * Free the given set of tokens.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004978 */
Ted Kremenekd071c602010-03-13 02:50:34 +00004979CINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU,
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004980 CXToken *Tokens, unsigned NumTokens);
Ted Kremenekd071c602010-03-13 02:50:34 +00004981
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004982/**
4983 * @}
4984 */
Ted Kremenekd071c602010-03-13 02:50:34 +00004985
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004986/**
Douglas Gregor6007cf22010-01-22 22:29:16 +00004987 * \defgroup CINDEX_DEBUG Debugging facilities
4988 *
4989 * These routines are used for testing and debugging, only, and should not
4990 * be relied upon.
4991 *
4992 * @{
4993 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004994
Steve Naroff76b8f132009-09-23 17:52:52 +00004995/* for debug/testing */
Ted Kremenek29004672010-02-17 00:41:32 +00004996CINDEX_LINKAGE CXString clang_getCursorKindSpelling(enum CXCursorKind Kind);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004997CINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(CXCursor,
4998 const char **startBuf,
Steve Naroff76b8f132009-09-23 17:52:52 +00004999 const char **endBuf,
5000 unsigned *startLine,
5001 unsigned *startColumn,
5002 unsigned *endLine,
5003 unsigned *endColumn);
Douglas Gregor1e21cc72010-02-18 23:07:20 +00005004CINDEX_LINKAGE void clang_enableStackTraces(void);
Daniel Dunbar23420652010-11-04 01:26:29 +00005005CINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void*), void *user_data,
5006 unsigned stack_size);
5007
Douglas Gregor9eb77012009-11-07 00:00:49 +00005008/**
Douglas Gregor6007cf22010-01-22 22:29:16 +00005009 * @}
5010 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005011
Douglas Gregor6007cf22010-01-22 22:29:16 +00005012/**
5013 * \defgroup CINDEX_CODE_COMPLET Code completion
5014 *
5015 * Code completion involves taking an (incomplete) source file, along with
5016 * knowledge of where the user is actively editing that file, and suggesting
5017 * syntactically- and semantically-valid constructs that the user might want to
5018 * use at that particular point in the source code. These data structures and
5019 * routines provide support for code completion.
5020 *
5021 * @{
5022 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005023
Douglas Gregor6007cf22010-01-22 22:29:16 +00005024/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005025 * A semantic string that describes a code-completion result.
Douglas Gregor9eb77012009-11-07 00:00:49 +00005026 *
5027 * A semantic string that describes the formatting of a code-completion
5028 * result as a single "template" of text that should be inserted into the
5029 * source buffer when a particular code-completion result is selected.
5030 * Each semantic string is made up of some number of "chunks", each of which
5031 * contains some text along with a description of what that text means, e.g.,
5032 * the name of the entity being referenced, whether the text chunk is part of
5033 * the template, or whether it is a "placeholder" that the user should replace
5034 * with actual code,of a specific kind. See \c CXCompletionChunkKind for a
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005035 * description of the different kinds of chunks.
Douglas Gregor9eb77012009-11-07 00:00:49 +00005036 */
5037typedef void *CXCompletionString;
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005038
Douglas Gregor9eb77012009-11-07 00:00:49 +00005039/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005040 * A single result of code completion.
Douglas Gregor9eb77012009-11-07 00:00:49 +00005041 */
5042typedef struct {
5043 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005044 * The kind of entity that this completion refers to.
Douglas Gregor9eb77012009-11-07 00:00:49 +00005045 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005046 * The cursor kind will be a macro, keyword, or a declaration (one of the
Douglas Gregor9eb77012009-11-07 00:00:49 +00005047 * *Decl cursor kinds), describing the entity that the completion is
5048 * referring to.
5049 *
5050 * \todo In the future, we would like to provide a full cursor, to allow
5051 * the client to extract additional information from declaration.
5052 */
5053 enum CXCursorKind CursorKind;
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005054
5055 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005056 * The code-completion string that describes how to insert this
Douglas Gregor9eb77012009-11-07 00:00:49 +00005057 * code-completion result into the editing buffer.
5058 */
5059 CXCompletionString CompletionString;
5060} CXCompletionResult;
5061
5062/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005063 * Describes a single piece of text within a code-completion string.
Douglas Gregor9eb77012009-11-07 00:00:49 +00005064 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005065 * Each "chunk" within a code-completion string (\c CXCompletionString) is
5066 * either a piece of text with a specific "kind" that describes how that text
Douglas Gregor9eb77012009-11-07 00:00:49 +00005067 * should be interpreted by the client or is another completion string.
5068 */
5069enum CXCompletionChunkKind {
5070 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005071 * A code-completion string that describes "optional" text that
Douglas Gregor9eb77012009-11-07 00:00:49 +00005072 * could be a part of the template (but is not required).
5073 *
5074 * The Optional chunk is the only kind of chunk that has a code-completion
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005075 * string for its representation, which is accessible via
Douglas Gregor9eb77012009-11-07 00:00:49 +00005076 * \c clang_getCompletionChunkCompletionString(). The code-completion string
5077 * describes an additional part of the template that is completely optional.
5078 * For example, optional chunks can be used to describe the placeholders for
5079 * arguments that match up with defaulted function parameters, e.g. given:
5080 *
5081 * \code
5082 * void f(int x, float y = 3.14, double z = 2.71828);
5083 * \endcode
5084 *
5085 * The code-completion string for this function would contain:
5086 * - a TypedText chunk for "f".
5087 * - a LeftParen chunk for "(".
5088 * - a Placeholder chunk for "int x"
5089 * - an Optional chunk containing the remaining defaulted arguments, e.g.,
5090 * - a Comma chunk for ","
Daniel Dunbar4053fae2010-02-17 08:07:44 +00005091 * - a Placeholder chunk for "float y"
Douglas Gregor9eb77012009-11-07 00:00:49 +00005092 * - an Optional chunk containing the last defaulted argument:
5093 * - a Comma chunk for ","
5094 * - a Placeholder chunk for "double z"
5095 * - a RightParen chunk for ")"
5096 *
Daniel Dunbar4053fae2010-02-17 08:07:44 +00005097 * There are many ways to handle Optional chunks. Two simple approaches are:
Douglas Gregor9eb77012009-11-07 00:00:49 +00005098 * - Completely ignore optional chunks, in which case the template for the
5099 * function "f" would only include the first parameter ("int x").
5100 * - Fully expand all optional chunks, in which case the template for the
5101 * function "f" would have all of the parameters.
5102 */
5103 CXCompletionChunk_Optional,
5104 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005105 * Text that a user would be expected to type to get this
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005106 * code-completion result.
Douglas Gregor9eb77012009-11-07 00:00:49 +00005107 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005108 * There will be exactly one "typed text" chunk in a semantic string, which
5109 * will typically provide the spelling of a keyword or the name of a
Douglas Gregor9eb77012009-11-07 00:00:49 +00005110 * declaration that could be used at the current code point. Clients are
5111 * expected to filter the code-completion results based on the text in this
5112 * chunk.
5113 */
5114 CXCompletionChunk_TypedText,
5115 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005116 * Text that should be inserted as part of a code-completion result.
Douglas Gregor9eb77012009-11-07 00:00:49 +00005117 *
5118 * A "text" chunk represents text that is part of the template to be
5119 * inserted into user code should this particular code-completion result
5120 * be selected.
5121 */
5122 CXCompletionChunk_Text,
5123 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005124 * Placeholder text that should be replaced by the user.
Douglas Gregor9eb77012009-11-07 00:00:49 +00005125 *
5126 * A "placeholder" chunk marks a place where the user should insert text
5127 * into the code-completion template. For example, placeholders might mark
5128 * the function parameters for a function declaration, to indicate that the
5129 * user should provide arguments for each of those parameters. The actual
5130 * text in a placeholder is a suggestion for the text to display before
5131 * the user replaces the placeholder with real code.
5132 */
5133 CXCompletionChunk_Placeholder,
5134 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005135 * Informative text that should be displayed but never inserted as
Douglas Gregor9eb77012009-11-07 00:00:49 +00005136 * part of the template.
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005137 *
Douglas Gregor9eb77012009-11-07 00:00:49 +00005138 * An "informative" chunk contains annotations that can be displayed to
5139 * help the user decide whether a particular code-completion result is the
5140 * right option, but which is not part of the actual template to be inserted
5141 * by code completion.
5142 */
5143 CXCompletionChunk_Informative,
5144 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005145 * Text that describes the current parameter when code-completion is
Douglas Gregor9eb77012009-11-07 00:00:49 +00005146 * referring to function call, message send, or template specialization.
5147 *
5148 * A "current parameter" chunk occurs when code-completion is providing
5149 * information about a parameter corresponding to the argument at the
5150 * code-completion point. For example, given a function
5151 *
5152 * \code
5153 * int add(int x, int y);
5154 * \endcode
5155 *
5156 * and the source code \c add(, where the code-completion point is after the
5157 * "(", the code-completion string will contain a "current parameter" chunk
5158 * for "int x", indicating that the current argument will initialize that
5159 * parameter. After typing further, to \c add(17, (where the code-completion
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005160 * point is after the ","), the code-completion string will contain a
Alexander Kornienko2a8c18d2018-04-06 15:14:32 +00005161 * "current parameter" chunk to "int y".
Douglas Gregor9eb77012009-11-07 00:00:49 +00005162 */
5163 CXCompletionChunk_CurrentParameter,
5164 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005165 * A left parenthesis ('('), used to initiate a function call or
Douglas Gregor9eb77012009-11-07 00:00:49 +00005166 * signal the beginning of a function parameter list.
5167 */
5168 CXCompletionChunk_LeftParen,
5169 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005170 * A right parenthesis (')'), used to finish a function call or
Douglas Gregor9eb77012009-11-07 00:00:49 +00005171 * signal the end of a function parameter list.
5172 */
5173 CXCompletionChunk_RightParen,
5174 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005175 * A left bracket ('[').
Douglas Gregor9eb77012009-11-07 00:00:49 +00005176 */
5177 CXCompletionChunk_LeftBracket,
5178 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005179 * A right bracket (']').
Douglas Gregor9eb77012009-11-07 00:00:49 +00005180 */
5181 CXCompletionChunk_RightBracket,
5182 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005183 * A left brace ('{').
Douglas Gregor9eb77012009-11-07 00:00:49 +00005184 */
5185 CXCompletionChunk_LeftBrace,
5186 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005187 * A right brace ('}').
Douglas Gregor9eb77012009-11-07 00:00:49 +00005188 */
5189 CXCompletionChunk_RightBrace,
5190 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005191 * A left angle bracket ('<').
Douglas Gregor9eb77012009-11-07 00:00:49 +00005192 */
5193 CXCompletionChunk_LeftAngle,
5194 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005195 * A right angle bracket ('>').
Douglas Gregor9eb77012009-11-07 00:00:49 +00005196 */
5197 CXCompletionChunk_RightAngle,
5198 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005199 * A comma separator (',').
Douglas Gregor9eb77012009-11-07 00:00:49 +00005200 */
Douglas Gregorb3fa9192009-12-18 18:53:37 +00005201 CXCompletionChunk_Comma,
5202 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005203 * Text that specifies the result type of a given result.
Douglas Gregorb3fa9192009-12-18 18:53:37 +00005204 *
5205 * This special kind of informative chunk is not meant to be inserted into
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005206 * the text buffer. Rather, it is meant to illustrate the type that an
Douglas Gregorb3fa9192009-12-18 18:53:37 +00005207 * expression using the given completion string would have.
5208 */
Douglas Gregor504a6ae2010-01-10 23:08:15 +00005209 CXCompletionChunk_ResultType,
5210 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005211 * A colon (':').
Douglas Gregor504a6ae2010-01-10 23:08:15 +00005212 */
5213 CXCompletionChunk_Colon,
5214 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005215 * A semicolon (';').
Douglas Gregor504a6ae2010-01-10 23:08:15 +00005216 */
5217 CXCompletionChunk_SemiColon,
5218 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005219 * An '=' sign.
Douglas Gregor504a6ae2010-01-10 23:08:15 +00005220 */
5221 CXCompletionChunk_Equal,
5222 /**
5223 * Horizontal space (' ').
5224 */
5225 CXCompletionChunk_HorizontalSpace,
5226 /**
Alex Lorenz6c2898a2017-04-06 14:03:25 +00005227 * Vertical space ('\\n'), after which it is generally a good idea to
Douglas Gregor504a6ae2010-01-10 23:08:15 +00005228 * perform indentation.
5229 */
5230 CXCompletionChunk_VerticalSpace
Douglas Gregor9eb77012009-11-07 00:00:49 +00005231};
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005232
Douglas Gregor9eb77012009-11-07 00:00:49 +00005233/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005234 * Determine the kind of a particular chunk within a completion string.
Douglas Gregor9eb77012009-11-07 00:00:49 +00005235 *
5236 * \param completion_string the completion string to query.
5237 *
5238 * \param chunk_number the 0-based index of the chunk in the completion string.
5239 *
5240 * \returns the kind of the chunk at the index \c chunk_number.
5241 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005242CINDEX_LINKAGE enum CXCompletionChunkKind
Douglas Gregor9eb77012009-11-07 00:00:49 +00005243clang_getCompletionChunkKind(CXCompletionString completion_string,
5244 unsigned chunk_number);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005245
Douglas Gregor9eb77012009-11-07 00:00:49 +00005246/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005247 * Retrieve the text associated with a particular chunk within a
Douglas Gregor9eb77012009-11-07 00:00:49 +00005248 * completion string.
5249 *
5250 * \param completion_string the completion string to query.
5251 *
5252 * \param chunk_number the 0-based index of the chunk in the completion string.
5253 *
5254 * \returns the text associated with the chunk at index \c chunk_number.
5255 */
Ted Kremenekf602f962010-02-17 01:42:24 +00005256CINDEX_LINKAGE CXString
Douglas Gregor9eb77012009-11-07 00:00:49 +00005257clang_getCompletionChunkText(CXCompletionString completion_string,
5258 unsigned chunk_number);
5259
5260/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005261 * Retrieve the completion string associated with a particular chunk
Douglas Gregor9eb77012009-11-07 00:00:49 +00005262 * within a completion string.
5263 *
5264 * \param completion_string the completion string to query.
5265 *
5266 * \param chunk_number the 0-based index of the chunk in the completion string.
5267 *
5268 * \returns the completion string associated with the chunk at index
Erik Verbruggen98ea7f62011-10-14 15:31:08 +00005269 * \c chunk_number.
Douglas Gregor9eb77012009-11-07 00:00:49 +00005270 */
5271CINDEX_LINKAGE CXCompletionString
5272clang_getCompletionChunkCompletionString(CXCompletionString completion_string,
5273 unsigned chunk_number);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005274
Douglas Gregor9eb77012009-11-07 00:00:49 +00005275/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005276 * Retrieve the number of chunks in the given code-completion string.
Douglas Gregor9eb77012009-11-07 00:00:49 +00005277 */
5278CINDEX_LINKAGE unsigned
5279clang_getNumCompletionChunks(CXCompletionString completion_string);
5280
5281/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005282 * Determine the priority of this code completion.
Douglas Gregora2db7932010-05-26 22:00:08 +00005283 *
Fangrui Song6907ce22018-07-30 19:24:48 +00005284 * The priority of a code completion indicates how likely it is that this
Douglas Gregora2db7932010-05-26 22:00:08 +00005285 * particular completion is the completion that the user will select. The
5286 * priority is selected by various internal heuristics.
5287 *
5288 * \param completion_string The completion string to query.
5289 *
5290 * \returns The priority of this completion string. Smaller values indicate
5291 * higher-priority (more likely) completions.
5292 */
5293CINDEX_LINKAGE unsigned
5294clang_getCompletionPriority(CXCompletionString completion_string);
Fangrui Song6907ce22018-07-30 19:24:48 +00005295
Douglas Gregora2db7932010-05-26 22:00:08 +00005296/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005297 * Determine the availability of the entity that this code-completion
Douglas Gregorf757a122010-08-23 23:00:57 +00005298 * string refers to.
5299 *
5300 * \param completion_string The completion string to query.
5301 *
5302 * \returns The availability of the completion string.
5303 */
Fangrui Song6907ce22018-07-30 19:24:48 +00005304CINDEX_LINKAGE enum CXAvailabilityKind
Douglas Gregorf757a122010-08-23 23:00:57 +00005305clang_getCompletionAvailability(CXCompletionString completion_string);
5306
5307/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005308 * Retrieve the number of annotations associated with the given
Erik Verbruggen98ea7f62011-10-14 15:31:08 +00005309 * completion string.
5310 *
5311 * \param completion_string the completion string to query.
5312 *
5313 * \returns the number of annotations associated with the given completion
5314 * string.
5315 */
5316CINDEX_LINKAGE unsigned
5317clang_getCompletionNumAnnotations(CXCompletionString completion_string);
5318
5319/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005320 * Retrieve the annotation associated with the given completion string.
Erik Verbruggen98ea7f62011-10-14 15:31:08 +00005321 *
5322 * \param completion_string the completion string to query.
5323 *
5324 * \param annotation_number the 0-based index of the annotation of the
5325 * completion string.
5326 *
5327 * \returns annotation string associated with the completion at index
5328 * \c annotation_number, or a NULL string if that annotation is not available.
5329 */
5330CINDEX_LINKAGE CXString
5331clang_getCompletionAnnotation(CXCompletionString completion_string,
5332 unsigned annotation_number);
5333
5334/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005335 * Retrieve the parent context of the given completion string.
Douglas Gregor78254c82012-03-27 23:34:16 +00005336 *
Fangrui Song6907ce22018-07-30 19:24:48 +00005337 * The parent context of a completion string is the semantic parent of
Douglas Gregor78254c82012-03-27 23:34:16 +00005338 * the declaration (if any) that the code completion represents. For example,
5339 * a code completion for an Objective-C method would have the method's class
5340 * or protocol as its context.
5341 *
5342 * \param completion_string The code completion string whose parent is
5343 * being queried.
5344 *
Argyrios Kyrtzidis9ae39562012-09-26 16:39:56 +00005345 * \param kind DEPRECATED: always set to CXCursor_NotImplemented if non-NULL.
Douglas Gregor78254c82012-03-27 23:34:16 +00005346 *
James Dennett574cb4c2012-06-15 05:41:51 +00005347 * \returns The name of the completion parent, e.g., "NSObject" if
Douglas Gregor78254c82012-03-27 23:34:16 +00005348 * the completion string represents a method in the NSObject class.
5349 */
5350CINDEX_LINKAGE CXString
5351clang_getCompletionParent(CXCompletionString completion_string,
5352 enum CXCursorKind *kind);
Dmitri Gribenko3292d062012-07-02 17:35:10 +00005353
5354/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005355 * Retrieve the brief documentation comment attached to the declaration
Dmitri Gribenko3292d062012-07-02 17:35:10 +00005356 * that corresponds to the given completion string.
5357 */
5358CINDEX_LINKAGE CXString
5359clang_getCompletionBriefComment(CXCompletionString completion_string);
5360
Douglas Gregor78254c82012-03-27 23:34:16 +00005361/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005362 * Retrieve a completion string for an arbitrary declaration or macro
Douglas Gregor3f35bb22011-08-04 20:04:59 +00005363 * definition cursor.
5364 *
5365 * \param cursor The cursor to query.
5366 *
5367 * \returns A non-context-sensitive completion string for declaration and macro
5368 * definition cursors, or NULL for other kinds of cursors.
5369 */
5370CINDEX_LINKAGE CXCompletionString
5371clang_getCursorCompletionString(CXCursor cursor);
Fangrui Song6907ce22018-07-30 19:24:48 +00005372
Douglas Gregor3f35bb22011-08-04 20:04:59 +00005373/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005374 * Contains the results of code-completion.
Douglas Gregorf72b6ac2009-12-18 16:20:58 +00005375 *
5376 * This data structure contains the results of code completion, as
Douglas Gregor6a9580282010-10-11 21:51:20 +00005377 * produced by \c clang_codeCompleteAt(). Its contents must be freed by
Douglas Gregorf72b6ac2009-12-18 16:20:58 +00005378 * \c clang_disposeCodeCompleteResults.
5379 */
5380typedef struct {
5381 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005382 * The code-completion results.
Douglas Gregorf72b6ac2009-12-18 16:20:58 +00005383 */
5384 CXCompletionResult *Results;
5385
5386 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005387 * The number of code-completion results stored in the
Douglas Gregorf72b6ac2009-12-18 16:20:58 +00005388 * \c Results array.
5389 */
5390 unsigned NumResults;
5391} CXCodeCompleteResults;
5392
5393/**
Ivan Donchevskii3957e482018-06-13 12:37:08 +00005394 * Retrieve the number of fix-its for the given completion index.
5395 *
5396 * Calling this makes sense only if CXCodeComplete_IncludeCompletionsWithFixIts
5397 * option was set.
5398 *
5399 * \param results The structure keeping all completion results
5400 *
5401 * \param completion_index The index of the completion
5402 *
5403 * \return The number of fix-its which must be applied before the completion at
5404 * completion_index can be applied
5405 */
5406CINDEX_LINKAGE unsigned
5407clang_getCompletionNumFixIts(CXCodeCompleteResults *results,
5408 unsigned completion_index);
5409
5410/**
5411 * Fix-its that *must* be applied before inserting the text for the
5412 * corresponding completion.
5413 *
5414 * By default, clang_codeCompleteAt() only returns completions with empty
5415 * fix-its. Extra completions with non-empty fix-its should be explicitly
5416 * requested by setting CXCodeComplete_IncludeCompletionsWithFixIts.
5417 *
5418 * For the clients to be able to compute position of the cursor after applying
5419 * fix-its, the following conditions are guaranteed to hold for
5420 * replacement_range of the stored fix-its:
5421 * - Ranges in the fix-its are guaranteed to never contain the completion
5422 * point (or identifier under completion point, if any) inside them, except
5423 * at the start or at the end of the range.
5424 * - If a fix-it range starts or ends with completion point (or starts or
5425 * ends after the identifier under completion point), it will contain at
5426 * least one character. It allows to unambiguously recompute completion
5427 * point after applying the fix-it.
5428 *
5429 * The intuition is that provided fix-its change code around the identifier we
5430 * complete, but are not allowed to touch the identifier itself or the
5431 * completion point. One example of completions with corrections are the ones
5432 * replacing '.' with '->' and vice versa:
5433 *
5434 * std::unique_ptr<std::vector<int>> vec_ptr;
5435 * In 'vec_ptr.^', one of the completions is 'push_back', it requires
5436 * replacing '.' with '->'.
5437 * In 'vec_ptr->^', one of the completions is 'release', it requires
5438 * replacing '->' with '.'.
5439 *
5440 * \param results The structure keeping all completion results
5441 *
5442 * \param completion_index The index of the completion
5443 *
5444 * \param fixit_index The index of the fix-it for the completion at
5445 * completion_index
5446 *
5447 * \param replacement_range The fix-it range that must be replaced before the
5448 * completion at completion_index can be applied
5449 *
5450 * \returns The fix-it string that must replace the code at replacement_range
5451 * before the completion at completion_index can be applied
5452 */
5453CINDEX_LINKAGE CXString clang_getCompletionFixIt(
5454 CXCodeCompleteResults *results, unsigned completion_index,
5455 unsigned fixit_index, CXSourceRange *replacement_range);
5456
5457/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005458 * Flags that can be passed to \c clang_codeCompleteAt() to
Douglas Gregorb68bc592010-08-05 09:09:23 +00005459 * modify its behavior.
5460 *
5461 * The enumerators in this enumeration can be bitwise-OR'd together to
5462 * provide multiple options to \c clang_codeCompleteAt().
5463 */
5464enum CXCodeComplete_Flags {
5465 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005466 * Whether to include macros within the set of code
Douglas Gregorb68bc592010-08-05 09:09:23 +00005467 * completions returned.
5468 */
5469 CXCodeComplete_IncludeMacros = 0x01,
5470
5471 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005472 * Whether to include code patterns for language constructs
Douglas Gregorb68bc592010-08-05 09:09:23 +00005473 * within the set of code completions, e.g., for loops.
5474 */
Dmitri Gribenko3292d062012-07-02 17:35:10 +00005475 CXCodeComplete_IncludeCodePatterns = 0x02,
5476
5477 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005478 * Whether to include brief documentation within the set of code
Dmitri Gribenko3292d062012-07-02 17:35:10 +00005479 * completions returned.
5480 */
Sam McCallbb2cf632018-01-12 14:51:47 +00005481 CXCodeComplete_IncludeBriefComments = 0x04,
5482
5483 /**
Sam McCallabdcc612018-01-24 17:50:20 +00005484 * Whether to speed up completion by omitting top- or namespace-level entities
5485 * defined in the preamble. There's no guarantee any particular entity is
5486 * omitted. This may be useful if the headers are indexed externally.
Sam McCallbb2cf632018-01-12 14:51:47 +00005487 */
Ivan Donchevskii3957e482018-06-13 12:37:08 +00005488 CXCodeComplete_SkipPreamble = 0x08,
5489
5490 /**
5491 * Whether to include completions with small
5492 * fix-its, e.g. change '.' to '->' on member access, etc.
5493 */
5494 CXCodeComplete_IncludeCompletionsWithFixIts = 0x10
Douglas Gregorb68bc592010-08-05 09:09:23 +00005495};
5496
5497/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005498 * Bits that represent the context under which completion is occurring.
Douglas Gregor21325842011-07-07 16:03:39 +00005499 *
5500 * The enumerators in this enumeration may be bitwise-OR'd together if multiple
5501 * contexts are occurring simultaneously.
5502 */
5503enum CXCompletionContext {
5504 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005505 * The context for completions is unexposed, as only Clang results
Douglas Gregor21325842011-07-07 16:03:39 +00005506 * should be included. (This is equivalent to having no context bits set.)
5507 */
5508 CXCompletionContext_Unexposed = 0,
Fangrui Song6907ce22018-07-30 19:24:48 +00005509
Douglas Gregor21325842011-07-07 16:03:39 +00005510 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005511 * Completions for any possible type should be included in the results.
Douglas Gregor21325842011-07-07 16:03:39 +00005512 */
5513 CXCompletionContext_AnyType = 1 << 0,
Fangrui Song6907ce22018-07-30 19:24:48 +00005514
Douglas Gregor21325842011-07-07 16:03:39 +00005515 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005516 * Completions for any possible value (variables, function calls, etc.)
Douglas Gregor21325842011-07-07 16:03:39 +00005517 * should be included in the results.
5518 */
5519 CXCompletionContext_AnyValue = 1 << 1,
5520 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005521 * Completions for values that resolve to an Objective-C object should
Douglas Gregor21325842011-07-07 16:03:39 +00005522 * be included in the results.
5523 */
5524 CXCompletionContext_ObjCObjectValue = 1 << 2,
5525 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005526 * Completions for values that resolve to an Objective-C selector
Douglas Gregor21325842011-07-07 16:03:39 +00005527 * should be included in the results.
5528 */
5529 CXCompletionContext_ObjCSelectorValue = 1 << 3,
5530 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005531 * Completions for values that resolve to a C++ class type should be
Douglas Gregor21325842011-07-07 16:03:39 +00005532 * included in the results.
5533 */
5534 CXCompletionContext_CXXClassTypeValue = 1 << 4,
Fangrui Song6907ce22018-07-30 19:24:48 +00005535
Douglas Gregor21325842011-07-07 16:03:39 +00005536 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005537 * Completions for fields of the member being accessed using the dot
Douglas Gregor21325842011-07-07 16:03:39 +00005538 * operator should be included in the results.
5539 */
5540 CXCompletionContext_DotMemberAccess = 1 << 5,
5541 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005542 * Completions for fields of the member being accessed using the arrow
Douglas Gregor21325842011-07-07 16:03:39 +00005543 * operator should be included in the results.
5544 */
5545 CXCompletionContext_ArrowMemberAccess = 1 << 6,
5546 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005547 * Completions for properties of the Objective-C object being accessed
Douglas Gregor21325842011-07-07 16:03:39 +00005548 * using the dot operator should be included in the results.
5549 */
5550 CXCompletionContext_ObjCPropertyAccess = 1 << 7,
Fangrui Song6907ce22018-07-30 19:24:48 +00005551
Douglas Gregor21325842011-07-07 16:03:39 +00005552 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005553 * Completions for enum tags should be included in the results.
Douglas Gregor21325842011-07-07 16:03:39 +00005554 */
5555 CXCompletionContext_EnumTag = 1 << 8,
5556 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005557 * Completions for union tags should be included in the results.
Douglas Gregor21325842011-07-07 16:03:39 +00005558 */
5559 CXCompletionContext_UnionTag = 1 << 9,
5560 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005561 * Completions for struct tags should be included in the results.
Douglas Gregor21325842011-07-07 16:03:39 +00005562 */
5563 CXCompletionContext_StructTag = 1 << 10,
Fangrui Song6907ce22018-07-30 19:24:48 +00005564
Douglas Gregor21325842011-07-07 16:03:39 +00005565 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005566 * Completions for C++ class names should be included in the results.
Douglas Gregor21325842011-07-07 16:03:39 +00005567 */
5568 CXCompletionContext_ClassTag = 1 << 11,
5569 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005570 * Completions for C++ namespaces and namespace aliases should be
Douglas Gregor21325842011-07-07 16:03:39 +00005571 * included in the results.
5572 */
5573 CXCompletionContext_Namespace = 1 << 12,
5574 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005575 * Completions for C++ nested name specifiers should be included in
Douglas Gregor21325842011-07-07 16:03:39 +00005576 * the results.
5577 */
5578 CXCompletionContext_NestedNameSpecifier = 1 << 13,
Fangrui Song6907ce22018-07-30 19:24:48 +00005579
Douglas Gregor21325842011-07-07 16:03:39 +00005580 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005581 * Completions for Objective-C interfaces (classes) should be included
Douglas Gregor21325842011-07-07 16:03:39 +00005582 * in the results.
5583 */
5584 CXCompletionContext_ObjCInterface = 1 << 14,
5585 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005586 * Completions for Objective-C protocols should be included in
Douglas Gregor21325842011-07-07 16:03:39 +00005587 * the results.
5588 */
5589 CXCompletionContext_ObjCProtocol = 1 << 15,
5590 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005591 * Completions for Objective-C categories should be included in
Douglas Gregor21325842011-07-07 16:03:39 +00005592 * the results.
5593 */
5594 CXCompletionContext_ObjCCategory = 1 << 16,
5595 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005596 * Completions for Objective-C instance messages should be included
Douglas Gregor21325842011-07-07 16:03:39 +00005597 * in the results.
5598 */
5599 CXCompletionContext_ObjCInstanceMessage = 1 << 17,
5600 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005601 * Completions for Objective-C class messages should be included in
Douglas Gregor21325842011-07-07 16:03:39 +00005602 * the results.
5603 */
5604 CXCompletionContext_ObjCClassMessage = 1 << 18,
5605 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005606 * Completions for Objective-C selector names should be included in
Douglas Gregor21325842011-07-07 16:03:39 +00005607 * the results.
5608 */
5609 CXCompletionContext_ObjCSelectorName = 1 << 19,
Fangrui Song6907ce22018-07-30 19:24:48 +00005610
Douglas Gregor21325842011-07-07 16:03:39 +00005611 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005612 * Completions for preprocessor macro names should be included in
Douglas Gregor21325842011-07-07 16:03:39 +00005613 * the results.
5614 */
5615 CXCompletionContext_MacroName = 1 << 20,
Fangrui Song6907ce22018-07-30 19:24:48 +00005616
Douglas Gregor21325842011-07-07 16:03:39 +00005617 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005618 * Natural language completions should be included in the results.
Douglas Gregor21325842011-07-07 16:03:39 +00005619 */
5620 CXCompletionContext_NaturalLanguage = 1 << 21,
Fangrui Song6907ce22018-07-30 19:24:48 +00005621
Douglas Gregor21325842011-07-07 16:03:39 +00005622 /**
Sam McCall3d8051a2018-09-18 08:40:41 +00005623 * #include file completions should be included in the results.
5624 */
5625 CXCompletionContext_IncludedFile = 1 << 22,
5626
5627 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005628 * The current context is unknown, so set all contexts.
Douglas Gregor21325842011-07-07 16:03:39 +00005629 */
Sam McCall3d8051a2018-09-18 08:40:41 +00005630 CXCompletionContext_Unknown = ((1 << 23) - 1)
Douglas Gregor21325842011-07-07 16:03:39 +00005631};
Fangrui Song6907ce22018-07-30 19:24:48 +00005632
Douglas Gregor21325842011-07-07 16:03:39 +00005633/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005634 * Returns a default set of code-completion options that can be
Fangrui Song6907ce22018-07-30 19:24:48 +00005635 * passed to\c clang_codeCompleteAt().
Douglas Gregorb68bc592010-08-05 09:09:23 +00005636 */
5637CINDEX_LINKAGE unsigned clang_defaultCodeCompleteOptions(void);
5638
5639/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005640 * Perform code completion at a given location in a translation unit.
Douglas Gregor8e984da2010-08-04 16:47:14 +00005641 *
5642 * This function performs code completion at a particular file, line, and
5643 * column within source code, providing results that suggest potential
5644 * code snippets based on the context of the completion. The basic model
5645 * for code completion is that Clang will parse a complete source file,
5646 * performing syntax checking up to the location where code-completion has
5647 * been requested. At that point, a special code-completion token is passed
5648 * to the parser, which recognizes this token and determines, based on the
5649 * current location in the C/Objective-C/C++ grammar and the state of
5650 * semantic analysis, what completions to provide. These completions are
5651 * returned via a new \c CXCodeCompleteResults structure.
5652 *
5653 * Code completion itself is meant to be triggered by the client when the
5654 * user types punctuation characters or whitespace, at which point the
5655 * code-completion location will coincide with the cursor. For example, if \c p
5656 * is a pointer, code-completion might be triggered after the "-" and then
Alexander Kornienko2a8c18d2018-04-06 15:14:32 +00005657 * after the ">" in \c p->. When the code-completion location is after the ">",
Douglas Gregor8e984da2010-08-04 16:47:14 +00005658 * the completion results will provide, e.g., the members of the struct that
5659 * "p" points to. The client is responsible for placing the cursor at the
5660 * beginning of the token currently being typed, then filtering the results
5661 * based on the contents of the token. For example, when code-completing for
5662 * the expression \c p->get, the client should provide the location just after
5663 * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the
5664 * client can filter the results based on the current token text ("get"), only
5665 * showing those results that start with "get". The intent of this interface
5666 * is to separate the relatively high-latency acquisition of code-completion
5667 * results from the filtering of results on a per-character basis, which must
5668 * have a lower latency.
5669 *
5670 * \param TU The translation unit in which code-completion should
5671 * occur. The source files for this translation unit need not be
5672 * completely up-to-date (and the contents of those source files may
5673 * be overridden via \p unsaved_files). Cursors referring into the
5674 * translation unit may be invalidated by this invocation.
5675 *
5676 * \param complete_filename The name of the source file where code
5677 * completion should be performed. This filename may be any file
5678 * included in the translation unit.
5679 *
5680 * \param complete_line The line at which code-completion should occur.
5681 *
5682 * \param complete_column The column at which code-completion should occur.
5683 * Note that the column should point just after the syntactic construct that
5684 * initiated code completion, and not in the middle of a lexical token.
5685 *
Vedant Kumarcbfe7bb2016-03-23 23:51:36 +00005686 * \param unsaved_files the Files that have not yet been saved to disk
Douglas Gregor8e984da2010-08-04 16:47:14 +00005687 * but may be required for parsing or code completion, including the
5688 * contents of those files. The contents and name of these files (as
5689 * specified by CXUnsavedFile) are copied when necessary, so the
5690 * client only needs to guarantee their validity until the call to
5691 * this function returns.
5692 *
5693 * \param num_unsaved_files The number of unsaved file entries in \p
5694 * unsaved_files.
5695 *
Douglas Gregorb68bc592010-08-05 09:09:23 +00005696 * \param options Extra options that control the behavior of code
5697 * completion, expressed as a bitwise OR of the enumerators of the
Fangrui Song6907ce22018-07-30 19:24:48 +00005698 * CXCodeComplete_Flags enumeration. The
Douglas Gregorb68bc592010-08-05 09:09:23 +00005699 * \c clang_defaultCodeCompleteOptions() function returns a default set
5700 * of code-completion options.
5701 *
Douglas Gregor8e984da2010-08-04 16:47:14 +00005702 * \returns If successful, a new \c CXCodeCompleteResults structure
5703 * containing code-completion results, which should eventually be
5704 * freed with \c clang_disposeCodeCompleteResults(). If code
5705 * completion fails, returns NULL.
5706 */
5707CINDEX_LINKAGE
5708CXCodeCompleteResults *clang_codeCompleteAt(CXTranslationUnit TU,
5709 const char *complete_filename,
5710 unsigned complete_line,
5711 unsigned complete_column,
5712 struct CXUnsavedFile *unsaved_files,
Douglas Gregorb68bc592010-08-05 09:09:23 +00005713 unsigned num_unsaved_files,
5714 unsigned options);
Douglas Gregor8e984da2010-08-04 16:47:14 +00005715
5716/**
Fangrui Song6907ce22018-07-30 19:24:48 +00005717 * Sort the code-completion results in case-insensitive alphabetical
Douglas Gregor49f67ce2010-08-26 13:48:20 +00005718 * order.
5719 *
5720 * \param Results The set of results to sort.
5721 * \param NumResults The number of results in \p Results.
5722 */
5723CINDEX_LINKAGE
5724void clang_sortCodeCompletionResults(CXCompletionResult *Results,
5725 unsigned NumResults);
Fangrui Song6907ce22018-07-30 19:24:48 +00005726
Douglas Gregor49f67ce2010-08-26 13:48:20 +00005727/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005728 * Free the given set of code-completion results.
Douglas Gregorf72b6ac2009-12-18 16:20:58 +00005729 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005730CINDEX_LINKAGE
Douglas Gregorf72b6ac2009-12-18 16:20:58 +00005731void clang_disposeCodeCompleteResults(CXCodeCompleteResults *Results);
Fangrui Song6907ce22018-07-30 19:24:48 +00005732
Douglas Gregor52606ff2010-01-20 01:10:47 +00005733/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005734 * Determine the number of diagnostics produced prior to the
Douglas Gregor33cdd812010-02-18 18:08:43 +00005735 * location where code completion was performed.
5736 */
Ted Kremenekd071c602010-03-13 02:50:34 +00005737CINDEX_LINKAGE
Douglas Gregor33cdd812010-02-18 18:08:43 +00005738unsigned clang_codeCompleteGetNumDiagnostics(CXCodeCompleteResults *Results);
5739
5740/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005741 * Retrieve a diagnostic associated with the given code completion.
Douglas Gregor33cdd812010-02-18 18:08:43 +00005742 *
James Dennett574cb4c2012-06-15 05:41:51 +00005743 * \param Results the code completion results to query.
Douglas Gregor33cdd812010-02-18 18:08:43 +00005744 * \param Index the zero-based diagnostic number to retrieve.
5745 *
5746 * \returns the requested diagnostic. This diagnostic must be freed
5747 * via a call to \c clang_disposeDiagnostic().
5748 */
Ted Kremenekd071c602010-03-13 02:50:34 +00005749CINDEX_LINKAGE
Douglas Gregor33cdd812010-02-18 18:08:43 +00005750CXDiagnostic clang_codeCompleteGetDiagnostic(CXCodeCompleteResults *Results,
5751 unsigned Index);
5752
5753/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005754 * Determines what completions are appropriate for the context
Douglas Gregor21325842011-07-07 16:03:39 +00005755 * the given code completion.
Fangrui Song6907ce22018-07-30 19:24:48 +00005756 *
Douglas Gregor21325842011-07-07 16:03:39 +00005757 * \param Results the code completion results to query
5758 *
5759 * \returns the kinds of completions that are appropriate for use
5760 * along with the given code completion results.
5761 */
5762CINDEX_LINKAGE
5763unsigned long long clang_codeCompleteGetContexts(
5764 CXCodeCompleteResults *Results);
Douglas Gregor63745d52011-07-21 01:05:26 +00005765
5766/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005767 * Returns the cursor kind for the container for the current code
Douglas Gregor63745d52011-07-21 01:05:26 +00005768 * completion context. The container is only guaranteed to be set for
5769 * contexts where a container exists (i.e. member accesses or Objective-C
5770 * message sends); if there is not a container, this function will return
5771 * CXCursor_InvalidCode.
5772 *
5773 * \param Results the code completion results to query
5774 *
5775 * \param IsIncomplete on return, this value will be false if Clang has complete
5776 * information about the container. If Clang does not have complete
5777 * information, this value will be true.
5778 *
5779 * \returns the container kind, or CXCursor_InvalidCode if there is not a
5780 * container
5781 */
5782CINDEX_LINKAGE
5783enum CXCursorKind clang_codeCompleteGetContainerKind(
5784 CXCodeCompleteResults *Results,
5785 unsigned *IsIncomplete);
5786
5787/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005788 * Returns the USR for the container for the current code completion
Douglas Gregor63745d52011-07-21 01:05:26 +00005789 * context. If there is not a container for the current context, this
5790 * function will return the empty string.
5791 *
5792 * \param Results the code completion results to query
5793 *
5794 * \returns the USR for the container
5795 */
5796CINDEX_LINKAGE
5797CXString clang_codeCompleteGetContainerUSR(CXCodeCompleteResults *Results);
NAKAMURA Takumiaa13f942015-12-09 07:52:46 +00005798
Douglas Gregorea777402011-07-26 15:24:30 +00005799/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005800 * Returns the currently-entered selector for an Objective-C message
Douglas Gregorea777402011-07-26 15:24:30 +00005801 * send, formatted like "initWithFoo:bar:". Only guaranteed to return a
5802 * non-empty string for CXCompletionContext_ObjCInstanceMessage and
5803 * CXCompletionContext_ObjCClassMessage.
5804 *
5805 * \param Results the code completion results to query
5806 *
5807 * \returns the selector (or partial selector) that has been entered thus far
5808 * for an Objective-C message send.
5809 */
5810CINDEX_LINKAGE
5811CXString clang_codeCompleteGetObjCSelector(CXCodeCompleteResults *Results);
Fangrui Song6907ce22018-07-30 19:24:48 +00005812
Douglas Gregor21325842011-07-07 16:03:39 +00005813/**
Douglas Gregor52606ff2010-01-20 01:10:47 +00005814 * @}
5815 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005816
Ted Kremenekc0f3f722010-01-22 22:44:15 +00005817/**
5818 * \defgroup CINDEX_MISC Miscellaneous utility functions
5819 *
5820 * @{
5821 */
Ted Kremenek3e315a22010-01-23 17:51:23 +00005822
5823/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005824 * Return a version string, suitable for showing to a user, but not
Ted Kremenek3e315a22010-01-23 17:51:23 +00005825 * intended to be parsed (the format is not guaranteed to be stable).
5826 */
NAKAMURA Takumieacd6672013-01-10 02:12:38 +00005827CINDEX_LINKAGE CXString clang_getClangVersion(void);
Ted Kremenekc0f3f722010-01-22 22:44:15 +00005828
Ted Kremenek1ec7b332011-03-18 23:05:39 +00005829/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005830 * Enable/disable crash recovery.
Ted Kremenek1ec7b332011-03-18 23:05:39 +00005831 *
James Dennett574cb4c2012-06-15 05:41:51 +00005832 * \param isEnabled Flag to indicate if crash recovery is enabled. A non-zero
5833 * value enables crash recovery, while 0 disables it.
Ted Kremenek1ec7b332011-03-18 23:05:39 +00005834 */
5835CINDEX_LINKAGE void clang_toggleCrashRecovery(unsigned isEnabled);
Fangrui Song6907ce22018-07-30 19:24:48 +00005836
Ted Kremenek0b86e3a2010-01-26 19:31:51 +00005837 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005838 * Visitor invoked for each file in a translation unit
Ted Kremenek0b86e3a2010-01-26 19:31:51 +00005839 * (used with clang_getInclusions()).
5840 *
5841 * This visitor function will be invoked by clang_getInclusions() for each
James Dennett574cb4c2012-06-15 05:41:51 +00005842 * file included (either at the top-level or by \#include directives) within
Ted Kremenek0b86e3a2010-01-26 19:31:51 +00005843 * a translation unit. The first argument is the file being included, and
5844 * the second and third arguments provide the inclusion stack. The
5845 * array is sorted in order of immediate inclusion. For example,
5846 * the first element refers to the location that included 'included_file'.
5847 */
5848typedef void (*CXInclusionVisitor)(CXFile included_file,
5849 CXSourceLocation* inclusion_stack,
5850 unsigned include_len,
5851 CXClientData client_data);
5852
5853/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005854 * Visit the set of preprocessor inclusions in a translation unit.
Ted Kremenek0b86e3a2010-01-26 19:31:51 +00005855 * The visitor function is called with the provided data for every included
5856 * file. This does not include headers included by the PCH file (unless one
5857 * is inspecting the inclusions in the PCH file itself).
5858 */
5859CINDEX_LINKAGE void clang_getInclusions(CXTranslationUnit tu,
5860 CXInclusionVisitor visitor,
5861 CXClientData client_data);
5862
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005863typedef enum {
5864 CXEval_Int = 1 ,
5865 CXEval_Float = 2,
5866 CXEval_ObjCStrLiteral = 3,
5867 CXEval_StrLiteral = 4,
5868 CXEval_CFStr = 5,
5869 CXEval_Other = 6,
5870
5871 CXEval_UnExposed = 0
5872
5873} CXEvalResultKind ;
5874
5875/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005876 * Evaluation result of a cursor
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005877 */
5878typedef void * CXEvalResult;
5879
5880/**
Fangrui Song6907ce22018-07-30 19:24:48 +00005881 * If cursor is a statement declaration tries to evaluate the
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005882 * statement and if its variable, tries to evaluate its initializer,
5883 * into its corresponding type.
5884 */
5885CINDEX_LINKAGE CXEvalResult clang_Cursor_Evaluate(CXCursor C);
5886
5887/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005888 * Returns the kind of the evaluated result.
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005889 */
Argyrios Kyrtzidisa851d7e2016-01-16 03:01:20 +00005890CINDEX_LINKAGE CXEvalResultKind clang_EvalResult_getKind(CXEvalResult E);
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005891
5892/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005893 * Returns the evaluation result as integer if the
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005894 * kind is Int.
5895 */
Argyrios Kyrtzidisa851d7e2016-01-16 03:01:20 +00005896CINDEX_LINKAGE int clang_EvalResult_getAsInt(CXEvalResult E);
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005897
5898/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005899 * Returns the evaluation result as a long long integer if the
Argyrios Kyrtzidis5dda1122016-12-01 23:41:27 +00005900 * kind is Int. This prevents overflows that may happen if the result is
5901 * returned with clang_EvalResult_getAsInt.
5902 */
5903CINDEX_LINKAGE long long clang_EvalResult_getAsLongLong(CXEvalResult E);
5904
5905/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005906 * Returns a non-zero value if the kind is Int and the evaluation
Argyrios Kyrtzidis5dda1122016-12-01 23:41:27 +00005907 * result resulted in an unsigned integer.
5908 */
5909CINDEX_LINKAGE unsigned clang_EvalResult_isUnsignedInt(CXEvalResult E);
5910
5911/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005912 * Returns the evaluation result as an unsigned integer if
Argyrios Kyrtzidis5dda1122016-12-01 23:41:27 +00005913 * the kind is Int and clang_EvalResult_isUnsignedInt is non-zero.
5914 */
5915CINDEX_LINKAGE unsigned long long clang_EvalResult_getAsUnsigned(CXEvalResult E);
5916
5917/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005918 * Returns the evaluation result as double if the
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005919 * kind is double.
5920 */
Argyrios Kyrtzidisa851d7e2016-01-16 03:01:20 +00005921CINDEX_LINKAGE double clang_EvalResult_getAsDouble(CXEvalResult E);
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005922
5923/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005924 * Returns the evaluation result as a constant string if the
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005925 * kind is other than Int or float. User must not free this pointer,
5926 * instead call clang_EvalResult_dispose on the CXEvalResult returned
5927 * by clang_Cursor_Evaluate.
5928 */
Argyrios Kyrtzidisa851d7e2016-01-16 03:01:20 +00005929CINDEX_LINKAGE const char* clang_EvalResult_getAsStr(CXEvalResult E);
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005930
5931/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005932 * Disposes the created Eval memory.
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005933 */
Argyrios Kyrtzidisa851d7e2016-01-16 03:01:20 +00005934CINDEX_LINKAGE void clang_EvalResult_dispose(CXEvalResult E);
Ted Kremenek0b86e3a2010-01-26 19:31:51 +00005935/**
Ted Kremenekc0f3f722010-01-22 22:44:15 +00005936 * @}
5937 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005938
Argyrios Kyrtzidisf89cc692011-07-11 20:15:00 +00005939/** \defgroup CINDEX_REMAPPING Remapping functions
5940 *
5941 * @{
5942 */
5943
5944/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005945 * A remapping of original source files and their translated files.
Argyrios Kyrtzidisf89cc692011-07-11 20:15:00 +00005946 */
5947typedef void *CXRemapping;
5948
5949/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005950 * Retrieve a remapping.
Argyrios Kyrtzidisf89cc692011-07-11 20:15:00 +00005951 *
5952 * \param path the path that contains metadata about remappings.
5953 *
5954 * \returns the requested remapping. This remapping must be freed
5955 * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
5956 */
5957CINDEX_LINKAGE CXRemapping clang_getRemappings(const char *path);
5958
5959/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005960 * Retrieve a remapping.
Ted Kremenekf7639e12012-03-06 20:06:33 +00005961 *
5962 * \param filePaths pointer to an array of file paths containing remapping info.
5963 *
5964 * \param numFiles number of file paths.
5965 *
5966 * \returns the requested remapping. This remapping must be freed
5967 * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
5968 */
5969CINDEX_LINKAGE
5970CXRemapping clang_getRemappingsFromFileList(const char **filePaths,
5971 unsigned numFiles);
5972
5973/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005974 * Determine the number of remappings.
Argyrios Kyrtzidisf89cc692011-07-11 20:15:00 +00005975 */
5976CINDEX_LINKAGE unsigned clang_remap_getNumFiles(CXRemapping);
5977
5978/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005979 * Get the original and the associated filename from the remapping.
Fangrui Song6907ce22018-07-30 19:24:48 +00005980 *
Argyrios Kyrtzidisf89cc692011-07-11 20:15:00 +00005981 * \param original If non-NULL, will be set to the original filename.
5982 *
5983 * \param transformed If non-NULL, will be set to the filename that the original
5984 * is associated with.
5985 */
5986CINDEX_LINKAGE void clang_remap_getFilenames(CXRemapping, unsigned index,
5987 CXString *original, CXString *transformed);
5988
5989/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005990 * Dispose the remapping.
Argyrios Kyrtzidisf89cc692011-07-11 20:15:00 +00005991 */
5992CINDEX_LINKAGE void clang_remap_dispose(CXRemapping);
5993
5994/**
5995 * @}
5996 */
5997
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00005998/** \defgroup CINDEX_HIGH Higher level API functions
5999 *
6000 * @{
6001 */
6002
6003enum CXVisitorResult {
6004 CXVisit_Break,
6005 CXVisit_Continue
6006};
6007
Saleem Abdulrasoolec988b72016-05-24 01:23:24 +00006008typedef struct CXCursorAndRangeVisitor {
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00006009 void *context;
6010 enum CXVisitorResult (*visit)(void *context, CXCursor, CXSourceRange);
6011} CXCursorAndRangeVisitor;
6012
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00006013typedef enum {
6014 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006015 * Function returned successfully.
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00006016 */
6017 CXResult_Success = 0,
6018 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006019 * One of the parameters was invalid for the function.
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00006020 */
6021 CXResult_Invalid = 1,
6022 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006023 * The function was terminated by a callback (e.g. it returned
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00006024 * CXVisit_Break)
6025 */
6026 CXResult_VisitBreak = 2
6027
6028} CXResult;
6029
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00006030/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006031 * Find references of a declaration in a specific file.
Fangrui Song6907ce22018-07-30 19:24:48 +00006032 *
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00006033 * \param cursor pointing to a declaration or a reference of one.
6034 *
6035 * \param file to search for references.
6036 *
6037 * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
6038 * each reference found.
6039 * The CXSourceRange will point inside the file; if the reference is inside
6040 * a macro (and not a macro argument) the CXSourceRange will be invalid.
Argyrios Kyrtzidis951f61f2013-03-08 20:42:33 +00006041 *
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00006042 * \returns one of the CXResult enumerators.
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00006043 */
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00006044CINDEX_LINKAGE CXResult clang_findReferencesInFile(CXCursor cursor, CXFile file,
6045 CXCursorAndRangeVisitor visitor);
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00006046
Argyrios Kyrtzidis503c83a2013-03-08 02:32:34 +00006047/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006048 * Find #import/#include directives in a specific file.
Argyrios Kyrtzidis503c83a2013-03-08 02:32:34 +00006049 *
6050 * \param TU translation unit containing the file to query.
6051 *
6052 * \param file to search for #import/#include directives.
6053 *
6054 * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
6055 * each directive found.
Argyrios Kyrtzidis951f61f2013-03-08 20:42:33 +00006056 *
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00006057 * \returns one of the CXResult enumerators.
Argyrios Kyrtzidis503c83a2013-03-08 02:32:34 +00006058 */
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00006059CINDEX_LINKAGE CXResult clang_findIncludesInFile(CXTranslationUnit TU,
6060 CXFile file,
6061 CXCursorAndRangeVisitor visitor);
Argyrios Kyrtzidis503c83a2013-03-08 02:32:34 +00006062
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00006063#ifdef __has_feature
6064# if __has_feature(blocks)
6065
6066typedef enum CXVisitorResult
6067 (^CXCursorAndRangeVisitorBlock)(CXCursor, CXSourceRange);
6068
6069CINDEX_LINKAGE
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00006070CXResult clang_findReferencesInFileWithBlock(CXCursor, CXFile,
6071 CXCursorAndRangeVisitorBlock);
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00006072
Argyrios Kyrtzidis503c83a2013-03-08 02:32:34 +00006073CINDEX_LINKAGE
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00006074CXResult clang_findIncludesInFileWithBlock(CXTranslationUnit, CXFile,
6075 CXCursorAndRangeVisitorBlock);
Argyrios Kyrtzidis503c83a2013-03-08 02:32:34 +00006076
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00006077# endif
6078#endif
6079
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006080/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006081 * The client's data object that is associated with a CXFile.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006082 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006083typedef void *CXIdxClientFile;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006084
6085/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006086 * The client's data object that is associated with a semantic entity.
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006087 */
6088typedef void *CXIdxClientEntity;
6089
6090/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006091 * The client's data object that is associated with a semantic container
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006092 * of entities.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006093 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006094typedef void *CXIdxClientContainer;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006095
6096/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006097 * The client's data object that is associated with an AST file (PCH
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006098 * or module).
6099 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006100typedef void *CXIdxClientASTFile;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006101
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006102/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006103 * Source location passed to index callbacks.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006104 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006105typedef struct {
6106 void *ptr_data[2];
6107 unsigned int_data;
6108} CXIdxLoc;
6109
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006110/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006111 * Data for ppIncludedFile callback.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006112 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006113typedef struct {
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006114 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006115 * Location of '#' in the \#include/\#import directive.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006116 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006117 CXIdxLoc hashLoc;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006118 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006119 * Filename as written in the \#include/\#import directive.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006120 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006121 const char *filename;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006122 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006123 * The actual file that the \#include/\#import directive resolved to.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006124 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006125 CXFile file;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006126 int isImport;
6127 int isAngled;
Argyrios Kyrtzidis5e2ec482012-10-18 00:17:05 +00006128 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006129 * Non-zero if the directive was automatically turned into a module
Argyrios Kyrtzidis5e2ec482012-10-18 00:17:05 +00006130 * import.
6131 */
6132 int isModuleImport;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006133} CXIdxIncludedFileInfo;
6134
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006135/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006136 * Data for IndexerCallbacks#importedASTFile.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006137 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006138typedef struct {
Argyrios Kyrtzidis472eda02012-10-02 16:10:38 +00006139 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006140 * Top level AST file containing the imported PCH, module or submodule.
Argyrios Kyrtzidis472eda02012-10-02 16:10:38 +00006141 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006142 CXFile file;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006143 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006144 * The imported module or NULL if the AST file is a PCH.
Argyrios Kyrtzidisdc78f3e2012-10-05 00:22:40 +00006145 */
6146 CXModule module;
6147 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006148 * Location where the file is imported. Applicable only for modules.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006149 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006150 CXIdxLoc loc;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006151 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006152 * Non-zero if an inclusion directive was automatically turned into
Argyrios Kyrtzidisdc78f3e2012-10-05 00:22:40 +00006153 * a module import. Applicable only for modules.
Argyrios Kyrtzidis472eda02012-10-02 16:10:38 +00006154 */
Argyrios Kyrtzidis184b1442012-10-03 21:05:44 +00006155 int isImplicit;
Argyrios Kyrtzidis472eda02012-10-02 16:10:38 +00006156
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006157} CXIdxImportedASTFileInfo;
6158
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006159typedef enum {
6160 CXIdxEntity_Unexposed = 0,
6161 CXIdxEntity_Typedef = 1,
6162 CXIdxEntity_Function = 2,
6163 CXIdxEntity_Variable = 3,
6164 CXIdxEntity_Field = 4,
6165 CXIdxEntity_EnumConstant = 5,
6166
6167 CXIdxEntity_ObjCClass = 6,
6168 CXIdxEntity_ObjCProtocol = 7,
6169 CXIdxEntity_ObjCCategory = 8,
6170
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00006171 CXIdxEntity_ObjCInstanceMethod = 9,
6172 CXIdxEntity_ObjCClassMethod = 10,
6173 CXIdxEntity_ObjCProperty = 11,
6174 CXIdxEntity_ObjCIvar = 12,
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006175
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00006176 CXIdxEntity_Enum = 13,
6177 CXIdxEntity_Struct = 14,
6178 CXIdxEntity_Union = 15,
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006179
6180 CXIdxEntity_CXXClass = 16,
6181 CXIdxEntity_CXXNamespace = 17,
6182 CXIdxEntity_CXXNamespaceAlias = 18,
6183 CXIdxEntity_CXXStaticVariable = 19,
6184 CXIdxEntity_CXXStaticMethod = 20,
6185 CXIdxEntity_CXXInstanceMethod = 21,
Joao Matose9a3ed42012-08-31 22:18:20 +00006186 CXIdxEntity_CXXConstructor = 22,
6187 CXIdxEntity_CXXDestructor = 23,
6188 CXIdxEntity_CXXConversionFunction = 24,
6189 CXIdxEntity_CXXTypeAlias = 25,
6190 CXIdxEntity_CXXInterface = 26
6191
6192} CXIdxEntityKind;
6193
Argyrios Kyrtzidis52002882011-12-07 20:44:12 +00006194typedef enum {
6195 CXIdxEntityLang_None = 0,
6196 CXIdxEntityLang_C = 1,
6197 CXIdxEntityLang_ObjC = 2,
Argyrios Kyrtzidisb4b85f22017-04-24 14:52:00 +00006198 CXIdxEntityLang_CXX = 3,
6199 CXIdxEntityLang_Swift = 4
Argyrios Kyrtzidis52002882011-12-07 20:44:12 +00006200} CXIdxEntityLanguage;
6201
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006202/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006203 * Extra C++ template information for an entity. This can apply to:
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006204 * CXIdxEntity_Function
6205 * CXIdxEntity_CXXClass
6206 * CXIdxEntity_CXXStaticMethod
6207 * CXIdxEntity_CXXInstanceMethod
6208 * CXIdxEntity_CXXConstructor
6209 * CXIdxEntity_CXXConversionFunction
6210 * CXIdxEntity_CXXTypeAlias
6211 */
6212typedef enum {
6213 CXIdxEntity_NonTemplate = 0,
6214 CXIdxEntity_Template = 1,
6215 CXIdxEntity_TemplatePartialSpecialization = 2,
6216 CXIdxEntity_TemplateSpecialization = 3
6217} CXIdxEntityCXXTemplateKind;
6218
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00006219typedef enum {
6220 CXIdxAttr_Unexposed = 0,
6221 CXIdxAttr_IBAction = 1,
6222 CXIdxAttr_IBOutlet = 2,
6223 CXIdxAttr_IBOutletCollection = 3
6224} CXIdxAttrKind;
6225
6226typedef struct {
6227 CXIdxAttrKind kind;
6228 CXCursor cursor;
6229 CXIdxLoc loc;
6230} CXIdxAttrInfo;
6231
6232typedef struct {
Argyrios Kyrtzidis4d873b72011-12-15 00:05:00 +00006233 CXIdxEntityKind kind;
6234 CXIdxEntityCXXTemplateKind templateKind;
6235 CXIdxEntityLanguage lang;
6236 const char *name;
6237 const char *USR;
6238 CXCursor cursor;
6239 const CXIdxAttrInfo *const *attributes;
6240 unsigned numAttributes;
6241} CXIdxEntityInfo;
6242
6243typedef struct {
6244 CXCursor cursor;
6245} CXIdxContainerInfo;
6246
6247typedef struct {
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00006248 const CXIdxAttrInfo *attrInfo;
6249 const CXIdxEntityInfo *objcClass;
6250 CXCursor classCursor;
6251 CXIdxLoc classLoc;
6252} CXIdxIBOutletCollectionAttrInfo;
6253
Argyrios Kyrtzidis8b71bc72012-12-06 19:41:16 +00006254typedef enum {
6255 CXIdxDeclFlag_Skipped = 0x1
6256} CXIdxDeclInfoFlags;
6257
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006258typedef struct {
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006259 const CXIdxEntityInfo *entityInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006260 CXCursor cursor;
6261 CXIdxLoc loc;
Argyrios Kyrtzidis663c8ec2011-12-07 20:44:19 +00006262 const CXIdxContainerInfo *semanticContainer;
6263 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006264 * Generally same as #semanticContainer but can be different in
Argyrios Kyrtzidis663c8ec2011-12-07 20:44:19 +00006265 * cases like out-of-line C++ member functions.
6266 */
6267 const CXIdxContainerInfo *lexicalContainer;
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006268 int isRedeclaration;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006269 int isDefinition;
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00006270 int isContainer;
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006271 const CXIdxContainerInfo *declAsContainer;
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00006272 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006273 * Whether the declaration exists in code or was created implicitly
Nico Weber7deebef2014-04-24 03:17:47 +00006274 * by the compiler, e.g. implicit Objective-C methods for properties.
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00006275 */
6276 int isImplicit;
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00006277 const CXIdxAttrInfo *const *attributes;
6278 unsigned numAttributes;
Argyrios Kyrtzidis8b71bc72012-12-06 19:41:16 +00006279
6280 unsigned flags;
6281
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006282} CXIdxDeclInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006283
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006284typedef enum {
6285 CXIdxObjCContainer_ForwardRef = 0,
6286 CXIdxObjCContainer_Interface = 1,
6287 CXIdxObjCContainer_Implementation = 2
6288} CXIdxObjCContainerKind;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006289
6290typedef struct {
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006291 const CXIdxDeclInfo *declInfo;
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006292 CXIdxObjCContainerKind kind;
6293} CXIdxObjCContainerDeclInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006294
6295typedef struct {
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006296 const CXIdxEntityInfo *base;
6297 CXCursor cursor;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006298 CXIdxLoc loc;
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006299} CXIdxBaseClassInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006300
6301typedef struct {
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006302 const CXIdxEntityInfo *protocol;
6303 CXCursor cursor;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006304 CXIdxLoc loc;
6305} CXIdxObjCProtocolRefInfo;
6306
6307typedef struct {
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006308 const CXIdxObjCProtocolRefInfo *const *protocols;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006309 unsigned numProtocols;
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00006310} CXIdxObjCProtocolRefListInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006311
6312typedef struct {
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00006313 const CXIdxObjCContainerDeclInfo *containerInfo;
6314 const CXIdxBaseClassInfo *superInfo;
6315 const CXIdxObjCProtocolRefListInfo *protocols;
6316} CXIdxObjCInterfaceDeclInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006317
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006318typedef struct {
Argyrios Kyrtzidis9b9f7a92011-12-13 18:47:45 +00006319 const CXIdxObjCContainerDeclInfo *containerInfo;
6320 const CXIdxEntityInfo *objcClass;
6321 CXCursor classCursor;
6322 CXIdxLoc classLoc;
6323 const CXIdxObjCProtocolRefListInfo *protocols;
6324} CXIdxObjCCategoryDeclInfo;
6325
6326typedef struct {
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006327 const CXIdxDeclInfo *declInfo;
Argyrios Kyrtzidis93db2922012-02-28 17:50:33 +00006328 const CXIdxEntityInfo *getter;
6329 const CXIdxEntityInfo *setter;
6330} CXIdxObjCPropertyDeclInfo;
6331
6332typedef struct {
6333 const CXIdxDeclInfo *declInfo;
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006334 const CXIdxBaseClassInfo *const *bases;
6335 unsigned numBases;
6336} CXIdxCXXClassDeclInfo;
6337
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006338/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006339 * Data for IndexerCallbacks#indexEntityReference.
Fangrui Song31b97192018-02-12 17:42:09 +00006340 *
6341 * This may be deprecated in a future version as this duplicates
6342 * the \c CXSymbolRole_Implicit bit in \c CXSymbolRole.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006343 */
Argyrios Kyrtzidis0c7735e52011-10-18 15:50:50 +00006344typedef enum {
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006345 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006346 * The entity is referenced directly in user's code.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006347 */
Argyrios Kyrtzidis0c7735e52011-10-18 15:50:50 +00006348 CXIdxEntityRef_Direct = 1,
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006349 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006350 * An implicit reference, e.g. a reference of an Objective-C method
Nico Weber7deebef2014-04-24 03:17:47 +00006351 * via the dot syntax.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006352 */
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00006353 CXIdxEntityRef_Implicit = 2
Argyrios Kyrtzidis0c7735e52011-10-18 15:50:50 +00006354} CXIdxEntityRefKind;
6355
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006356/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006357 * Roles that are attributed to symbol occurrences.
Fangrui Song31b97192018-02-12 17:42:09 +00006358 *
6359 * Internal: this currently mirrors low 9 bits of clang::index::SymbolRole with
6360 * higher bits zeroed. These high bits may be exposed in the future.
6361 */
6362typedef enum {
6363 CXSymbolRole_None = 0,
6364 CXSymbolRole_Declaration = 1 << 0,
6365 CXSymbolRole_Definition = 1 << 1,
6366 CXSymbolRole_Reference = 1 << 2,
6367 CXSymbolRole_Read = 1 << 3,
6368 CXSymbolRole_Write = 1 << 4,
6369 CXSymbolRole_Call = 1 << 5,
6370 CXSymbolRole_Dynamic = 1 << 6,
6371 CXSymbolRole_AddressOf = 1 << 7,
6372 CXSymbolRole_Implicit = 1 << 8
6373} CXSymbolRole;
6374
6375/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006376 * Data for IndexerCallbacks#indexEntityReference.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006377 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006378typedef struct {
Argyrios Kyrtzidis663c8ec2011-12-07 20:44:19 +00006379 CXIdxEntityRefKind kind;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006380 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006381 * Reference cursor.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006382 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006383 CXCursor cursor;
6384 CXIdxLoc loc;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006385 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006386 * The entity that gets referenced.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006387 */
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006388 const CXIdxEntityInfo *referencedEntity;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006389 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006390 * Immediate "parent" of the reference. For example:
Fangrui Song6907ce22018-07-30 19:24:48 +00006391 *
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006392 * \code
6393 * Foo *var;
6394 * \endcode
Fangrui Song6907ce22018-07-30 19:24:48 +00006395 *
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006396 * The parent of reference of type 'Foo' is the variable 'var'.
Argyrios Kyrtzidis25cb0ff2011-12-13 18:47:41 +00006397 * For references inside statement bodies of functions/methods,
6398 * the parentEntity will be the function/method.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006399 */
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006400 const CXIdxEntityInfo *parentEntity;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006401 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006402 * Lexical container context of the reference.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006403 */
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006404 const CXIdxContainerInfo *container;
Fangrui Song31b97192018-02-12 17:42:09 +00006405 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006406 * Sets of symbol roles of the reference.
Fangrui Song31b97192018-02-12 17:42:09 +00006407 */
6408 CXSymbolRole role;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006409} CXIdxEntityRefInfo;
6410
James Dennett574cb4c2012-06-15 05:41:51 +00006411/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006412 * A group of callbacks used by #clang_indexSourceFile and
James Dennett574cb4c2012-06-15 05:41:51 +00006413 * #clang_indexTranslationUnit.
6414 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006415typedef struct {
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006416 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006417 * Called periodically to check whether indexing should be aborted.
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006418 * Should return 0 to continue, and non-zero to abort.
6419 */
6420 int (*abortQuery)(CXClientData client_data, void *reserved);
6421
6422 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006423 * Called at the end of indexing; passes the complete diagnostic set.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006424 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006425 void (*diagnostic)(CXClientData client_data,
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00006426 CXDiagnosticSet, void *reserved);
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006427
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006428 CXIdxClientFile (*enteredMainFile)(CXClientData client_data,
James Dennett574cb4c2012-06-15 05:41:51 +00006429 CXFile mainFile, void *reserved);
Fangrui Song6907ce22018-07-30 19:24:48 +00006430
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006431 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006432 * Called when a file gets \#included/\#imported.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006433 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006434 CXIdxClientFile (*ppIncludedFile)(CXClientData client_data,
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006435 const CXIdxIncludedFileInfo *);
Fangrui Song6907ce22018-07-30 19:24:48 +00006436
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006437 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006438 * Called when a AST file (PCH or module) gets imported.
Fangrui Song6907ce22018-07-30 19:24:48 +00006439 *
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006440 * AST files will not get indexed (there will not be callbacks to index all
6441 * the entities in an AST file). The recommended action is that, if the AST
Argyrios Kyrtzidis472eda02012-10-02 16:10:38 +00006442 * file is not already indexed, to initiate a new indexing job specific to
6443 * the AST file.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006444 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006445 CXIdxClientASTFile (*importedASTFile)(CXClientData client_data,
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006446 const CXIdxImportedASTFileInfo *);
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006447
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006448 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006449 * Called at the beginning of indexing a translation unit.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006450 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006451 CXIdxClientContainer (*startedTranslationUnit)(CXClientData client_data,
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006452 void *reserved);
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006453
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006454 void (*indexDeclaration)(CXClientData client_data,
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006455 const CXIdxDeclInfo *);
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006456
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006457 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006458 * Called to index a reference of an entity.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006459 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006460 void (*indexEntityReference)(CXClientData client_data,
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006461 const CXIdxEntityRefInfo *);
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006462
6463} IndexerCallbacks;
6464
NAKAMURA Takumiaacef7e2011-11-11 02:51:09 +00006465CINDEX_LINKAGE int clang_index_isEntityObjCContainerKind(CXIdxEntityKind);
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006466CINDEX_LINKAGE const CXIdxObjCContainerDeclInfo *
6467clang_index_getObjCContainerDeclInfo(const CXIdxDeclInfo *);
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006468
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006469CINDEX_LINKAGE const CXIdxObjCInterfaceDeclInfo *
6470clang_index_getObjCInterfaceDeclInfo(const CXIdxDeclInfo *);
6471
NAKAMURA Takumiaacef7e2011-11-11 02:51:09 +00006472CINDEX_LINKAGE
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006473const CXIdxObjCCategoryDeclInfo *
6474clang_index_getObjCCategoryDeclInfo(const CXIdxDeclInfo *);
6475
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00006476CINDEX_LINKAGE const CXIdxObjCProtocolRefListInfo *
6477clang_index_getObjCProtocolRefListInfo(const CXIdxDeclInfo *);
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006478
Argyrios Kyrtzidis93db2922012-02-28 17:50:33 +00006479CINDEX_LINKAGE const CXIdxObjCPropertyDeclInfo *
6480clang_index_getObjCPropertyDeclInfo(const CXIdxDeclInfo *);
6481
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00006482CINDEX_LINKAGE const CXIdxIBOutletCollectionAttrInfo *
6483clang_index_getIBOutletCollectionAttrInfo(const CXIdxAttrInfo *);
6484
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006485CINDEX_LINKAGE const CXIdxCXXClassDeclInfo *
6486clang_index_getCXXClassDeclInfo(const CXIdxDeclInfo *);
6487
6488/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006489 * For retrieving a custom CXIdxClientContainer attached to a
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006490 * container.
6491 */
6492CINDEX_LINKAGE CXIdxClientContainer
6493clang_index_getClientContainer(const CXIdxContainerInfo *);
6494
6495/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006496 * For setting a custom CXIdxClientContainer attached to a
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006497 * container.
6498 */
6499CINDEX_LINKAGE void
6500clang_index_setClientContainer(const CXIdxContainerInfo *,CXIdxClientContainer);
6501
6502/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006503 * For retrieving a custom CXIdxClientEntity attached to an entity.
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006504 */
6505CINDEX_LINKAGE CXIdxClientEntity
6506clang_index_getClientEntity(const CXIdxEntityInfo *);
6507
6508/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006509 * For setting a custom CXIdxClientEntity attached to an entity.
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006510 */
6511CINDEX_LINKAGE void
6512clang_index_setClientEntity(const CXIdxEntityInfo *, CXIdxClientEntity);
6513
6514/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006515 * An indexing action/session, to be applied to one or multiple
Argyrios Kyrtzidis8b71bc72012-12-06 19:41:16 +00006516 * translation units.
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006517 */
6518typedef void *CXIndexAction;
6519
6520/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006521 * An indexing action/session, to be applied to one or multiple
Argyrios Kyrtzidis8b71bc72012-12-06 19:41:16 +00006522 * translation units.
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006523 *
6524 * \param CIdx The index object with which the index action will be associated.
6525 */
6526CINDEX_LINKAGE CXIndexAction clang_IndexAction_create(CXIndex CIdx);
6527
6528/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006529 * Destroy the given index action.
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006530 *
6531 * The index action must not be destroyed until all of the translation units
6532 * created within that index action have been destroyed.
6533 */
6534CINDEX_LINKAGE void clang_IndexAction_dispose(CXIndexAction);
6535
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006536typedef enum {
6537 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006538 * Used to indicate that no special indexing options are needed.
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006539 */
6540 CXIndexOpt_None = 0x0,
Fangrui Song6907ce22018-07-30 19:24:48 +00006541
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006542 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006543 * Used to indicate that IndexerCallbacks#indexEntityReference should
James Dennett574cb4c2012-06-15 05:41:51 +00006544 * be invoked for only one reference of an entity per source file that does
6545 * not also include a declaration/definition of the entity.
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006546 */
Argyrios Kyrtzidisfb7d1452012-01-14 00:11:49 +00006547 CXIndexOpt_SuppressRedundantRefs = 0x1,
6548
6549 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006550 * Function-local symbols should be indexed. If this is not set
Argyrios Kyrtzidisfb7d1452012-01-14 00:11:49 +00006551 * function-local symbols will be ignored.
6552 */
Argyrios Kyrtzidis7e747952012-02-14 22:23:11 +00006553 CXIndexOpt_IndexFunctionLocalSymbols = 0x2,
6554
6555 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006556 * Implicit function/class template instantiations should be indexed.
Argyrios Kyrtzidis7e747952012-02-14 22:23:11 +00006557 * If this is not set, implicit instantiations will be ignored.
6558 */
Argyrios Kyrtzidis6c9ed7d2012-03-27 21:38:03 +00006559 CXIndexOpt_IndexImplicitTemplateInstantiations = 0x4,
6560
6561 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006562 * Suppress all compiler warnings when parsing for indexing.
Argyrios Kyrtzidis6c9ed7d2012-03-27 21:38:03 +00006563 */
Argyrios Kyrtzidis8b71bc72012-12-06 19:41:16 +00006564 CXIndexOpt_SuppressWarnings = 0x8,
6565
6566 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006567 * Skip a function/method body that was already parsed during an
Nico Weber7deebef2014-04-24 03:17:47 +00006568 * indexing session associated with a \c CXIndexAction object.
Argyrios Kyrtzidis8b71bc72012-12-06 19:41:16 +00006569 * Bodies in system headers are always skipped.
6570 */
6571 CXIndexOpt_SkipParsedBodiesInSession = 0x10
6572
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006573} CXIndexOptFlags;
6574
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006575/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006576 * Index the given source file and the translation unit corresponding
James Dennett574cb4c2012-06-15 05:41:51 +00006577 * to that file via callbacks implemented through #IndexerCallbacks.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006578 *
6579 * \param client_data pointer data supplied by the client, which will
6580 * be passed to the invoked callbacks.
6581 *
6582 * \param index_callbacks Pointer to indexing callbacks that the client
6583 * implements.
6584 *
James Dennett574cb4c2012-06-15 05:41:51 +00006585 * \param index_callbacks_size Size of #IndexerCallbacks structure that gets
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006586 * passed in index_callbacks.
6587 *
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006588 * \param index_options A bitmask of options that affects how indexing is
6589 * performed. This should be a bitwise OR of the CXIndexOpt_XXX flags.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006590 *
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00006591 * \param[out] out_TU pointer to store a \c CXTranslationUnit that can be
6592 * reused after indexing is finished. Set to \c NULL if you do not require it.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006593 *
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00006594 * \returns 0 on success or if there were errors from which the compiler could
Eric Christopher2c4555a2015-06-19 01:52:53 +00006595 * recover. If there is a failure from which there is no recovery, returns
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00006596 * a non-zero \c CXErrorCode.
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006597 *
James Dennett574cb4c2012-06-15 05:41:51 +00006598 * The rest of the parameters are the same as #clang_parseTranslationUnit.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006599 */
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006600CINDEX_LINKAGE int clang_indexSourceFile(CXIndexAction,
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006601 CXClientData client_data,
6602 IndexerCallbacks *index_callbacks,
6603 unsigned index_callbacks_size,
6604 unsigned index_options,
6605 const char *source_filename,
6606 const char * const *command_line_args,
6607 int num_command_line_args,
6608 struct CXUnsavedFile *unsaved_files,
6609 unsigned num_unsaved_files,
6610 CXTranslationUnit *out_TU,
6611 unsigned TU_options);
6612
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006613/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006614 * Same as clang_indexSourceFile but requires a full command line
Benjamin Kramerc02670e2015-11-18 16:14:27 +00006615 * for \c command_line_args including argv[0]. This is useful if the standard
6616 * library paths are relative to the binary.
6617 */
6618CINDEX_LINKAGE int clang_indexSourceFileFullArgv(
6619 CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks,
6620 unsigned index_callbacks_size, unsigned index_options,
6621 const char *source_filename, const char *const *command_line_args,
6622 int num_command_line_args, struct CXUnsavedFile *unsaved_files,
6623 unsigned num_unsaved_files, CXTranslationUnit *out_TU, unsigned TU_options);
6624
6625/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006626 * Index the given translation unit via callbacks implemented through
James Dennett574cb4c2012-06-15 05:41:51 +00006627 * #IndexerCallbacks.
Fangrui Song6907ce22018-07-30 19:24:48 +00006628 *
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006629 * The order of callback invocations is not guaranteed to be the same as
6630 * when indexing a source file. The high level order will be:
Fangrui Song6907ce22018-07-30 19:24:48 +00006631 *
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006632 * -Preprocessor callbacks invocations
6633 * -Declaration/reference callbacks invocations
6634 * -Diagnostic callback invocations
6635 *
James Dennett574cb4c2012-06-15 05:41:51 +00006636 * The parameters are the same as #clang_indexSourceFile.
Fangrui Song6907ce22018-07-30 19:24:48 +00006637 *
Eric Christopher2c4555a2015-06-19 01:52:53 +00006638 * \returns If there is a failure from which there is no recovery, returns
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006639 * non-zero, otherwise returns 0.
6640 */
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006641CINDEX_LINKAGE int clang_indexTranslationUnit(CXIndexAction,
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006642 CXClientData client_data,
6643 IndexerCallbacks *index_callbacks,
6644 unsigned index_callbacks_size,
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006645 unsigned index_options,
6646 CXTranslationUnit);
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006647
6648/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006649 * Retrieve the CXIdxFile, file, line, column, and offset represented by
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006650 * the given CXIdxLoc.
6651 *
6652 * If the location refers into a macro expansion, retrieves the
6653 * location of the macro expansion and if it refers into a macro argument
6654 * retrieves the location of the argument.
6655 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006656CINDEX_LINKAGE void clang_indexLoc_getFileLocation(CXIdxLoc loc,
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006657 CXIdxClientFile *indexFile,
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006658 CXFile *file,
6659 unsigned *line,
6660 unsigned *column,
6661 unsigned *offset);
6662
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006663/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006664 * Retrieve the CXSourceLocation represented by the given CXIdxLoc.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006665 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006666CINDEX_LINKAGE
6667CXSourceLocation clang_indexLoc_getCXSourceLocation(CXIdxLoc loc);
6668
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00006669/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006670 * Visitor invoked for each field found by a traversal.
Argyrios Kyrtzidis2bff5162015-04-13 16:55:04 +00006671 *
6672 * This visitor function will be invoked for each field found by
6673 * \c clang_Type_visitFields. Its first argument is the cursor being
6674 * visited, its second argument is the client data provided to
6675 * \c clang_Type_visitFields.
6676 *
6677 * The visitor should return one of the \c CXVisitorResult values
6678 * to direct \c clang_Type_visitFields.
6679 */
6680typedef enum CXVisitorResult (*CXFieldVisitor)(CXCursor C,
6681 CXClientData client_data);
6682
6683/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006684 * Visit the fields of a particular type.
Argyrios Kyrtzidis2bff5162015-04-13 16:55:04 +00006685 *
6686 * This function visits all the direct fields of the given cursor,
6687 * invoking the given \p visitor function with the cursors of each
6688 * visited field. The traversal may be ended prematurely, if
6689 * the visitor returns \c CXFieldVisit_Break.
6690 *
6691 * \param T the record type whose field may be visited.
6692 *
6693 * \param visitor the visitor function that will be invoked for each
6694 * field of \p T.
6695 *
6696 * \param client_data pointer data supplied by the client, which will
6697 * be passed to the visitor each time it is invoked.
6698 *
6699 * \returns a non-zero value if the traversal was terminated
6700 * prematurely by the visitor returning \c CXFieldVisit_Break.
6701 */
6702CINDEX_LINKAGE unsigned clang_Type_visitFields(CXType T,
6703 CXFieldVisitor visitor,
6704 CXClientData client_data);
6705
Argyrios Kyrtzidis2bff5162015-04-13 16:55:04 +00006706/**
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00006707 * @}
6708 */
6709
Douglas Gregor6007cf22010-01-22 22:29:16 +00006710/**
6711 * @}
6712 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00006713
Ted Kremenekb60d87c2009-08-26 22:36:44 +00006714#ifdef __cplusplus
6715}
6716#endif
6717#endif