blob: 19471af4a675c3408fe03effd8adfc59e89ca4b5 [file] [log] [blame]
Ted Kremenekb60d87c2009-08-26 22:36:44 +00001/*===-- clang-c/Index.h - Indexing Public C Interface -------------*- C -*-===*\
2|* *|
Chandler Carruth2946cd72019-01-19 08:50:56 +00003|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
4|* Exceptions. *|
5|* See https://llvm.org/LICENSE.txt for license information. *|
6|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
Ted Kremenekb60d87c2009-08-26 22:36:44 +00007|* *|
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
Duncan P. N. Exon Smith8c484052019-11-14 13:57:57 -080021#include "clang-c/BuildSystem.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"
Duncan P. N. Exon Smith8c484052019-11-14 13:57:57 -080024#include "clang-c/ExternC.h"
25#include "clang-c/Platform.h"
Arnaud A. de Grandmaison0271b322012-06-28 22:01:06 +000026
Argyrios Kyrtzidis1c4db8d2012-11-06 21:21:49 +000027/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000028 * The version constants for the libclang API.
Argyrios Kyrtzidis1c4db8d2012-11-06 21:21:49 +000029 * CINDEX_VERSION_MINOR should increase when there are API additions.
30 * CINDEX_VERSION_MAJOR is intended for "major" source/ABI breaking changes.
31 *
32 * The policy about the libclang API was always to keep it source and ABI
Ivan Donchevskii65c766e2018-01-03 10:40:11 +000033 * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
34 */
35#define CINDEX_VERSION_MAJOR 0
Henry Jen38ca7b12020-04-16 07:58:02 -040036#define CINDEX_VERSION_MINOR 60
Ivan Donchevskii65c766e2018-01-03 10:40:11 +000037
Michael Kruse7520cf02020-03-25 09:26:14 -050038#define CINDEX_VERSION_ENCODE(major, minor) (((major)*10000) + ((minor)*1))
Argyrios Kyrtzidis5b216ed2012-10-29 23:24:44 +000039
Michael Kruse7520cf02020-03-25 09:26:14 -050040#define CINDEX_VERSION \
41 CINDEX_VERSION_ENCODE(CINDEX_VERSION_MAJOR, CINDEX_VERSION_MINOR)
Argyrios Kyrtzidis5b216ed2012-10-29 23:24:44 +000042
Michael Kruse7520cf02020-03-25 09:26:14 -050043#define CINDEX_VERSION_STRINGIZE_(major, minor) #major "." #minor
44#define CINDEX_VERSION_STRINGIZE(major, minor) \
45 CINDEX_VERSION_STRINGIZE_(major, minor)
Argyrios Kyrtzidis5b216ed2012-10-29 23:24:44 +000046
Michael Kruse7520cf02020-03-25 09:26:14 -050047#define CINDEX_VERSION_STRING \
48 CINDEX_VERSION_STRINGIZE(CINDEX_VERSION_MAJOR, CINDEX_VERSION_MINOR)
Argyrios Kyrtzidis5b216ed2012-10-29 23:24:44 +000049
Duncan P. N. Exon Smith8c484052019-11-14 13:57:57 -080050LLVM_CLANG_C_EXTERN_C_BEGIN
Ted Kremenekb60d87c2009-08-26 22:36:44 +000051
Douglas Gregor4a4e0eb2011-02-23 17:45:25 +000052/** \defgroup CINDEX libclang: C Interface to Clang
Douglas Gregor52606ff2010-01-20 01:10:47 +000053 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +000054 * The C Interface to Clang provides a relatively small API that exposes
Douglas Gregorc8e390c2010-01-20 22:45:41 +000055 * facilities for parsing source code into an abstract syntax tree (AST),
56 * loading already-parsed ASTs, traversing the AST, associating
57 * physical source locations with elements within the AST, and other
58 * facilities that support Clang-based development tools.
Douglas Gregor52606ff2010-01-20 01:10:47 +000059 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +000060 * This C interface to Clang will never provide all of the information
Douglas Gregorc8e390c2010-01-20 22:45:41 +000061 * representation stored in Clang's C++ AST, nor should it: the intent is to
62 * maintain an API that is relatively stable from one release to the next,
63 * providing only the basic functionality needed to support development tools.
Daniel Dunbar62ebf252010-01-24 02:54:26 +000064 *
65 * To avoid namespace pollution, data types are prefixed with "CX" and
Douglas Gregorc8e390c2010-01-20 22:45:41 +000066 * functions are prefixed with "clang_".
Douglas Gregor52606ff2010-01-20 01:10:47 +000067 *
68 * @{
69 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +000070
Douglas Gregor802f12f2010-01-20 22:28:27 +000071/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000072 * An "index" that consists of a set of translation units that would
Douglas Gregor802f12f2010-01-20 22:28:27 +000073 * typically be linked together into an executable or library.
74 */
75typedef void *CXIndex;
Steve Naroffd5e8e862009-08-27 19:51:58 +000076
Douglas Gregor802f12f2010-01-20 22:28:27 +000077/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000078 * An opaque type representing target information for a given translation
Emilio Cobos Alvarez485ad422017-04-28 15:56:39 +000079 * unit.
80 */
81typedef struct CXTargetInfoImpl *CXTargetInfo;
82
83/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000084 * A single translation unit, which resides in an index.
Douglas Gregor802f12f2010-01-20 22:28:27 +000085 */
Ted Kremenek7df92ae2010-11-17 23:24:11 +000086typedef struct CXTranslationUnitImpl *CXTranslationUnit;
Steve Naroffd5e8e862009-08-27 19:51:58 +000087
Douglas Gregor802f12f2010-01-20 22:28:27 +000088/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000089 * Opaque pointer representing client data that will be passed through
Douglas Gregor6007cf22010-01-22 22:29:16 +000090 * to various callbacks and visitors.
Douglas Gregor802f12f2010-01-20 22:28:27 +000091 */
Douglas Gregor6007cf22010-01-22 22:29:16 +000092typedef void *CXClientData;
Daniel Dunbar62ebf252010-01-24 02:54:26 +000093
Douglas Gregor9485bf92009-12-02 09:21:34 +000094/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000095 * Provides the contents of a file that has not yet been saved to disk.
Douglas Gregor9485bf92009-12-02 09:21:34 +000096 *
97 * Each CXUnsavedFile instance provides the name of a file on the
98 * system along with the current contents of that file that have not
99 * yet been saved to disk.
100 */
101struct CXUnsavedFile {
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000102 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000103 * The file whose contents have not yet been saved.
Douglas Gregor9485bf92009-12-02 09:21:34 +0000104 *
105 * This file must already exist in the file system.
106 */
107 const char *Filename;
108
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000109 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000110 * A buffer containing the unsaved contents of this file.
Douglas Gregor9485bf92009-12-02 09:21:34 +0000111 */
112 const char *Contents;
113
114 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000115 * The length of the unsaved contents of this buffer.
Douglas Gregor9485bf92009-12-02 09:21:34 +0000116 */
117 unsigned long Length;
118};
119
Peter Collingbourne5caf5af2010-08-24 00:31:37 +0000120/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000121 * Describes the availability of a particular entity, which indicates
Peter Collingbourne5caf5af2010-08-24 00:31:37 +0000122 * whether the use of this entity will result in a warning or error due to
123 * it being deprecated or unavailable.
124 */
Douglas Gregorf757a122010-08-23 23:00:57 +0000125enum CXAvailabilityKind {
Peter Collingbourne5caf5af2010-08-24 00:31:37 +0000126 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000127 * The entity is available.
Peter Collingbourne5caf5af2010-08-24 00:31:37 +0000128 */
Douglas Gregorf757a122010-08-23 23:00:57 +0000129 CXAvailability_Available,
Peter Collingbourne5caf5af2010-08-24 00:31:37 +0000130 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000131 * The entity is available, but has been deprecated (and its use is
Peter Collingbourne5caf5af2010-08-24 00:31:37 +0000132 * not recommended).
133 */
Douglas Gregorf757a122010-08-23 23:00:57 +0000134 CXAvailability_Deprecated,
Peter Collingbourne5caf5af2010-08-24 00:31:37 +0000135 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000136 * The entity is not available; any use of it will be an error.
Peter Collingbourne5caf5af2010-08-24 00:31:37 +0000137 */
Erik Verbruggen2e657ff2011-10-06 07:27:49 +0000138 CXAvailability_NotAvailable,
139 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000140 * The entity is available, but not accessible; any use of it will be
Erik Verbruggen2e657ff2011-10-06 07:27:49 +0000141 * an error.
142 */
143 CXAvailability_NotAccessible
Douglas Gregorf757a122010-08-23 23:00:57 +0000144};
Douglas Gregord6225d32012-05-08 00:14:45 +0000145
146/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000147 * Describes a version number of the form major.minor.subminor.
Douglas Gregord6225d32012-05-08 00:14:45 +0000148 */
149typedef struct CXVersion {
150 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000151 * The major version number, e.g., the '10' in '10.7.3'. A negative
Douglas Gregord6225d32012-05-08 00:14:45 +0000152 * value indicates that there is no version number at all.
153 */
154 int Major;
155 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000156 * The minor version number, e.g., the '7' in '10.7.3'. This value
Fangrui Song6907ce22018-07-30 19:24:48 +0000157 * will be negative if no minor version number was provided, e.g., for
Douglas Gregord6225d32012-05-08 00:14:45 +0000158 * version '10'.
159 */
160 int Minor;
161 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000162 * The subminor version number, e.g., the '3' in '10.7.3'. This value
Douglas Gregord6225d32012-05-08 00:14:45 +0000163 * will be negative if no minor or subminor version number was provided,
164 * e.g., in version '10' or '10.7'.
165 */
166 int Subminor;
167} CXVersion;
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000168
169/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000170 * Describes the exception specification of a cursor.
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000171 *
172 * A negative value indicates that the cursor is not a function declaration.
173 */
174enum CXCursor_ExceptionSpecificationKind {
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000175 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000176 * The cursor has no exception specification.
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000177 */
178 CXCursor_ExceptionSpecificationKind_None,
179
180 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000181 * The cursor has exception specification throw()
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000182 */
183 CXCursor_ExceptionSpecificationKind_DynamicNone,
184
185 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000186 * The cursor has exception specification throw(T1, T2)
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000187 */
188 CXCursor_ExceptionSpecificationKind_Dynamic,
189
190 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000191 * The cursor has exception specification throw(...).
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000192 */
193 CXCursor_ExceptionSpecificationKind_MSAny,
194
195 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000196 * The cursor has exception specification basic noexcept.
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000197 */
198 CXCursor_ExceptionSpecificationKind_BasicNoexcept,
199
200 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000201 * The cursor has exception specification computed noexcept.
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000202 */
203 CXCursor_ExceptionSpecificationKind_ComputedNoexcept,
204
205 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000206 * The exception specification has not yet been evaluated.
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000207 */
208 CXCursor_ExceptionSpecificationKind_Unevaluated,
209
210 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000211 * The exception specification has not yet been instantiated.
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000212 */
213 CXCursor_ExceptionSpecificationKind_Uninstantiated,
214
215 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000216 * The exception specification has not been parsed yet.
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000217 */
Erich Keaned02f4a12019-05-30 17:31:54 +0000218 CXCursor_ExceptionSpecificationKind_Unparsed,
219
220 /**
221 * The cursor has a __declspec(nothrow) exception specification.
222 */
223 CXCursor_ExceptionSpecificationKind_NoThrow
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000224};
225
Douglas Gregor802f12f2010-01-20 22:28:27 +0000226/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000227 * Provides a shared context for creating translation units.
James Dennett574cb4c2012-06-15 05:41:51 +0000228 *
229 * It provides two options:
Steve Naroff531e2842009-10-20 14:46:24 +0000230 *
231 * - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local"
232 * declarations (when loading any new translation units). A "local" declaration
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000233 * is one that belongs in the translation unit itself and not in a precompiled
Steve Naroff531e2842009-10-20 14:46:24 +0000234 * header that was used by the translation unit. If zero, all declarations
235 * will be enumerated.
236 *
Steve Naroffbb4568a2009-10-20 16:36:34 +0000237 * Here is an example:
238 *
James Dennett574cb4c2012-06-15 05:41:51 +0000239 * \code
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000240 * // excludeDeclsFromPCH = 1, displayDiagnostics=1
241 * Idx = clang_createIndex(1, 1);
Steve Naroffbb4568a2009-10-20 16:36:34 +0000242 *
243 * // IndexTest.pch was produced with the following command:
244 * // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch"
245 * TU = clang_createTranslationUnit(Idx, "IndexTest.pch");
246 *
247 * // This will load all the symbols from 'IndexTest.pch'
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000248 * clang_visitChildren(clang_getTranslationUnitCursor(TU),
Douglas Gregor990b5762010-01-20 21:37:00 +0000249 * TranslationUnitVisitor, 0);
Steve Naroffbb4568a2009-10-20 16:36:34 +0000250 * clang_disposeTranslationUnit(TU);
251 *
252 * // This will load all the symbols from 'IndexTest.c', excluding symbols
253 * // from 'IndexTest.pch'.
Daniel Dunbard0159262010-01-25 00:43:14 +0000254 * char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" };
255 * TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args,
256 * 0, 0);
Douglas Gregorfed36b12010-01-20 23:57:43 +0000257 * clang_visitChildren(clang_getTranslationUnitCursor(TU),
258 * TranslationUnitVisitor, 0);
Steve Naroffbb4568a2009-10-20 16:36:34 +0000259 * clang_disposeTranslationUnit(TU);
James Dennett574cb4c2012-06-15 05:41:51 +0000260 * \endcode
Steve Naroffbb4568a2009-10-20 16:36:34 +0000261 *
262 * This process of creating the 'pch', loading it separately, and using it (via
263 * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks
264 * (which gives the indexer the same performance benefit as the compiler).
Steve Naroff531e2842009-10-20 14:46:24 +0000265 */
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000266CINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH,
267 int displayDiagnostics);
Ted Kremenekd071c602010-03-13 02:50:34 +0000268
Douglas Gregor408bb742010-02-08 23:03:06 +0000269/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000270 * Destroy the given index.
Douglas Gregor408bb742010-02-08 23:03:06 +0000271 *
272 * The index must not be destroyed until all of the translation units created
273 * within that index have been destroyed.
274 */
Daniel Dunbar11089662009-12-03 01:54:28 +0000275CINDEX_LINKAGE void clang_disposeIndex(CXIndex index);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000276
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000277typedef enum {
278 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000279 * Used to indicate that no special CXIndex options are needed.
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000280 */
281 CXGlobalOpt_None = 0x0,
282
283 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000284 * Used to indicate that threads that libclang creates for indexing
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000285 * purposes should use background priority.
James Dennett574cb4c2012-06-15 05:41:51 +0000286 *
287 * Affects #clang_indexSourceFile, #clang_indexTranslationUnit,
288 * #clang_parseTranslationUnit, #clang_saveTranslationUnit.
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000289 */
290 CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1,
291
292 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000293 * Used to indicate that threads that libclang creates for editing
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000294 * purposes should use background priority.
James Dennett574cb4c2012-06-15 05:41:51 +0000295 *
296 * Affects #clang_reparseTranslationUnit, #clang_codeCompleteAt,
297 * #clang_annotateTokens
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000298 */
299 CXGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2,
300
301 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000302 * Used to indicate that all threads that libclang creates should use
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000303 * background priority.
304 */
305 CXGlobalOpt_ThreadBackgroundPriorityForAll =
306 CXGlobalOpt_ThreadBackgroundPriorityForIndexing |
307 CXGlobalOpt_ThreadBackgroundPriorityForEditing
308
309} CXGlobalOptFlags;
310
311/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000312 * Sets general options associated with a CXIndex.
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000313 *
314 * For example:
315 * \code
316 * CXIndex idx = ...;
317 * clang_CXIndex_setGlobalOptions(idx,
318 * clang_CXIndex_getGlobalOptions(idx) |
319 * CXGlobalOpt_ThreadBackgroundPriorityForIndexing);
320 * \endcode
321 *
322 * \param options A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags.
323 */
324CINDEX_LINKAGE void clang_CXIndex_setGlobalOptions(CXIndex, unsigned options);
325
326/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000327 * Gets the general options associated with a CXIndex.
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000328 *
329 * \returns A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags that
330 * are associated with the given CXIndex object.
331 */
332CINDEX_LINKAGE unsigned clang_CXIndex_getGlobalOptions(CXIndex);
333
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000334/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000335 * Sets the invocation emission path option in a CXIndex.
Alex Lorenz08615792017-12-04 21:56:36 +0000336 *
337 * The invocation emission path specifies a path which will contain log
338 * files for certain libclang invocations. A null value (default) implies that
339 * libclang invocations are not logged..
340 */
341CINDEX_LINKAGE void
342clang_CXIndex_setInvocationEmissionPathOption(CXIndex, const char *Path);
343
344/**
Douglas Gregor6007cf22010-01-22 22:29:16 +0000345 * \defgroup CINDEX_FILES File manipulation routines
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000346 *
347 * @{
348 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000349
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000350/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000351 * A particular source file that is part of a translation unit.
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000352 */
353typedef void *CXFile;
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000354
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000355/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000356 * Retrieve the complete file and path name of the given file.
Steve Naroff6231f182009-10-27 14:35:18 +0000357 */
Ted Kremenekc560b682010-02-17 00:41:20 +0000358CINDEX_LINKAGE CXString clang_getFileName(CXFile SFile);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000359
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000360/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000361 * Retrieve the last modification time of the given file.
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000362 */
Douglas Gregor249c1212009-10-31 15:48:08 +0000363CINDEX_LINKAGE time_t clang_getFileTime(CXFile SFile);
Steve Naroff6231f182009-10-27 14:35:18 +0000364
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000365/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000366 * Uniquely identifies a CXFile, that refers to the same underlying file,
Argyrios Kyrtzidisac08b262013-01-26 04:52:52 +0000367 * across an indexing session.
368 */
369typedef struct {
370 unsigned long long data[3];
371} CXFileUniqueID;
372
373/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000374 * Retrieve the unique ID for the given \c file.
Argyrios Kyrtzidisac08b262013-01-26 04:52:52 +0000375 *
376 * \param file the file to get the ID for.
377 * \param outID stores the returned CXFileUniqueID.
378 * \returns If there was a failure getting the unique ID, returns non-zero,
379 * otherwise returns 0.
Michael Kruse7520cf02020-03-25 09:26:14 -0500380 */
Argyrios Kyrtzidisac08b262013-01-26 04:52:52 +0000381CINDEX_LINKAGE int clang_getFileUniqueID(CXFile file, CXFileUniqueID *outID);
382
383/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000384 * Determine whether the given header is guarded against
Douglas Gregor37aa4932011-05-04 00:14:37 +0000385 * multiple inclusions, either with the conventional
James Dennett574cb4c2012-06-15 05:41:51 +0000386 * \#ifndef/\#define/\#endif macro guards or with \#pragma once.
Douglas Gregor37aa4932011-05-04 00:14:37 +0000387 */
Michael Kruse7520cf02020-03-25 09:26:14 -0500388CINDEX_LINKAGE unsigned clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu,
389 CXFile file);
Douglas Gregor37aa4932011-05-04 00:14:37 +0000390
391/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000392 * Retrieve a file handle within the given translation unit.
Douglas Gregor816fd362010-01-22 21:44:22 +0000393 *
394 * \param tu the translation unit
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000395 *
Samuel Antao4c8035b2016-12-12 18:00:20 +0000396 * \param file_name the name of the file.
Douglas Gregor816fd362010-01-22 21:44:22 +0000397 *
398 * \returns the file handle for the named file in the translation unit \p tu,
399 * or a NULL file handle if the file was not a part of this translation unit.
400 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000401CINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu,
Douglas Gregor816fd362010-01-22 21:44:22 +0000402 const char *file_name);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000403
Douglas Gregor816fd362010-01-22 21:44:22 +0000404/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000405 * Retrieve the buffer associated with the given file.
Erik Verbruggen3afa3ce2017-12-06 09:02:52 +0000406 *
407 * \param tu the translation unit
408 *
409 * \param file the file for which to retrieve the buffer.
410 *
411 * \param size [out] if non-NULL, will be set to the size of the buffer.
412 *
413 * \returns a pointer to the buffer in memory that holds the contents of
414 * \p file, or a NULL pointer when the file is not loaded.
415 */
416CINDEX_LINKAGE const char *clang_getFileContents(CXTranslationUnit tu,
417 CXFile file, size_t *size);
418
419/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000420 * Returns non-zero if the \c file1 and \c file2 point to the same file,
Argyrios Kyrtzidisac3997e2014-08-16 00:26:19 +0000421 * or they are both NULL.
422 */
423CINDEX_LINKAGE int clang_File_isEqual(CXFile file1, CXFile file2);
424
425/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000426 * Returns the real path name of \c file.
Fangrui Songe46ac5f2018-04-07 20:50:35 +0000427 *
428 * An empty string may be returned. Use \c clang_getFileName() in that case.
429 */
430CINDEX_LINKAGE CXString clang_File_tryGetRealPathName(CXFile file);
431
432/**
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000433 * @}
434 */
435
436/**
437 * \defgroup CINDEX_LOCATIONS Physical source locations
438 *
439 * Clang represents physical source locations in its abstract syntax tree in
440 * great detail, with file, line, and column information for the majority of
441 * the tokens parsed in the source code. These data types and functions are
442 * used to represent source location information, either for a particular
443 * point in the program or for a range of points in the program, and extract
444 * specific location information from those data types.
445 *
446 * @{
447 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000448
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000449/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000450 * Identifies a specific source location within a translation
Douglas Gregor4f46e782010-01-19 21:36:55 +0000451 * unit.
452 *
Chandler Carruth4aa01ef2011-08-31 16:53:37 +0000453 * Use clang_getExpansionLocation() or clang_getSpellingLocation()
Douglas Gregor229bebd2010-11-09 06:24:54 +0000454 * to map a source location to a particular file, line, and column.
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000455 */
456typedef struct {
Argyrios Kyrtzidis49d9d0292013-01-11 22:29:47 +0000457 const void *ptr_data[2];
Douglas Gregor4f46e782010-01-19 21:36:55 +0000458 unsigned int_data;
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000459} CXSourceLocation;
Ted Kremeneka44d99c2010-01-05 23:18:49 +0000460
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000461/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000462 * Identifies a half-open character range in the source code.
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000463 *
Douglas Gregor4f46e782010-01-19 21:36:55 +0000464 * Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the
465 * starting and end locations from a source range, respectively.
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000466 */
467typedef struct {
Argyrios Kyrtzidis49d9d0292013-01-11 22:29:47 +0000468 const void *ptr_data[2];
Douglas Gregor4f46e782010-01-19 21:36:55 +0000469 unsigned begin_int_data;
470 unsigned end_int_data;
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000471} CXSourceRange;
Ted Kremeneka44d99c2010-01-05 23:18:49 +0000472
Douglas Gregor4f46e782010-01-19 21:36:55 +0000473/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000474 * Retrieve a NULL (invalid) source location.
Douglas Gregor816fd362010-01-22 21:44:22 +0000475 */
NAKAMURA Takumieacd6672013-01-10 02:12:38 +0000476CINDEX_LINKAGE CXSourceLocation clang_getNullLocation(void);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000477
Douglas Gregor816fd362010-01-22 21:44:22 +0000478/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000479 * Determine whether two source locations, which must refer into
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000480 * the same translation unit, refer to exactly the same point in the source
Douglas Gregor816fd362010-01-22 21:44:22 +0000481 * code.
482 *
483 * \returns non-zero if the source locations refer to the same location, zero
484 * if they refer to different locations.
485 */
486CINDEX_LINKAGE unsigned clang_equalLocations(CXSourceLocation loc1,
487 CXSourceLocation loc2);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000488
Douglas Gregor816fd362010-01-22 21:44:22 +0000489/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000490 * Retrieves the source location associated with a given file/line/column
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000491 * in a particular translation unit.
Douglas Gregor816fd362010-01-22 21:44:22 +0000492 */
493CINDEX_LINKAGE CXSourceLocation clang_getLocation(CXTranslationUnit tu,
Michael Kruse7520cf02020-03-25 09:26:14 -0500494 CXFile file, unsigned line,
Douglas Gregor816fd362010-01-22 21:44:22 +0000495 unsigned column);
David Chisnall2e16ac52010-10-15 17:07:39 +0000496/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000497 * Retrieves the source location associated with a given character offset
David Chisnall2e16ac52010-10-15 17:07:39 +0000498 * in a particular translation unit.
499 */
500CINDEX_LINKAGE CXSourceLocation clang_getLocationForOffset(CXTranslationUnit tu,
501 CXFile file,
502 unsigned offset);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000503
Douglas Gregor816fd362010-01-22 21:44:22 +0000504/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000505 * Returns non-zero if the given source location is in a system header.
Argyrios Kyrtzidis25f7af12013-04-12 17:06:51 +0000506 */
507CINDEX_LINKAGE int clang_Location_isInSystemHeader(CXSourceLocation location);
508
509/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000510 * Returns non-zero if the given source location is in the main file of
Stefanus Du Toitdb51c632013-08-08 17:48:14 +0000511 * the corresponding translation unit.
512 */
513CINDEX_LINKAGE int clang_Location_isFromMainFile(CXSourceLocation location);
514
515/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000516 * Retrieve a NULL (invalid) source range.
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000517 */
NAKAMURA Takumieacd6672013-01-10 02:12:38 +0000518CINDEX_LINKAGE CXSourceRange clang_getNullRange(void);
Ted Kremenekd071c602010-03-13 02:50:34 +0000519
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000520/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000521 * Retrieve a source range given the beginning and ending source
Douglas Gregor816fd362010-01-22 21:44:22 +0000522 * locations.
523 */
524CINDEX_LINKAGE CXSourceRange clang_getRange(CXSourceLocation begin,
525 CXSourceLocation end);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000526
Douglas Gregor816fd362010-01-22 21:44:22 +0000527/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000528 * Determine whether two ranges are equivalent.
Douglas Gregor757e38b2011-07-23 19:35:14 +0000529 *
530 * \returns non-zero if the ranges are the same, zero if they differ.
531 */
532CINDEX_LINKAGE unsigned clang_equalRanges(CXSourceRange range1,
533 CXSourceRange range2);
534
535/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000536 * Returns non-zero if \p range is null.
Argyrios Kyrtzidise7e42912011-09-28 18:14:21 +0000537 */
Erik Verbruggend610b0f2011-10-06 12:11:57 +0000538CINDEX_LINKAGE int clang_Range_isNull(CXSourceRange range);
Argyrios Kyrtzidise7e42912011-09-28 18:14:21 +0000539
540/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000541 * Retrieve the file, line, column, and offset represented by
Douglas Gregor9bd6db52010-01-26 19:19:08 +0000542 * the given source location.
Douglas Gregor4f46e782010-01-19 21:36:55 +0000543 *
Chandler Carruth4aa01ef2011-08-31 16:53:37 +0000544 * If the location refers into a macro expansion, retrieves the
545 * location of the macro expansion.
Douglas Gregor229bebd2010-11-09 06:24:54 +0000546 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000547 * \param location the location within a source file that will be decomposed
548 * into its parts.
Douglas Gregor4f46e782010-01-19 21:36:55 +0000549 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000550 * \param file [out] if non-NULL, will be set to the file to which the given
Douglas Gregor4f46e782010-01-19 21:36:55 +0000551 * source location points.
552 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000553 * \param line [out] if non-NULL, will be set to the line to which the given
Douglas Gregor4f46e782010-01-19 21:36:55 +0000554 * source location points.
555 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000556 * \param column [out] if non-NULL, will be set to the column to which the given
557 * source location points.
Douglas Gregor9bd6db52010-01-26 19:19:08 +0000558 *
559 * \param offset [out] if non-NULL, will be set to the offset into the
560 * buffer to which the given source location points.
Douglas Gregor4f46e782010-01-19 21:36:55 +0000561 */
Chandler Carruth4aa01ef2011-08-31 16:53:37 +0000562CINDEX_LINKAGE void clang_getExpansionLocation(CXSourceLocation location,
Michael Kruse7520cf02020-03-25 09:26:14 -0500563 CXFile *file, unsigned *line,
Chandler Carruth4aa01ef2011-08-31 16:53:37 +0000564 unsigned *column,
565 unsigned *offset);
566
567/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000568 * Retrieve the file, line and column represented by the given source
Vassil Vassilev4b8e29d2017-04-06 10:05:46 +0000569 * location, as specified in a # line directive.
Argyrios Kyrtzidis91672b32011-09-13 21:49:08 +0000570 *
571 * Example: given the following source code in a file somefile.c
572 *
James Dennett574cb4c2012-06-15 05:41:51 +0000573 * \code
Argyrios Kyrtzidis91672b32011-09-13 21:49:08 +0000574 * #123 "dummy.c" 1
575 *
576 * static int func(void)
577 * {
578 * return 0;
579 * }
James Dennett574cb4c2012-06-15 05:41:51 +0000580 * \endcode
Argyrios Kyrtzidis91672b32011-09-13 21:49:08 +0000581 *
582 * the location information returned by this function would be
583 *
584 * File: dummy.c Line: 124 Column: 12
585 *
586 * whereas clang_getExpansionLocation would have returned
587 *
588 * File: somefile.c Line: 3 Column: 12
589 *
590 * \param location the location within a source file that will be decomposed
591 * into its parts.
592 *
593 * \param filename [out] if non-NULL, will be set to the filename of the
594 * source location. Note that filenames returned will be for "virtual" files,
595 * which don't necessarily exist on the machine running clang - e.g. when
596 * parsing preprocessed output obtained from a different environment. If
597 * a non-NULL value is passed in, remember to dispose of the returned value
598 * using \c clang_disposeString() once you've finished with it. For an invalid
599 * source location, an empty string is returned.
600 *
601 * \param line [out] if non-NULL, will be set to the line number of the
602 * source location. For an invalid source location, zero is returned.
603 *
604 * \param column [out] if non-NULL, will be set to the column number of the
605 * source location. For an invalid source location, zero is returned.
606 */
607CINDEX_LINKAGE void clang_getPresumedLocation(CXSourceLocation location,
608 CXString *filename,
Michael Kruse7520cf02020-03-25 09:26:14 -0500609 unsigned *line, unsigned *column);
Argyrios Kyrtzidis91672b32011-09-13 21:49:08 +0000610
611/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000612 * Legacy API to retrieve the file, line, column, and offset represented
Chandler Carruth4aa01ef2011-08-31 16:53:37 +0000613 * by the given source location.
614 *
615 * This interface has been replaced by the newer interface
James Dennett574cb4c2012-06-15 05:41:51 +0000616 * #clang_getExpansionLocation(). See that interface's documentation for
Chandler Carruth4aa01ef2011-08-31 16:53:37 +0000617 * details.
618 */
Douglas Gregor4f46e782010-01-19 21:36:55 +0000619CINDEX_LINKAGE void clang_getInstantiationLocation(CXSourceLocation location,
Michael Kruse7520cf02020-03-25 09:26:14 -0500620 CXFile *file, unsigned *line,
Douglas Gregor9bd6db52010-01-26 19:19:08 +0000621 unsigned *column,
622 unsigned *offset);
Douglas Gregor47751d62010-01-26 03:07:15 +0000623
624/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000625 * Retrieve the file, line, column, and offset represented by
Douglas Gregor229bebd2010-11-09 06:24:54 +0000626 * the given source location.
627 *
628 * If the location refers into a macro instantiation, return where the
629 * location was originally spelled in the source file.
630 *
631 * \param location the location within a source file that will be decomposed
632 * into its parts.
633 *
634 * \param file [out] if non-NULL, will be set to the file to which the given
635 * source location points.
636 *
637 * \param line [out] if non-NULL, will be set to the line to which the given
638 * source location points.
639 *
640 * \param column [out] if non-NULL, will be set to the column to which the given
641 * source location points.
642 *
643 * \param offset [out] if non-NULL, will be set to the offset into the
644 * buffer to which the given source location points.
645 */
646CINDEX_LINKAGE void clang_getSpellingLocation(CXSourceLocation location,
Michael Kruse7520cf02020-03-25 09:26:14 -0500647 CXFile *file, unsigned *line,
Douglas Gregor229bebd2010-11-09 06:24:54 +0000648 unsigned *column,
649 unsigned *offset);
650
651/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000652 * Retrieve the file, line, column, and offset represented by
Argyrios Kyrtzidis56be7162013-01-04 18:30:13 +0000653 * the given source location.
654 *
655 * If the location refers into a macro expansion, return where the macro was
656 * expanded or where the macro argument was written, if the location points at
657 * a macro argument.
658 *
659 * \param location the location within a source file that will be decomposed
660 * into its parts.
661 *
662 * \param file [out] if non-NULL, will be set to the file to which the given
663 * source location points.
664 *
665 * \param line [out] if non-NULL, will be set to the line to which the given
666 * source location points.
667 *
668 * \param column [out] if non-NULL, will be set to the column to which the given
669 * source location points.
670 *
671 * \param offset [out] if non-NULL, will be set to the offset into the
672 * buffer to which the given source location points.
673 */
674CINDEX_LINKAGE void clang_getFileLocation(CXSourceLocation location,
Michael Kruse7520cf02020-03-25 09:26:14 -0500675 CXFile *file, unsigned *line,
676 unsigned *column, unsigned *offset);
Argyrios Kyrtzidis56be7162013-01-04 18:30:13 +0000677
678/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000679 * Retrieve a source location representing the first character within a
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000680 * source range.
Douglas Gregor4f46e782010-01-19 21:36:55 +0000681 */
682CINDEX_LINKAGE CXSourceLocation clang_getRangeStart(CXSourceRange range);
683
684/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000685 * Retrieve a source location representing the last character within a
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000686 * source range.
Douglas Gregor4f46e782010-01-19 21:36:55 +0000687 */
688CINDEX_LINKAGE CXSourceLocation clang_getRangeEnd(CXSourceRange range);
689
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000690/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000691 * Identifies an array of ranges.
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000692 */
693typedef struct {
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000694 /** The number of ranges in the \c ranges array. */
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000695 unsigned count;
696 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000697 * An array of \c CXSourceRanges.
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000698 */
699 CXSourceRange *ranges;
Argyrios Kyrtzidis0e282ef2013-12-06 18:55:45 +0000700} CXSourceRangeList;
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000701
702/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000703 * Retrieve all ranges that were skipped by the preprocessor.
Argyrios Kyrtzidis0e282ef2013-12-06 18:55:45 +0000704 *
705 * The preprocessor will skip lines when they are surrounded by an
706 * if/ifdef/ifndef directive whose condition does not evaluate to true.
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000707 */
Argyrios Kyrtzidis0e282ef2013-12-06 18:55:45 +0000708CINDEX_LINKAGE CXSourceRangeList *clang_getSkippedRanges(CXTranslationUnit tu,
709 CXFile file);
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000710
711/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000712 * Retrieve all ranges from all files that were skipped by the
Cameron Desrochersd8091282016-08-18 15:43:55 +0000713 * preprocessor.
714 *
715 * The preprocessor will skip lines when they are surrounded by an
716 * if/ifdef/ifndef directive whose condition does not evaluate to true.
717 */
Michael Kruse7520cf02020-03-25 09:26:14 -0500718CINDEX_LINKAGE CXSourceRangeList *
719clang_getAllSkippedRanges(CXTranslationUnit tu);
Cameron Desrochersd8091282016-08-18 15:43:55 +0000720
721/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000722 * Destroy the given \c CXSourceRangeList.
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000723 */
Argyrios Kyrtzidis0e282ef2013-12-06 18:55:45 +0000724CINDEX_LINKAGE void clang_disposeSourceRangeList(CXSourceRangeList *ranges);
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000725
726/**
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000727 * @}
728 */
Douglas Gregor6007cf22010-01-22 22:29:16 +0000729
730/**
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000731 * \defgroup CINDEX_DIAG Diagnostic reporting
732 *
733 * @{
734 */
735
736/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000737 * Describes the severity of a particular diagnostic.
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000738 */
739enum CXDiagnosticSeverity {
740 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000741 * A diagnostic that has been suppressed, e.g., by a command-line
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000742 * option.
743 */
744 CXDiagnostic_Ignored = 0,
Ted Kremenekd071c602010-03-13 02:50:34 +0000745
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000746 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000747 * This diagnostic is a note that should be attached to the
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000748 * previous (non-note) diagnostic.
749 */
Michael Kruse7520cf02020-03-25 09:26:14 -0500750 CXDiagnostic_Note = 1,
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000751
752 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000753 * This diagnostic indicates suspicious code that may not be
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000754 * wrong.
755 */
756 CXDiagnostic_Warning = 2,
757
758 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000759 * This diagnostic indicates that the code is ill-formed.
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000760 */
Michael Kruse7520cf02020-03-25 09:26:14 -0500761 CXDiagnostic_Error = 3,
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000762
763 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000764 * This diagnostic indicates that the code is ill-formed such
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000765 * that future parser recovery is unlikely to produce useful
766 * results.
767 */
Michael Kruse7520cf02020-03-25 09:26:14 -0500768 CXDiagnostic_Fatal = 4
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000769};
770
771/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000772 * A single diagnostic, containing the diagnostic's severity,
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000773 * location, text, source ranges, and fix-it hints.
774 */
775typedef void *CXDiagnostic;
776
777/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000778 * A group of CXDiagnostics.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000779 */
780typedef void *CXDiagnosticSet;
Fangrui Song6907ce22018-07-30 19:24:48 +0000781
Ted Kremenekd010ba42011-11-10 08:43:12 +0000782/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000783 * Determine the number of diagnostics in a CXDiagnosticSet.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000784 */
785CINDEX_LINKAGE unsigned clang_getNumDiagnosticsInSet(CXDiagnosticSet Diags);
786
787/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000788 * Retrieve a diagnostic associated with the given CXDiagnosticSet.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000789 *
James Dennett574cb4c2012-06-15 05:41:51 +0000790 * \param Diags the CXDiagnosticSet to query.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000791 * \param Index the zero-based diagnostic number to retrieve.
792 *
793 * \returns the requested diagnostic. This diagnostic must be freed
794 * via a call to \c clang_disposeDiagnostic().
795 */
796CINDEX_LINKAGE CXDiagnostic clang_getDiagnosticInSet(CXDiagnosticSet Diags,
Fangrui Song6907ce22018-07-30 19:24:48 +0000797 unsigned Index);
Ted Kremenekd010ba42011-11-10 08:43:12 +0000798
Ted Kremenekd010ba42011-11-10 08:43:12 +0000799/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000800 * Describes the kind of error that occurred (if any) in a call to
Ted Kremenekd010ba42011-11-10 08:43:12 +0000801 * \c clang_loadDiagnostics.
802 */
803enum CXLoadDiag_Error {
804 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000805 * Indicates that no error occurred.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000806 */
807 CXLoadDiag_None = 0,
Fangrui Song6907ce22018-07-30 19:24:48 +0000808
Ted Kremenekd010ba42011-11-10 08:43:12 +0000809 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000810 * Indicates that an unknown error occurred while attempting to
Ted Kremenekd010ba42011-11-10 08:43:12 +0000811 * deserialize diagnostics.
812 */
813 CXLoadDiag_Unknown = 1,
Fangrui Song6907ce22018-07-30 19:24:48 +0000814
Ted Kremenekd010ba42011-11-10 08:43:12 +0000815 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000816 * Indicates that the file containing the serialized diagnostics
Ted Kremenekd010ba42011-11-10 08:43:12 +0000817 * could not be opened.
818 */
819 CXLoadDiag_CannotLoad = 2,
Fangrui Song6907ce22018-07-30 19:24:48 +0000820
Ted Kremenekd010ba42011-11-10 08:43:12 +0000821 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000822 * Indicates that the serialized diagnostics file is invalid or
James Dennett574cb4c2012-06-15 05:41:51 +0000823 * corrupt.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000824 */
825 CXLoadDiag_InvalidFile = 3
826};
Fangrui Song6907ce22018-07-30 19:24:48 +0000827
Ted Kremenekd010ba42011-11-10 08:43:12 +0000828/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000829 * Deserialize a set of diagnostics from a Clang diagnostics bitcode
James Dennett574cb4c2012-06-15 05:41:51 +0000830 * file.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000831 *
James Dennett574cb4c2012-06-15 05:41:51 +0000832 * \param file The name of the file to deserialize.
833 * \param error A pointer to a enum value recording if there was a problem
Ted Kremenekd010ba42011-11-10 08:43:12 +0000834 * deserializing the diagnostics.
James Dennett574cb4c2012-06-15 05:41:51 +0000835 * \param errorString A pointer to a CXString for recording the error string
Ted Kremenekd010ba42011-11-10 08:43:12 +0000836 * if the file was not successfully loaded.
837 *
838 * \returns A loaded CXDiagnosticSet if successful, and NULL otherwise. These
James Dennett574cb4c2012-06-15 05:41:51 +0000839 * diagnostics should be released using clang_disposeDiagnosticSet().
Ted Kremenekd010ba42011-11-10 08:43:12 +0000840 */
Michael Kruse7520cf02020-03-25 09:26:14 -0500841CINDEX_LINKAGE CXDiagnosticSet clang_loadDiagnostics(
842 const char *file, enum CXLoadDiag_Error *error, CXString *errorString);
Ted Kremenekd010ba42011-11-10 08:43:12 +0000843
844/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000845 * Release a CXDiagnosticSet and all of its contained diagnostics.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000846 */
847CINDEX_LINKAGE void clang_disposeDiagnosticSet(CXDiagnosticSet Diags);
848
849/**
Fangrui Song6907ce22018-07-30 19:24:48 +0000850 * Retrieve the child diagnostics of a CXDiagnostic.
James Dennett574cb4c2012-06-15 05:41:51 +0000851 *
852 * This CXDiagnosticSet does not need to be released by
Sylvestre Ledrud29d97c2013-11-17 09:46:45 +0000853 * clang_disposeDiagnosticSet.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000854 */
855CINDEX_LINKAGE CXDiagnosticSet clang_getChildDiagnostics(CXDiagnostic D);
856
857/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000858 * Determine the number of diagnostics produced for the given
Douglas Gregor33cdd812010-02-18 18:08:43 +0000859 * translation unit.
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000860 */
Douglas Gregor33cdd812010-02-18 18:08:43 +0000861CINDEX_LINKAGE unsigned clang_getNumDiagnostics(CXTranslationUnit Unit);
862
863/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000864 * Retrieve a diagnostic associated with the given translation unit.
Douglas Gregor33cdd812010-02-18 18:08:43 +0000865 *
866 * \param Unit the translation unit to query.
867 * \param Index the zero-based diagnostic number to retrieve.
868 *
869 * \returns the requested diagnostic. This diagnostic must be freed
870 * via a call to \c clang_disposeDiagnostic().
871 */
872CINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit,
873 unsigned Index);
874
875/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000876 * Retrieve the complete set of diagnostics associated with a
Ted Kremenekb4a8b052011-12-09 22:28:32 +0000877 * translation unit.
878 *
879 * \param Unit the translation unit to query.
880 */
881CINDEX_LINKAGE CXDiagnosticSet
Michael Kruse7520cf02020-03-25 09:26:14 -0500882clang_getDiagnosticSetFromTU(CXTranslationUnit Unit);
Ted Kremenekb4a8b052011-12-09 22:28:32 +0000883
884/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000885 * Destroy a diagnostic.
Douglas Gregor33cdd812010-02-18 18:08:43 +0000886 */
887CINDEX_LINKAGE void clang_disposeDiagnostic(CXDiagnostic Diagnostic);
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000888
889/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000890 * Options to control the display of diagnostics.
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000891 *
892 * The values in this enum are meant to be combined to customize the
Sylvestre Ledrud29d97c2013-11-17 09:46:45 +0000893 * behavior of \c clang_formatDiagnostic().
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000894 */
895enum CXDiagnosticDisplayOptions {
896 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000897 * Display the source-location information where the
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000898 * diagnostic was located.
899 *
900 * When set, diagnostics will be prefixed by the file, line, and
901 * (optionally) column to which the diagnostic refers. For example,
902 *
903 * \code
904 * test.c:28: warning: extra tokens at end of #endif directive
905 * \endcode
906 *
907 * This option corresponds to the clang flag \c -fshow-source-location.
908 */
909 CXDiagnostic_DisplaySourceLocation = 0x01,
910
911 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000912 * If displaying the source-location information of the
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000913 * diagnostic, also include the column number.
914 *
915 * This option corresponds to the clang flag \c -fshow-column.
916 */
917 CXDiagnostic_DisplayColumn = 0x02,
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 information about source ranges in a
922 * machine-parsable format.
923 *
Ted Kremenekd071c602010-03-13 02:50:34 +0000924 * This option corresponds to the clang flag
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000925 * \c -fdiagnostics-print-source-range-info.
926 */
Douglas Gregora750e8e2010-11-19 16:18:16 +0000927 CXDiagnostic_DisplaySourceRanges = 0x04,
Fangrui Song6907ce22018-07-30 19:24:48 +0000928
Douglas Gregora750e8e2010-11-19 16:18:16 +0000929 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000930 * Display the option name associated with this diagnostic, if any.
Douglas Gregora750e8e2010-11-19 16:18:16 +0000931 *
932 * The option name displayed (e.g., -Wconversion) will be placed in brackets
933 * after the diagnostic text. This option corresponds to the clang flag
934 * \c -fdiagnostics-show-option.
935 */
936 CXDiagnostic_DisplayOption = 0x08,
Fangrui Song6907ce22018-07-30 19:24:48 +0000937
Douglas Gregora750e8e2010-11-19 16:18:16 +0000938 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000939 * Display the category number associated with this diagnostic, if any.
Douglas Gregora750e8e2010-11-19 16:18:16 +0000940 *
941 * The category number is displayed within brackets after the diagnostic text.
Fangrui Song6907ce22018-07-30 19:24:48 +0000942 * This option corresponds to the clang flag
Douglas Gregora750e8e2010-11-19 16:18:16 +0000943 * \c -fdiagnostics-show-category=id.
944 */
945 CXDiagnostic_DisplayCategoryId = 0x10,
946
947 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000948 * Display the category name associated with this diagnostic, if any.
Douglas Gregora750e8e2010-11-19 16:18:16 +0000949 *
950 * The category name is displayed within brackets after the diagnostic text.
Fangrui Song6907ce22018-07-30 19:24:48 +0000951 * This option corresponds to the clang flag
Douglas Gregora750e8e2010-11-19 16:18:16 +0000952 * \c -fdiagnostics-show-category=name.
953 */
954 CXDiagnostic_DisplayCategoryName = 0x20
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000955};
956
957/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000958 * Format the given diagnostic in a manner that is suitable for display.
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000959 *
Douglas Gregord770f732010-02-22 23:17:23 +0000960 * This routine will format the given diagnostic to a string, rendering
Ted Kremenekd071c602010-03-13 02:50:34 +0000961 * the diagnostic according to the various options given. The
962 * \c clang_defaultDiagnosticDisplayOptions() function returns the set of
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000963 * options that most closely mimics the behavior of the clang compiler.
964 *
965 * \param Diagnostic The diagnostic to print.
966 *
Ted Kremenekd071c602010-03-13 02:50:34 +0000967 * \param Options A set of options that control the diagnostic display,
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000968 * created by combining \c CXDiagnosticDisplayOptions values.
Douglas Gregord770f732010-02-22 23:17:23 +0000969 *
970 * \returns A new string containing for formatted diagnostic.
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000971 */
Douglas Gregord770f732010-02-22 23:17:23 +0000972CINDEX_LINKAGE CXString clang_formatDiagnostic(CXDiagnostic Diagnostic,
973 unsigned Options);
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000974
975/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000976 * Retrieve the set of display options most similar to the
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000977 * default behavior of the clang compiler.
978 *
979 * \returns A set of display options suitable for use with \c
Sylvestre Ledrud29d97c2013-11-17 09:46:45 +0000980 * clang_formatDiagnostic().
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000981 */
982CINDEX_LINKAGE unsigned clang_defaultDiagnosticDisplayOptions(void);
983
984/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000985 * Determine the severity of the given diagnostic.
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000986 */
Ted Kremenekd071c602010-03-13 02:50:34 +0000987CINDEX_LINKAGE enum CXDiagnosticSeverity
Michael Kruse7520cf02020-03-25 09:26:14 -0500988 clang_getDiagnosticSeverity(CXDiagnostic);
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000989
990/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000991 * Retrieve the source location of the given diagnostic.
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000992 *
993 * This location is where Clang would print the caret ('^') when
994 * displaying the diagnostic on the command line.
995 */
996CINDEX_LINKAGE CXSourceLocation clang_getDiagnosticLocation(CXDiagnostic);
997
998/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000999 * Retrieve the text of the given diagnostic.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001000 */
1001CINDEX_LINKAGE CXString clang_getDiagnosticSpelling(CXDiagnostic);
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +00001002
1003/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001004 * Retrieve the name of the command-line option that enabled this
Douglas Gregora750e8e2010-11-19 16:18:16 +00001005 * diagnostic.
1006 *
1007 * \param Diag The diagnostic to be queried.
1008 *
1009 * \param Disable If non-NULL, will be set to the option that disables this
1010 * diagnostic (if any).
1011 *
1012 * \returns A string that contains the command-line option used to enable this
Fangrui Song6907ce22018-07-30 19:24:48 +00001013 * warning, such as "-Wconversion" or "-pedantic".
Douglas Gregora750e8e2010-11-19 16:18:16 +00001014 */
1015CINDEX_LINKAGE CXString clang_getDiagnosticOption(CXDiagnostic Diag,
1016 CXString *Disable);
1017
1018/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001019 * Retrieve the category number for this diagnostic.
Douglas Gregora750e8e2010-11-19 16:18:16 +00001020 *
1021 * Diagnostics can be categorized into groups along with other, related
Fangrui Song6907ce22018-07-30 19:24:48 +00001022 * diagnostics (e.g., diagnostics under the same warning flag). This routine
Douglas Gregora750e8e2010-11-19 16:18:16 +00001023 * retrieves the category number for the given diagnostic.
1024 *
1025 * \returns The number of the category that contains this diagnostic, or zero
1026 * if this diagnostic is uncategorized.
1027 */
1028CINDEX_LINKAGE unsigned clang_getDiagnosticCategory(CXDiagnostic);
1029
1030/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001031 * Retrieve the name of a particular diagnostic category. This
Ted Kremenek26a6d492012-04-12 00:03:31 +00001032 * is now deprecated. Use clang_getDiagnosticCategoryText()
1033 * instead.
Douglas Gregora750e8e2010-11-19 16:18:16 +00001034 *
Fangrui Song6907ce22018-07-30 19:24:48 +00001035 * \param Category A diagnostic category number, as returned by
Douglas Gregora750e8e2010-11-19 16:18:16 +00001036 * \c clang_getDiagnosticCategory().
1037 *
1038 * \returns The name of the given diagnostic category.
1039 */
Michael Kruse7520cf02020-03-25 09:26:14 -05001040CINDEX_DEPRECATED CINDEX_LINKAGE CXString
1041clang_getDiagnosticCategoryName(unsigned Category);
Ted Kremenek26a6d492012-04-12 00:03:31 +00001042
1043/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001044 * Retrieve the diagnostic category text for a given diagnostic.
Ted Kremenek26a6d492012-04-12 00:03:31 +00001045 *
Ted Kremenek26a6d492012-04-12 00:03:31 +00001046 * \returns The text of the given diagnostic category.
1047 */
1048CINDEX_LINKAGE CXString clang_getDiagnosticCategoryText(CXDiagnostic);
Fangrui Song6907ce22018-07-30 19:24:48 +00001049
Douglas Gregora750e8e2010-11-19 16:18:16 +00001050/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001051 * Determine the number of source ranges associated with the given
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +00001052 * diagnostic.
1053 */
1054CINDEX_LINKAGE unsigned clang_getDiagnosticNumRanges(CXDiagnostic);
Ted Kremenekd071c602010-03-13 02:50:34 +00001055
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001056/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001057 * Retrieve a source range associated with the diagnostic.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001058 *
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +00001059 * A diagnostic's source ranges highlight important elements in the source
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001060 * code. On the command line, Clang displays source ranges by
Ted Kremenekd071c602010-03-13 02:50:34 +00001061 * underlining them with '~' characters.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001062 *
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +00001063 * \param Diagnostic the diagnostic whose range is being extracted.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001064 *
Ted Kremenekd071c602010-03-13 02:50:34 +00001065 * \param Range the zero-based index specifying which range to
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001066 *
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +00001067 * \returns the requested source range.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001068 */
Ted Kremenekd071c602010-03-13 02:50:34 +00001069CINDEX_LINKAGE CXSourceRange clang_getDiagnosticRange(CXDiagnostic Diagnostic,
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +00001070 unsigned Range);
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001071
1072/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001073 * Determine the number of fix-it hints associated with the
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001074 * given diagnostic.
1075 */
1076CINDEX_LINKAGE unsigned clang_getDiagnosticNumFixIts(CXDiagnostic Diagnostic);
1077
1078/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001079 * Retrieve the replacement information for a given fix-it.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001080 *
Douglas Gregor836ec942010-02-19 18:16:06 +00001081 * Fix-its are described in terms of a source range whose contents
1082 * should be replaced by a string. This approach generalizes over
1083 * three kinds of operations: removal of source code (the range covers
1084 * the code to be removed and the replacement string is empty),
1085 * replacement of source code (the range covers the code to be
1086 * replaced and the replacement string provides the new code), and
1087 * insertion (both the start and end of the range point at the
1088 * insertion location, and the replacement string provides the text to
1089 * insert).
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001090 *
Douglas Gregor836ec942010-02-19 18:16:06 +00001091 * \param Diagnostic The diagnostic whose fix-its are being queried.
1092 *
1093 * \param FixIt The zero-based index of the fix-it.
1094 *
1095 * \param ReplacementRange The source range whose contents will be
1096 * replaced with the returned replacement string. Note that source
1097 * ranges are half-open ranges [a, b), so the source code should be
1098 * replaced from a and up to (but not including) b.
1099 *
1100 * \returns A string containing text that should be replace the source
1101 * code indicated by the \c ReplacementRange.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001102 */
Michael Kruse7520cf02020-03-25 09:26:14 -05001103CINDEX_LINKAGE CXString clang_getDiagnosticFixIt(
1104 CXDiagnostic Diagnostic, unsigned FixIt, CXSourceRange *ReplacementRange);
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001105
1106/**
1107 * @}
1108 */
1109
1110/**
1111 * \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation
1112 *
1113 * The routines in this group provide the ability to create and destroy
1114 * translation units from files, either by parsing the contents of the files or
1115 * by reading in a serialized representation of a translation unit.
1116 *
1117 * @{
1118 */
Ted Kremenekd071c602010-03-13 02:50:34 +00001119
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001120/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001121 * Get the original translation unit source file name.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001122 */
1123CINDEX_LINKAGE CXString
1124clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit);
1125
1126/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001127 * Return the CXTranslationUnit for a given source file and the provided
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001128 * command line arguments one would pass to the compiler.
1129 *
1130 * Note: The 'source_filename' argument is optional. If the caller provides a
1131 * NULL pointer, the name of the source file is expected to reside in the
1132 * specified command line arguments.
1133 *
1134 * Note: When encountered in 'clang_command_line_args', the following options
1135 * are ignored:
1136 *
1137 * '-c'
1138 * '-emit-ast'
1139 * '-fsyntax-only'
James Dennett574cb4c2012-06-15 05:41:51 +00001140 * '-o \<output file>' (both '-o' and '\<output file>' are ignored)
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001141 *
Ted Kremenekbd4972442010-11-08 04:28:51 +00001142 * \param CIdx The index object with which the translation unit will be
1143 * associated.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001144 *
James Dennett574cb4c2012-06-15 05:41:51 +00001145 * \param source_filename The name of the source file to load, or NULL if the
Ted Kremenekbd4972442010-11-08 04:28:51 +00001146 * source file is included in \p clang_command_line_args.
1147 *
1148 * \param num_clang_command_line_args The number of command-line arguments in
1149 * \p clang_command_line_args.
1150 *
1151 * \param clang_command_line_args The command-line arguments that would be
1152 * passed to the \c clang executable if it were being invoked out-of-process.
1153 * These command-line options will be parsed and will affect how the translation
1154 * unit is parsed. Note that the following options are ignored: '-c',
James Dennett574cb4c2012-06-15 05:41:51 +00001155 * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001156 *
1157 * \param num_unsaved_files the number of unsaved file entries in \p
1158 * unsaved_files.
1159 *
1160 * \param unsaved_files the files that have not yet been saved to disk
1161 * but may be required for code completion, including the contents of
Ted Kremenekde24a942010-04-12 18:47:26 +00001162 * those files. The contents and name of these files (as specified by
1163 * CXUnsavedFile) are copied when necessary, so the client only needs to
1164 * guarantee their validity until the call to this function returns.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001165 */
1166CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnitFromSourceFile(
Michael Kruse7520cf02020-03-25 09:26:14 -05001167 CXIndex CIdx, const char *source_filename, int num_clang_command_line_args,
1168 const char *const *clang_command_line_args, unsigned num_unsaved_files,
1169 struct CXUnsavedFile *unsaved_files);
Ted Kremenekd071c602010-03-13 02:50:34 +00001170
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001171/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001172 * Same as \c clang_createTranslationUnit2, but returns
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001173 * the \c CXTranslationUnit instead of an error code. In case of an error this
1174 * routine returns a \c NULL \c CXTranslationUnit, without further detailed
1175 * error codes.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001176 */
Michael Kruse7520cf02020-03-25 09:26:14 -05001177CINDEX_LINKAGE CXTranslationUnit
1178clang_createTranslationUnit(CXIndex CIdx, const char *ast_filename);
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001179
1180/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001181 * Create a translation unit from an AST file (\c -emit-ast).
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001182 *
1183 * \param[out] out_TU A non-NULL pointer to store the created
1184 * \c CXTranslationUnit.
1185 *
1186 * \returns Zero on success, otherwise returns an error code.
1187 */
Michael Kruse7520cf02020-03-25 09:26:14 -05001188CINDEX_LINKAGE enum CXErrorCode
1189clang_createTranslationUnit2(CXIndex CIdx, const char *ast_filename,
1190 CXTranslationUnit *out_TU);
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001191
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001192/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001193 * Flags that control the creation of translation units.
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001194 *
1195 * The enumerators in this enumeration type are meant to be bitwise
1196 * ORed together to specify which options should be used when
1197 * constructing the translation unit.
1198 */
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001199enum CXTranslationUnit_Flags {
1200 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001201 * Used to indicate that no special translation-unit options are
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001202 * needed.
1203 */
1204 CXTranslationUnit_None = 0x0,
1205
1206 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001207 * Used to indicate that the parser should construct a "detailed"
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001208 * preprocessing record, including all macro definitions and instantiations.
1209 *
1210 * Constructing a detailed preprocessing record requires more memory
1211 * and time to parse, since the information contained in the record
1212 * is usually not retained. However, it can be useful for
1213 * applications that require more detailed information about the
1214 * behavior of the preprocessor.
1215 */
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001216 CXTranslationUnit_DetailedPreprocessingRecord = 0x01,
1217
1218 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001219 * Used to indicate that the translation unit is incomplete.
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001220 *
Douglas Gregor4a47bca2010-08-09 22:28:58 +00001221 * When a translation unit is considered "incomplete", semantic
1222 * analysis that is typically performed at the end of the
1223 * translation unit will be suppressed. For example, this suppresses
1224 * the completion of tentative declarations in C and of
1225 * instantiation of implicitly-instantiation function templates in
1226 * C++. This option is typically used when parsing a header with the
1227 * intent of producing a precompiled header.
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001228 */
Douglas Gregor4a47bca2010-08-09 22:28:58 +00001229 CXTranslationUnit_Incomplete = 0x02,
Fangrui Song6907ce22018-07-30 19:24:48 +00001230
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001231 /**
Fangrui Song6907ce22018-07-30 19:24:48 +00001232 * Used to indicate that the translation unit should be built with an
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001233 * implicit precompiled header for the preamble.
1234 *
1235 * An implicit precompiled header is used as an optimization when a
1236 * particular translation unit is likely to be reparsed many times
1237 * when the sources aren't changing that often. In this case, an
1238 * implicit precompiled header will be built containing all of the
1239 * initial includes at the top of the main file (what we refer to as
1240 * the "preamble" of the file). In subsequent parses, if the
1241 * preamble or the files in it have not changed, \c
1242 * clang_reparseTranslationUnit() will re-use the implicit
1243 * precompiled header to improve parsing performance.
1244 */
Douglas Gregorde051182010-08-11 15:58:42 +00001245 CXTranslationUnit_PrecompiledPreamble = 0x04,
Fangrui Song6907ce22018-07-30 19:24:48 +00001246
Douglas Gregorde051182010-08-11 15:58:42 +00001247 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001248 * Used to indicate that the translation unit should cache some
Douglas Gregorde051182010-08-11 15:58:42 +00001249 * code-completion results with each reparse of the source file.
1250 *
1251 * Caching of code-completion results is a performance optimization that
1252 * introduces some overhead to reparsing but improves the performance of
1253 * code-completion operations.
1254 */
Douglas Gregorf5a18542010-10-27 17:24:53 +00001255 CXTranslationUnit_CacheCompletionResults = 0x08,
Argyrios Kyrtzidis0db720f2012-10-11 16:05:00 +00001256
Douglas Gregorf5a18542010-10-27 17:24:53 +00001257 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001258 * Used to indicate that the translation unit will be serialized with
Argyrios Kyrtzidis0db720f2012-10-11 16:05:00 +00001259 * \c clang_saveTranslationUnit.
Douglas Gregorf5a18542010-10-27 17:24:53 +00001260 *
Argyrios Kyrtzidis0db720f2012-10-11 16:05:00 +00001261 * This option is typically used when parsing a header with the intent of
1262 * producing a precompiled header.
Douglas Gregorf5a18542010-10-27 17:24:53 +00001263 */
Argyrios Kyrtzidis0db720f2012-10-11 16:05:00 +00001264 CXTranslationUnit_ForSerialization = 0x10,
Douglas Gregorf5a18542010-10-27 17:24:53 +00001265
1266 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001267 * DEPRECATED: Enabled chained precompiled preambles in C++.
Douglas Gregorf5a18542010-10-27 17:24:53 +00001268 *
1269 * Note: this is a *temporary* option that is available only while
Douglas Gregor2ed0ee12011-08-25 22:54:01 +00001270 * we are testing C++ precompiled preamble support. It is deprecated.
Douglas Gregorf5a18542010-10-27 17:24:53 +00001271 */
Erik Verbruggen6e922512012-04-12 10:11:59 +00001272 CXTranslationUnit_CXXChainedPCH = 0x20,
1273
1274 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001275 * Used to indicate that function/method bodies should be skipped while
Erik Verbruggen6e922512012-04-12 10:11:59 +00001276 * parsing.
1277 *
1278 * This option can be used to search for declarations/definitions while
1279 * ignoring the usages.
1280 */
Dmitri Gribenko3292d062012-07-02 17:35:10 +00001281 CXTranslationUnit_SkipFunctionBodies = 0x40,
1282
1283 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001284 * Used to indicate that brief documentation comments should be
Dmitri Gribenko3292d062012-07-02 17:35:10 +00001285 * included into the set of code completions returned from this translation
1286 * unit.
1287 */
Benjamin Kramer5c248d82015-12-15 09:30:31 +00001288 CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 0x80,
1289
1290 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001291 * Used to indicate that the precompiled preamble should be created on
Benjamin Kramer5c248d82015-12-15 09:30:31 +00001292 * the first parse. Otherwise it will be created on the first reparse. This
1293 * trades runtime on the first parse (serializing the preamble takes time) for
1294 * reduced runtime on the second parse (can now reuse the preamble).
1295 */
Manuel Klimek016c0242016-03-01 10:56:19 +00001296 CXTranslationUnit_CreatePreambleOnFirstParse = 0x100,
1297
1298 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001299 * Do not stop processing when fatal errors are encountered.
Manuel Klimek016c0242016-03-01 10:56:19 +00001300 *
1301 * When fatal errors are encountered while parsing a translation unit,
1302 * semantic analysis is typically stopped early when compiling code. A common
1303 * source for fatal errors are unresolvable include files. For the
1304 * purposes of an IDE, this is undesirable behavior and as much information
1305 * as possible should be reported. Use this flag to enable this behavior.
1306 */
Argyrios Kyrtzidis735e92c2017-06-09 01:20:48 +00001307 CXTranslationUnit_KeepGoing = 0x200,
1308
Ivan Donchevskiif70d28b2018-05-17 09:15:22 +00001309 /**
1310 * Sets the preprocessor in a mode for parsing a single file only.
1311 */
Ivan Donchevskii6e895282018-05-17 09:24:37 +00001312 CXTranslationUnit_SingleFileParse = 0x400,
1313
1314 /**
Ivan Donchevskii3957e482018-06-13 12:37:08 +00001315 * Used in combination with CXTranslationUnit_SkipFunctionBodies to
Ivan Donchevskii6e895282018-05-17 09:24:37 +00001316 * constrain the skipping of function bodies to the preamble.
1317 *
1318 * The function bodies of the main file are not skipped.
1319 */
Michael Wu153085d2018-08-03 04:21:25 +00001320 CXTranslationUnit_LimitSkipFunctionBodiesToPreamble = 0x800,
1321
1322 /**
1323 * Used to indicate that attributed types should be included in CXType.
1324 */
Michael Wu40ff1052018-08-03 05:20:23 +00001325 CXTranslationUnit_IncludeAttributedTypes = 0x1000,
1326
1327 /**
1328 * Used to indicate that implicit attributes should be visited.
1329 */
Nikolai Kosjar8edd8da2019-06-11 14:14:24 +00001330 CXTranslationUnit_VisitImplicitAttributes = 0x2000,
1331
1332 /**
1333 * Used to indicate that non-errors from included files should be ignored.
1334 *
1335 * If set, clang_getDiagnosticSetFromTU() will not report e.g. warnings from
1336 * included files anymore. This speeds up clang_getDiagnosticSetFromTU() for
1337 * the case where these warnings are not of interest, as for an IDE for
1338 * example, which typically shows only the diagnostics in the main file.
1339 */
Evgeny Mankov2ed2e622019-08-27 22:15:32 +00001340 CXTranslationUnit_IgnoreNonErrorsFromIncludedFiles = 0x4000,
1341
1342 /**
1343 * Tells the preprocessor not to skip excluded conditional blocks.
1344 */
Vitaly Buka712a9b02019-08-28 01:04:50 +00001345 CXTranslationUnit_RetainExcludedConditionalBlocks = 0x8000
Ivan Donchevskiif70d28b2018-05-17 09:15:22 +00001346};
1347
1348/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001349 * Returns the set of flags that is suitable for parsing a translation
Douglas Gregor4a47bca2010-08-09 22:28:58 +00001350 * unit that is being edited.
1351 *
1352 * The set of flags returned provide options for \c clang_parseTranslationUnit()
1353 * to indicate that the translation unit is likely to be reparsed many times,
1354 * either explicitly (via \c clang_reparseTranslationUnit()) or implicitly
1355 * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag
Fangrui Song6907ce22018-07-30 19:24:48 +00001356 * set contains an unspecified set of optimizations (e.g., the precompiled
Douglas Gregor4a47bca2010-08-09 22:28:58 +00001357 * preamble) geared toward improving the performance of these routines. The
1358 * set of optimizations enabled may change from one version to the next.
1359 */
Douglas Gregorde051182010-08-11 15:58:42 +00001360CINDEX_LINKAGE unsigned clang_defaultEditingTranslationUnitOptions(void);
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001361
1362/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001363 * Same as \c clang_parseTranslationUnit2, but returns
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001364 * the \c CXTranslationUnit instead of an error code. In case of an error this
1365 * routine returns a \c NULL \c CXTranslationUnit, without further detailed
1366 * error codes.
1367 */
Michael Kruse7520cf02020-03-25 09:26:14 -05001368CINDEX_LINKAGE CXTranslationUnit clang_parseTranslationUnit(
1369 CXIndex CIdx, const char *source_filename,
1370 const char *const *command_line_args, int num_command_line_args,
1371 struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files,
1372 unsigned options);
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001373
Douglas Gregor4a47bca2010-08-09 22:28:58 +00001374/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001375 * Parse the given source file and the translation unit corresponding
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001376 * to that file.
1377 *
1378 * This routine is the main entry point for the Clang C API, providing the
1379 * ability to parse a source file into a translation unit that can then be
1380 * queried by other functions in the API. This routine accepts a set of
1381 * command-line arguments so that the compilation can be configured in the same
1382 * way that the compiler is configured on the command line.
1383 *
Fangrui Song6907ce22018-07-30 19:24:48 +00001384 * \param CIdx The index object with which the translation unit will be
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001385 * associated.
1386 *
1387 * \param source_filename The name of the source file to load, or NULL if the
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001388 * source file is included in \c command_line_args.
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001389 *
1390 * \param command_line_args The command-line arguments that would be
1391 * passed to the \c clang executable if it were being invoked out-of-process.
1392 * These command-line options will be parsed and will affect how the translation
Fangrui Song6907ce22018-07-30 19:24:48 +00001393 * unit is parsed. Note that the following options are ignored: '-c',
James Dennett574cb4c2012-06-15 05:41:51 +00001394 * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001395 *
1396 * \param num_command_line_args The number of command-line arguments in
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001397 * \c command_line_args.
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001398 *
1399 * \param unsaved_files the files that have not yet been saved to disk
Douglas Gregor8e984da2010-08-04 16:47:14 +00001400 * but may be required for parsing, including the contents of
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001401 * those files. The contents and name of these files (as specified by
1402 * CXUnsavedFile) are copied when necessary, so the client only needs to
1403 * guarantee their validity until the call to this function returns.
1404 *
1405 * \param num_unsaved_files the number of unsaved file entries in \p
1406 * unsaved_files.
1407 *
1408 * \param options A bitmask of options that affects how the translation unit
1409 * is managed but not its compilation. This should be a bitwise OR of the
1410 * CXTranslationUnit_XXX flags.
1411 *
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001412 * \param[out] out_TU A non-NULL pointer to store the created
1413 * \c CXTranslationUnit, describing the parsed code and containing any
1414 * diagnostics produced by the compiler.
1415 *
1416 * \returns Zero on success, otherwise returns an error code.
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001417 */
Michael Kruse7520cf02020-03-25 09:26:14 -05001418CINDEX_LINKAGE enum CXErrorCode clang_parseTranslationUnit2(
1419 CXIndex CIdx, const char *source_filename,
1420 const char *const *command_line_args, int num_command_line_args,
1421 struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files,
1422 unsigned options, CXTranslationUnit *out_TU);
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001423
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001424/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001425 * Same as clang_parseTranslationUnit2 but requires a full command line
Benjamin Kramerc02670e2015-11-18 16:14:27 +00001426 * for \c command_line_args including argv[0]. This is useful if the standard
1427 * library paths are relative to the binary.
1428 */
1429CINDEX_LINKAGE enum CXErrorCode clang_parseTranslationUnit2FullArgv(
1430 CXIndex CIdx, const char *source_filename,
1431 const char *const *command_line_args, int num_command_line_args,
1432 struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files,
1433 unsigned options, CXTranslationUnit *out_TU);
1434
1435/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001436 * Flags that control how translation units are saved.
Douglas Gregor6bb92ec2010-08-13 15:35:05 +00001437 *
1438 * The enumerators in this enumeration type are meant to be bitwise
1439 * ORed together to specify which options should be used when
1440 * saving the translation unit.
1441 */
1442enum CXSaveTranslationUnit_Flags {
1443 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001444 * Used to indicate that no special saving options are needed.
Douglas Gregor6bb92ec2010-08-13 15:35:05 +00001445 */
1446 CXSaveTranslationUnit_None = 0x0
1447};
1448
1449/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001450 * Returns the set of flags that is suitable for saving a translation
Douglas Gregor6bb92ec2010-08-13 15:35:05 +00001451 * unit.
1452 *
1453 * The set of flags returned provide options for
1454 * \c clang_saveTranslationUnit() by default. The returned flag
1455 * set contains an unspecified set of options that save translation units with
1456 * the most commonly-requested data.
1457 */
1458CINDEX_LINKAGE unsigned clang_defaultSaveOptions(CXTranslationUnit TU);
1459
1460/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001461 * Describes the kind of error that occurred (if any) in a call to
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001462 * \c clang_saveTranslationUnit().
1463 */
1464enum CXSaveError {
1465 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001466 * Indicates that no error occurred while saving a translation unit.
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001467 */
1468 CXSaveError_None = 0,
Fangrui Song6907ce22018-07-30 19:24:48 +00001469
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001470 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001471 * Indicates that an unknown error occurred while attempting to save
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001472 * the file.
1473 *
Fangrui Song6907ce22018-07-30 19:24:48 +00001474 * This error typically indicates that file I/O failed when attempting to
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001475 * write the file.
1476 */
1477 CXSaveError_Unknown = 1,
Fangrui Song6907ce22018-07-30 19:24:48 +00001478
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001479 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001480 * Indicates that errors during translation prevented this attempt
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001481 * to save the translation unit.
Fangrui Song6907ce22018-07-30 19:24:48 +00001482 *
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001483 * Errors that prevent the translation unit from being saved can be
1484 * extracted using \c clang_getNumDiagnostics() and \c clang_getDiagnostic().
1485 */
1486 CXSaveError_TranslationErrors = 2,
Fangrui Song6907ce22018-07-30 19:24:48 +00001487
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001488 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001489 * Indicates that the translation unit to be saved was somehow
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001490 * invalid (e.g., NULL).
1491 */
1492 CXSaveError_InvalidTU = 3
1493};
Fangrui Song6907ce22018-07-30 19:24:48 +00001494
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001495/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001496 * Saves a translation unit into a serialized representation of
Douglas Gregore9386682010-08-13 05:36:37 +00001497 * that translation unit on disk.
1498 *
1499 * Any translation unit that was parsed without error can be saved
1500 * into a file. The translation unit can then be deserialized into a
1501 * new \c CXTranslationUnit with \c clang_createTranslationUnit() or,
1502 * if it is an incomplete translation unit that corresponds to a
1503 * header, used as a precompiled header when parsing other translation
1504 * units.
1505 *
1506 * \param TU The translation unit to save.
Douglas Gregor6bb92ec2010-08-13 15:35:05 +00001507 *
Douglas Gregore9386682010-08-13 05:36:37 +00001508 * \param FileName The file to which the translation unit will be saved.
1509 *
Douglas Gregor6bb92ec2010-08-13 15:35:05 +00001510 * \param options A bitmask of options that affects how the translation unit
1511 * is saved. This should be a bitwise OR of the
1512 * CXSaveTranslationUnit_XXX flags.
1513 *
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001514 * \returns A value that will match one of the enumerators of the CXSaveError
Fangrui Song6907ce22018-07-30 19:24:48 +00001515 * enumeration. Zero (CXSaveError_None) indicates that the translation unit was
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001516 * saved successfully, while a non-zero value indicates that a problem occurred.
Douglas Gregore9386682010-08-13 05:36:37 +00001517 */
1518CINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU,
Douglas Gregor6bb92ec2010-08-13 15:35:05 +00001519 const char *FileName,
1520 unsigned options);
Douglas Gregore9386682010-08-13 05:36:37 +00001521
1522/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001523 * Suspend a translation unit in order to free memory associated with it.
Erik Verbruggen346066b2017-05-30 14:25:54 +00001524 *
1525 * A suspended translation unit uses significantly less memory but on the other
1526 * side does not support any other calls than \c clang_reparseTranslationUnit
1527 * to resume it or \c clang_disposeTranslationUnit to dispose it completely.
1528 */
1529CINDEX_LINKAGE unsigned clang_suspendTranslationUnit(CXTranslationUnit);
1530
1531/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001532 * Destroy the specified CXTranslationUnit object.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001533 */
1534CINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit);
Ted Kremenekd071c602010-03-13 02:50:34 +00001535
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001536/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001537 * Flags that control the reparsing of translation units.
Douglas Gregorde051182010-08-11 15:58:42 +00001538 *
1539 * The enumerators in this enumeration type are meant to be bitwise
1540 * ORed together to specify which options should be used when
1541 * reparsing the translation unit.
1542 */
1543enum CXReparse_Flags {
1544 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001545 * Used to indicate that no special reparsing options are needed.
Douglas Gregorde051182010-08-11 15:58:42 +00001546 */
1547 CXReparse_None = 0x0
1548};
Fangrui Song6907ce22018-07-30 19:24:48 +00001549
Douglas Gregorde051182010-08-11 15:58:42 +00001550/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001551 * Returns the set of flags that is suitable for reparsing a translation
Douglas Gregorde051182010-08-11 15:58:42 +00001552 * unit.
1553 *
1554 * The set of flags returned provide options for
1555 * \c clang_reparseTranslationUnit() by default. The returned flag
1556 * set contains an unspecified set of optimizations geared toward common uses
Fangrui Song6907ce22018-07-30 19:24:48 +00001557 * of reparsing. The set of optimizations enabled may change from one version
Douglas Gregorde051182010-08-11 15:58:42 +00001558 * to the next.
1559 */
1560CINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU);
1561
1562/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001563 * Reparse the source files that produced this translation unit.
Douglas Gregoraa21cc42010-07-19 21:46:24 +00001564 *
1565 * This routine can be used to re-parse the source files that originally
1566 * created the given translation unit, for example because those source files
1567 * have changed (either on disk or as passed via \p unsaved_files). The
1568 * source code will be reparsed with the same command-line options as it
Fangrui Song6907ce22018-07-30 19:24:48 +00001569 * was originally parsed.
Douglas Gregoraa21cc42010-07-19 21:46:24 +00001570 *
1571 * Reparsing a translation unit invalidates all cursors and source locations
1572 * that refer into that translation unit. This makes reparsing a translation
1573 * unit semantically equivalent to destroying the translation unit and then
1574 * creating a new translation unit with the same command-line arguments.
Fangrui Song6907ce22018-07-30 19:24:48 +00001575 * However, it may be more efficient to reparse a translation
Douglas Gregoraa21cc42010-07-19 21:46:24 +00001576 * unit using this routine.
1577 *
1578 * \param TU The translation unit whose contents will be re-parsed. The
Fangrui Song6907ce22018-07-30 19:24:48 +00001579 * translation unit must originally have been built with
Douglas Gregoraa21cc42010-07-19 21:46:24 +00001580 * \c clang_createTranslationUnitFromSourceFile().
1581 *
1582 * \param num_unsaved_files The number of unsaved file entries in \p
1583 * unsaved_files.
1584 *
1585 * \param unsaved_files The files that have not yet been saved to disk
1586 * but may be required for parsing, including the contents of
1587 * those files. The contents and name of these files (as specified by
1588 * CXUnsavedFile) are copied when necessary, so the client only needs to
1589 * guarantee their validity until the call to this function returns.
Fangrui Song6907ce22018-07-30 19:24:48 +00001590 *
Douglas Gregorde051182010-08-11 15:58:42 +00001591 * \param options A bitset of options composed of the flags in CXReparse_Flags.
1592 * The function \c clang_defaultReparseOptions() produces a default set of
1593 * options recommended for most uses, based on the translation unit.
1594 *
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001595 * \returns 0 if the sources could be reparsed. A non-zero error code will be
Douglas Gregoraa21cc42010-07-19 21:46:24 +00001596 * returned if reparsing was impossible, such that the translation unit is
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001597 * invalid. In such cases, the only valid call for \c TU is
1598 * \c clang_disposeTranslationUnit(TU). The error codes returned by this
1599 * routine are described by the \c CXErrorCode enum.
Douglas Gregoraa21cc42010-07-19 21:46:24 +00001600 */
Michael Kruse7520cf02020-03-25 09:26:14 -05001601CINDEX_LINKAGE int
1602clang_reparseTranslationUnit(CXTranslationUnit TU, unsigned num_unsaved_files,
1603 struct CXUnsavedFile *unsaved_files,
1604 unsigned options);
Ted Kremenek83f642e2011-04-18 22:47:10 +00001605
1606/**
Michael Kruse7520cf02020-03-25 09:26:14 -05001607 * Categorizes how memory is being used by a translation unit.
1608 */
Ted Kremenek23324122011-04-20 16:41:07 +00001609enum CXTUResourceUsageKind {
1610 CXTUResourceUsage_AST = 1,
1611 CXTUResourceUsage_Identifiers = 2,
1612 CXTUResourceUsage_Selectors = 3,
1613 CXTUResourceUsage_GlobalCompletionResults = 4,
Ted Kremenek21735e62011-04-28 04:10:31 +00001614 CXTUResourceUsage_SourceManagerContentCache = 5,
Ted Kremenekf5df0ce2011-04-28 04:53:38 +00001615 CXTUResourceUsage_AST_SideTables = 6,
Ted Kremenek8d587902011-04-28 20:36:42 +00001616 CXTUResourceUsage_SourceManager_Membuffer_Malloc = 7,
Ted Kremenek5e1ed7b2011-04-28 23:46:20 +00001617 CXTUResourceUsage_SourceManager_Membuffer_MMap = 8,
Fangrui Song6907ce22018-07-30 19:24:48 +00001618 CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc = 9,
1619 CXTUResourceUsage_ExternalASTSource_Membuffer_MMap = 10,
Ted Kremenek2160a0d2011-05-04 01:38:46 +00001620 CXTUResourceUsage_Preprocessor = 11,
1621 CXTUResourceUsage_PreprocessingRecord = 12,
Ted Kremenek120992a2011-07-26 23:46:06 +00001622 CXTUResourceUsage_SourceManager_DataStructures = 13,
Ted Kremenekfbcce6f2011-07-26 23:46:11 +00001623 CXTUResourceUsage_Preprocessor_HeaderSearch = 14,
Ted Kremenek23324122011-04-20 16:41:07 +00001624 CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST,
1625 CXTUResourceUsage_MEMORY_IN_BYTES_END =
Michael Kruse7520cf02020-03-25 09:26:14 -05001626 CXTUResourceUsage_Preprocessor_HeaderSearch,
Ted Kremenek23324122011-04-20 16:41:07 +00001627
1628 CXTUResourceUsage_First = CXTUResourceUsage_AST,
Ted Kremenekfbcce6f2011-07-26 23:46:11 +00001629 CXTUResourceUsage_Last = CXTUResourceUsage_Preprocessor_HeaderSearch
Ted Kremenek83f642e2011-04-18 22:47:10 +00001630};
1631
1632/**
Michael Kruse7520cf02020-03-25 09:26:14 -05001633 * Returns the human-readable null-terminated C string that represents
1634 * the name of the memory category. This string should never be freed.
1635 */
Ted Kremenek83f642e2011-04-18 22:47:10 +00001636CINDEX_LINKAGE
Ted Kremenek23324122011-04-20 16:41:07 +00001637const char *clang_getTUResourceUsageName(enum CXTUResourceUsageKind kind);
Ted Kremenek83f642e2011-04-18 22:47:10 +00001638
Ted Kremenek23324122011-04-20 16:41:07 +00001639typedef struct CXTUResourceUsageEntry {
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001640 /* The memory usage category. */
Fangrui Song6907ce22018-07-30 19:24:48 +00001641 enum CXTUResourceUsageKind kind;
1642 /* Amount of resources used.
Ted Kremenek23324122011-04-20 16:41:07 +00001643 The units will depend on the resource kind. */
Ted Kremenek83f642e2011-04-18 22:47:10 +00001644 unsigned long amount;
Ted Kremenek23324122011-04-20 16:41:07 +00001645} CXTUResourceUsageEntry;
Ted Kremenek83f642e2011-04-18 22:47:10 +00001646
1647/**
Michael Kruse7520cf02020-03-25 09:26:14 -05001648 * The memory usage of a CXTranslationUnit, broken into categories.
1649 */
Ted Kremenek23324122011-04-20 16:41:07 +00001650typedef struct CXTUResourceUsage {
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001651 /* Private data member, used for queries. */
Ted Kremenek83f642e2011-04-18 22:47:10 +00001652 void *data;
1653
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001654 /* The number of entries in the 'entries' array. */
Ted Kremenek83f642e2011-04-18 22:47:10 +00001655 unsigned numEntries;
1656
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001657 /* An array of key-value pairs, representing the breakdown of memory
Ted Kremenek83f642e2011-04-18 22:47:10 +00001658 usage. */
Ted Kremenek23324122011-04-20 16:41:07 +00001659 CXTUResourceUsageEntry *entries;
Ted Kremenek83f642e2011-04-18 22:47:10 +00001660
Ted Kremenek23324122011-04-20 16:41:07 +00001661} CXTUResourceUsage;
Ted Kremenek83f642e2011-04-18 22:47:10 +00001662
1663/**
Michael Kruse7520cf02020-03-25 09:26:14 -05001664 * Return the memory usage of a translation unit. This object
1665 * should be released with clang_disposeCXTUResourceUsage().
1666 */
1667CINDEX_LINKAGE CXTUResourceUsage
1668clang_getCXTUResourceUsage(CXTranslationUnit TU);
Ted Kremenek83f642e2011-04-18 22:47:10 +00001669
Ted Kremenek23324122011-04-20 16:41:07 +00001670CINDEX_LINKAGE void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage);
Ted Kremenek83f642e2011-04-18 22:47:10 +00001671
Douglas Gregoraa21cc42010-07-19 21:46:24 +00001672/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001673 * Get target information for this translation unit.
Emilio Cobos Alvarez485ad422017-04-28 15:56:39 +00001674 *
1675 * The CXTargetInfo object cannot outlive the CXTranslationUnit object.
1676 */
1677CINDEX_LINKAGE CXTargetInfo
1678clang_getTranslationUnitTargetInfo(CXTranslationUnit CTUnit);
1679
1680/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001681 * Destroy the CXTargetInfo object.
Emilio Cobos Alvarez485ad422017-04-28 15:56:39 +00001682 */
Michael Kruse7520cf02020-03-25 09:26:14 -05001683CINDEX_LINKAGE void clang_TargetInfo_dispose(CXTargetInfo Info);
Emilio Cobos Alvarez485ad422017-04-28 15:56:39 +00001684
1685/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001686 * Get the normalized target triple as a string.
Emilio Cobos Alvarez485ad422017-04-28 15:56:39 +00001687 *
1688 * Returns the empty string in case of any error.
1689 */
Michael Kruse7520cf02020-03-25 09:26:14 -05001690CINDEX_LINKAGE CXString clang_TargetInfo_getTriple(CXTargetInfo Info);
Emilio Cobos Alvarez485ad422017-04-28 15:56:39 +00001691
1692/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001693 * Get the pointer width of the target in bits.
Emilio Cobos Alvarez485ad422017-04-28 15:56:39 +00001694 *
1695 * Returns -1 in case of error.
1696 */
Michael Kruse7520cf02020-03-25 09:26:14 -05001697CINDEX_LINKAGE int clang_TargetInfo_getPointerWidth(CXTargetInfo Info);
Emilio Cobos Alvarez485ad422017-04-28 15:56:39 +00001698
1699/**
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001700 * @}
1701 */
Ted Kremenekd071c602010-03-13 02:50:34 +00001702
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001703/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001704 * Describes the kind of entity that a cursor refers to.
Douglas Gregor6007cf22010-01-22 22:29:16 +00001705 */
1706enum CXCursorKind {
1707 /* Declarations */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001708 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001709 * A declaration whose specific kind is not exposed via this
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001710 * interface.
Douglas Gregor6007cf22010-01-22 22:29:16 +00001711 *
1712 * Unexposed declarations have the same operations as any other kind
1713 * of declaration; one can extract their location information,
1714 * spelling, find their definitions, etc. However, the specific kind
1715 * of the declaration is not reported.
1716 */
Michael Kruse7520cf02020-03-25 09:26:14 -05001717 CXCursor_UnexposedDecl = 1,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001718 /** A C or C++ struct. */
Michael Kruse7520cf02020-03-25 09:26:14 -05001719 CXCursor_StructDecl = 2,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001720 /** A C or C++ union. */
Michael Kruse7520cf02020-03-25 09:26:14 -05001721 CXCursor_UnionDecl = 3,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001722 /** A C++ class. */
Michael Kruse7520cf02020-03-25 09:26:14 -05001723 CXCursor_ClassDecl = 4,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001724 /** An enumeration. */
Michael Kruse7520cf02020-03-25 09:26:14 -05001725 CXCursor_EnumDecl = 5,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001726 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001727 * A field (in C) or non-static data member (in C++) in a
Douglas Gregor6007cf22010-01-22 22:29:16 +00001728 * struct, union, or C++ class.
1729 */
Michael Kruse7520cf02020-03-25 09:26:14 -05001730 CXCursor_FieldDecl = 6,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001731 /** An enumerator constant. */
Michael Kruse7520cf02020-03-25 09:26:14 -05001732 CXCursor_EnumConstantDecl = 7,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001733 /** A function. */
Michael Kruse7520cf02020-03-25 09:26:14 -05001734 CXCursor_FunctionDecl = 8,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001735 /** A variable. */
Michael Kruse7520cf02020-03-25 09:26:14 -05001736 CXCursor_VarDecl = 9,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001737 /** A function or method parameter. */
Michael Kruse7520cf02020-03-25 09:26:14 -05001738 CXCursor_ParmDecl = 10,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001739 /** An Objective-C \@interface. */
Michael Kruse7520cf02020-03-25 09:26:14 -05001740 CXCursor_ObjCInterfaceDecl = 11,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001741 /** An Objective-C \@interface for a category. */
Michael Kruse7520cf02020-03-25 09:26:14 -05001742 CXCursor_ObjCCategoryDecl = 12,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001743 /** An Objective-C \@protocol declaration. */
Michael Kruse7520cf02020-03-25 09:26:14 -05001744 CXCursor_ObjCProtocolDecl = 13,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001745 /** An Objective-C \@property declaration. */
Michael Kruse7520cf02020-03-25 09:26:14 -05001746 CXCursor_ObjCPropertyDecl = 14,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001747 /** An Objective-C instance variable. */
Michael Kruse7520cf02020-03-25 09:26:14 -05001748 CXCursor_ObjCIvarDecl = 15,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001749 /** An Objective-C instance method. */
Michael Kruse7520cf02020-03-25 09:26:14 -05001750 CXCursor_ObjCInstanceMethodDecl = 16,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001751 /** An Objective-C class method. */
Michael Kruse7520cf02020-03-25 09:26:14 -05001752 CXCursor_ObjCClassMethodDecl = 17,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001753 /** An Objective-C \@implementation. */
Michael Kruse7520cf02020-03-25 09:26:14 -05001754 CXCursor_ObjCImplementationDecl = 18,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001755 /** An Objective-C \@implementation for a category. */
Michael Kruse7520cf02020-03-25 09:26:14 -05001756 CXCursor_ObjCCategoryImplDecl = 19,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001757 /** A typedef. */
Michael Kruse7520cf02020-03-25 09:26:14 -05001758 CXCursor_TypedefDecl = 20,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001759 /** A C++ class method. */
Michael Kruse7520cf02020-03-25 09:26:14 -05001760 CXCursor_CXXMethod = 21,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001761 /** A C++ namespace. */
Michael Kruse7520cf02020-03-25 09:26:14 -05001762 CXCursor_Namespace = 22,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001763 /** A linkage specification, e.g. 'extern "C"'. */
Michael Kruse7520cf02020-03-25 09:26:14 -05001764 CXCursor_LinkageSpec = 23,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001765 /** A C++ constructor. */
Michael Kruse7520cf02020-03-25 09:26:14 -05001766 CXCursor_Constructor = 24,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001767 /** A C++ destructor. */
Michael Kruse7520cf02020-03-25 09:26:14 -05001768 CXCursor_Destructor = 25,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001769 /** A C++ conversion function. */
Michael Kruse7520cf02020-03-25 09:26:14 -05001770 CXCursor_ConversionFunction = 26,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001771 /** A C++ template type parameter. */
Michael Kruse7520cf02020-03-25 09:26:14 -05001772 CXCursor_TemplateTypeParameter = 27,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001773 /** A C++ non-type template parameter. */
Michael Kruse7520cf02020-03-25 09:26:14 -05001774 CXCursor_NonTypeTemplateParameter = 28,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001775 /** A C++ template template parameter. */
Michael Kruse7520cf02020-03-25 09:26:14 -05001776 CXCursor_TemplateTemplateParameter = 29,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001777 /** A C++ function template. */
Michael Kruse7520cf02020-03-25 09:26:14 -05001778 CXCursor_FunctionTemplate = 30,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001779 /** A C++ class template. */
Michael Kruse7520cf02020-03-25 09:26:14 -05001780 CXCursor_ClassTemplate = 31,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001781 /** A C++ class template partial specialization. */
Douglas Gregorf96abb22010-08-31 19:31:58 +00001782 CXCursor_ClassTemplatePartialSpecialization = 32,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001783 /** A C++ namespace alias declaration. */
Michael Kruse7520cf02020-03-25 09:26:14 -05001784 CXCursor_NamespaceAlias = 33,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001785 /** A C++ using directive. */
Michael Kruse7520cf02020-03-25 09:26:14 -05001786 CXCursor_UsingDirective = 34,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001787 /** A C++ using declaration. */
Michael Kruse7520cf02020-03-25 09:26:14 -05001788 CXCursor_UsingDeclaration = 35,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001789 /** A C++ alias declaration */
Michael Kruse7520cf02020-03-25 09:26:14 -05001790 CXCursor_TypeAliasDecl = 36,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001791 /** An Objective-C \@synthesize definition. */
Michael Kruse7520cf02020-03-25 09:26:14 -05001792 CXCursor_ObjCSynthesizeDecl = 37,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001793 /** An Objective-C \@dynamic definition. */
Michael Kruse7520cf02020-03-25 09:26:14 -05001794 CXCursor_ObjCDynamicDecl = 38,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001795 /** An access specifier. */
Michael Kruse7520cf02020-03-25 09:26:14 -05001796 CXCursor_CXXAccessSpecifier = 39,
Douglas Gregor4c362d52011-10-05 19:00:14 +00001797
Michael Kruse7520cf02020-03-25 09:26:14 -05001798 CXCursor_FirstDecl = CXCursor_UnexposedDecl,
1799 CXCursor_LastDecl = CXCursor_CXXAccessSpecifier,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001800
Douglas Gregor6007cf22010-01-22 22:29:16 +00001801 /* References */
Michael Kruse7520cf02020-03-25 09:26:14 -05001802 CXCursor_FirstRef = 40, /* Decl references */
1803 CXCursor_ObjCSuperClassRef = 40,
1804 CXCursor_ObjCProtocolRef = 41,
1805 CXCursor_ObjCClassRef = 42,
Douglas Gregor6007cf22010-01-22 22:29:16 +00001806 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001807 * A reference to a type declaration.
Douglas Gregor6007cf22010-01-22 22:29:16 +00001808 *
1809 * A type reference occurs anywhere where a type is named but not
1810 * declared. For example, given:
1811 *
1812 * \code
1813 * typedef unsigned size_type;
1814 * size_type size;
1815 * \endcode
1816 *
1817 * The typedef is a declaration of size_type (CXCursor_TypedefDecl),
1818 * while the type of the variable "size" is referenced. The cursor
1819 * referenced by the type of size is the typedef for size_type.
1820 */
Michael Kruse7520cf02020-03-25 09:26:14 -05001821 CXCursor_TypeRef = 43,
1822 CXCursor_CXXBaseSpecifier = 44,
Fangrui Song6907ce22018-07-30 19:24:48 +00001823 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001824 * A reference to a class template, function template, template
Douglas Gregorf3af3112010-09-09 21:42:20 +00001825 * template parameter, or class template partial specialization.
Douglas Gregora23e8f72010-08-31 20:37:03 +00001826 */
Michael Kruse7520cf02020-03-25 09:26:14 -05001827 CXCursor_TemplateRef = 45,
Douglas Gregora89314e2010-08-31 23:48:11 +00001828 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001829 * A reference to a namespace or namespace alias.
Douglas Gregora89314e2010-08-31 23:48:11 +00001830 */
Michael Kruse7520cf02020-03-25 09:26:14 -05001831 CXCursor_NamespaceRef = 46,
Douglas Gregorf3af3112010-09-09 21:42:20 +00001832 /**
Fangrui Song6907ce22018-07-30 19:24:48 +00001833 * A reference to a member of a struct, union, or class that occurs in
Douglas Gregora93ab662010-09-10 00:22:18 +00001834 * some non-expression context, e.g., a designated initializer.
Douglas Gregorf3af3112010-09-09 21:42:20 +00001835 */
Michael Kruse7520cf02020-03-25 09:26:14 -05001836 CXCursor_MemberRef = 47,
Douglas Gregora93ab662010-09-10 00:22:18 +00001837 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001838 * A reference to a labeled statement.
Douglas Gregora93ab662010-09-10 00:22:18 +00001839 *
Fangrui Song6907ce22018-07-30 19:24:48 +00001840 * This cursor kind is used to describe the jump to "start_over" in the
Douglas Gregora93ab662010-09-10 00:22:18 +00001841 * goto statement in the following example:
1842 *
1843 * \code
1844 * start_over:
1845 * ++counter;
1846 *
1847 * goto start_over;
1848 * \endcode
1849 *
1850 * A label reference cursor refers to a label statement.
1851 */
Michael Kruse7520cf02020-03-25 09:26:14 -05001852 CXCursor_LabelRef = 48,
Fangrui Song6907ce22018-07-30 19:24:48 +00001853
Douglas Gregor16a2bdd2010-09-13 22:52:57 +00001854 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001855 * A reference to a set of overloaded functions or function templates
Douglas Gregor16a2bdd2010-09-13 22:52:57 +00001856 * that has not yet been resolved to a specific function or function template.
1857 *
1858 * An overloaded declaration reference cursor occurs in C++ templates where
1859 * a dependent name refers to a function. For example:
1860 *
1861 * \code
1862 * template<typename T> void swap(T&, T&);
1863 *
1864 * struct X { ... };
1865 * void swap(X&, X&);
1866 *
1867 * template<typename T>
1868 * void reverse(T* first, T* last) {
1869 * while (first < last - 1) {
1870 * swap(*first, *--last);
1871 * ++first;
1872 * }
1873 * }
1874 *
1875 * struct Y { };
1876 * void swap(Y&, Y&);
1877 * \endcode
1878 *
1879 * Here, the identifier "swap" is associated with an overloaded declaration
1880 * reference. In the template definition, "swap" refers to either of the two
1881 * "swap" functions declared above, so both results will be available. At
1882 * instantiation time, "swap" may also refer to other functions found via
1883 * argument-dependent lookup (e.g., the "swap" function at the end of the
1884 * example).
1885 *
Fangrui Song6907ce22018-07-30 19:24:48 +00001886 * The functions \c clang_getNumOverloadedDecls() and
Douglas Gregor16a2bdd2010-09-13 22:52:57 +00001887 * \c clang_getOverloadedDecl() can be used to retrieve the definitions
1888 * referenced by this cursor.
1889 */
Michael Kruse7520cf02020-03-25 09:26:14 -05001890 CXCursor_OverloadedDeclRef = 49,
Fangrui Song6907ce22018-07-30 19:24:48 +00001891
Douglas Gregor30093832012-02-15 00:54:55 +00001892 /**
Fangrui Song6907ce22018-07-30 19:24:48 +00001893 * A reference to a variable that occurs in some non-expression
Douglas Gregor30093832012-02-15 00:54:55 +00001894 * context, e.g., a C++ lambda capture list.
1895 */
Michael Kruse7520cf02020-03-25 09:26:14 -05001896 CXCursor_VariableRef = 50,
Fangrui Song6907ce22018-07-30 19:24:48 +00001897
Michael Kruse7520cf02020-03-25 09:26:14 -05001898 CXCursor_LastRef = CXCursor_VariableRef,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001899
Douglas Gregor6007cf22010-01-22 22:29:16 +00001900 /* Error conditions */
Michael Kruse7520cf02020-03-25 09:26:14 -05001901 CXCursor_FirstInvalid = 70,
1902 CXCursor_InvalidFile = 70,
1903 CXCursor_NoDeclFound = 71,
1904 CXCursor_NotImplemented = 72,
1905 CXCursor_InvalidCode = 73,
1906 CXCursor_LastInvalid = CXCursor_InvalidCode,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001907
Douglas Gregor6007cf22010-01-22 22:29:16 +00001908 /* Expressions */
Michael Kruse7520cf02020-03-25 09:26:14 -05001909 CXCursor_FirstExpr = 100,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001910
Douglas Gregor6007cf22010-01-22 22:29:16 +00001911 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001912 * An expression whose specific kind is not exposed via this
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001913 * interface.
Douglas Gregor6007cf22010-01-22 22:29:16 +00001914 *
1915 * Unexposed expressions have the same operations as any other kind
1916 * of expression; one can extract their location information,
1917 * spelling, children, etc. However, the specific kind of the
1918 * expression is not reported.
1919 */
Michael Kruse7520cf02020-03-25 09:26:14 -05001920 CXCursor_UnexposedExpr = 100,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001921
Douglas Gregor6007cf22010-01-22 22:29:16 +00001922 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001923 * An expression that refers to some value declaration, such
Nico Weber7deebef2014-04-24 03:17:47 +00001924 * as a function, variable, or enumerator.
Douglas Gregor6007cf22010-01-22 22:29:16 +00001925 */
Michael Kruse7520cf02020-03-25 09:26:14 -05001926 CXCursor_DeclRefExpr = 101,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001927
Douglas Gregor6007cf22010-01-22 22:29:16 +00001928 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001929 * An expression that refers to a member of a struct, union,
Douglas Gregor6007cf22010-01-22 22:29:16 +00001930 * class, Objective-C class, etc.
1931 */
Michael Kruse7520cf02020-03-25 09:26:14 -05001932 CXCursor_MemberRefExpr = 102,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001933
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001934 /** An expression that calls a function. */
Michael Kruse7520cf02020-03-25 09:26:14 -05001935 CXCursor_CallExpr = 103,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001936
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001937 /** An expression that sends a message to an Objective-C
Douglas Gregor6007cf22010-01-22 22:29:16 +00001938 object or class. */
Michael Kruse7520cf02020-03-25 09:26:14 -05001939 CXCursor_ObjCMessageExpr = 104,
Ted Kremenek33b9a422010-04-11 21:47:37 +00001940
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001941 /** An expression that represents a block literal. */
Michael Kruse7520cf02020-03-25 09:26:14 -05001942 CXCursor_BlockExpr = 105,
Ted Kremenek33b9a422010-04-11 21:47:37 +00001943
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001944 /** An integer literal.
Douglas Gregor4c362d52011-10-05 19:00:14 +00001945 */
Michael Kruse7520cf02020-03-25 09:26:14 -05001946 CXCursor_IntegerLiteral = 106,
Douglas Gregor4c362d52011-10-05 19:00:14 +00001947
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001948 /** A floating point number literal.
Douglas Gregor4c362d52011-10-05 19:00:14 +00001949 */
Michael Kruse7520cf02020-03-25 09:26:14 -05001950 CXCursor_FloatingLiteral = 107,
Douglas Gregor4c362d52011-10-05 19:00:14 +00001951
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001952 /** An imaginary number literal.
Douglas Gregor4c362d52011-10-05 19:00:14 +00001953 */
Michael Kruse7520cf02020-03-25 09:26:14 -05001954 CXCursor_ImaginaryLiteral = 108,
Douglas Gregor4c362d52011-10-05 19:00:14 +00001955
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001956 /** A string literal.
Douglas Gregor4c362d52011-10-05 19:00:14 +00001957 */
Michael Kruse7520cf02020-03-25 09:26:14 -05001958 CXCursor_StringLiteral = 109,
Douglas Gregor4c362d52011-10-05 19:00:14 +00001959
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001960 /** A character literal.
Douglas Gregor4c362d52011-10-05 19:00:14 +00001961 */
Michael Kruse7520cf02020-03-25 09:26:14 -05001962 CXCursor_CharacterLiteral = 110,
Douglas Gregor4c362d52011-10-05 19:00:14 +00001963
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001964 /** A parenthesized expression, e.g. "(1)".
Douglas Gregor4c362d52011-10-05 19:00:14 +00001965 *
1966 * This AST node is only formed if full location information is requested.
1967 */
Michael Kruse7520cf02020-03-25 09:26:14 -05001968 CXCursor_ParenExpr = 111,
Douglas Gregor4c362d52011-10-05 19:00:14 +00001969
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001970 /** This represents the unary-expression's (except sizeof and
Douglas Gregor4c362d52011-10-05 19:00:14 +00001971 * alignof).
1972 */
Michael Kruse7520cf02020-03-25 09:26:14 -05001973 CXCursor_UnaryOperator = 112,
Douglas Gregor4c362d52011-10-05 19:00:14 +00001974
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001975 /** [C99 6.5.2.1] Array Subscripting.
Douglas Gregor4c362d52011-10-05 19:00:14 +00001976 */
Michael Kruse7520cf02020-03-25 09:26:14 -05001977 CXCursor_ArraySubscriptExpr = 113,
Douglas Gregor4c362d52011-10-05 19:00:14 +00001978
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001979 /** A builtin binary operation expression such as "x + y" or
Douglas Gregor4c362d52011-10-05 19:00:14 +00001980 * "x <= y".
1981 */
Michael Kruse7520cf02020-03-25 09:26:14 -05001982 CXCursor_BinaryOperator = 114,
Douglas Gregor4c362d52011-10-05 19:00:14 +00001983
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001984 /** Compound assignment such as "+=".
Douglas Gregor4c362d52011-10-05 19:00:14 +00001985 */
Michael Kruse7520cf02020-03-25 09:26:14 -05001986 CXCursor_CompoundAssignOperator = 115,
Douglas Gregor4c362d52011-10-05 19:00:14 +00001987
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001988 /** The ?: ternary operator.
Douglas Gregor4c362d52011-10-05 19:00:14 +00001989 */
Michael Kruse7520cf02020-03-25 09:26:14 -05001990 CXCursor_ConditionalOperator = 116,
Douglas Gregor4c362d52011-10-05 19:00:14 +00001991
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001992 /** An explicit cast in C (C99 6.5.4) or a C-style cast in C++
Douglas Gregor4c362d52011-10-05 19:00:14 +00001993 * (C++ [expr.cast]), which uses the syntax (Type)expr.
1994 *
1995 * For example: (int)f.
1996 */
Michael Kruse7520cf02020-03-25 09:26:14 -05001997 CXCursor_CStyleCastExpr = 117,
Douglas Gregor4c362d52011-10-05 19:00:14 +00001998
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001999 /** [C99 6.5.2.5]
Douglas Gregor4c362d52011-10-05 19:00:14 +00002000 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002001 CXCursor_CompoundLiteralExpr = 118,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002002
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002003 /** Describes an C or C++ initializer list.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002004 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002005 CXCursor_InitListExpr = 119,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002006
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002007 /** The GNU address of label extension, representing &&label.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002008 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002009 CXCursor_AddrLabelExpr = 120,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002010
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002011 /** This is the GNU Statement Expression extension: ({int X=4; X;})
Douglas Gregor4c362d52011-10-05 19:00:14 +00002012 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002013 CXCursor_StmtExpr = 121,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002014
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002015 /** Represents a C11 generic selection.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002016 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002017 CXCursor_GenericSelectionExpr = 122,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002018
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002019 /** Implements the GNU __null extension, which is a name for a null
Douglas Gregor4c362d52011-10-05 19:00:14 +00002020 * pointer constant that has integral type (e.g., int or long) and is the same
2021 * size and alignment as a pointer.
2022 *
2023 * The __null extension is typically only used by system headers, which define
2024 * NULL as __null in C++ rather than using 0 (which is an integer that may not
2025 * match the size of a pointer).
2026 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002027 CXCursor_GNUNullExpr = 123,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002028
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002029 /** C++'s static_cast<> expression.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002030 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002031 CXCursor_CXXStaticCastExpr = 124,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002032
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002033 /** C++'s dynamic_cast<> expression.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002034 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002035 CXCursor_CXXDynamicCastExpr = 125,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002036
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002037 /** C++'s reinterpret_cast<> expression.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002038 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002039 CXCursor_CXXReinterpretCastExpr = 126,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002040
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002041 /** C++'s const_cast<> expression.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002042 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002043 CXCursor_CXXConstCastExpr = 127,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002044
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002045 /** Represents an explicit C++ type conversion that uses "functional"
Douglas Gregor4c362d52011-10-05 19:00:14 +00002046 * notion (C++ [expr.type.conv]).
2047 *
2048 * Example:
2049 * \code
2050 * x = int(0.5);
2051 * \endcode
2052 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002053 CXCursor_CXXFunctionalCastExpr = 128,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002054
Anastasia Stulovaa6a237f2020-05-18 11:02:01 +01002055 /** OpenCL's addrspace_cast<> expression.
2056 */
2057 CXCursor_CXXAddrspaceCastExpr = 129,
2058
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002059 /** A C++ typeid expression (C++ [expr.typeid]).
Douglas Gregor4c362d52011-10-05 19:00:14 +00002060 */
Anastasia Stulovaa6a237f2020-05-18 11:02:01 +01002061 CXCursor_CXXTypeidExpr = 130,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002062
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002063 /** [C++ 2.13.5] C++ Boolean Literal.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002064 */
Anastasia Stulovaa6a237f2020-05-18 11:02:01 +01002065 CXCursor_CXXBoolLiteralExpr = 131,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002066
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002067 /** [C++0x 2.14.7] C++ Pointer Literal.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002068 */
Anastasia Stulovaa6a237f2020-05-18 11:02:01 +01002069 CXCursor_CXXNullPtrLiteralExpr = 132,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002070
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002071 /** Represents the "this" expression in C++
Douglas Gregor4c362d52011-10-05 19:00:14 +00002072 */
Anastasia Stulovaa6a237f2020-05-18 11:02:01 +01002073 CXCursor_CXXThisExpr = 133,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002074
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002075 /** [C++ 15] C++ Throw Expression.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002076 *
2077 * This handles 'throw' and 'throw' assignment-expression. When
2078 * assignment-expression isn't present, Op will be null.
2079 */
Anastasia Stulovaa6a237f2020-05-18 11:02:01 +01002080 CXCursor_CXXThrowExpr = 134,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002081
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002082 /** A new expression for memory allocation and constructor calls, e.g:
Douglas Gregor4c362d52011-10-05 19:00:14 +00002083 * "new CXXNewExpr(foo)".
2084 */
Anastasia Stulovaa6a237f2020-05-18 11:02:01 +01002085 CXCursor_CXXNewExpr = 135,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002086
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002087 /** A delete expression for memory deallocation and destructor calls,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002088 * e.g. "delete[] pArray".
2089 */
Anastasia Stulovaa6a237f2020-05-18 11:02:01 +01002090 CXCursor_CXXDeleteExpr = 136,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002091
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002092 /** A unary expression. (noexcept, sizeof, or other traits)
Douglas Gregor4c362d52011-10-05 19:00:14 +00002093 */
Anastasia Stulovaa6a237f2020-05-18 11:02:01 +01002094 CXCursor_UnaryExpr = 137,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002095
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002096 /** An Objective-C string literal i.e. @"foo".
Douglas Gregor4c362d52011-10-05 19:00:14 +00002097 */
Anastasia Stulovaa6a237f2020-05-18 11:02:01 +01002098 CXCursor_ObjCStringLiteral = 138,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002099
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002100 /** An Objective-C \@encode expression.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002101 */
Anastasia Stulovaa6a237f2020-05-18 11:02:01 +01002102 CXCursor_ObjCEncodeExpr = 139,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002103
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002104 /** An Objective-C \@selector expression.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002105 */
Anastasia Stulovaa6a237f2020-05-18 11:02:01 +01002106 CXCursor_ObjCSelectorExpr = 140,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002107
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002108 /** An Objective-C \@protocol expression.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002109 */
Anastasia Stulovaa6a237f2020-05-18 11:02:01 +01002110 CXCursor_ObjCProtocolExpr = 141,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002111
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002112 /** An Objective-C "bridged" cast expression, which casts between
Douglas Gregor4c362d52011-10-05 19:00:14 +00002113 * Objective-C pointers and C pointers, transferring ownership in the process.
2114 *
2115 * \code
2116 * NSString *str = (__bridge_transfer NSString *)CFCreateString();
2117 * \endcode
2118 */
Anastasia Stulovaa6a237f2020-05-18 11:02:01 +01002119 CXCursor_ObjCBridgedCastExpr = 142,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002120
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002121 /** Represents a C++0x pack expansion that produces a sequence of
Douglas Gregor4c362d52011-10-05 19:00:14 +00002122 * expressions.
2123 *
2124 * A pack expansion expression contains a pattern (which itself is an
2125 * expression) followed by an ellipsis. For example:
2126 *
2127 * \code
2128 * template<typename F, typename ...Types>
2129 * void forward(F f, Types &&...args) {
2130 * f(static_cast<Types&&>(args)...);
2131 * }
2132 * \endcode
2133 */
Anastasia Stulovaa6a237f2020-05-18 11:02:01 +01002134 CXCursor_PackExpansionExpr = 143,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002135
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002136 /** Represents an expression that computes the length of a parameter
Douglas Gregor4c362d52011-10-05 19:00:14 +00002137 * pack.
2138 *
2139 * \code
2140 * template<typename ...Types>
2141 * struct count {
2142 * static const unsigned value = sizeof...(Types);
2143 * };
2144 * \endcode
2145 */
Anastasia Stulovaa6a237f2020-05-18 11:02:01 +01002146 CXCursor_SizeOfPackExpr = 144,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002147
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002148 /* Represents a C++ lambda expression that produces a local function
Douglas Gregor30093832012-02-15 00:54:55 +00002149 * object.
2150 *
2151 * \code
2152 * void abssort(float *x, unsigned N) {
2153 * std::sort(x, x + N,
2154 * [](float a, float b) {
2155 * return std::abs(a) < std::abs(b);
2156 * });
2157 * }
2158 * \endcode
2159 */
Anastasia Stulovaa6a237f2020-05-18 11:02:01 +01002160 CXCursor_LambdaExpr = 145,
Fangrui Song6907ce22018-07-30 19:24:48 +00002161
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002162 /** Objective-c Boolean Literal.
Ted Kremenek77006f62012-03-06 20:06:06 +00002163 */
Anastasia Stulovaa6a237f2020-05-18 11:02:01 +01002164 CXCursor_ObjCBoolLiteralExpr = 146,
Ted Kremenek77006f62012-03-06 20:06:06 +00002165
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002166 /** Represents the "self" expression in an Objective-C method.
Argyrios Kyrtzidisc2233be2013-04-23 17:57:17 +00002167 */
Anastasia Stulovaa6a237f2020-05-18 11:02:01 +01002168 CXCursor_ObjCSelfExpr = 147,
Argyrios Kyrtzidisc2233be2013-04-23 17:57:17 +00002169
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002170 /** OpenMP 4.0 [2.4, Array Section].
Alexey Bataev1a3320e2015-08-25 14:24:04 +00002171 */
Anastasia Stulovaa6a237f2020-05-18 11:02:01 +01002172 CXCursor_OMPArraySectionExpr = 148,
Alexey Bataev1a3320e2015-08-25 14:24:04 +00002173
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002174 /** Represents an @available(...) check.
Erik Pilkington29099de2016-07-16 00:35:23 +00002175 */
Anastasia Stulovaa6a237f2020-05-18 11:02:01 +01002176 CXCursor_ObjCAvailabilityCheckExpr = 149,
Erik Pilkington29099de2016-07-16 00:35:23 +00002177
Leonard Chandb01c3a2018-06-20 17:19:40 +00002178 /**
2179 * Fixed point literal
2180 */
Anastasia Stulovaa6a237f2020-05-18 11:02:01 +01002181 CXCursor_FixedPointLiteral = 150,
Leonard Chandb01c3a2018-06-20 17:19:40 +00002182
Alexey Bataev7ac9efb2020-02-05 09:33:05 -05002183 /** OpenMP 5.0 [2.1.4, Array Shaping].
2184 */
Anastasia Stulovaa6a237f2020-05-18 11:02:01 +01002185 CXCursor_OMPArrayShapingExpr = 151,
Alexey Bataev7ac9efb2020-02-05 09:33:05 -05002186
Alexey Bataev13a15042020-04-01 15:06:38 -04002187 /**
2188 * OpenMP 5.0 [2.1.6 Iterators]
2189 */
Anastasia Stulovaa6a237f2020-05-18 11:02:01 +01002190 CXCursor_OMPIteratorExpr = 152,
Alexey Bataev13a15042020-04-01 15:06:38 -04002191
2192 CXCursor_LastExpr = CXCursor_OMPIteratorExpr,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002193
Douglas Gregor6007cf22010-01-22 22:29:16 +00002194 /* Statements */
Michael Kruse7520cf02020-03-25 09:26:14 -05002195 CXCursor_FirstStmt = 200,
Douglas Gregor6007cf22010-01-22 22:29:16 +00002196 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002197 * A statement whose specific kind is not exposed via this
Douglas Gregor6007cf22010-01-22 22:29:16 +00002198 * interface.
2199 *
2200 * Unexposed statements have the same operations as any other kind of
2201 * statement; one can extract their location information, spelling,
2202 * children, etc. However, the specific kind of the statement is not
2203 * reported.
2204 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002205 CXCursor_UnexposedStmt = 200,
Fangrui Song6907ce22018-07-30 19:24:48 +00002206
2207 /** A labelled statement in a function.
Douglas Gregora93ab662010-09-10 00:22:18 +00002208 *
Fangrui Song6907ce22018-07-30 19:24:48 +00002209 * This cursor kind is used to describe the "start_over:" label statement in
Douglas Gregora93ab662010-09-10 00:22:18 +00002210 * the following example:
2211 *
2212 * \code
2213 * start_over:
2214 * ++counter;
2215 * \endcode
2216 *
2217 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002218 CXCursor_LabelStmt = 201,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002219
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002220 /** A group of statements like { stmt stmt }.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002221 *
2222 * This cursor kind is used to describe compound statements, e.g. function
2223 * bodies.
2224 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002225 CXCursor_CompoundStmt = 202,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002226
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002227 /** A case statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002228 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002229 CXCursor_CaseStmt = 203,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002230
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002231 /** A default statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002232 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002233 CXCursor_DefaultStmt = 204,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002234
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002235 /** An if statement
Douglas Gregor4c362d52011-10-05 19:00:14 +00002236 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002237 CXCursor_IfStmt = 205,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002238
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002239 /** A switch statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002240 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002241 CXCursor_SwitchStmt = 206,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002242
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002243 /** A while statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002244 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002245 CXCursor_WhileStmt = 207,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002246
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002247 /** A do statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002248 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002249 CXCursor_DoStmt = 208,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002250
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002251 /** A for statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002252 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002253 CXCursor_ForStmt = 209,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002254
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002255 /** A goto statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002256 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002257 CXCursor_GotoStmt = 210,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002258
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002259 /** An indirect goto statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002260 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002261 CXCursor_IndirectGotoStmt = 211,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002262
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002263 /** A continue statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002264 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002265 CXCursor_ContinueStmt = 212,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002266
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002267 /** A break statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002268 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002269 CXCursor_BreakStmt = 213,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002270
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002271 /** A return statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002272 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002273 CXCursor_ReturnStmt = 214,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002274
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002275 /** A GCC inline assembly statement extension.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002276 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002277 CXCursor_GCCAsmStmt = 215,
2278 CXCursor_AsmStmt = CXCursor_GCCAsmStmt,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002279
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002280 /** Objective-C's overall \@try-\@catch-\@finally statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002281 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002282 CXCursor_ObjCAtTryStmt = 216,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002283
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002284 /** Objective-C's \@catch statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002285 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002286 CXCursor_ObjCAtCatchStmt = 217,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002287
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002288 /** Objective-C's \@finally statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002289 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002290 CXCursor_ObjCAtFinallyStmt = 218,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002291
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002292 /** Objective-C's \@throw statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002293 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002294 CXCursor_ObjCAtThrowStmt = 219,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002295
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002296 /** Objective-C's \@synchronized statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002297 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002298 CXCursor_ObjCAtSynchronizedStmt = 220,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002299
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002300 /** Objective-C's autorelease pool statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002301 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002302 CXCursor_ObjCAutoreleasePoolStmt = 221,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002303
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002304 /** Objective-C's collection statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002305 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002306 CXCursor_ObjCForCollectionStmt = 222,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002307
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002308 /** C++'s catch statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002309 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002310 CXCursor_CXXCatchStmt = 223,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002311
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002312 /** C++'s try statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002313 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002314 CXCursor_CXXTryStmt = 224,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002315
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002316 /** C++'s for (* : *) statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002317 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002318 CXCursor_CXXForRangeStmt = 225,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002319
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002320 /** Windows Structured Exception Handling's try statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002321 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002322 CXCursor_SEHTryStmt = 226,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002323
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002324 /** Windows Structured Exception Handling's except statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002325 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002326 CXCursor_SEHExceptStmt = 227,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002327
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002328 /** Windows Structured Exception Handling's finally statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002329 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002330 CXCursor_SEHFinallyStmt = 228,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002331
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002332 /** A MS inline assembly statement extension.
Chad Rosier32503022012-06-11 20:47:18 +00002333 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002334 CXCursor_MSAsmStmt = 229,
Chad Rosier32503022012-06-11 20:47:18 +00002335
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002336 /** The null statement ";": C99 6.8.3p3.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002337 *
2338 * This cursor kind is used to describe the null statement.
2339 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002340 CXCursor_NullStmt = 230,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002341
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002342 /** Adaptor class for mixing declarations with statements and
Douglas Gregor4c362d52011-10-05 19:00:14 +00002343 * expressions.
2344 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002345 CXCursor_DeclStmt = 231,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002346
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002347 /** OpenMP parallel directive.
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002348 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002349 CXCursor_OMPParallelDirective = 232,
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002350
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002351 /** OpenMP SIMD directive.
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002352 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002353 CXCursor_OMPSimdDirective = 233,
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002354
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002355 /** OpenMP for directive.
Alexey Bataevf29276e2014-06-18 04:14:57 +00002356 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002357 CXCursor_OMPForDirective = 234,
Alexey Bataevf29276e2014-06-18 04:14:57 +00002358
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002359 /** OpenMP sections directive.
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002360 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002361 CXCursor_OMPSectionsDirective = 235,
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002362
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002363 /** OpenMP section directive.
Alexey Bataev1e0498a2014-06-26 08:21:58 +00002364 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002365 CXCursor_OMPSectionDirective = 236,
Alexey Bataev1e0498a2014-06-26 08:21:58 +00002366
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002367 /** OpenMP single directive.
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00002368 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002369 CXCursor_OMPSingleDirective = 237,
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00002370
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002371 /** OpenMP parallel for directive.
Alexey Bataev4acb8592014-07-07 13:01:15 +00002372 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002373 CXCursor_OMPParallelForDirective = 238,
Alexey Bataev4acb8592014-07-07 13:01:15 +00002374
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002375 /** OpenMP parallel sections directive.
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002376 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002377 CXCursor_OMPParallelSectionsDirective = 239,
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002378
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002379 /** OpenMP task directive.
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002380 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002381 CXCursor_OMPTaskDirective = 240,
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002382
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002383 /** OpenMP master directive.
Alexander Musman80c22892014-07-17 08:54:58 +00002384 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002385 CXCursor_OMPMasterDirective = 241,
Alexander Musman80c22892014-07-17 08:54:58 +00002386
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002387 /** OpenMP critical directive.
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002388 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002389 CXCursor_OMPCriticalDirective = 242,
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002390
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002391 /** OpenMP taskyield directive.
Alexey Bataev68446b72014-07-18 07:47:19 +00002392 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002393 CXCursor_OMPTaskyieldDirective = 243,
Alexey Bataev68446b72014-07-18 07:47:19 +00002394
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002395 /** OpenMP barrier directive.
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00002396 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002397 CXCursor_OMPBarrierDirective = 244,
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00002398
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002399 /** OpenMP taskwait directive.
Alexey Bataev2df347a2014-07-18 10:17:07 +00002400 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002401 CXCursor_OMPTaskwaitDirective = 245,
Alexey Bataev2df347a2014-07-18 10:17:07 +00002402
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002403 /** OpenMP flush directive.
Alexey Bataev6125da92014-07-21 11:26:11 +00002404 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002405 CXCursor_OMPFlushDirective = 246,
Alexey Bataev0162e452014-07-22 10:10:35 +00002406
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002407 /** Windows Structured Exception Handling's leave statement.
Reid Klecknerba764482014-07-24 18:22:15 +00002408 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002409 CXCursor_SEHLeaveStmt = 247,
Reid Klecknerba764482014-07-24 18:22:15 +00002410
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002411 /** OpenMP ordered directive.
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002412 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002413 CXCursor_OMPOrderedDirective = 248,
Alexey Bataev6125da92014-07-21 11:26:11 +00002414
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002415 /** OpenMP atomic directive.
Alexey Bataev0162e452014-07-22 10:10:35 +00002416 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002417 CXCursor_OMPAtomicDirective = 249,
Alexey Bataev0162e452014-07-22 10:10:35 +00002418
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002419 /** OpenMP for SIMD directive.
Alexander Musmanf82886e2014-09-18 05:12:34 +00002420 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002421 CXCursor_OMPForSimdDirective = 250,
Alexander Musmanf82886e2014-09-18 05:12:34 +00002422
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002423 /** OpenMP parallel for SIMD directive.
Alexander Musmane4e893b2014-09-23 09:33:00 +00002424 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002425 CXCursor_OMPParallelForSimdDirective = 251,
Alexander Musmane4e893b2014-09-23 09:33:00 +00002426
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002427 /** OpenMP target directive.
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002428 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002429 CXCursor_OMPTargetDirective = 252,
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002430
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002431 /** OpenMP teams directive.
Alexey Bataev13314bf2014-10-09 04:18:56 +00002432 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002433 CXCursor_OMPTeamsDirective = 253,
Alexey Bataev13314bf2014-10-09 04:18:56 +00002434
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002435 /** OpenMP taskgroup directive.
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002436 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002437 CXCursor_OMPTaskgroupDirective = 254,
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002438
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002439 /** OpenMP cancellation point directive.
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002440 */
Michael Wong65f367f2015-07-21 13:44:28 +00002441 CXCursor_OMPCancellationPointDirective = 255,
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002442
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002443 /** OpenMP cancel directive.
Alexey Bataev80909872015-07-02 11:25:17 +00002444 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002445 CXCursor_OMPCancelDirective = 256,
Alexey Bataev80909872015-07-02 11:25:17 +00002446
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002447 /** OpenMP target data directive.
Michael Wong65f367f2015-07-21 13:44:28 +00002448 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002449 CXCursor_OMPTargetDataDirective = 257,
Michael Wong65f367f2015-07-21 13:44:28 +00002450
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002451 /** OpenMP taskloop directive.
Alexey Bataev49f6e782015-12-01 04:18:41 +00002452 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002453 CXCursor_OMPTaskLoopDirective = 258,
Alexey Bataev49f6e782015-12-01 04:18:41 +00002454
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002455 /** OpenMP taskloop simd directive.
Alexey Bataev0a6ed842015-12-03 09:40:15 +00002456 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002457 CXCursor_OMPTaskLoopSimdDirective = 259,
Alexey Bataev0a6ed842015-12-03 09:40:15 +00002458
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002459 /** OpenMP distribute directive.
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00002460 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002461 CXCursor_OMPDistributeDirective = 260,
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00002462
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002463 /** OpenMP target enter data directive.
Samuel Antaodf67fc42016-01-19 19:15:56 +00002464 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002465 CXCursor_OMPTargetEnterDataDirective = 261,
Samuel Antaodf67fc42016-01-19 19:15:56 +00002466
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002467 /** OpenMP target exit data directive.
Samuel Antao72590762016-01-19 20:04:50 +00002468 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002469 CXCursor_OMPTargetExitDataDirective = 262,
Samuel Antao72590762016-01-19 20:04:50 +00002470
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002471 /** OpenMP target parallel directive.
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002472 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002473 CXCursor_OMPTargetParallelDirective = 263,
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002474
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002475 /** OpenMP target parallel for directive.
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00002476 */
2477 CXCursor_OMPTargetParallelForDirective = 264,
2478
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002479 /** OpenMP target update directive.
Samuel Antao686c70c2016-05-26 17:30:50 +00002480 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002481 CXCursor_OMPTargetUpdateDirective = 265,
Samuel Antao686c70c2016-05-26 17:30:50 +00002482
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002483 /** OpenMP distribute parallel for directive.
Carlo Bertolli9925f152016-06-27 14:55:37 +00002484 */
2485 CXCursor_OMPDistributeParallelForDirective = 266,
2486
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002487 /** OpenMP distribute parallel for simd directive.
Kelvin Li4a39add2016-07-05 05:00:15 +00002488 */
2489 CXCursor_OMPDistributeParallelForSimdDirective = 267,
2490
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002491 /** OpenMP distribute simd directive.
Kelvin Li787f3fc2016-07-06 04:45:38 +00002492 */
2493 CXCursor_OMPDistributeSimdDirective = 268,
2494
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002495 /** OpenMP target parallel for simd directive.
Kelvin Lia579b912016-07-14 02:54:56 +00002496 */
2497 CXCursor_OMPTargetParallelForSimdDirective = 269,
2498
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002499 /** OpenMP target simd directive.
Kelvin Li986330c2016-07-20 22:57:10 +00002500 */
2501 CXCursor_OMPTargetSimdDirective = 270,
2502
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002503 /** OpenMP teams distribute directive.
Kelvin Li02532872016-08-05 14:37:37 +00002504 */
2505 CXCursor_OMPTeamsDistributeDirective = 271,
2506
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002507 /** OpenMP teams distribute simd directive.
Kelvin Li4e325f72016-10-25 12:50:55 +00002508 */
2509 CXCursor_OMPTeamsDistributeSimdDirective = 272,
2510
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002511 /** OpenMP teams distribute parallel for simd directive.
Kelvin Li579e41c2016-11-30 23:51:03 +00002512 */
2513 CXCursor_OMPTeamsDistributeParallelForSimdDirective = 273,
2514
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002515 /** OpenMP teams distribute parallel for directive.
Kelvin Li7ade93f2016-12-09 03:24:30 +00002516 */
2517 CXCursor_OMPTeamsDistributeParallelForDirective = 274,
2518
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002519 /** OpenMP target teams directive.
Kelvin Libf594a52016-12-17 05:48:59 +00002520 */
2521 CXCursor_OMPTargetTeamsDirective = 275,
2522
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002523 /** OpenMP target teams distribute directive.
Kelvin Li83c451e2016-12-25 04:52:54 +00002524 */
2525 CXCursor_OMPTargetTeamsDistributeDirective = 276,
2526
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002527 /** OpenMP target teams distribute parallel for directive.
Kelvin Li80e8f562016-12-29 22:16:30 +00002528 */
2529 CXCursor_OMPTargetTeamsDistributeParallelForDirective = 277,
2530
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002531 /** OpenMP target teams distribute parallel for simd directive.
Kelvin Li1851df52017-01-03 05:23:48 +00002532 */
2533 CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective = 278,
2534
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002535 /** OpenMP target teams distribute simd directive.
Kelvin Lida681182017-01-10 18:08:18 +00002536 */
2537 CXCursor_OMPTargetTeamsDistributeSimdDirective = 279,
2538
Erik Pilkingtoneee944e2019-07-02 18:28:13 +00002539 /** C++2a std::bit_cast expression.
2540 */
2541 CXCursor_BuiltinBitCastExpr = 280,
2542
Alexey Bataev60e51c42019-10-10 20:13:02 +00002543 /** OpenMP master taskloop directive.
2544 */
2545 CXCursor_OMPMasterTaskLoopDirective = 281,
2546
Alexey Bataev5bbcead2019-10-14 17:17:41 +00002547 /** OpenMP parallel master taskloop directive.
2548 */
2549 CXCursor_OMPParallelMasterTaskLoopDirective = 282,
Alexey Bataev60e51c42019-10-10 20:13:02 +00002550
Alexey Bataevb8552ab2019-10-18 16:47:35 +00002551 /** OpenMP master taskloop simd directive.
2552 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002553 CXCursor_OMPMasterTaskLoopSimdDirective = 283,
Alexey Bataevb8552ab2019-10-18 16:47:35 +00002554
Alexey Bataev14a388f2019-10-25 10:27:13 -04002555 /** OpenMP parallel master taskloop simd directive.
2556 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002557 CXCursor_OMPParallelMasterTaskLoopSimdDirective = 284,
Alexey Bataevb8552ab2019-10-18 16:47:35 +00002558
cchen47d60942019-12-05 13:43:48 -05002559 /** OpenMP parallel master directive.
2560 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002561 CXCursor_OMPParallelMasterDirective = 285,
cchen47d60942019-12-05 13:43:48 -05002562
Alexey Bataevc112e942020-02-28 09:52:15 -05002563 /** OpenMP depobj directive.
2564 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002565 CXCursor_OMPDepobjDirective = 286,
Alexey Bataevc112e942020-02-28 09:52:15 -05002566
Alexey Bataevfcba7c32020-03-20 07:03:01 -04002567 /** OpenMP scan directive.
2568 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002569 CXCursor_OMPScanDirective = 287,
Alexey Bataevfcba7c32020-03-20 07:03:01 -04002570
2571 CXCursor_LastStmt = CXCursor_OMPScanDirective,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002572
Douglas Gregor6007cf22010-01-22 22:29:16 +00002573 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002574 * Cursor that represents the translation unit itself.
Douglas Gregor6007cf22010-01-22 22:29:16 +00002575 *
2576 * The translation unit cursor exists primarily to act as the root
2577 * cursor for traversing the contents of a translation unit.
2578 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002579 CXCursor_TranslationUnit = 300,
Ted Kremenekbff31432010-02-18 03:09:07 +00002580
Bill Wendling44426052012-12-20 19:22:21 +00002581 /* Attributes */
Michael Kruse7520cf02020-03-25 09:26:14 -05002582 CXCursor_FirstAttr = 400,
Ted Kremenekbff31432010-02-18 03:09:07 +00002583 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002584 * An attribute whose specific kind is not exposed via this
Ted Kremenekbff31432010-02-18 03:09:07 +00002585 * interface.
2586 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002587 CXCursor_UnexposedAttr = 400,
Ted Kremenekbff31432010-02-18 03:09:07 +00002588
Michael Kruse7520cf02020-03-25 09:26:14 -05002589 CXCursor_IBActionAttr = 401,
2590 CXCursor_IBOutletAttr = 402,
2591 CXCursor_IBOutletCollectionAttr = 403,
2592 CXCursor_CXXFinalAttr = 404,
2593 CXCursor_CXXOverrideAttr = 405,
2594 CXCursor_AnnotateAttr = 406,
2595 CXCursor_AsmLabelAttr = 407,
2596 CXCursor_PackedAttr = 408,
2597 CXCursor_PureAttr = 409,
2598 CXCursor_ConstAttr = 410,
2599 CXCursor_NoDuplicateAttr = 411,
2600 CXCursor_CUDAConstantAttr = 412,
2601 CXCursor_CUDADeviceAttr = 413,
2602 CXCursor_CUDAGlobalAttr = 414,
2603 CXCursor_CUDAHostAttr = 415,
2604 CXCursor_CUDASharedAttr = 416,
2605 CXCursor_VisibilityAttr = 417,
2606 CXCursor_DLLExport = 418,
2607 CXCursor_DLLImport = 419,
2608 CXCursor_NSReturnsRetained = 420,
2609 CXCursor_NSReturnsNotRetained = 421,
2610 CXCursor_NSReturnsAutoreleased = 422,
2611 CXCursor_NSConsumesSelf = 423,
2612 CXCursor_NSConsumed = 424,
2613 CXCursor_ObjCException = 425,
2614 CXCursor_ObjCNSObject = 426,
2615 CXCursor_ObjCIndependentClass = 427,
2616 CXCursor_ObjCPreciseLifetime = 428,
2617 CXCursor_ObjCReturnsInnerPointer = 429,
2618 CXCursor_ObjCRequiresSuper = 430,
2619 CXCursor_ObjCRootClass = 431,
2620 CXCursor_ObjCSubclassingRestricted = 432,
2621 CXCursor_ObjCExplicitProtocolImpl = 433,
2622 CXCursor_ObjCDesignatedInitializer = 434,
2623 CXCursor_ObjCRuntimeVisible = 435,
2624 CXCursor_ObjCBoxable = 436,
2625 CXCursor_FlagEnum = 437,
2626 CXCursor_ConvergentAttr = 438,
2627 CXCursor_WarnUnusedAttr = 439,
2628 CXCursor_WarnUnusedResultAttr = 440,
2629 CXCursor_AlignedAttr = 441,
2630 CXCursor_LastAttr = CXCursor_AlignedAttr,
Eli Bendersky2581e662014-05-28 19:29:58 +00002631
Douglas Gregor92a524f2010-03-18 00:42:48 +00002632 /* Preprocessing */
Michael Kruse7520cf02020-03-25 09:26:14 -05002633 CXCursor_PreprocessingDirective = 500,
2634 CXCursor_MacroDefinition = 501,
2635 CXCursor_MacroExpansion = 502,
2636 CXCursor_MacroInstantiation = CXCursor_MacroExpansion,
2637 CXCursor_InclusionDirective = 503,
2638 CXCursor_FirstPreprocessing = CXCursor_PreprocessingDirective,
2639 CXCursor_LastPreprocessing = CXCursor_InclusionDirective,
Argyrios Kyrtzidis50e5b1d2012-10-05 00:22:24 +00002640
2641 /* Extra Declarations */
2642 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002643 * A module import declaration.
Argyrios Kyrtzidis50e5b1d2012-10-05 00:22:24 +00002644 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002645 CXCursor_ModuleImportDecl = 600,
2646 CXCursor_TypeAliasTemplateDecl = 601,
Olivier Goffart81978012016-06-09 16:15:55 +00002647 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002648 * A static_assert or _Static_assert node
Olivier Goffart81978012016-06-09 16:15:55 +00002649 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002650 CXCursor_StaticAssert = 602,
Olivier Goffartd211c642016-11-04 06:29:27 +00002651 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002652 * a friend declaration.
Olivier Goffartd211c642016-11-04 06:29:27 +00002653 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002654 CXCursor_FriendDecl = 603,
2655 CXCursor_FirstExtraDecl = CXCursor_ModuleImportDecl,
2656 CXCursor_LastExtraDecl = CXCursor_FriendDecl,
Francisco Lopes da Silva975a9f62015-01-21 16:24:11 +00002657
2658 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002659 * A code completion overload candidate.
Francisco Lopes da Silva975a9f62015-01-21 16:24:11 +00002660 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002661 CXCursor_OverloadCandidate = 700
Douglas Gregor6007cf22010-01-22 22:29:16 +00002662};
2663
2664/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002665 * A cursor representing some element in the abstract syntax tree for
Douglas Gregor6007cf22010-01-22 22:29:16 +00002666 * a translation unit.
2667 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002668 * The cursor abstraction unifies the different kinds of entities in a
Douglas Gregor6007cf22010-01-22 22:29:16 +00002669 * program--declaration, statements, expressions, references to declarations,
2670 * etc.--under a single "cursor" abstraction with a common set of operations.
2671 * Common operation for a cursor include: getting the physical location in
2672 * a source file where the cursor points, getting the name associated with a
2673 * cursor, and retrieving cursors for any child nodes of a particular cursor.
2674 *
2675 * Cursors can be produced in two specific ways.
2676 * clang_getTranslationUnitCursor() produces a cursor for a translation unit,
2677 * from which one can use clang_visitChildren() to explore the rest of the
2678 * translation unit. clang_getCursor() maps from a physical source location
2679 * to the entity that resides at that location, allowing one to map from the
2680 * source code into the AST.
2681 */
2682typedef struct {
2683 enum CXCursorKind kind;
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00002684 int xdata;
Dmitri Gribenkoba2f7462013-01-11 21:01:49 +00002685 const void *data[3];
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002686} CXCursor;
Douglas Gregor6007cf22010-01-22 22:29:16 +00002687
2688/**
2689 * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations
2690 *
2691 * @{
2692 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002693
Douglas Gregor6007cf22010-01-22 22:29:16 +00002694/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002695 * Retrieve the NULL cursor, which represents no entity.
Douglas Gregor6007cf22010-01-22 22:29:16 +00002696 */
2697CINDEX_LINKAGE CXCursor clang_getNullCursor(void);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002698
Douglas Gregor6007cf22010-01-22 22:29:16 +00002699/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002700 * Retrieve the cursor that represents the given translation unit.
Douglas Gregor6007cf22010-01-22 22:29:16 +00002701 *
2702 * The translation unit cursor can be used to start traversing the
2703 * various declarations within the given translation unit.
2704 */
2705CINDEX_LINKAGE CXCursor clang_getTranslationUnitCursor(CXTranslationUnit);
2706
2707/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002708 * Determine whether two cursors are equivalent.
Douglas Gregor6007cf22010-01-22 22:29:16 +00002709 */
2710CINDEX_LINKAGE unsigned clang_equalCursors(CXCursor, CXCursor);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002711
Douglas Gregor6007cf22010-01-22 22:29:16 +00002712/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002713 * Returns non-zero if \p cursor is null.
Argyrios Kyrtzidisd6e9fa52011-09-27 00:30:30 +00002714 */
Dmitri Gribenko8994e0c2012-09-13 13:11:20 +00002715CINDEX_LINKAGE int clang_Cursor_isNull(CXCursor cursor);
Argyrios Kyrtzidisd6e9fa52011-09-27 00:30:30 +00002716
2717/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002718 * Compute a hash value for the given cursor.
Douglas Gregor06a3f302010-11-20 00:09:34 +00002719 */
2720CINDEX_LINKAGE unsigned clang_hashCursor(CXCursor);
Fangrui Song6907ce22018-07-30 19:24:48 +00002721
Douglas Gregor06a3f302010-11-20 00:09:34 +00002722/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002723 * Retrieve the kind of the given cursor.
Douglas Gregor6007cf22010-01-22 22:29:16 +00002724 */
2725CINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor);
2726
2727/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002728 * Determine whether the given cursor kind represents a declaration.
Ivan Donchevskii65c766e2018-01-03 10:40:11 +00002729 */
2730CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind);
2731
2732/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002733 * Determine whether the given declaration is invalid.
Ivan Donchevskii08ff9102018-01-04 10:59:50 +00002734 *
2735 * A declaration is invalid if it could not be parsed successfully.
2736 *
2737 * \returns non-zero if the cursor represents a declaration and it is
2738 * invalid, otherwise NULL.
2739 */
2740CINDEX_LINKAGE unsigned clang_isInvalidDeclaration(CXCursor);
2741
2742/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002743 * Determine whether the given cursor kind represents a simple
Ivan Donchevskii65c766e2018-01-03 10:40:11 +00002744 * reference.
Douglas Gregor6007cf22010-01-22 22:29:16 +00002745 *
2746 * Note that other kinds of cursors (such as expressions) can also refer to
2747 * other cursors. Use clang_getCursorReferenced() to determine whether a
2748 * particular cursor refers to another entity.
2749 */
2750CINDEX_LINKAGE unsigned clang_isReference(enum CXCursorKind);
2751
2752/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002753 * Determine whether the given cursor kind represents an expression.
Douglas Gregor6007cf22010-01-22 22:29:16 +00002754 */
2755CINDEX_LINKAGE unsigned clang_isExpression(enum CXCursorKind);
2756
2757/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002758 * Determine whether the given cursor kind represents a statement.
Douglas Gregor6007cf22010-01-22 22:29:16 +00002759 */
2760CINDEX_LINKAGE unsigned clang_isStatement(enum CXCursorKind);
2761
2762/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002763 * Determine whether the given cursor kind represents an attribute.
Douglas Gregora98034a2011-07-06 03:00:34 +00002764 */
2765CINDEX_LINKAGE unsigned clang_isAttribute(enum CXCursorKind);
2766
2767/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002768 * Determine whether the given cursor has any attributes.
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00002769 */
2770CINDEX_LINKAGE unsigned clang_Cursor_hasAttrs(CXCursor C);
2771
2772/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002773 * Determine whether the given cursor kind represents an invalid
Douglas Gregor6007cf22010-01-22 22:29:16 +00002774 * cursor.
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002775 */
Douglas Gregor6007cf22010-01-22 22:29:16 +00002776CINDEX_LINKAGE unsigned clang_isInvalid(enum CXCursorKind);
2777
2778/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002779 * Determine whether the given cursor kind represents a translation
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002780 * unit.
Douglas Gregor6007cf22010-01-22 22:29:16 +00002781 */
2782CINDEX_LINKAGE unsigned clang_isTranslationUnit(enum CXCursorKind);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002783
Ted Kremenekff9021b2010-03-08 21:17:29 +00002784/***
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002785 * Determine whether the given cursor represents a preprocessing
Douglas Gregor92a524f2010-03-18 00:42:48 +00002786 * element, such as a preprocessor directive or macro instantiation.
2787 */
2788CINDEX_LINKAGE unsigned clang_isPreprocessing(enum CXCursorKind);
Fangrui Song6907ce22018-07-30 19:24:48 +00002789
Douglas Gregor92a524f2010-03-18 00:42:48 +00002790/***
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002791 * Determine whether the given cursor represents a currently
Ted Kremenekff9021b2010-03-08 21:17:29 +00002792 * unexposed piece of the AST (e.g., CXCursor_UnexposedStmt).
2793 */
2794CINDEX_LINKAGE unsigned clang_isUnexposed(enum CXCursorKind);
2795
Douglas Gregor6007cf22010-01-22 22:29:16 +00002796/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002797 * Describe the linkage of the entity referred to by a cursor.
Ted Kremenekfb4961d2010-03-03 06:36:57 +00002798 */
2799enum CXLinkageKind {
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002800 /** This value indicates that no linkage information is available
Ted Kremenekfb4961d2010-03-03 06:36:57 +00002801 * for a provided CXCursor. */
2802 CXLinkage_Invalid,
2803 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002804 * This is the linkage for variables, parameters, and so on that
Ted Kremenekfb4961d2010-03-03 06:36:57 +00002805 * have automatic storage. This covers normal (non-extern) local variables.
2806 */
2807 CXLinkage_NoLinkage,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002808 /** This is the linkage for static variables and static functions. */
Ted Kremenekfb4961d2010-03-03 06:36:57 +00002809 CXLinkage_Internal,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002810 /** This is the linkage for entities with external linkage that live
Ted Kremenekfb4961d2010-03-03 06:36:57 +00002811 * in C++ anonymous namespaces.*/
2812 CXLinkage_UniqueExternal,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002813 /** This is the linkage for entities with true, external linkage. */
Ted Kremenekfb4961d2010-03-03 06:36:57 +00002814 CXLinkage_External
2815};
2816
2817/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002818 * Determine the linkage of the entity referred to by a given cursor.
Ted Kremenekfb4961d2010-03-03 06:36:57 +00002819 */
2820CINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor);
2821
Ehsan Akhgarib743de72016-05-31 15:55:51 +00002822enum CXVisibilityKind {
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002823 /** This value indicates that no visibility information is available
Ehsan Akhgarib743de72016-05-31 15:55:51 +00002824 * for a provided CXCursor. */
2825 CXVisibility_Invalid,
2826
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002827 /** Symbol not seen by the linker. */
Ehsan Akhgarib743de72016-05-31 15:55:51 +00002828 CXVisibility_Hidden,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002829 /** Symbol seen by the linker but resolves to a symbol inside this object. */
Ehsan Akhgarib743de72016-05-31 15:55:51 +00002830 CXVisibility_Protected,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002831 /** Symbol seen by the linker and acts like a normal symbol. */
Ehsan Akhgarib743de72016-05-31 15:55:51 +00002832 CXVisibility_Default
2833};
2834
2835/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002836 * Describe the visibility of the entity referred to by a cursor.
Ehsan Akhgarib743de72016-05-31 15:55:51 +00002837 *
2838 * This returns the default visibility if not explicitly specified by
2839 * a visibility attribute. The default visibility may be changed by
2840 * commandline arguments.
2841 *
2842 * \param cursor The cursor to query.
2843 *
2844 * \returns The visibility of the cursor.
2845 */
2846CINDEX_LINKAGE enum CXVisibilityKind clang_getCursorVisibility(CXCursor cursor);
2847
Ehsan Akhgari93697fa2015-11-23 19:56:46 +00002848/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002849 * Determine the availability of the entity that this cursor refers to,
Douglas Gregord6225d32012-05-08 00:14:45 +00002850 * taking the current target platform into account.
Douglas Gregorf757a122010-08-23 23:00:57 +00002851 *
2852 * \param cursor The cursor to query.
2853 *
2854 * \returns The availability of the cursor.
2855 */
Fangrui Song6907ce22018-07-30 19:24:48 +00002856CINDEX_LINKAGE enum CXAvailabilityKind
Douglas Gregorf757a122010-08-23 23:00:57 +00002857clang_getCursorAvailability(CXCursor cursor);
2858
2859/**
Douglas Gregord6225d32012-05-08 00:14:45 +00002860 * Describes the availability of a given entity on a particular platform, e.g.,
2861 * a particular class might only be available on Mac OS 10.7 or newer.
2862 */
2863typedef struct CXPlatformAvailability {
2864 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002865 * A string that describes the platform for which this structure
Douglas Gregord6225d32012-05-08 00:14:45 +00002866 * provides availability information.
2867 *
Manman Renccf25bb2016-06-28 20:55:30 +00002868 * Possible values are "ios" or "macos".
Douglas Gregord6225d32012-05-08 00:14:45 +00002869 */
2870 CXString Platform;
2871 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002872 * The version number in which this entity was introduced.
Douglas Gregord6225d32012-05-08 00:14:45 +00002873 */
2874 CXVersion Introduced;
2875 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002876 * The version number in which this entity was deprecated (but is
Douglas Gregord6225d32012-05-08 00:14:45 +00002877 * still available).
2878 */
2879 CXVersion Deprecated;
2880 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002881 * The version number in which this entity was obsoleted, and therefore
Douglas Gregord6225d32012-05-08 00:14:45 +00002882 * is no longer available.
2883 */
2884 CXVersion Obsoleted;
2885 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002886 * Whether the entity is unconditionally unavailable on this platform.
Douglas Gregord6225d32012-05-08 00:14:45 +00002887 */
2888 int Unavailable;
2889 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002890 * An optional message to provide to a user of this API, e.g., to
Douglas Gregord6225d32012-05-08 00:14:45 +00002891 * suggest replacement APIs.
2892 */
2893 CXString Message;
2894} CXPlatformAvailability;
2895
2896/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002897 * Determine the availability of the entity that this cursor refers to
Douglas Gregord6225d32012-05-08 00:14:45 +00002898 * on any platforms for which availability information is known.
2899 *
2900 * \param cursor The cursor to query.
2901 *
Fangrui Song6907ce22018-07-30 19:24:48 +00002902 * \param always_deprecated If non-NULL, will be set to indicate whether the
Douglas Gregord6225d32012-05-08 00:14:45 +00002903 * entity is deprecated on all platforms.
2904 *
Fangrui Song6907ce22018-07-30 19:24:48 +00002905 * \param deprecated_message If non-NULL, will be set to the message text
Douglas Gregord6225d32012-05-08 00:14:45 +00002906 * provided along with the unconditional deprecation of this entity. The client
2907 * is responsible for deallocating this string.
2908 *
James Dennett574cb4c2012-06-15 05:41:51 +00002909 * \param always_unavailable If non-NULL, will be set to indicate whether the
Douglas Gregord6225d32012-05-08 00:14:45 +00002910 * entity is unavailable on all platforms.
2911 *
2912 * \param unavailable_message If non-NULL, will be set to the message text
Fangrui Song6907ce22018-07-30 19:24:48 +00002913 * provided along with the unconditional unavailability of this entity. The
Douglas Gregord6225d32012-05-08 00:14:45 +00002914 * client is responsible for deallocating this string.
2915 *
2916 * \param availability If non-NULL, an array of CXPlatformAvailability instances
2917 * that will be populated with platform availability information, up to either
2918 * the number of platforms for which availability information is available (as
2919 * returned by this function) or \c availability_size, whichever is smaller.
2920 *
Fangrui Song6907ce22018-07-30 19:24:48 +00002921 * \param availability_size The number of elements available in the
Douglas Gregord6225d32012-05-08 00:14:45 +00002922 * \c availability array.
2923 *
2924 * \returns The number of platforms (N) for which availability information is
2925 * available (which is unrelated to \c availability_size).
2926 *
Fangrui Song6907ce22018-07-30 19:24:48 +00002927 * Note that the client is responsible for calling
2928 * \c clang_disposeCXPlatformAvailability to free each of the
2929 * platform-availability structures returned. There are
Douglas Gregord6225d32012-05-08 00:14:45 +00002930 * \c min(N, availability_size) such structures.
2931 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002932CINDEX_LINKAGE int clang_getCursorPlatformAvailability(
2933 CXCursor cursor, int *always_deprecated, CXString *deprecated_message,
2934 int *always_unavailable, CXString *unavailable_message,
2935 CXPlatformAvailability *availability, int availability_size);
Douglas Gregord6225d32012-05-08 00:14:45 +00002936
2937/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002938 * Free the memory associated with a \c CXPlatformAvailability structure.
Douglas Gregord6225d32012-05-08 00:14:45 +00002939 */
2940CINDEX_LINKAGE void
2941clang_disposeCXPlatformAvailability(CXPlatformAvailability *availability);
Fangrui Song6907ce22018-07-30 19:24:48 +00002942
Douglas Gregord6225d32012-05-08 00:14:45 +00002943/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002944 * Describe the "language" of the entity referred to by a cursor.
Ted Kremenek4ed29252010-04-12 21:22:16 +00002945 */
Reid Kleckner9e3bc722013-12-30 17:48:49 +00002946enum CXLanguageKind {
Ted Kremenekee457512010-04-14 20:58:32 +00002947 CXLanguage_Invalid = 0,
Ted Kremenek4ed29252010-04-12 21:22:16 +00002948 CXLanguage_C,
2949 CXLanguage_ObjC,
Ted Kremenekee457512010-04-14 20:58:32 +00002950 CXLanguage_CPlusPlus
Ted Kremenek4ed29252010-04-12 21:22:16 +00002951};
2952
2953/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002954 * Determine the "language" of the entity referred to by a given cursor.
Ted Kremenek4ed29252010-04-12 21:22:16 +00002955 */
2956CINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor);
2957
Argyrios Kyrtzidisd6e9fa52011-09-27 00:30:30 +00002958/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002959 * Describe the "thread-local storage (TLS) kind" of the declaration
Saleem Abdulrasool50bc5652017-09-13 02:15:09 +00002960 * referred to by a cursor.
2961 */
Michael Kruse7520cf02020-03-25 09:26:14 -05002962enum CXTLSKind { CXTLS_None = 0, CXTLS_Dynamic, CXTLS_Static };
Saleem Abdulrasool50bc5652017-09-13 02:15:09 +00002963
2964/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002965 * Determine the "thread-local storage (TLS) kind" of the declaration
Saleem Abdulrasool50bc5652017-09-13 02:15:09 +00002966 * referred to by a cursor.
2967 */
2968CINDEX_LINKAGE enum CXTLSKind clang_getCursorTLSKind(CXCursor cursor);
2969
2970/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002971 * Returns the translation unit that a cursor originated from.
Argyrios Kyrtzidisd6e9fa52011-09-27 00:30:30 +00002972 */
2973CINDEX_LINKAGE CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor);
2974
Ted Kremenekc0b98662013-04-24 07:17:12 +00002975/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002976 * A fast container representing a set of CXCursors.
Ted Kremenekc0b98662013-04-24 07:17:12 +00002977 */
2978typedef struct CXCursorSetImpl *CXCursorSet;
2979
2980/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002981 * Creates an empty CXCursorSet.
Ted Kremenekc0b98662013-04-24 07:17:12 +00002982 */
2983CINDEX_LINKAGE CXCursorSet clang_createCXCursorSet(void);
2984
2985/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002986 * Disposes a CXCursorSet and releases its associated memory.
Ted Kremenekc0b98662013-04-24 07:17:12 +00002987 */
2988CINDEX_LINKAGE void clang_disposeCXCursorSet(CXCursorSet cset);
2989
2990/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002991 * Queries a CXCursorSet to see if it contains a specific CXCursor.
Ted Kremenekc0b98662013-04-24 07:17:12 +00002992 *
2993 * \returns non-zero if the set contains the specified cursor.
Michael Kruse7520cf02020-03-25 09:26:14 -05002994 */
Ted Kremenekc0b98662013-04-24 07:17:12 +00002995CINDEX_LINKAGE unsigned clang_CXCursorSet_contains(CXCursorSet cset,
2996 CXCursor cursor);
2997
2998/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002999 * Inserts a CXCursor into a CXCursorSet.
Ted Kremenekc0b98662013-04-24 07:17:12 +00003000 *
3001 * \returns zero if the CXCursor was already in the set, and non-zero otherwise.
Michael Kruse7520cf02020-03-25 09:26:14 -05003002 */
Ted Kremenekc0b98662013-04-24 07:17:12 +00003003CINDEX_LINKAGE unsigned clang_CXCursorSet_insert(CXCursorSet cset,
3004 CXCursor cursor);
3005
Douglas Gregor0576ce72010-09-22 21:22:29 +00003006/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003007 * Determine the semantic parent of the given cursor.
Douglas Gregor0576ce72010-09-22 21:22:29 +00003008 *
3009 * The semantic parent of a cursor is the cursor that semantically contains
3010 * the given \p cursor. For many declarations, the lexical and semantic parents
Fangrui Song6907ce22018-07-30 19:24:48 +00003011 * are equivalent (the lexical parent is returned by
Douglas Gregor0576ce72010-09-22 21:22:29 +00003012 * \c clang_getCursorLexicalParent()). They diverge when declarations or
3013 * definitions are provided out-of-line. For example:
3014 *
3015 * \code
3016 * class C {
3017 * void f();
3018 * };
3019 *
3020 * void C::f() { }
3021 * \endcode
3022 *
Nico Weber7deebef2014-04-24 03:17:47 +00003023 * In the out-of-line definition of \c C::f, the semantic parent is
Douglas Gregor0576ce72010-09-22 21:22:29 +00003024 * the class \c C, of which this function is a member. The lexical parent is
3025 * the place where the declaration actually occurs in the source code; in this
Nico Weber7deebef2014-04-24 03:17:47 +00003026 * case, the definition occurs in the translation unit. In general, the
Douglas Gregor0576ce72010-09-22 21:22:29 +00003027 * lexical parent for a given entity can change without affecting the semantics
3028 * of the program, and the lexical parent of different declarations of the
3029 * same entity may be different. Changing the semantic parent of a declaration,
3030 * on the other hand, can have a major impact on semantics, and redeclarations
3031 * of a particular entity should all have the same semantic context.
3032 *
3033 * In the example above, both declarations of \c C::f have \c C as their
3034 * semantic context, while the lexical context of the first \c C::f is \c C
3035 * and the lexical context of the second \c C::f is the translation unit.
Douglas Gregor7ecd19e2010-12-21 07:55:45 +00003036 *
3037 * For global declarations, the semantic parent is the translation unit.
Douglas Gregor0576ce72010-09-22 21:22:29 +00003038 */
3039CINDEX_LINKAGE CXCursor clang_getCursorSemanticParent(CXCursor cursor);
3040
3041/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003042 * Determine the lexical parent of the given cursor.
Douglas Gregor0576ce72010-09-22 21:22:29 +00003043 *
3044 * The lexical parent of a cursor is the cursor in which the given \p cursor
3045 * was actually written. For many declarations, the lexical and semantic parents
Fangrui Song6907ce22018-07-30 19:24:48 +00003046 * are equivalent (the semantic parent is returned by
Douglas Gregor0576ce72010-09-22 21:22:29 +00003047 * \c clang_getCursorSemanticParent()). They diverge when declarations or
3048 * definitions are provided out-of-line. For example:
3049 *
3050 * \code
3051 * class C {
3052 * void f();
3053 * };
3054 *
3055 * void C::f() { }
3056 * \endcode
3057 *
Nico Weber7deebef2014-04-24 03:17:47 +00003058 * In the out-of-line definition of \c C::f, the semantic parent is
Douglas Gregor0576ce72010-09-22 21:22:29 +00003059 * the class \c C, of which this function is a member. The lexical parent is
3060 * the place where the declaration actually occurs in the source code; in this
Nico Weber7deebef2014-04-24 03:17:47 +00003061 * case, the definition occurs in the translation unit. In general, the
Douglas Gregor0576ce72010-09-22 21:22:29 +00003062 * lexical parent for a given entity can change without affecting the semantics
3063 * of the program, and the lexical parent of different declarations of the
3064 * same entity may be different. Changing the semantic parent of a declaration,
3065 * on the other hand, can have a major impact on semantics, and redeclarations
3066 * of a particular entity should all have the same semantic context.
3067 *
3068 * In the example above, both declarations of \c C::f have \c C as their
3069 * semantic context, while the lexical context of the first \c C::f is \c C
3070 * and the lexical context of the second \c C::f is the translation unit.
Douglas Gregor7ecd19e2010-12-21 07:55:45 +00003071 *
3072 * For declarations written in the global scope, the lexical parent is
3073 * the translation unit.
Douglas Gregor0576ce72010-09-22 21:22:29 +00003074 */
3075CINDEX_LINKAGE CXCursor clang_getCursorLexicalParent(CXCursor cursor);
Douglas Gregor99a26af2010-10-01 20:25:15 +00003076
3077/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003078 * Determine the set of methods that are overridden by the given
Douglas Gregor99a26af2010-10-01 20:25:15 +00003079 * method.
3080 *
3081 * In both Objective-C and C++, a method (aka virtual member function,
3082 * in C++) can override a virtual method in a base class. For
3083 * Objective-C, a method is said to override any method in the class's
Argyrios Kyrtzidisbfb24252012-03-08 00:20:03 +00003084 * base class, its protocols, or its categories' protocols, that has the same
3085 * selector and is of the same kind (class or instance).
3086 * If no such method exists, the search continues to the class's superclass,
3087 * its protocols, and its categories, and so on. A method from an Objective-C
3088 * implementation is considered to override the same methods as its
3089 * corresponding method in the interface.
Douglas Gregor99a26af2010-10-01 20:25:15 +00003090 *
3091 * For C++, a virtual member function overrides any virtual member
3092 * function with the same signature that occurs in its base
3093 * classes. With multiple inheritance, a virtual member function can
3094 * override several virtual member functions coming from different
3095 * base classes.
3096 *
3097 * In all cases, this function determines the immediate overridden
3098 * method, rather than all of the overridden methods. For example, if
3099 * a method is originally declared in a class A, then overridden in B
3100 * (which in inherits from A) and also in C (which inherited from B),
3101 * then the only overridden method returned from this function when
3102 * invoked on C's method will be B's method. The client may then
3103 * invoke this function again, given the previously-found overridden
3104 * methods, to map out the complete method-override set.
3105 *
3106 * \param cursor A cursor representing an Objective-C or C++
3107 * method. This routine will compute the set of methods that this
3108 * method overrides.
Fangrui Song6907ce22018-07-30 19:24:48 +00003109 *
Douglas Gregor99a26af2010-10-01 20:25:15 +00003110 * \param overridden A pointer whose pointee will be replaced with a
3111 * pointer to an array of cursors, representing the set of overridden
3112 * methods. If there are no overridden methods, the pointee will be
Fangrui Song6907ce22018-07-30 19:24:48 +00003113 * set to NULL. The pointee must be freed via a call to
Douglas Gregor99a26af2010-10-01 20:25:15 +00003114 * \c clang_disposeOverriddenCursors().
3115 *
3116 * \param num_overridden A pointer to the number of overridden
3117 * functions, will be set to the number of overridden functions in the
3118 * array pointed to by \p overridden.
3119 */
Fangrui Song6907ce22018-07-30 19:24:48 +00003120CINDEX_LINKAGE void clang_getOverriddenCursors(CXCursor cursor,
Douglas Gregor99a26af2010-10-01 20:25:15 +00003121 CXCursor **overridden,
3122 unsigned *num_overridden);
3123
3124/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003125 * Free the set of overridden cursors returned by \c
Douglas Gregor99a26af2010-10-01 20:25:15 +00003126 * clang_getOverriddenCursors().
3127 */
3128CINDEX_LINKAGE void clang_disposeOverriddenCursors(CXCursor *overridden);
3129
Ted Kremenek4ed29252010-04-12 21:22:16 +00003130/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003131 * Retrieve the file that is included by the given inclusion directive
Douglas Gregor796d76a2010-10-20 22:00:55 +00003132 * cursor.
3133 */
3134CINDEX_LINKAGE CXFile clang_getIncludedFile(CXCursor cursor);
Fangrui Song6907ce22018-07-30 19:24:48 +00003135
Douglas Gregor796d76a2010-10-20 22:00:55 +00003136/**
Douglas Gregor6007cf22010-01-22 22:29:16 +00003137 * @}
3138 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003139
Douglas Gregor6007cf22010-01-22 22:29:16 +00003140/**
3141 * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code
3142 *
3143 * Cursors represent a location within the Abstract Syntax Tree (AST). These
3144 * routines help map between cursors and the physical locations where the
3145 * described entities occur in the source code. The mapping is provided in
3146 * both directions, so one can map from source code to the AST and back.
3147 *
3148 * @{
Steve Naroffa1c72842009-08-28 15:28:48 +00003149 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003150
Steve Naroff20bad0b2009-10-21 13:56:23 +00003151/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003152 * Map a source location to the cursor that describes the entity at that
Douglas Gregor816fd362010-01-22 21:44:22 +00003153 * location in the source code.
3154 *
3155 * clang_getCursor() maps an arbitrary source location within a translation
3156 * unit down to the most specific cursor that describes the entity at that
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003157 * location. For example, given an expression \c x + y, invoking
Douglas Gregor816fd362010-01-22 21:44:22 +00003158 * clang_getCursor() with a source location pointing to "x" will return the
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003159 * cursor for "x"; similarly for "y". If the cursor points anywhere between
Douglas Gregor816fd362010-01-22 21:44:22 +00003160 * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor()
3161 * will return a cursor referring to the "+" expression.
3162 *
3163 * \returns a cursor representing the entity at the given source location, or
3164 * a NULL cursor if no such entity can be found.
Steve Naroff20bad0b2009-10-21 13:56:23 +00003165 */
Douglas Gregor816fd362010-01-22 21:44:22 +00003166CINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, CXSourceLocation);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003167
Douglas Gregor66a58812010-01-18 22:46:11 +00003168/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003169 * Retrieve the physical location of the source constructor referenced
Douglas Gregor66a58812010-01-18 22:46:11 +00003170 * by the given cursor.
3171 *
3172 * The location of a declaration is typically the location of the name of that
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003173 * declaration, where the name of that declaration would occur if it is
3174 * unnamed, or some keyword that introduces that particular declaration.
3175 * The location of a reference is where that reference occurs within the
Douglas Gregor66a58812010-01-18 22:46:11 +00003176 * source code.
3177 */
3178CINDEX_LINKAGE CXSourceLocation clang_getCursorLocation(CXCursor);
Douglas Gregor6007cf22010-01-22 22:29:16 +00003179
Douglas Gregor6b8232f2010-01-19 19:34:47 +00003180/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003181 * Retrieve the physical extent of the source construct referenced by
Douglas Gregor33c34ac2010-01-19 00:34:46 +00003182 * the given cursor.
3183 *
3184 * The extent of a cursor starts with the file/line/column pointing at the
3185 * first character within the source construct that the cursor refers to and
Nico Weber7deebef2014-04-24 03:17:47 +00003186 * ends with the last character within that source construct. For a
Douglas Gregor33c34ac2010-01-19 00:34:46 +00003187 * declaration, the extent covers the declaration itself. For a reference,
3188 * the extent covers the location of the reference (e.g., where the referenced
3189 * entity was actually used).
3190 */
3191CINDEX_LINKAGE CXSourceRange clang_getCursorExtent(CXCursor);
Douglas Gregorad27e8b2010-01-19 01:20:04 +00003192
Douglas Gregor6007cf22010-01-22 22:29:16 +00003193/**
3194 * @}
3195 */
Fangrui Song6907ce22018-07-30 19:24:48 +00003196
Douglas Gregor6007cf22010-01-22 22:29:16 +00003197/**
Ted Kremenek6bca9842010-05-14 21:29:26 +00003198 * \defgroup CINDEX_TYPES Type information for CXCursors
3199 *
3200 * @{
3201 */
3202
3203/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003204 * Describes the kind of type
Ted Kremenek6bca9842010-05-14 21:29:26 +00003205 */
3206enum CXTypeKind {
3207 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003208 * Represents an invalid type (e.g., where no type is available).
Ted Kremenek6bca9842010-05-14 21:29:26 +00003209 */
3210 CXType_Invalid = 0,
3211
3212 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003213 * A type whose specific kind is not exposed via this
Ted Kremenek6bca9842010-05-14 21:29:26 +00003214 * interface.
3215 */
3216 CXType_Unexposed = 1,
3217
3218 /* Builtin types */
3219 CXType_Void = 2,
3220 CXType_Bool = 3,
3221 CXType_Char_U = 4,
3222 CXType_UChar = 5,
3223 CXType_Char16 = 6,
3224 CXType_Char32 = 7,
3225 CXType_UShort = 8,
3226 CXType_UInt = 9,
3227 CXType_ULong = 10,
3228 CXType_ULongLong = 11,
3229 CXType_UInt128 = 12,
3230 CXType_Char_S = 13,
3231 CXType_SChar = 14,
3232 CXType_WChar = 15,
3233 CXType_Short = 16,
3234 CXType_Int = 17,
3235 CXType_Long = 18,
3236 CXType_LongLong = 19,
3237 CXType_Int128 = 20,
3238 CXType_Float = 21,
3239 CXType_Double = 22,
3240 CXType_LongDouble = 23,
3241 CXType_NullPtr = 24,
3242 CXType_Overload = 25,
3243 CXType_Dependent = 26,
3244 CXType_ObjCId = 27,
3245 CXType_ObjCClass = 28,
3246 CXType_ObjCSel = 29,
Nemanja Ivanovicbb1ea2d2016-05-09 08:52:33 +00003247 CXType_Float128 = 30,
Joey Gouly6ea21852017-02-10 15:51:11 +00003248 CXType_Half = 31,
Sjoerd Meijercc623ad2017-09-08 15:15:00 +00003249 CXType_Float16 = 32,
Leonard Chanf921d852018-06-04 16:07:52 +00003250 CXType_ShortAccum = 33,
3251 CXType_Accum = 34,
3252 CXType_LongAccum = 35,
3253 CXType_UShortAccum = 36,
3254 CXType_UAccum = 37,
3255 CXType_ULongAccum = 38,
Ties Stuijecd682b2020-06-05 00:20:02 +01003256 CXType_BFloat16 = 39,
Ted Kremenek6bca9842010-05-14 21:29:26 +00003257 CXType_FirstBuiltin = CXType_Void,
Ties Stuijecd682b2020-06-05 00:20:02 +01003258 CXType_LastBuiltin = CXType_BFloat16,
Ted Kremenek6bca9842010-05-14 21:29:26 +00003259
3260 CXType_Complex = 100,
3261 CXType_Pointer = 101,
3262 CXType_BlockPointer = 102,
3263 CXType_LValueReference = 103,
3264 CXType_RValueReference = 104,
3265 CXType_Record = 105,
3266 CXType_Enum = 106,
3267 CXType_Typedef = 107,
3268 CXType_ObjCInterface = 108,
Ted Kremenekc1508872010-06-21 20:15:39 +00003269 CXType_ObjCObjectPointer = 109,
3270 CXType_FunctionNoProto = 110,
Argyrios Kyrtzidis2b0cf602011-09-27 17:44:34 +00003271 CXType_FunctionProto = 111,
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003272 CXType_ConstantArray = 112,
Argyrios Kyrtzidis0661a712013-07-23 17:36:21 +00003273 CXType_Vector = 113,
3274 CXType_IncompleteArray = 114,
3275 CXType_VariableArray = 115,
Argyrios Kyrtzidis7a4253b2013-10-03 16:19:23 +00003276 CXType_DependentSizedArray = 116,
Sergey Kalinichevc0151202015-11-15 13:10:10 +00003277 CXType_MemberPointer = 117,
Sergey Kalinichev69770ae2016-05-03 06:58:29 +00003278 CXType_Auto = 118,
3279
3280 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003281 * Represents a type that was referred to using an elaborated type keyword.
Sergey Kalinichev69770ae2016-05-03 06:58:29 +00003282 *
3283 * E.g., struct S, or via a qualified name, e.g., N::M::type, or both.
3284 */
Sven van Haastregtcc4f1e42017-05-23 10:36:43 +00003285 CXType_Elaborated = 119,
3286
3287 /* OpenCL PipeType. */
3288 CXType_Pipe = 120,
3289
3290 /* OpenCL builtin types. */
3291 CXType_OCLImage1dRO = 121,
3292 CXType_OCLImage1dArrayRO = 122,
3293 CXType_OCLImage1dBufferRO = 123,
3294 CXType_OCLImage2dRO = 124,
3295 CXType_OCLImage2dArrayRO = 125,
3296 CXType_OCLImage2dDepthRO = 126,
3297 CXType_OCLImage2dArrayDepthRO = 127,
3298 CXType_OCLImage2dMSAARO = 128,
3299 CXType_OCLImage2dArrayMSAARO = 129,
3300 CXType_OCLImage2dMSAADepthRO = 130,
3301 CXType_OCLImage2dArrayMSAADepthRO = 131,
3302 CXType_OCLImage3dRO = 132,
3303 CXType_OCLImage1dWO = 133,
3304 CXType_OCLImage1dArrayWO = 134,
3305 CXType_OCLImage1dBufferWO = 135,
3306 CXType_OCLImage2dWO = 136,
3307 CXType_OCLImage2dArrayWO = 137,
3308 CXType_OCLImage2dDepthWO = 138,
3309 CXType_OCLImage2dArrayDepthWO = 139,
3310 CXType_OCLImage2dMSAAWO = 140,
3311 CXType_OCLImage2dArrayMSAAWO = 141,
3312 CXType_OCLImage2dMSAADepthWO = 142,
3313 CXType_OCLImage2dArrayMSAADepthWO = 143,
3314 CXType_OCLImage3dWO = 144,
3315 CXType_OCLImage1dRW = 145,
3316 CXType_OCLImage1dArrayRW = 146,
3317 CXType_OCLImage1dBufferRW = 147,
3318 CXType_OCLImage2dRW = 148,
3319 CXType_OCLImage2dArrayRW = 149,
3320 CXType_OCLImage2dDepthRW = 150,
3321 CXType_OCLImage2dArrayDepthRW = 151,
3322 CXType_OCLImage2dMSAARW = 152,
3323 CXType_OCLImage2dArrayMSAARW = 153,
3324 CXType_OCLImage2dMSAADepthRW = 154,
3325 CXType_OCLImage2dArrayMSAADepthRW = 155,
3326 CXType_OCLImage3dRW = 156,
3327 CXType_OCLSampler = 157,
3328 CXType_OCLEvent = 158,
3329 CXType_OCLQueue = 159,
Michael Wu9c852612018-08-03 03:03:20 +00003330 CXType_OCLReserveID = 160,
3331
Michael Wuced99b92018-08-03 04:02:40 +00003332 CXType_ObjCObject = 161,
Michael Wu153085d2018-08-03 04:21:25 +00003333 CXType_ObjCTypeParam = 162,
Andrew Savonichev3fee3512018-11-08 11:25:41 +00003334 CXType_Attributed = 163,
3335
3336 CXType_OCLIntelSubgroupAVCMcePayload = 164,
3337 CXType_OCLIntelSubgroupAVCImePayload = 165,
3338 CXType_OCLIntelSubgroupAVCRefPayload = 166,
3339 CXType_OCLIntelSubgroupAVCSicPayload = 167,
3340 CXType_OCLIntelSubgroupAVCMceResult = 168,
3341 CXType_OCLIntelSubgroupAVCImeResult = 169,
3342 CXType_OCLIntelSubgroupAVCRefResult = 170,
3343 CXType_OCLIntelSubgroupAVCSicResult = 171,
3344 CXType_OCLIntelSubgroupAVCImeResultSingleRefStreamout = 172,
3345 CXType_OCLIntelSubgroupAVCImeResultDualRefStreamout = 173,
3346 CXType_OCLIntelSubgroupAVCImeSingleRefStreamin = 174,
3347
Sven van Haastregtc9945cc2019-04-17 09:08:50 +00003348 CXType_OCLIntelSubgroupAVCImeDualRefStreamin = 175,
3349
Henry Jen38ca7b12020-04-16 07:58:02 -04003350 CXType_ExtVector = 176,
3351 CXType_Atomic = 177
Ted Kremenek6bca9842010-05-14 21:29:26 +00003352};
3353
3354/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003355 * Describes the calling convention of a function type
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003356 */
3357enum CXCallingConv {
3358 CXCallingConv_Default = 0,
3359 CXCallingConv_C = 1,
3360 CXCallingConv_X86StdCall = 2,
3361 CXCallingConv_X86FastCall = 3,
3362 CXCallingConv_X86ThisCall = 4,
3363 CXCallingConv_X86Pascal = 5,
3364 CXCallingConv_AAPCS = 6,
3365 CXCallingConv_AAPCS_VFP = 7,
Erich Keane757d3172016-11-02 18:29:35 +00003366 CXCallingConv_X86RegCall = 8,
Guy Benyeif0a014b2012-12-25 08:53:55 +00003367 CXCallingConv_IntelOclBicc = 9,
Martin Storsjo022e7822017-07-17 20:49:45 +00003368 CXCallingConv_Win64 = 10,
Nikolai Bozhenovce25d412017-08-08 14:13:50 +00003369 /* Alias for compatibility with older versions of API. */
3370 CXCallingConv_X86_64Win64 = CXCallingConv_Win64,
Charles Davisb5a214e2013-08-30 04:39:01 +00003371 CXCallingConv_X86_64SysV = 11,
Reid Klecknerd7857f02014-10-24 17:42:17 +00003372 CXCallingConv_X86VectorCall = 12,
John McCall477f2bb2016-03-03 06:39:32 +00003373 CXCallingConv_Swift = 13,
Roman Levenstein35aa5ce2016-03-16 18:00:46 +00003374 CXCallingConv_PreserveMost = 14,
3375 CXCallingConv_PreserveAll = 15,
Sander de Smalen44a22532018-11-26 16:38:37 +00003376 CXCallingConv_AArch64VectorCall = 16,
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003377
3378 CXCallingConv_Invalid = 100,
3379 CXCallingConv_Unexposed = 200
3380};
3381
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003382/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003383 * The type of an element in the abstract syntax tree.
Ted Kremenek6bca9842010-05-14 21:29:26 +00003384 *
3385 */
3386typedef struct {
3387 enum CXTypeKind kind;
3388 void *data[2];
3389} CXType;
3390
3391/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003392 * Retrieve the type of a CXCursor (if any).
Ted Kremenek6bca9842010-05-14 21:29:26 +00003393 */
3394CINDEX_LINKAGE CXType clang_getCursorType(CXCursor C);
3395
3396/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003397 * Pretty-print the underlying type using the rules of the
Dmitri Gribenko00353722013-02-15 21:15:49 +00003398 * language of the translation unit from which it came.
3399 *
3400 * If the type is invalid, an empty string is returned.
3401 */
3402CINDEX_LINKAGE CXString clang_getTypeSpelling(CXType CT);
3403
3404/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003405 * Retrieve the underlying type of a typedef declaration.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003406 *
3407 * If the cursor does not reference a typedef declaration, an invalid type is
3408 * returned.
3409 */
3410CINDEX_LINKAGE CXType clang_getTypedefDeclUnderlyingType(CXCursor C);
3411
3412/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003413 * Retrieve the integer type of an enum declaration.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003414 *
3415 * If the cursor does not reference an enum declaration, an invalid type is
3416 * returned.
3417 */
3418CINDEX_LINKAGE CXType clang_getEnumDeclIntegerType(CXCursor C);
3419
3420/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003421 * Retrieve the integer value of an enum constant declaration as a signed
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003422 * long long.
3423 *
Michael Kruse7520cf02020-03-25 09:26:14 -05003424 * If the cursor does not reference an enum constant declaration, LLONG_MIN is
3425 * returned. Since this is also potentially a valid constant value, the kind of
3426 * the cursor must be verified before calling this function.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003427 */
3428CINDEX_LINKAGE long long clang_getEnumConstantDeclValue(CXCursor C);
3429
3430/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003431 * Retrieve the integer value of an enum constant declaration as an unsigned
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003432 * long long.
3433 *
Michael Kruse7520cf02020-03-25 09:26:14 -05003434 * If the cursor does not reference an enum constant declaration, ULLONG_MAX is
3435 * returned. Since this is also potentially a valid constant value, the kind of
3436 * the cursor must be verified before calling this function.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003437 */
Michael Kruse7520cf02020-03-25 09:26:14 -05003438CINDEX_LINKAGE unsigned long long
3439clang_getEnumConstantDeclUnsignedValue(CXCursor C);
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003440
3441/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003442 * Retrieve the bit width of a bit field declaration as an integer.
Dmitri Gribenkob506ba12012-12-04 15:13:46 +00003443 *
3444 * If a cursor that is not a bit field declaration is passed in, -1 is returned.
3445 */
3446CINDEX_LINKAGE int clang_getFieldDeclBitWidth(CXCursor C);
3447
3448/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003449 * Retrieve the number of non-variadic arguments associated with a given
Argyrios Kyrtzidis0c27e4b2012-04-11 19:32:19 +00003450 * cursor.
3451 *
Argyrios Kyrtzidisb2792972013-04-01 17:38:59 +00003452 * The number of arguments can be determined for calls as well as for
3453 * declarations of functions or methods. For other cursors -1 is returned.
Argyrios Kyrtzidis0c27e4b2012-04-11 19:32:19 +00003454 */
3455CINDEX_LINKAGE int clang_Cursor_getNumArguments(CXCursor C);
3456
3457/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003458 * Retrieve the argument cursor of a function or method.
Argyrios Kyrtzidis0c27e4b2012-04-11 19:32:19 +00003459 *
Argyrios Kyrtzidisb2792972013-04-01 17:38:59 +00003460 * The argument cursor can be determined for calls as well as for declarations
3461 * of functions or methods. For other cursors and for invalid indices, an
3462 * invalid cursor is returned.
Argyrios Kyrtzidis0c27e4b2012-04-11 19:32:19 +00003463 */
3464CINDEX_LINKAGE CXCursor clang_Cursor_getArgument(CXCursor C, unsigned i);
3465
3466/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003467 * Describes the kind of a template argument.
Eli Benderskyc27a0c42014-10-10 20:01:05 +00003468 *
3469 * See the definition of llvm::clang::TemplateArgument::ArgKind for full
3470 * element descriptions.
3471 */
3472enum CXTemplateArgumentKind {
3473 CXTemplateArgumentKind_Null,
3474 CXTemplateArgumentKind_Type,
3475 CXTemplateArgumentKind_Declaration,
3476 CXTemplateArgumentKind_NullPtr,
3477 CXTemplateArgumentKind_Integral,
3478 CXTemplateArgumentKind_Template,
3479 CXTemplateArgumentKind_TemplateExpansion,
3480 CXTemplateArgumentKind_Expression,
3481 CXTemplateArgumentKind_Pack,
3482 /* Indicates an error case, preventing the kind from being deduced. */
3483 CXTemplateArgumentKind_Invalid
3484};
3485
3486/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003487 *Returns the number of template args of a function decl representing a
Eli Benderskyc27a0c42014-10-10 20:01:05 +00003488 * template specialization.
3489 *
3490 * If the argument cursor cannot be converted into a template function
3491 * declaration, -1 is returned.
3492 *
3493 * For example, for the following declaration and specialization:
3494 * template <typename T, int kInt, bool kBool>
3495 * void foo() { ... }
3496 *
3497 * template <>
3498 * void foo<float, -7, true>();
3499 *
3500 * The value 3 would be returned from this call.
3501 */
3502CINDEX_LINKAGE int clang_Cursor_getNumTemplateArguments(CXCursor C);
3503
3504/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003505 * Retrieve the kind of the I'th template argument of the CXCursor C.
Eli Benderskyc27a0c42014-10-10 20:01:05 +00003506 *
3507 * If the argument CXCursor does not represent a FunctionDecl, an invalid
3508 * template argument kind is returned.
3509 *
3510 * For example, for the following declaration and specialization:
3511 * template <typename T, int kInt, bool kBool>
3512 * void foo() { ... }
3513 *
3514 * template <>
3515 * void foo<float, -7, true>();
3516 *
3517 * For I = 0, 1, and 2, Type, Integral, and Integral will be returned,
3518 * respectively.
3519 */
Michael Kruse7520cf02020-03-25 09:26:14 -05003520CINDEX_LINKAGE enum CXTemplateArgumentKind
3521clang_Cursor_getTemplateArgumentKind(CXCursor C, unsigned I);
Eli Benderskyc27a0c42014-10-10 20:01:05 +00003522
3523/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003524 * Retrieve a CXType representing the type of a TemplateArgument of a
Eli Benderskyc27a0c42014-10-10 20:01:05 +00003525 * function decl representing a template specialization.
3526 *
3527 * If the argument CXCursor does not represent a FunctionDecl whose I'th
3528 * template argument has a kind of CXTemplateArgKind_Integral, an invalid type
3529 * is returned.
3530 *
3531 * For example, for the following declaration and specialization:
3532 * template <typename T, int kInt, bool kBool>
3533 * void foo() { ... }
3534 *
3535 * template <>
3536 * void foo<float, -7, true>();
3537 *
3538 * If called with I = 0, "float", will be returned.
3539 * Invalid types will be returned for I == 1 or 2.
3540 */
3541CINDEX_LINKAGE CXType clang_Cursor_getTemplateArgumentType(CXCursor C,
3542 unsigned I);
3543
3544/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003545 * Retrieve the value of an Integral TemplateArgument (of a function
Eli Benderskyc27a0c42014-10-10 20:01:05 +00003546 * decl representing a template specialization) as a signed long long.
3547 *
3548 * It is undefined to call this function on a CXCursor that does not represent a
3549 * FunctionDecl or whose I'th template argument is not an integral value.
3550 *
3551 * For example, for the following declaration and specialization:
3552 * template <typename T, int kInt, bool kBool>
3553 * void foo() { ... }
3554 *
3555 * template <>
3556 * void foo<float, -7, true>();
3557 *
3558 * If called with I = 1 or 2, -7 or true will be returned, respectively.
3559 * For I == 0, this function's behavior is undefined.
3560 */
3561CINDEX_LINKAGE long long clang_Cursor_getTemplateArgumentValue(CXCursor C,
3562 unsigned I);
3563
3564/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003565 * Retrieve the value of an Integral TemplateArgument (of a function
Eli Benderskyc27a0c42014-10-10 20:01:05 +00003566 * decl representing a template specialization) as an unsigned long long.
3567 *
3568 * It is undefined to call this function on a CXCursor that does not represent a
3569 * FunctionDecl or whose I'th template argument is not an integral value.
3570 *
3571 * For example, for the following declaration and specialization:
3572 * template <typename T, int kInt, bool kBool>
3573 * void foo() { ... }
3574 *
3575 * template <>
3576 * void foo<float, 2147483649, true>();
3577 *
3578 * If called with I = 1 or 2, 2147483649 or true will be returned, respectively.
3579 * For I == 0, this function's behavior is undefined.
3580 */
Michael Kruse7520cf02020-03-25 09:26:14 -05003581CINDEX_LINKAGE unsigned long long
3582clang_Cursor_getTemplateArgumentUnsignedValue(CXCursor C, unsigned I);
Eli Benderskyc27a0c42014-10-10 20:01:05 +00003583
3584/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003585 * Determine whether two CXTypes represent the same type.
Ted Kremenek6bca9842010-05-14 21:29:26 +00003586 *
James Dennett574cb4c2012-06-15 05:41:51 +00003587 * \returns non-zero if the CXTypes represent the same type and
3588 * zero otherwise.
Ted Kremenek6bca9842010-05-14 21:29:26 +00003589 */
3590CINDEX_LINKAGE unsigned clang_equalTypes(CXType A, CXType B);
3591
3592/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003593 * Return the canonical type for a CXType.
Ted Kremenek6bca9842010-05-14 21:29:26 +00003594 *
3595 * Clang's type system explicitly models typedefs and all the ways
3596 * a specific type can be represented. The canonical type is the underlying
3597 * type with all the "sugar" removed. For example, if 'T' is a typedef
3598 * for 'int', the canonical type for 'T' would be 'int'.
3599 */
3600CINDEX_LINKAGE CXType clang_getCanonicalType(CXType T);
3601
3602/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003603 * Determine whether a CXType has the "const" qualifier set,
James Dennett574cb4c2012-06-15 05:41:51 +00003604 * without looking through typedefs that may have added "const" at a
3605 * different level.
Douglas Gregor56a63802011-01-27 16:27:11 +00003606 */
3607CINDEX_LINKAGE unsigned clang_isConstQualifiedType(CXType T);
3608
3609/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003610 * Determine whether a CXCursor that is a macro, is
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00003611 * function like.
3612 */
3613CINDEX_LINKAGE unsigned clang_Cursor_isMacroFunctionLike(CXCursor C);
3614
3615/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003616 * Determine whether a CXCursor that is a macro, is a
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00003617 * builtin one.
3618 */
3619CINDEX_LINKAGE unsigned clang_Cursor_isMacroBuiltin(CXCursor C);
3620
3621/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003622 * Determine whether a CXCursor that is a function declaration, is an
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00003623 * inline declaration.
3624 */
3625CINDEX_LINKAGE unsigned clang_Cursor_isFunctionInlined(CXCursor C);
3626
3627/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003628 * Determine whether a CXType has the "volatile" qualifier set,
James Dennett574cb4c2012-06-15 05:41:51 +00003629 * without looking through typedefs that may have added "volatile" at
3630 * a different level.
Douglas Gregor56a63802011-01-27 16:27:11 +00003631 */
3632CINDEX_LINKAGE unsigned clang_isVolatileQualifiedType(CXType T);
3633
3634/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003635 * Determine whether a CXType has the "restrict" qualifier set,
James Dennett574cb4c2012-06-15 05:41:51 +00003636 * without looking through typedefs that may have added "restrict" at a
3637 * different level.
Douglas Gregor56a63802011-01-27 16:27:11 +00003638 */
3639CINDEX_LINKAGE unsigned clang_isRestrictQualifiedType(CXType T);
3640
3641/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003642 * Returns the address space of the given type.
Sven van Haastregte8910422017-06-08 14:22:04 +00003643 */
3644CINDEX_LINKAGE unsigned clang_getAddressSpace(CXType T);
3645
3646/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003647 * Returns the typedef name of the given type.
Sven van Haastregte8910422017-06-08 14:22:04 +00003648 */
3649CINDEX_LINKAGE CXString clang_getTypedefName(CXType CT);
3650
3651/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003652 * For pointer types, returns the type of the pointee.
Ted Kremenek6bca9842010-05-14 21:29:26 +00003653 */
3654CINDEX_LINKAGE CXType clang_getPointeeType(CXType T);
3655
3656/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003657 * Return the cursor for the declaration of the given type.
Ted Kremenek6bca9842010-05-14 21:29:26 +00003658 */
3659CINDEX_LINKAGE CXCursor clang_getTypeDeclaration(CXType T);
3660
David Chisnall50e4eba2010-12-30 14:05:53 +00003661/**
3662 * Returns the Objective-C type encoding for the specified declaration.
3663 */
3664CINDEX_LINKAGE CXString clang_getDeclObjCTypeEncoding(CXCursor C);
Ted Kremenek6bca9842010-05-14 21:29:26 +00003665
3666/**
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00003667 * Returns the Objective-C type encoding for the specified CXType.
3668 */
Fangrui Song6907ce22018-07-30 19:24:48 +00003669CINDEX_LINKAGE CXString clang_Type_getObjCEncoding(CXType type);
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00003670
3671/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003672 * Retrieve the spelling of a given CXTypeKind.
Ted Kremenek6bca9842010-05-14 21:29:26 +00003673 */
3674CINDEX_LINKAGE CXString clang_getTypeKindSpelling(enum CXTypeKind K);
3675
3676/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003677 * Retrieve the calling convention associated with a function type.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003678 *
3679 * If a non-function type is passed in, CXCallingConv_Invalid is returned.
3680 */
3681CINDEX_LINKAGE enum CXCallingConv clang_getFunctionTypeCallingConv(CXType T);
3682
3683/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003684 * Retrieve the return type associated with a function type.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003685 *
3686 * If a non-function type is passed in, an invalid type is returned.
Ted Kremenekc1508872010-06-21 20:15:39 +00003687 */
3688CINDEX_LINKAGE CXType clang_getResultType(CXType T);
3689
3690/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003691 * Retrieve the exception specification type associated with a function type.
Richard Smitheedb0c92018-05-11 19:46:31 +00003692 * This is a value of type CXCursor_ExceptionSpecificationKind.
Jonathan Coe0a5b03b2017-06-27 22:54:56 +00003693 *
3694 * If a non-function type is passed in, an error code of -1 is returned.
3695 */
3696CINDEX_LINKAGE int clang_getExceptionSpecificationType(CXType T);
3697
3698/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003699 * Retrieve the number of non-variadic parameters associated with a
James Dennett574cb4c2012-06-15 05:41:51 +00003700 * function type.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003701 *
Argyrios Kyrtzidis0c27e4b2012-04-11 19:32:19 +00003702 * If a non-function type is passed in, -1 is returned.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003703 */
Argyrios Kyrtzidis0c27e4b2012-04-11 19:32:19 +00003704CINDEX_LINKAGE int clang_getNumArgTypes(CXType T);
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003705
3706/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003707 * Retrieve the type of a parameter of a function type.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003708 *
James Dennett574cb4c2012-06-15 05:41:51 +00003709 * If a non-function type is passed in or the function does not have enough
3710 * parameters, an invalid type is returned.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003711 */
3712CINDEX_LINKAGE CXType clang_getArgType(CXType T, unsigned i);
3713
3714/**
Michael Wu9c852612018-08-03 03:03:20 +00003715 * Retrieves the base type of the ObjCObjectType.
3716 *
3717 * If the type is not an ObjC object, an invalid type is returned.
3718 */
3719CINDEX_LINKAGE CXType clang_Type_getObjCObjectBaseType(CXType T);
3720
3721/**
3722 * Retrieve the number of protocol references associated with an ObjC object/id.
3723 *
3724 * If the type is not an ObjC object, 0 is returned.
3725 */
3726CINDEX_LINKAGE unsigned clang_Type_getNumObjCProtocolRefs(CXType T);
3727
3728/**
3729 * Retrieve the decl for a protocol reference for an ObjC object/id.
3730 *
3731 * If the type is not an ObjC object or there are not enough protocol
3732 * references, an invalid cursor is returned.
3733 */
3734CINDEX_LINKAGE CXCursor clang_Type_getObjCProtocolDecl(CXType T, unsigned i);
3735
3736/**
Nico Weber87e80e52020-02-14 15:18:50 -05003737 * Retrieve the number of type arguments associated with an ObjC object.
Michael Wu9c852612018-08-03 03:03:20 +00003738 *
3739 * If the type is not an ObjC object, 0 is returned.
3740 */
3741CINDEX_LINKAGE unsigned clang_Type_getNumObjCTypeArgs(CXType T);
3742
3743/**
3744 * Retrieve a type argument associated with an ObjC object.
3745 *
3746 * If the type is not an ObjC or the index is not valid,
3747 * an invalid type is returned.
3748 */
3749CINDEX_LINKAGE CXType clang_Type_getObjCTypeArg(CXType T, unsigned i);
3750
3751/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003752 * Return 1 if the CXType is a variadic function type, and 0 otherwise.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003753 */
3754CINDEX_LINKAGE unsigned clang_isFunctionTypeVariadic(CXType T);
3755
3756/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003757 * Retrieve the return type associated with a given cursor.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003758 *
3759 * This only returns a valid type if the cursor refers to a function or method.
Ted Kremenekc62ab8d2010-06-21 20:48:56 +00003760 */
3761CINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C);
3762
3763/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003764 * Retrieve the exception specification type associated with a given cursor.
Richard Smitheedb0c92018-05-11 19:46:31 +00003765 * This is a value of type CXCursor_ExceptionSpecificationKind.
Jonathan Coe0a5b03b2017-06-27 22:54:56 +00003766 *
Michael Kruse7520cf02020-03-25 09:26:14 -05003767 * This only returns a valid result if the cursor refers to a function or
3768 * method.
Jonathan Coe0a5b03b2017-06-27 22:54:56 +00003769 */
3770CINDEX_LINKAGE int clang_getCursorExceptionSpecificationType(CXCursor C);
3771
3772/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003773 * Return 1 if the CXType is a POD (plain old data) type, and 0
Ted Kremenek0c7476a2010-07-30 00:14:11 +00003774 * otherwise.
3775 */
3776CINDEX_LINKAGE unsigned clang_isPODType(CXType T);
3777
3778/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003779 * Return the element type of an array, complex, or vector type.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003780 *
3781 * If a type is passed in that is not an array, complex, or vector type,
3782 * an invalid type is returned.
3783 */
3784CINDEX_LINKAGE CXType clang_getElementType(CXType T);
3785
3786/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003787 * Return the number of elements of an array or vector type.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003788 *
3789 * If a type is passed in that is not an array or vector type,
3790 * -1 is returned.
3791 */
3792CINDEX_LINKAGE long long clang_getNumElements(CXType T);
3793
3794/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003795 * Return the element type of an array type.
Argyrios Kyrtzidis2b0cf602011-09-27 17:44:34 +00003796 *
3797 * If a non-array type is passed in, an invalid type is returned.
3798 */
3799CINDEX_LINKAGE CXType clang_getArrayElementType(CXType T);
3800
3801/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003802 * Return the array size of a constant array.
Argyrios Kyrtzidis2b0cf602011-09-27 17:44:34 +00003803 *
3804 * If a non-array type is passed in, -1 is returned.
3805 */
3806CINDEX_LINKAGE long long clang_getArraySize(CXType T);
3807
3808/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003809 * Retrieve the type named by the qualified-id.
Sergey Kalinichev69770ae2016-05-03 06:58:29 +00003810 *
3811 * If a non-elaborated type is passed in, an invalid type is returned.
3812 */
3813CINDEX_LINKAGE CXType clang_Type_getNamedType(CXType T);
3814
3815/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003816 * Determine if a typedef is 'transparent' tag.
Argyrios Kyrtzidis3b25c912017-03-21 16:56:02 +00003817 *
3818 * A typedef is considered 'transparent' if it shares a name and spelling
3819 * location with its underlying tag type, as is the case with the NS_ENUM macro.
3820 *
3821 * \returns non-zero if transparent and zero otherwise.
3822 */
3823CINDEX_LINKAGE unsigned clang_Type_isTransparentTagTypedef(CXType T);
3824
Michael Wu7649e622018-08-03 04:38:04 +00003825enum CXTypeNullabilityKind {
3826 /**
3827 * Values of this type can never be null.
3828 */
3829 CXTypeNullability_NonNull = 0,
3830 /**
3831 * Values of this type can be null.
3832 */
3833 CXTypeNullability_Nullable = 1,
3834 /**
3835 * Whether values of this type can be null is (explicitly)
3836 * unspecified. This captures a (fairly rare) case where we
3837 * can't conclude anything about the nullability of the type even
3838 * though it has been considered.
3839 */
3840 CXTypeNullability_Unspecified = 2,
3841 /**
3842 * Nullability is not applicable to this type.
3843 */
3844 CXTypeNullability_Invalid = 3
3845};
3846
3847/**
3848 * Retrieve the nullability kind of a pointer type.
3849 */
3850CINDEX_LINKAGE enum CXTypeNullabilityKind clang_Type_getNullability(CXType T);
3851
Argyrios Kyrtzidis3b25c912017-03-21 16:56:02 +00003852/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003853 * List the possible error codes for \c clang_Type_getSizeOf,
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003854 * \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf and
3855 * \c clang_Cursor_getOffsetOf.
3856 *
3857 * A value of this enumeration type can be returned if the target type is not
3858 * a valid argument to sizeof, alignof or offsetof.
3859 */
3860enum CXTypeLayoutError {
3861 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003862 * Type is of kind CXType_Invalid.
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003863 */
3864 CXTypeLayoutError_Invalid = -1,
3865 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003866 * The type is an incomplete Type.
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003867 */
3868 CXTypeLayoutError_Incomplete = -2,
3869 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003870 * The type is a dependent Type.
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003871 */
3872 CXTypeLayoutError_Dependent = -3,
3873 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003874 * The type is not a constant size type.
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003875 */
3876 CXTypeLayoutError_NotConstantSize = -4,
3877 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003878 * The Field name is not valid for this record.
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003879 */
Emilio Cobos Alvarez0d76dc22019-02-26 15:04:18 +00003880 CXTypeLayoutError_InvalidFieldName = -5,
3881 /**
3882 * The type is undeduced.
3883 */
3884 CXTypeLayoutError_Undeduced = -6
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003885};
3886
3887/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003888 * Return the alignment of a type in bytes as per C++[expr.alignof]
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003889 * standard.
3890 *
3891 * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
3892 * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
3893 * is returned.
3894 * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
3895 * returned.
3896 * If the type declaration is not a constant size type,
3897 * CXTypeLayoutError_NotConstantSize is returned.
3898 */
3899CINDEX_LINKAGE long long clang_Type_getAlignOf(CXType T);
3900
3901/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003902 * Return the class type of an member pointer type.
Argyrios Kyrtzidis7a4253b2013-10-03 16:19:23 +00003903 *
3904 * If a non-member-pointer type is passed in, an invalid type is returned.
3905 */
3906CINDEX_LINKAGE CXType clang_Type_getClassType(CXType T);
3907
3908/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003909 * Return the size of a type in bytes as per C++[expr.sizeof] standard.
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003910 *
3911 * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
3912 * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
3913 * is returned.
3914 * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
3915 * returned.
3916 */
3917CINDEX_LINKAGE long long clang_Type_getSizeOf(CXType T);
3918
3919/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003920 * Return the offset of a field named S in a record of type T in bits
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003921 * as it would be returned by __offsetof__ as per C++11[18.2p4]
3922 *
3923 * If the cursor is not a record field declaration, CXTypeLayoutError_Invalid
3924 * is returned.
3925 * If the field's type declaration is an incomplete type,
3926 * CXTypeLayoutError_Incomplete is returned.
3927 * If the field's type declaration is a dependent type,
3928 * CXTypeLayoutError_Dependent is returned.
3929 * If the field's name S is not found,
3930 * CXTypeLayoutError_InvalidFieldName is returned.
3931 */
3932CINDEX_LINKAGE long long clang_Type_getOffsetOf(CXType T, const char *S);
3933
Argyrios Kyrtzidis2bff5162015-04-13 16:55:04 +00003934/**
Michael Wu153085d2018-08-03 04:21:25 +00003935 * Return the type that was modified by this attributed type.
3936 *
3937 * If the type is not an attributed type, an invalid type is returned.
3938 */
3939CINDEX_LINKAGE CXType clang_Type_getModifiedType(CXType T);
3940
3941/**
Henry Jen38ca7b12020-04-16 07:58:02 -04003942 * Gets the type contained by this atomic type.
3943 *
3944 * If a non-atomic type is passed in, an invalid type is returned.
3945 */
3946CINDEX_LINKAGE CXType clang_Type_getValueType(CXType CT);
3947
3948/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003949 * Return the offset of the field represented by the Cursor.
Argyrios Kyrtzidis2bff5162015-04-13 16:55:04 +00003950 *
3951 * If the cursor is not a field declaration, -1 is returned.
3952 * If the cursor semantic parent is not a record field declaration,
3953 * CXTypeLayoutError_Invalid is returned.
3954 * If the field's type declaration is an incomplete type,
3955 * CXTypeLayoutError_Incomplete is returned.
3956 * If the field's type declaration is a dependent type,
3957 * CXTypeLayoutError_Dependent is returned.
3958 * If the field's name S is not found,
3959 * CXTypeLayoutError_InvalidFieldName is returned.
3960 */
3961CINDEX_LINKAGE long long clang_Cursor_getOffsetOfField(CXCursor C);
3962
3963/**
Ivan Donchevskii50be5732019-04-29 13:44:07 +00003964 * Determine whether the given cursor represents an anonymous
3965 * tag or namespace
3966 */
3967CINDEX_LINKAGE unsigned clang_Cursor_isAnonymous(CXCursor C);
3968
3969/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003970 * Determine whether the given cursor represents an anonymous record
Argyrios Kyrtzidis2bff5162015-04-13 16:55:04 +00003971 * declaration.
3972 */
Ivan Donchevskii50be5732019-04-29 13:44:07 +00003973CINDEX_LINKAGE unsigned clang_Cursor_isAnonymousRecordDecl(CXCursor C);
Argyrios Kyrtzidis2bff5162015-04-13 16:55:04 +00003974
Nikolai Kosjarcfe1ab92019-05-10 13:58:34 +00003975/**
3976 * Determine whether the given cursor represents an inline namespace
3977 * declaration.
3978 */
3979CINDEX_LINKAGE unsigned clang_Cursor_isInlineNamespace(CXCursor C);
3980
Argyrios Kyrtzidisadff3ae2013-10-11 19:58:38 +00003981enum CXRefQualifierKind {
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003982 /** No ref-qualifier was provided. */
Argyrios Kyrtzidisadff3ae2013-10-11 19:58:38 +00003983 CXRefQualifier_None = 0,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003984 /** An lvalue ref-qualifier was provided (\c &). */
Argyrios Kyrtzidisadff3ae2013-10-11 19:58:38 +00003985 CXRefQualifier_LValue,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003986 /** An rvalue ref-qualifier was provided (\c &&). */
Argyrios Kyrtzidisadff3ae2013-10-11 19:58:38 +00003987 CXRefQualifier_RValue
3988};
3989
3990/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003991 * Returns the number of template arguments for given template
Argyrios Kyrtzidis35f5aab2016-11-15 20:51:46 +00003992 * specialization, or -1 if type \c T is not a template specialization.
Dmitri Gribenko6ede6ab2014-02-27 16:05:05 +00003993 */
3994CINDEX_LINKAGE int clang_Type_getNumTemplateArguments(CXType T);
3995
3996/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003997 * Returns the type template argument of a template class specialization
Dmitri Gribenko6ede6ab2014-02-27 16:05:05 +00003998 * at given index.
3999 *
4000 * This function only returns template type arguments and does not handle
4001 * template template arguments or variadic packs.
4002 */
Michael Kruse7520cf02020-03-25 09:26:14 -05004003CINDEX_LINKAGE CXType clang_Type_getTemplateArgumentAsType(CXType T,
4004 unsigned i);
Dmitri Gribenko6ede6ab2014-02-27 16:05:05 +00004005
4006/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004007 * Retrieve the ref-qualifier kind of a function or method.
Argyrios Kyrtzidisadff3ae2013-10-11 19:58:38 +00004008 *
4009 * The ref-qualifier is returned for C++ functions or methods. For other types
4010 * or non-C++ declarations, CXRefQualifier_None is returned.
4011 */
4012CINDEX_LINKAGE enum CXRefQualifierKind clang_Type_getCXXRefQualifier(CXType T);
4013
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00004014/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004015 * Returns non-zero if the cursor specifies a Record member that is a
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00004016 * bitfield.
4017 */
4018CINDEX_LINKAGE unsigned clang_Cursor_isBitField(CXCursor C);
4019
4020/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004021 * Returns 1 if the base class specified by the cursor with kind
Ted Kremenekae9e2212010-08-27 21:34:58 +00004022 * CX_CXXBaseSpecifier is virtual.
4023 */
4024CINDEX_LINKAGE unsigned clang_isVirtualBase(CXCursor);
Fangrui Song6907ce22018-07-30 19:24:48 +00004025
Ted Kremenekae9e2212010-08-27 21:34:58 +00004026/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004027 * Represents the C++ access control level to a base class for a
Ted Kremenekae9e2212010-08-27 21:34:58 +00004028 * cursor with kind CX_CXXBaseSpecifier.
4029 */
4030enum CX_CXXAccessSpecifier {
4031 CX_CXXInvalidAccessSpecifier,
4032 CX_CXXPublic,
4033 CX_CXXProtected,
4034 CX_CXXPrivate
4035};
4036
4037/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004038 * Returns the access control level for the referenced object.
Argyrios Kyrtzidisf6464082013-04-11 17:31:13 +00004039 *
Michael Kruse7520cf02020-03-25 09:26:14 -05004040 * If the cursor refers to a C++ declaration, its access control level within
4041 * its parent scope is returned. Otherwise, if the cursor refers to a base
4042 * specifier or access specifier, the specifier itself is returned.
Ted Kremenekae9e2212010-08-27 21:34:58 +00004043 */
4044CINDEX_LINKAGE enum CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor);
4045
4046/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004047 * Represents the storage classes as declared in the source. CX_SC_Invalid
Chad Rosierdb1cc7f2014-12-05 15:50:44 +00004048 * was added for the case that the passed cursor in not a declaration.
Argyrios Kyrtzidis4e0854f2014-10-15 17:05:31 +00004049 */
4050enum CX_StorageClass {
4051 CX_SC_Invalid,
4052 CX_SC_None,
4053 CX_SC_Extern,
4054 CX_SC_Static,
4055 CX_SC_PrivateExtern,
4056 CX_SC_OpenCLWorkGroupLocal,
4057 CX_SC_Auto,
4058 CX_SC_Register
4059};
4060
4061/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004062 * Returns the storage class for a function or variable declaration.
Argyrios Kyrtzidis4e0854f2014-10-15 17:05:31 +00004063 *
4064 * If the passed in Cursor is not a function or variable declaration,
4065 * CX_SC_Invalid is returned else the storage class.
4066 */
4067CINDEX_LINKAGE enum CX_StorageClass clang_Cursor_getStorageClass(CXCursor);
4068
4069/**
Fangrui Song6907ce22018-07-30 19:24:48 +00004070 * Determine the number of overloaded declarations referenced by a
Douglas Gregor16a2bdd2010-09-13 22:52:57 +00004071 * \c CXCursor_OverloadedDeclRef cursor.
4072 *
4073 * \param cursor The cursor whose overloaded declarations are being queried.
4074 *
4075 * \returns The number of overloaded declarations referenced by \c cursor. If it
4076 * is not a \c CXCursor_OverloadedDeclRef cursor, returns 0.
4077 */
4078CINDEX_LINKAGE unsigned clang_getNumOverloadedDecls(CXCursor cursor);
4079
4080/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004081 * Retrieve a cursor for one of the overloaded declarations referenced
Douglas Gregor16a2bdd2010-09-13 22:52:57 +00004082 * by a \c CXCursor_OverloadedDeclRef cursor.
4083 *
4084 * \param cursor The cursor whose overloaded declarations are being queried.
4085 *
4086 * \param index The zero-based index into the set of overloaded declarations in
4087 * the cursor.
4088 *
Fangrui Song6907ce22018-07-30 19:24:48 +00004089 * \returns A cursor representing the declaration referenced by the given
4090 * \c cursor at the specified \c index. If the cursor does not have an
Douglas Gregor16a2bdd2010-09-13 22:52:57 +00004091 * associated set of overloaded declarations, or if the index is out of bounds,
4092 * returns \c clang_getNullCursor();
4093 */
Fangrui Song6907ce22018-07-30 19:24:48 +00004094CINDEX_LINKAGE CXCursor clang_getOverloadedDecl(CXCursor cursor,
Douglas Gregor16a2bdd2010-09-13 22:52:57 +00004095 unsigned index);
Fangrui Song6907ce22018-07-30 19:24:48 +00004096
Douglas Gregor16a2bdd2010-09-13 22:52:57 +00004097/**
Ted Kremenek6bca9842010-05-14 21:29:26 +00004098 * @}
4099 */
Fangrui Song6907ce22018-07-30 19:24:48 +00004100
Ted Kremeneka5940822010-08-26 01:42:22 +00004101/**
Ted Kremenek2c2c5f32010-08-27 21:34:51 +00004102 * \defgroup CINDEX_ATTRIBUTES Information for attributes
Ted Kremeneka5940822010-08-26 01:42:22 +00004103 *
4104 * @{
4105 */
4106
Ted Kremeneka5940822010-08-26 01:42:22 +00004107/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004108 * For cursors representing an iboutletcollection attribute,
Ted Kremeneka5940822010-08-26 01:42:22 +00004109 * this function returns the collection element type.
4110 *
4111 */
4112CINDEX_LINKAGE CXType clang_getIBOutletCollectionType(CXCursor);
4113
4114/**
4115 * @}
4116 */
Ted Kremenek6bca9842010-05-14 21:29:26 +00004117
4118/**
Douglas Gregor6007cf22010-01-22 22:29:16 +00004119 * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors
4120 *
4121 * These routines provide the ability to traverse the abstract syntax tree
4122 * using cursors.
4123 *
4124 * @{
4125 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004126
Douglas Gregor6007cf22010-01-22 22:29:16 +00004127/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004128 * Describes how the traversal of the children of a particular
Douglas Gregor6007cf22010-01-22 22:29:16 +00004129 * cursor should proceed after visiting a particular child cursor.
4130 *
4131 * A value of this enumeration type should be returned by each
4132 * \c CXCursorVisitor to indicate how clang_visitChildren() proceed.
4133 */
4134enum CXChildVisitResult {
4135 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004136 * Terminates the cursor traversal.
Douglas Gregor6007cf22010-01-22 22:29:16 +00004137 */
4138 CXChildVisit_Break,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004139 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004140 * Continues the cursor traversal with the next sibling of
Douglas Gregor6007cf22010-01-22 22:29:16 +00004141 * the cursor just visited, without visiting its children.
4142 */
4143 CXChildVisit_Continue,
4144 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004145 * Recursively traverse the children of this cursor, using
Douglas Gregor6007cf22010-01-22 22:29:16 +00004146 * the same visitor and client data.
4147 */
4148 CXChildVisit_Recurse
4149};
4150
4151/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004152 * Visitor invoked for each cursor found by a traversal.
Douglas Gregor6007cf22010-01-22 22:29:16 +00004153 *
4154 * This visitor function will be invoked for each cursor found by
4155 * clang_visitCursorChildren(). Its first argument is the cursor being
4156 * visited, its second argument is the parent visitor for that cursor,
4157 * and its third argument is the client data provided to
4158 * clang_visitCursorChildren().
4159 *
4160 * The visitor should return one of the \c CXChildVisitResult values
4161 * to direct clang_visitCursorChildren().
4162 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004163typedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor,
4164 CXCursor parent,
Douglas Gregor6007cf22010-01-22 22:29:16 +00004165 CXClientData client_data);
4166
4167/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004168 * Visit the children of a particular cursor.
Douglas Gregor6007cf22010-01-22 22:29:16 +00004169 *
4170 * This function visits all the direct children of the given cursor,
4171 * invoking the given \p visitor function with the cursors of each
4172 * visited child. The traversal may be recursive, if the visitor returns
4173 * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if
4174 * the visitor returns \c CXChildVisit_Break.
4175 *
Douglas Gregor6007cf22010-01-22 22:29:16 +00004176 * \param parent the cursor whose child may be visited. All kinds of
Daniel Dunbarb9999fd2010-01-24 04:10:31 +00004177 * cursors can be visited, including invalid cursors (which, by
Douglas Gregor6007cf22010-01-22 22:29:16 +00004178 * definition, have no children).
4179 *
4180 * \param visitor the visitor function that will be invoked for each
4181 * child of \p parent.
4182 *
4183 * \param client_data pointer data supplied by the client, which will
4184 * be passed to the visitor each time it is invoked.
4185 *
4186 * \returns a non-zero value if the traversal was terminated
4187 * prematurely by the visitor returning \c CXChildVisit_Break.
4188 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004189CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent,
Douglas Gregor6007cf22010-01-22 22:29:16 +00004190 CXCursorVisitor visitor,
4191 CXClientData client_data);
David Chisnallb2aa0ef2010-11-03 14:12:26 +00004192#ifdef __has_feature
Michael Kruse7520cf02020-03-25 09:26:14 -05004193#if __has_feature(blocks)
David Chisnallb2aa0ef2010-11-03 14:12:26 +00004194/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004195 * Visitor invoked for each cursor found by a traversal.
David Chisnallb2aa0ef2010-11-03 14:12:26 +00004196 *
4197 * This visitor block will be invoked for each cursor found by
4198 * clang_visitChildrenWithBlock(). Its first argument is the cursor being
4199 * visited, its second argument is the parent visitor for that cursor.
4200 *
4201 * The visitor should return one of the \c CXChildVisitResult values
4202 * to direct clang_visitChildrenWithBlock().
4203 */
Michael Kruse7520cf02020-03-25 09:26:14 -05004204typedef enum CXChildVisitResult (^CXCursorVisitorBlock)(CXCursor cursor,
4205 CXCursor parent);
David Chisnallb2aa0ef2010-11-03 14:12:26 +00004206
4207/**
4208 * Visits the children of a cursor using the specified block. Behaves
4209 * identically to clang_visitChildren() in all other respects.
4210 */
Michael Kruse7520cf02020-03-25 09:26:14 -05004211CINDEX_LINKAGE unsigned
4212clang_visitChildrenWithBlock(CXCursor parent, CXCursorVisitorBlock block);
4213#endif
David Chisnallb2aa0ef2010-11-03 14:12:26 +00004214#endif
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004215
Douglas Gregor6007cf22010-01-22 22:29:16 +00004216/**
4217 * @}
4218 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004219
Douglas Gregor6007cf22010-01-22 22:29:16 +00004220/**
4221 * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST
4222 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004223 * These routines provide the ability to determine references within and
Douglas Gregor6007cf22010-01-22 22:29:16 +00004224 * across translation units, by providing the names of the entities referenced
4225 * by cursors, follow reference cursors to the declarations they reference,
4226 * and associate declarations with their definitions.
4227 *
4228 * @{
4229 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004230
Douglas Gregor6007cf22010-01-22 22:29:16 +00004231/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004232 * Retrieve a Unified Symbol Resolution (USR) for the entity referenced
Douglas Gregor6007cf22010-01-22 22:29:16 +00004233 * by the given cursor.
4234 *
4235 * A Unified Symbol Resolution (USR) is a string that identifies a particular
4236 * entity (function, class, variable, etc.) within a program. USRs can be
4237 * compared across translation units to determine, e.g., when references in
4238 * one translation refer to an entity defined in another translation unit.
4239 */
4240CINDEX_LINKAGE CXString clang_getCursorUSR(CXCursor);
4241
4242/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004243 * Construct a USR for a specified Objective-C class.
Ted Kremenekd071c602010-03-13 02:50:34 +00004244 */
4245CINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name);
4246
4247/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004248 * Construct a USR for a specified Objective-C category.
Ted Kremenekd071c602010-03-13 02:50:34 +00004249 */
Michael Kruse7520cf02020-03-25 09:26:14 -05004250CINDEX_LINKAGE CXString clang_constructUSR_ObjCCategory(
4251 const char *class_name, const char *category_name);
Ted Kremenekd071c602010-03-13 02:50:34 +00004252
4253/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004254 * Construct a USR for a specified Objective-C protocol.
Ted Kremenekd071c602010-03-13 02:50:34 +00004255 */
4256CINDEX_LINKAGE CXString
Michael Kruse7520cf02020-03-25 09:26:14 -05004257clang_constructUSR_ObjCProtocol(const char *protocol_name);
Ted Kremenekd071c602010-03-13 02:50:34 +00004258
Ted Kremenekd071c602010-03-13 02:50:34 +00004259/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004260 * Construct a USR for a specified Objective-C instance variable and
Ted Kremenekd071c602010-03-13 02:50:34 +00004261 * the USR for its containing class.
4262 */
4263CINDEX_LINKAGE CXString clang_constructUSR_ObjCIvar(const char *name,
4264 CXString classUSR);
4265
4266/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004267 * Construct a USR for a specified Objective-C method and
Ted Kremenekd071c602010-03-13 02:50:34 +00004268 * the USR for its containing class.
4269 */
4270CINDEX_LINKAGE CXString clang_constructUSR_ObjCMethod(const char *name,
4271 unsigned isInstanceMethod,
4272 CXString classUSR);
4273
4274/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004275 * Construct a USR for a specified Objective-C property and the USR
Ted Kremenekd071c602010-03-13 02:50:34 +00004276 * for its containing class.
4277 */
4278CINDEX_LINKAGE CXString clang_constructUSR_ObjCProperty(const char *property,
4279 CXString classUSR);
4280
4281/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004282 * Retrieve a name for the entity referenced by this cursor.
Douglas Gregor6007cf22010-01-22 22:29:16 +00004283 */
4284CINDEX_LINKAGE CXString clang_getCursorSpelling(CXCursor);
4285
Douglas Gregor97c75712010-10-02 22:49:11 +00004286/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004287 * Retrieve a range for a piece that forms the cursors spelling name.
Argyrios Kyrtzidis191a6a82012-03-30 20:58:35 +00004288 * Most of the times there is only one range for the complete spelling but for
Nico Weber7deebef2014-04-24 03:17:47 +00004289 * Objective-C methods and Objective-C message expressions, there are multiple
4290 * pieces for each selector identifier.
Fangrui Song6907ce22018-07-30 19:24:48 +00004291 *
Argyrios Kyrtzidis191a6a82012-03-30 20:58:35 +00004292 * \param pieceIndex the index of the spelling name piece. If this is greater
4293 * than the actual number of pieces, it will return a NULL (invalid) range.
Fangrui Song6907ce22018-07-30 19:24:48 +00004294 *
Argyrios Kyrtzidis191a6a82012-03-30 20:58:35 +00004295 * \param options Reserved.
4296 */
Michael Kruse7520cf02020-03-25 09:26:14 -05004297CINDEX_LINKAGE CXSourceRange clang_Cursor_getSpellingNameRange(
4298 CXCursor, unsigned pieceIndex, unsigned options);
Argyrios Kyrtzidis191a6a82012-03-30 20:58:35 +00004299
4300/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004301 * Opaque pointer representing a policy that controls pretty printing
Jonathan Coe45ef5032018-01-16 10:19:56 +00004302 * for \c clang_getCursorPrettyPrinted.
4303 */
4304typedef void *CXPrintingPolicy;
4305
4306/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004307 * Properties for the printing policy.
Jonathan Coe45ef5032018-01-16 10:19:56 +00004308 *
4309 * See \c clang::PrintingPolicy for more information.
4310 */
4311enum CXPrintingPolicyProperty {
4312 CXPrintingPolicy_Indentation,
4313 CXPrintingPolicy_SuppressSpecifiers,
4314 CXPrintingPolicy_SuppressTagKeyword,
4315 CXPrintingPolicy_IncludeTagDefinition,
4316 CXPrintingPolicy_SuppressScope,
4317 CXPrintingPolicy_SuppressUnwrittenScope,
4318 CXPrintingPolicy_SuppressInitializers,
4319 CXPrintingPolicy_ConstantArraySizeAsWritten,
4320 CXPrintingPolicy_AnonymousTagLocations,
4321 CXPrintingPolicy_SuppressStrongLifetime,
4322 CXPrintingPolicy_SuppressLifetimeQualifiers,
4323 CXPrintingPolicy_SuppressTemplateArgsInCXXConstructors,
4324 CXPrintingPolicy_Bool,
4325 CXPrintingPolicy_Restrict,
4326 CXPrintingPolicy_Alignof,
4327 CXPrintingPolicy_UnderscoreAlignof,
4328 CXPrintingPolicy_UseVoidForZeroParams,
4329 CXPrintingPolicy_TerseOutput,
4330 CXPrintingPolicy_PolishForDeclaration,
4331 CXPrintingPolicy_Half,
4332 CXPrintingPolicy_MSWChar,
4333 CXPrintingPolicy_IncludeNewlines,
4334 CXPrintingPolicy_MSVCFormatting,
4335 CXPrintingPolicy_ConstantsAsWritten,
4336 CXPrintingPolicy_SuppressImplicitBase,
4337 CXPrintingPolicy_FullyQualifiedName,
4338
4339 CXPrintingPolicy_LastProperty = CXPrintingPolicy_FullyQualifiedName
4340};
4341
4342/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004343 * Get a property value for the given printing policy.
Jonathan Coe45ef5032018-01-16 10:19:56 +00004344 */
Ivan Donchevskii4cab0fe2018-01-16 12:11:59 +00004345CINDEX_LINKAGE unsigned
Jonathan Coe45ef5032018-01-16 10:19:56 +00004346clang_PrintingPolicy_getProperty(CXPrintingPolicy Policy,
4347 enum CXPrintingPolicyProperty Property);
4348
4349/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004350 * Set a property value for the given printing policy.
Jonathan Coe45ef5032018-01-16 10:19:56 +00004351 */
Michael Kruse7520cf02020-03-25 09:26:14 -05004352CINDEX_LINKAGE void
4353clang_PrintingPolicy_setProperty(CXPrintingPolicy Policy,
4354 enum CXPrintingPolicyProperty Property,
4355 unsigned Value);
Jonathan Coe45ef5032018-01-16 10:19:56 +00004356
4357/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004358 * Retrieve the default policy for the cursor.
Jonathan Coe45ef5032018-01-16 10:19:56 +00004359 *
4360 * The policy should be released after use with \c
4361 * clang_PrintingPolicy_dispose.
4362 */
4363CINDEX_LINKAGE CXPrintingPolicy clang_getCursorPrintingPolicy(CXCursor);
4364
4365/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004366 * Release a printing policy.
Jonathan Coe45ef5032018-01-16 10:19:56 +00004367 */
4368CINDEX_LINKAGE void clang_PrintingPolicy_dispose(CXPrintingPolicy Policy);
4369
4370/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004371 * Pretty print declarations.
Jonathan Coe45ef5032018-01-16 10:19:56 +00004372 *
4373 * \param Cursor The cursor representing a declaration.
4374 *
4375 * \param Policy The policy to control the entities being printed. If
4376 * NULL, a default policy is used.
4377 *
4378 * \returns The pretty printed declaration or the empty string for
4379 * other cursors.
4380 */
4381CINDEX_LINKAGE CXString clang_getCursorPrettyPrinted(CXCursor Cursor,
4382 CXPrintingPolicy Policy);
4383
4384/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004385 * Retrieve the display name for the entity referenced by this cursor.
Douglas Gregor97c75712010-10-02 22:49:11 +00004386 *
4387 * The display name contains extra information that helps identify the cursor,
Fangrui Song6907ce22018-07-30 19:24:48 +00004388 * such as the parameters of a function or template or the arguments of a
Douglas Gregor97c75712010-10-02 22:49:11 +00004389 * class template specialization.
4390 */
4391CINDEX_LINKAGE CXString clang_getCursorDisplayName(CXCursor);
Fangrui Song6907ce22018-07-30 19:24:48 +00004392
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004393/** For a cursor that is a reference, retrieve a cursor representing the
Douglas Gregorad27e8b2010-01-19 01:20:04 +00004394 * entity that it references.
4395 *
4396 * Reference cursors refer to other entities in the AST. For example, an
4397 * Objective-C superclass reference cursor refers to an Objective-C class.
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004398 * This function produces the cursor for the Objective-C class from the
Douglas Gregorad27e8b2010-01-19 01:20:04 +00004399 * cursor for the superclass reference. If the input cursor is a declaration or
4400 * definition, it returns that declaration or definition unchanged.
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004401 * Otherwise, returns the NULL cursor.
Douglas Gregorad27e8b2010-01-19 01:20:04 +00004402 */
4403CINDEX_LINKAGE CXCursor clang_getCursorReferenced(CXCursor);
Douglas Gregor6b8232f2010-01-19 19:34:47 +00004404
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004405/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004406 * For a cursor that is either a reference to or a declaration
Douglas Gregor6b8232f2010-01-19 19:34:47 +00004407 * of some entity, retrieve a cursor that describes the definition of
4408 * that entity.
4409 *
4410 * Some entities can be declared multiple times within a translation
4411 * unit, but only one of those declarations can also be a
4412 * definition. For example, given:
4413 *
4414 * \code
4415 * int f(int, int);
4416 * int g(int x, int y) { return f(x, y); }
4417 * int f(int a, int b) { return a + b; }
4418 * int f(int, int);
4419 * \endcode
4420 *
4421 * there are three declarations of the function "f", but only the
4422 * second one is a definition. The clang_getCursorDefinition()
4423 * function will take any cursor pointing to a declaration of "f"
4424 * (the first or fourth lines of the example) or a cursor referenced
4425 * that uses "f" (the call to "f' inside "g") and will return a
4426 * declaration cursor pointing to the definition (the second "f"
4427 * declaration).
4428 *
4429 * If given a cursor for which there is no corresponding definition,
4430 * e.g., because there is no definition of that entity within this
4431 * translation unit, returns a NULL cursor.
4432 */
4433CINDEX_LINKAGE CXCursor clang_getCursorDefinition(CXCursor);
4434
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004435/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004436 * Determine whether the declaration pointed to by this cursor
Douglas Gregor6b8232f2010-01-19 19:34:47 +00004437 * is also a definition of that entity.
4438 */
4439CINDEX_LINKAGE unsigned clang_isCursorDefinition(CXCursor);
4440
Douglas Gregor6007cf22010-01-22 22:29:16 +00004441/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004442 * Retrieve the canonical cursor corresponding to the given cursor.
Douglas Gregorfec4dc92010-11-19 23:44:15 +00004443 *
4444 * In the C family of languages, many kinds of entities can be declared several
4445 * times within a single translation unit. For example, a structure type can
4446 * be forward-declared (possibly multiple times) and later defined:
4447 *
4448 * \code
4449 * struct X;
4450 * struct X;
4451 * struct X {
4452 * int member;
4453 * };
4454 * \endcode
4455 *
Fangrui Song6907ce22018-07-30 19:24:48 +00004456 * The declarations and the definition of \c X are represented by three
4457 * different cursors, all of which are declarations of the same underlying
Douglas Gregorfec4dc92010-11-19 23:44:15 +00004458 * entity. One of these cursor is considered the "canonical" cursor, which
Fangrui Song6907ce22018-07-30 19:24:48 +00004459 * is effectively the representative for the underlying entity. One can
Douglas Gregorfec4dc92010-11-19 23:44:15 +00004460 * determine if two cursors are declarations of the same underlying entity by
4461 * comparing their canonical cursors.
4462 *
4463 * \returns The canonical cursor for the entity referred to by the given cursor.
4464 */
4465CINDEX_LINKAGE CXCursor clang_getCanonicalCursor(CXCursor);
4466
Argyrios Kyrtzidis210f29f2012-03-30 22:15:48 +00004467/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004468 * If the cursor points to a selector identifier in an Objective-C
Nico Weber7deebef2014-04-24 03:17:47 +00004469 * method or message expression, this returns the selector index.
Argyrios Kyrtzidis210f29f2012-03-30 22:15:48 +00004470 *
James Dennett574cb4c2012-06-15 05:41:51 +00004471 * After getting a cursor with #clang_getCursor, this can be called to
Argyrios Kyrtzidis210f29f2012-03-30 22:15:48 +00004472 * determine if the location points to a selector identifier.
4473 *
Nico Weber7deebef2014-04-24 03:17:47 +00004474 * \returns The selector index if the cursor is an Objective-C method or message
Argyrios Kyrtzidis210f29f2012-03-30 22:15:48 +00004475 * expression and the cursor is pointing to a selector identifier, or -1
4476 * otherwise.
4477 */
4478CINDEX_LINKAGE int clang_Cursor_getObjCSelectorIndex(CXCursor);
4479
Douglas Gregorfec4dc92010-11-19 23:44:15 +00004480/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004481 * Given a cursor pointing to a C++ method call or an Objective-C
Nico Weber7deebef2014-04-24 03:17:47 +00004482 * message, returns non-zero if the method/message is "dynamic", meaning:
Fangrui Song6907ce22018-07-30 19:24:48 +00004483 *
Argyrios Kyrtzidisb6df68212012-07-02 23:54:36 +00004484 * For a C++ method: the call is virtual.
Nico Weber7deebef2014-04-24 03:17:47 +00004485 * For an Objective-C message: the receiver is an object instance, not 'super'
4486 * or a specific class.
Fangrui Song6907ce22018-07-30 19:24:48 +00004487 *
Argyrios Kyrtzidisb6df68212012-07-02 23:54:36 +00004488 * If the method/message is "static" or the cursor does not point to a
4489 * method/message, it will return zero.
4490 */
4491CINDEX_LINKAGE int clang_Cursor_isDynamicCall(CXCursor C);
4492
4493/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004494 * Given a cursor pointing to an Objective-C message or property
Argyrios Kyrtzidis2a684862017-04-27 17:23:04 +00004495 * reference, or C++ method call, returns the CXType of the receiver.
Argyrios Kyrtzidisb26a24c2012-11-01 02:01:34 +00004496 */
4497CINDEX_LINKAGE CXType clang_Cursor_getReceiverType(CXCursor C);
4498
4499/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004500 * Property attributes for a \c CXCursor_ObjCPropertyDecl.
Argyrios Kyrtzidis9adfd8a2013-04-18 22:15:49 +00004501 */
4502typedef enum {
Michael Kruse7520cf02020-03-25 09:26:14 -05004503 CXObjCPropertyAttr_noattr = 0x00,
4504 CXObjCPropertyAttr_readonly = 0x01,
4505 CXObjCPropertyAttr_getter = 0x02,
4506 CXObjCPropertyAttr_assign = 0x04,
Argyrios Kyrtzidis9adfd8a2013-04-18 22:15:49 +00004507 CXObjCPropertyAttr_readwrite = 0x08,
Michael Kruse7520cf02020-03-25 09:26:14 -05004508 CXObjCPropertyAttr_retain = 0x10,
4509 CXObjCPropertyAttr_copy = 0x20,
Argyrios Kyrtzidis9adfd8a2013-04-18 22:15:49 +00004510 CXObjCPropertyAttr_nonatomic = 0x40,
Michael Kruse7520cf02020-03-25 09:26:14 -05004511 CXObjCPropertyAttr_setter = 0x80,
4512 CXObjCPropertyAttr_atomic = 0x100,
4513 CXObjCPropertyAttr_weak = 0x200,
4514 CXObjCPropertyAttr_strong = 0x400,
Manman Ren04fd4d82016-05-31 23:22:04 +00004515 CXObjCPropertyAttr_unsafe_unretained = 0x800,
Manman Ren400e4c32016-06-03 23:11:41 +00004516 CXObjCPropertyAttr_class = 0x1000
Argyrios Kyrtzidis9adfd8a2013-04-18 22:15:49 +00004517} CXObjCPropertyAttrKind;
4518
4519/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004520 * Given a cursor that represents a property declaration, return the
Argyrios Kyrtzidis9adfd8a2013-04-18 22:15:49 +00004521 * associated property attributes. The bits are formed from
4522 * \c CXObjCPropertyAttrKind.
4523 *
4524 * \param reserved Reserved for future use, pass 0.
4525 */
Michael Kruse7520cf02020-03-25 09:26:14 -05004526CINDEX_LINKAGE unsigned
4527clang_Cursor_getObjCPropertyAttributes(CXCursor C, unsigned reserved);
Argyrios Kyrtzidis9adfd8a2013-04-18 22:15:49 +00004528
4529/**
Michael Wu6e88f532018-08-03 05:38:29 +00004530 * Given a cursor that represents a property declaration, return the
4531 * name of the method that implements the getter.
4532 */
4533CINDEX_LINKAGE CXString clang_Cursor_getObjCPropertyGetterName(CXCursor C);
4534
4535/**
4536 * Given a cursor that represents a property declaration, return the
4537 * name of the method that implements the setter, if any.
4538 */
4539CINDEX_LINKAGE CXString clang_Cursor_getObjCPropertySetterName(CXCursor C);
4540
4541/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004542 * 'Qualifiers' written next to the return and parameter types in
Nico Weber7deebef2014-04-24 03:17:47 +00004543 * Objective-C method declarations.
Argyrios Kyrtzidis9d9bc012013-04-18 23:29:12 +00004544 */
4545typedef enum {
4546 CXObjCDeclQualifier_None = 0x0,
4547 CXObjCDeclQualifier_In = 0x1,
4548 CXObjCDeclQualifier_Inout = 0x2,
4549 CXObjCDeclQualifier_Out = 0x4,
4550 CXObjCDeclQualifier_Bycopy = 0x8,
4551 CXObjCDeclQualifier_Byref = 0x10,
4552 CXObjCDeclQualifier_Oneway = 0x20
4553} CXObjCDeclQualifierKind;
4554
4555/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004556 * Given a cursor that represents an Objective-C method or parameter
Nico Weber7deebef2014-04-24 03:17:47 +00004557 * declaration, return the associated Objective-C qualifiers for the return
4558 * type or the parameter respectively. The bits are formed from
4559 * CXObjCDeclQualifierKind.
Argyrios Kyrtzidis9d9bc012013-04-18 23:29:12 +00004560 */
4561CINDEX_LINKAGE unsigned clang_Cursor_getObjCDeclQualifiers(CXCursor C);
4562
4563/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004564 * Given a cursor that represents an Objective-C method or property
Alex Lorenz6c2898a2017-04-06 14:03:25 +00004565 * declaration, return non-zero if the declaration was affected by "\@optional".
4566 * Returns zero if the cursor is not such a declaration or it is "\@required".
Argyrios Kyrtzidis7b50fc52013-07-05 20:44:37 +00004567 */
4568CINDEX_LINKAGE unsigned clang_Cursor_isObjCOptional(CXCursor C);
4569
4570/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004571 * Returns non-zero if the given cursor is a variadic function or method.
Argyrios Kyrtzidis23814e42013-04-18 23:53:05 +00004572 */
4573CINDEX_LINKAGE unsigned clang_Cursor_isVariadic(CXCursor C);
4574
4575/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004576 * Returns non-zero if the given cursor points to a symbol marked with
Argyrios Kyrtzidis0381cc72017-05-10 15:10:36 +00004577 * external_source_symbol attribute.
4578 *
4579 * \param language If non-NULL, and the attribute is present, will be set to
4580 * the 'language' string from the attribute.
4581 *
4582 * \param definedIn If non-NULL, and the attribute is present, will be set to
4583 * the 'definedIn' string from the attribute.
4584 *
4585 * \param isGenerated If non-NULL, and the attribute is present, will be set to
Argyrios Kyrtzidis8b337c02017-05-10 15:48:16 +00004586 * non-zero if the 'generated_declaration' is set in the attribute.
Argyrios Kyrtzidis0381cc72017-05-10 15:10:36 +00004587 */
4588CINDEX_LINKAGE unsigned clang_Cursor_isExternalSymbol(CXCursor C,
Michael Kruse7520cf02020-03-25 09:26:14 -05004589 CXString *language,
4590 CXString *definedIn,
4591 unsigned *isGenerated);
Argyrios Kyrtzidis0381cc72017-05-10 15:10:36 +00004592
4593/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004594 * Given a cursor that represents a declaration, return the associated
Dmitri Gribenkoaab83832012-06-20 00:34:58 +00004595 * comment's source range. The range may include multiple consecutive comments
4596 * with whitespace in between.
4597 */
4598CINDEX_LINKAGE CXSourceRange clang_Cursor_getCommentRange(CXCursor C);
4599
4600/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004601 * Given a cursor that represents a declaration, return the associated
Dmitri Gribenkoaab83832012-06-20 00:34:58 +00004602 * comment text, including comment markers.
4603 */
4604CINDEX_LINKAGE CXString clang_Cursor_getRawCommentText(CXCursor C);
4605
4606/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004607 * Given a cursor that represents a documentable entity (e.g.,
4608 * declaration), return the associated \paragraph; otherwise return the
Dmitri Gribenko5e4fe002012-07-20 21:34:34 +00004609 * first paragraph.
Dmitri Gribenko5188c4b2012-06-26 20:39:18 +00004610 */
4611CINDEX_LINKAGE CXString clang_Cursor_getBriefCommentText(CXCursor C);
4612
4613/**
Dmitri Gribenko5e4fe002012-07-20 21:34:34 +00004614 * @}
4615 */
4616
Eli Bendersky44a206f2014-07-31 18:04:56 +00004617/** \defgroup CINDEX_MANGLE Name Mangling API Functions
4618 *
4619 * @{
4620 */
4621
4622/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004623 * Retrieve the CXString representing the mangled name of the cursor.
Eli Bendersky44a206f2014-07-31 18:04:56 +00004624 */
4625CINDEX_LINKAGE CXString clang_Cursor_getMangling(CXCursor);
4626
4627/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004628 * Retrieve the CXStrings representing the mangled symbols of the C++
Saleem Abdulrasool60034432015-11-12 03:57:22 +00004629 * constructor or destructor at the cursor.
4630 */
4631CINDEX_LINKAGE CXStringSet *clang_Cursor_getCXXManglings(CXCursor);
4632
4633/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004634 * Retrieve the CXStrings representing the mangled symbols of the ObjC
Dave Lee1a532c92017-09-22 16:58:57 +00004635 * class interface or implementation at the cursor.
4636 */
4637CINDEX_LINKAGE CXStringSet *clang_Cursor_getObjCManglings(CXCursor);
4638
4639/**
Eli Bendersky44a206f2014-07-31 18:04:56 +00004640 * @}
4641 */
4642
Dmitri Gribenko5e4fe002012-07-20 21:34:34 +00004643/**
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004644 * \defgroup CINDEX_MODULE Module introspection
4645 *
4646 * The functions in this group provide access to information about modules.
4647 *
4648 * @{
4649 */
4650
4651typedef void *CXModule;
4652
4653/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004654 * Given a CXCursor_ModuleImportDecl cursor, return the associated module.
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004655 */
4656CINDEX_LINKAGE CXModule clang_Cursor_getModule(CXCursor C);
4657
4658/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004659 * Given a CXFile header file, return the module that contains it, if one
Argyrios Kyrtzidisf6d49c32014-05-14 23:14:37 +00004660 * exists.
4661 */
4662CINDEX_LINKAGE CXModule clang_getModuleForFile(CXTranslationUnit, CXFile);
4663
4664/**
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004665 * \param Module a module object.
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004666 *
Argyrios Kyrtzidis12fdb9e2013-04-26 22:47:49 +00004667 * \returns the module file where the provided module object came from.
4668 */
4669CINDEX_LINKAGE CXFile clang_Module_getASTFile(CXModule Module);
4670
4671/**
4672 * \param Module a module object.
4673 *
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004674 * \returns the parent of a sub-module or NULL if the given module is top-level,
4675 * e.g. for 'std.vector' it will return the 'std' module.
4676 */
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004677CINDEX_LINKAGE CXModule clang_Module_getParent(CXModule Module);
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004678
4679/**
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004680 * \param Module a module object.
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004681 *
4682 * \returns the name of the module, e.g. for the 'std.vector' sub-module it
4683 * will return "vector".
4684 */
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004685CINDEX_LINKAGE CXString clang_Module_getName(CXModule Module);
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004686
4687/**
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004688 * \param Module a module object.
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004689 *
4690 * \returns the full name of the module, e.g. "std.vector".
4691 */
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004692CINDEX_LINKAGE CXString clang_Module_getFullName(CXModule Module);
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004693
4694/**
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004695 * \param Module a module object.
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004696 *
Argyrios Kyrtzidis884337f2014-05-15 04:44:25 +00004697 * \returns non-zero if the module is a system one.
4698 */
4699CINDEX_LINKAGE int clang_Module_isSystem(CXModule Module);
4700
4701/**
4702 * \param Module a module object.
4703 *
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004704 * \returns the number of top level headers associated with this module.
4705 */
Argyrios Kyrtzidis3c5305c2013-03-13 21:13:43 +00004706CINDEX_LINKAGE unsigned clang_Module_getNumTopLevelHeaders(CXTranslationUnit,
4707 CXModule Module);
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004708
4709/**
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004710 * \param Module a module object.
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004711 *
4712 * \param Index top level header index (zero-based).
4713 *
4714 * \returns the specified top level header associated with the module.
4715 */
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004716CINDEX_LINKAGE
Michael Kruse7520cf02020-03-25 09:26:14 -05004717CXFile clang_Module_getTopLevelHeader(CXTranslationUnit, CXModule Module,
4718 unsigned Index);
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004719
4720/**
4721 * @}
4722 */
4723
4724/**
Ted Kremenek9cfe9e62010-05-17 20:06:56 +00004725 * \defgroup CINDEX_CPP C++ AST introspection
4726 *
4727 * The routines in this group provide access information in the ASTs specific
4728 * to C++ language features.
4729 *
4730 * @{
4731 */
4732
4733/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004734 * Determine if a C++ constructor is a converting constructor.
Jonathan Coe29565352016-04-27 12:48:25 +00004735 */
Michael Kruse7520cf02020-03-25 09:26:14 -05004736CINDEX_LINKAGE unsigned
4737clang_CXXConstructor_isConvertingConstructor(CXCursor C);
Jonathan Coe29565352016-04-27 12:48:25 +00004738
4739/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004740 * Determine if a C++ constructor is a copy constructor.
Jonathan Coe29565352016-04-27 12:48:25 +00004741 */
4742CINDEX_LINKAGE unsigned clang_CXXConstructor_isCopyConstructor(CXCursor C);
4743
4744/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004745 * Determine if a C++ constructor is the default constructor.
Jonathan Coe29565352016-04-27 12:48:25 +00004746 */
4747CINDEX_LINKAGE unsigned clang_CXXConstructor_isDefaultConstructor(CXCursor C);
4748
4749/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004750 * Determine if a C++ constructor is a move constructor.
Jonathan Coe29565352016-04-27 12:48:25 +00004751 */
4752CINDEX_LINKAGE unsigned clang_CXXConstructor_isMoveConstructor(CXCursor C);
4753
4754/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004755 * Determine if a C++ field is declared 'mutable'.
Saleem Abdulrasool6ea75db2015-10-27 15:50:22 +00004756 */
4757CINDEX_LINKAGE unsigned clang_CXXField_isMutable(CXCursor C);
4758
4759/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004760 * Determine if a C++ method is declared '= default'.
Jonathan Coe29565352016-04-27 12:48:25 +00004761 */
4762CINDEX_LINKAGE unsigned clang_CXXMethod_isDefaulted(CXCursor C);
4763
4764/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004765 * Determine if a C++ member function or member function template is
Dmitri Gribenko62770be2013-05-17 18:38:35 +00004766 * pure virtual.
4767 */
4768CINDEX_LINKAGE unsigned clang_CXXMethod_isPureVirtual(CXCursor C);
4769
4770/**
Fangrui Song6907ce22018-07-30 19:24:48 +00004771 * Determine if a C++ member function or member function template is
Douglas Gregorf11309e2010-08-31 22:12:17 +00004772 * declared 'static'.
Ted Kremenek9cfe9e62010-05-17 20:06:56 +00004773 */
4774CINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C);
4775
4776/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004777 * Determine if a C++ member function or member function template is
Douglas Gregor9519d922011-05-12 15:17:24 +00004778 * explicitly declared 'virtual' or if it overrides a virtual method from
4779 * one of the base classes.
4780 */
4781CINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual(CXCursor C);
4782
4783/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004784 * Determine if a C++ record is abstract, i.e. whether a class or struct
Alex Lorenz34ccadc2017-12-14 22:01:50 +00004785 * has a pure virtual member function.
4786 */
4787CINDEX_LINKAGE unsigned clang_CXXRecord_isAbstract(CXCursor C);
4788
4789/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004790 * Determine if an enum declaration refers to a scoped enum.
Alex Lorenzff7f42e2017-07-12 11:35:11 +00004791 */
4792CINDEX_LINKAGE unsigned clang_EnumDecl_isScoped(CXCursor C);
4793
4794/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004795 * Determine if a C++ member function or member function template is
Dmitri Gribenkoe570ede2014-04-07 14:59:13 +00004796 * declared 'const'.
4797 */
4798CINDEX_LINKAGE unsigned clang_CXXMethod_isConst(CXCursor C);
4799
4800/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004801 * Given a cursor that represents a template, determine
Douglas Gregorf11309e2010-08-31 22:12:17 +00004802 * the cursor kind of the specializations would be generated by instantiating
4803 * the template.
4804 *
4805 * This routine can be used to determine what flavor of function template,
4806 * class template, or class template partial specialization is stored in the
4807 * cursor. For example, it can describe whether a class template cursor is
4808 * declared with "struct", "class" or "union".
4809 *
4810 * \param C The cursor to query. This cursor should represent a template
4811 * declaration.
4812 *
4813 * \returns The cursor kind of the specializations that would be generated
4814 * by instantiating the template \p C. If \p C is not a template, returns
4815 * \c CXCursor_NoDeclFound.
4816 */
4817CINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind(CXCursor C);
Fangrui Song6907ce22018-07-30 19:24:48 +00004818
Douglas Gregorf11309e2010-08-31 22:12:17 +00004819/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004820 * Given a cursor that may represent a specialization or instantiation
Douglas Gregord3f48bd2010-09-02 00:07:54 +00004821 * of a template, retrieve the cursor that represents the template that it
4822 * specializes or from which it was instantiated.
4823 *
Fangrui Song6907ce22018-07-30 19:24:48 +00004824 * This routine determines the template involved both for explicit
Douglas Gregord3f48bd2010-09-02 00:07:54 +00004825 * specializations of templates and for implicit instantiations of the template,
4826 * both of which are referred to as "specializations". For a class template
Fangrui Song6907ce22018-07-30 19:24:48 +00004827 * specialization (e.g., \c std::vector<bool>), this routine will return
Douglas Gregord3f48bd2010-09-02 00:07:54 +00004828 * either the primary template (\c std::vector) or, if the specialization was
4829 * instantiated from a class template partial specialization, the class template
4830 * partial specialization. For a class template partial specialization and a
4831 * function template specialization (including instantiations), this
4832 * this routine will return the specialized template.
4833 *
4834 * For members of a class template (e.g., member functions, member classes, or
Fangrui Song6907ce22018-07-30 19:24:48 +00004835 * static data members), returns the specialized or instantiated member.
Douglas Gregord3f48bd2010-09-02 00:07:54 +00004836 * Although not strictly "templates" in the C++ language, members of class
4837 * templates have the same notions of specializations and instantiations that
4838 * templates do, so this routine treats them similarly.
4839 *
4840 * \param C A cursor that may be a specialization of a template or a member
4841 * of a template.
4842 *
Fangrui Song6907ce22018-07-30 19:24:48 +00004843 * \returns If the given cursor is a specialization or instantiation of a
Douglas Gregord3f48bd2010-09-02 00:07:54 +00004844 * template or a member thereof, the template or member that it specializes or
4845 * from which it was instantiated. Otherwise, returns a NULL cursor.
4846 */
4847CINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate(CXCursor C);
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004848
4849/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004850 * Given a cursor that references something else, return the source range
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004851 * covering that reference.
4852 *
4853 * \param C A cursor pointing to a member reference, a declaration reference, or
4854 * an operator call.
Fangrui Song6907ce22018-07-30 19:24:48 +00004855 * \param NameFlags A bitset with three independent flags:
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004856 * CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and
4857 * CXNameRange_WantSinglePiece.
Fangrui Song6907ce22018-07-30 19:24:48 +00004858 * \param PieceIndex For contiguous names or when passing the flag
4859 * CXNameRange_WantSinglePiece, only one piece with index 0 is
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004860 * available. When the CXNameRange_WantSinglePiece flag is not passed for a
Benjamin Kramer474261a2012-06-02 10:20:41 +00004861 * non-contiguous names, this index can be used to retrieve the individual
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004862 * pieces of the name. See also CXNameRange_WantSinglePiece.
4863 *
4864 * \returns The piece of the name pointed to by the given cursor. If there is no
4865 * name, or if the PieceIndex is out-of-range, a null-cursor will be returned.
4866 */
Michael Kruse7520cf02020-03-25 09:26:14 -05004867CINDEX_LINKAGE CXSourceRange clang_getCursorReferenceNameRange(
4868 CXCursor C, unsigned NameFlags, unsigned PieceIndex);
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004869
4870enum CXNameRefFlags {
4871 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004872 * Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004873 * range.
4874 */
4875 CXNameRange_WantQualifier = 0x1,
Fangrui Song6907ce22018-07-30 19:24:48 +00004876
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004877 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004878 * Include the explicit template arguments, e.g. \<int> in x.f<int>,
James Dennett574cb4c2012-06-15 05:41:51 +00004879 * in the range.
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004880 */
4881 CXNameRange_WantTemplateArgs = 0x2,
4882
4883 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004884 * If the name is non-contiguous, return the full spanning range.
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004885 *
4886 * Non-contiguous names occur in Objective-C when a selector with two or more
4887 * parameters is used, or in C++ when using an operator:
4888 * \code
Nico Weber7deebef2014-04-24 03:17:47 +00004889 * [object doSomething:here withValue:there]; // Objective-C
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004890 * return some_vector[1]; // C++
4891 * \endcode
4892 */
4893 CXNameRange_WantSinglePiece = 0x4
4894};
Fangrui Song6907ce22018-07-30 19:24:48 +00004895
Douglas Gregord3f48bd2010-09-02 00:07:54 +00004896/**
Ted Kremenek9cfe9e62010-05-17 20:06:56 +00004897 * @}
4898 */
4899
4900/**
Douglas Gregor61656112010-01-26 18:31:56 +00004901 * \defgroup CINDEX_LEX Token extraction and manipulation
4902 *
4903 * The routines in this group provide access to the tokens within a
4904 * translation unit, along with a semantic mapping of those tokens to
4905 * their corresponding cursors.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004906 *
4907 * @{
4908 */
4909
4910/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004911 * Describes a kind of token.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004912 */
4913typedef enum CXTokenKind {
4914 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004915 * A token that contains some kind of punctuation.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004916 */
4917 CXToken_Punctuation,
Ted Kremenekd071c602010-03-13 02:50:34 +00004918
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004919 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004920 * A language keyword.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004921 */
4922 CXToken_Keyword,
Ted Kremenekd071c602010-03-13 02:50:34 +00004923
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004924 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004925 * An identifier (that is not a keyword).
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004926 */
4927 CXToken_Identifier,
Ted Kremenekd071c602010-03-13 02:50:34 +00004928
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004929 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004930 * A numeric, string, or character literal.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004931 */
4932 CXToken_Literal,
Ted Kremenekd071c602010-03-13 02:50:34 +00004933
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004934 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004935 * A comment.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004936 */
4937 CXToken_Comment
4938} CXTokenKind;
4939
4940/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004941 * Describes a single preprocessing token.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004942 */
4943typedef struct {
4944 unsigned int_data[4];
4945 void *ptr_data;
4946} CXToken;
4947
4948/**
Ivan Donchevskii3957e482018-06-13 12:37:08 +00004949 * Get the raw lexical token starting with the given location.
4950 *
4951 * \param TU the translation unit whose text is being tokenized.
4952 *
4953 * \param Location the source location with which the token starts.
4954 *
4955 * \returns The token starting with the given location or NULL if no such token
4956 * exist. The returned pointer must be freed with clang_disposeTokens before the
4957 * translation unit is destroyed.
4958 */
4959CINDEX_LINKAGE CXToken *clang_getToken(CXTranslationUnit TU,
4960 CXSourceLocation Location);
4961
4962/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004963 * Determine the kind of the given token.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004964 */
4965CINDEX_LINKAGE CXTokenKind clang_getTokenKind(CXToken);
Ted Kremenekd071c602010-03-13 02:50:34 +00004966
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004967/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004968 * Determine the spelling of the given token.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004969 *
4970 * The spelling of a token is the textual representation of that token, e.g.,
4971 * the text of an identifier or keyword.
4972 */
4973CINDEX_LINKAGE CXString clang_getTokenSpelling(CXTranslationUnit, CXToken);
Ted Kremenekd071c602010-03-13 02:50:34 +00004974
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004975/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004976 * Retrieve the source location of the given token.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004977 */
Ted Kremenekd071c602010-03-13 02:50:34 +00004978CINDEX_LINKAGE CXSourceLocation clang_getTokenLocation(CXTranslationUnit,
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004979 CXToken);
Ted Kremenekd071c602010-03-13 02:50:34 +00004980
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004981/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004982 * Retrieve a source range that covers the given token.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004983 */
4984CINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken);
4985
4986/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004987 * Tokenize the source code described by the given range into raw
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004988 * lexical tokens.
4989 *
4990 * \param TU the translation unit whose text is being tokenized.
4991 *
4992 * \param Range the source range in which text should be tokenized. All of the
4993 * tokens produced by tokenization will fall within this source range,
4994 *
4995 * \param Tokens this pointer will be set to point to the array of tokens
4996 * that occur within the given source range. The returned pointer must be
4997 * freed with clang_disposeTokens() before the translation unit is destroyed.
4998 *
4999 * \param NumTokens will be set to the number of tokens in the \c *Tokens
5000 * array.
5001 *
5002 */
5003CINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
5004 CXToken **Tokens, unsigned *NumTokens);
Ted Kremenekd071c602010-03-13 02:50:34 +00005005
Douglas Gregor27b4fa92010-01-26 17:06:03 +00005006/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005007 * Annotate the given set of tokens by providing cursors for each token
Douglas Gregor27b4fa92010-01-26 17:06:03 +00005008 * that can be mapped to a specific entity within the abstract syntax tree.
5009 *
Douglas Gregor61656112010-01-26 18:31:56 +00005010 * This token-annotation routine is equivalent to invoking
5011 * clang_getCursor() for the source locations of each of the
5012 * tokens. The cursors provided are filtered, so that only those
5013 * cursors that have a direct correspondence to the token are
5014 * accepted. For example, given a function call \c f(x),
5015 * clang_getCursor() would provide the following cursors:
5016 *
5017 * * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'.
5018 * * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'.
5019 * * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'.
5020 *
5021 * Only the first and last of these cursors will occur within the
5022 * annotate, since the tokens "f" and "x' directly refer to a function
5023 * and a variable, respectively, but the parentheses are just a small
5024 * part of the full syntax of the function call expression, which is
5025 * not provided as an annotation.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00005026 *
5027 * \param TU the translation unit that owns the given tokens.
5028 *
5029 * \param Tokens the set of tokens to annotate.
5030 *
5031 * \param NumTokens the number of tokens in \p Tokens.
5032 *
5033 * \param Cursors an array of \p NumTokens cursors, whose contents will be
5034 * replaced with the cursors corresponding to each token.
5035 */
Michael Kruse7520cf02020-03-25 09:26:14 -05005036CINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU, CXToken *Tokens,
5037 unsigned NumTokens, CXCursor *Cursors);
Ted Kremenekd071c602010-03-13 02:50:34 +00005038
Douglas Gregor27b4fa92010-01-26 17:06:03 +00005039/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005040 * Free the given set of tokens.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00005041 */
Michael Kruse7520cf02020-03-25 09:26:14 -05005042CINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU, CXToken *Tokens,
5043 unsigned NumTokens);
Ted Kremenekd071c602010-03-13 02:50:34 +00005044
Douglas Gregor27b4fa92010-01-26 17:06:03 +00005045/**
5046 * @}
5047 */
Ted Kremenekd071c602010-03-13 02:50:34 +00005048
Douglas Gregor27b4fa92010-01-26 17:06:03 +00005049/**
Douglas Gregor6007cf22010-01-22 22:29:16 +00005050 * \defgroup CINDEX_DEBUG Debugging facilities
5051 *
5052 * These routines are used for testing and debugging, only, and should not
5053 * be relied upon.
5054 *
5055 * @{
5056 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005057
Steve Naroff76b8f132009-09-23 17:52:52 +00005058/* for debug/testing */
Ted Kremenek29004672010-02-17 00:41:32 +00005059CINDEX_LINKAGE CXString clang_getCursorKindSpelling(enum CXCursorKind Kind);
Michael Kruse7520cf02020-03-25 09:26:14 -05005060CINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(
5061 CXCursor, const char **startBuf, const char **endBuf, unsigned *startLine,
5062 unsigned *startColumn, unsigned *endLine, unsigned *endColumn);
Douglas Gregor1e21cc72010-02-18 23:07:20 +00005063CINDEX_LINKAGE void clang_enableStackTraces(void);
Michael Kruse7520cf02020-03-25 09:26:14 -05005064CINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void *), void *user_data,
Daniel Dunbar23420652010-11-04 01:26:29 +00005065 unsigned stack_size);
5066
Douglas Gregor9eb77012009-11-07 00:00:49 +00005067/**
Douglas Gregor6007cf22010-01-22 22:29:16 +00005068 * @}
5069 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005070
Douglas Gregor6007cf22010-01-22 22:29:16 +00005071/**
5072 * \defgroup CINDEX_CODE_COMPLET Code completion
5073 *
5074 * Code completion involves taking an (incomplete) source file, along with
5075 * knowledge of where the user is actively editing that file, and suggesting
5076 * syntactically- and semantically-valid constructs that the user might want to
5077 * use at that particular point in the source code. These data structures and
5078 * routines provide support for code completion.
5079 *
5080 * @{
5081 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005082
Douglas Gregor6007cf22010-01-22 22:29:16 +00005083/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005084 * A semantic string that describes a code-completion result.
Douglas Gregor9eb77012009-11-07 00:00:49 +00005085 *
5086 * A semantic string that describes the formatting of a code-completion
5087 * result as a single "template" of text that should be inserted into the
5088 * source buffer when a particular code-completion result is selected.
5089 * Each semantic string is made up of some number of "chunks", each of which
5090 * contains some text along with a description of what that text means, e.g.,
5091 * the name of the entity being referenced, whether the text chunk is part of
5092 * the template, or whether it is a "placeholder" that the user should replace
5093 * with actual code,of a specific kind. See \c CXCompletionChunkKind for a
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005094 * description of the different kinds of chunks.
Douglas Gregor9eb77012009-11-07 00:00:49 +00005095 */
5096typedef void *CXCompletionString;
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005097
Douglas Gregor9eb77012009-11-07 00:00:49 +00005098/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005099 * A single result of code completion.
Douglas Gregor9eb77012009-11-07 00:00:49 +00005100 */
5101typedef struct {
5102 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005103 * The kind of entity that this completion refers to.
Douglas Gregor9eb77012009-11-07 00:00:49 +00005104 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005105 * The cursor kind will be a macro, keyword, or a declaration (one of the
Douglas Gregor9eb77012009-11-07 00:00:49 +00005106 * *Decl cursor kinds), describing the entity that the completion is
5107 * referring to.
5108 *
5109 * \todo In the future, we would like to provide a full cursor, to allow
5110 * the client to extract additional information from declaration.
5111 */
5112 enum CXCursorKind CursorKind;
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005113
5114 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005115 * The code-completion string that describes how to insert this
Douglas Gregor9eb77012009-11-07 00:00:49 +00005116 * code-completion result into the editing buffer.
5117 */
5118 CXCompletionString CompletionString;
5119} CXCompletionResult;
5120
5121/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005122 * Describes a single piece of text within a code-completion string.
Douglas Gregor9eb77012009-11-07 00:00:49 +00005123 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005124 * Each "chunk" within a code-completion string (\c CXCompletionString) is
5125 * either a piece of text with a specific "kind" that describes how that text
Douglas Gregor9eb77012009-11-07 00:00:49 +00005126 * should be interpreted by the client or is another completion string.
5127 */
5128enum CXCompletionChunkKind {
5129 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005130 * A code-completion string that describes "optional" text that
Douglas Gregor9eb77012009-11-07 00:00:49 +00005131 * could be a part of the template (but is not required).
5132 *
5133 * The Optional chunk is the only kind of chunk that has a code-completion
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005134 * string for its representation, which is accessible via
Douglas Gregor9eb77012009-11-07 00:00:49 +00005135 * \c clang_getCompletionChunkCompletionString(). The code-completion string
5136 * describes an additional part of the template that is completely optional.
5137 * For example, optional chunks can be used to describe the placeholders for
5138 * arguments that match up with defaulted function parameters, e.g. given:
5139 *
5140 * \code
5141 * void f(int x, float y = 3.14, double z = 2.71828);
5142 * \endcode
5143 *
5144 * The code-completion string for this function would contain:
5145 * - a TypedText chunk for "f".
5146 * - a LeftParen chunk for "(".
5147 * - a Placeholder chunk for "int x"
5148 * - an Optional chunk containing the remaining defaulted arguments, e.g.,
5149 * - a Comma chunk for ","
Daniel Dunbar4053fae2010-02-17 08:07:44 +00005150 * - a Placeholder chunk for "float y"
Douglas Gregor9eb77012009-11-07 00:00:49 +00005151 * - an Optional chunk containing the last defaulted argument:
5152 * - a Comma chunk for ","
5153 * - a Placeholder chunk for "double z"
5154 * - a RightParen chunk for ")"
5155 *
Daniel Dunbar4053fae2010-02-17 08:07:44 +00005156 * There are many ways to handle Optional chunks. Two simple approaches are:
Douglas Gregor9eb77012009-11-07 00:00:49 +00005157 * - Completely ignore optional chunks, in which case the template for the
5158 * function "f" would only include the first parameter ("int x").
5159 * - Fully expand all optional chunks, in which case the template for the
5160 * function "f" would have all of the parameters.
5161 */
5162 CXCompletionChunk_Optional,
5163 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005164 * Text that a user would be expected to type to get this
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005165 * code-completion result.
Douglas Gregor9eb77012009-11-07 00:00:49 +00005166 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005167 * There will be exactly one "typed text" chunk in a semantic string, which
5168 * will typically provide the spelling of a keyword or the name of a
Douglas Gregor9eb77012009-11-07 00:00:49 +00005169 * declaration that could be used at the current code point. Clients are
5170 * expected to filter the code-completion results based on the text in this
5171 * chunk.
5172 */
5173 CXCompletionChunk_TypedText,
5174 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005175 * Text that should be inserted as part of a code-completion result.
Douglas Gregor9eb77012009-11-07 00:00:49 +00005176 *
5177 * A "text" chunk represents text that is part of the template to be
5178 * inserted into user code should this particular code-completion result
5179 * be selected.
5180 */
5181 CXCompletionChunk_Text,
5182 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005183 * Placeholder text that should be replaced by the user.
Douglas Gregor9eb77012009-11-07 00:00:49 +00005184 *
5185 * A "placeholder" chunk marks a place where the user should insert text
5186 * into the code-completion template. For example, placeholders might mark
5187 * the function parameters for a function declaration, to indicate that the
5188 * user should provide arguments for each of those parameters. The actual
5189 * text in a placeholder is a suggestion for the text to display before
5190 * the user replaces the placeholder with real code.
5191 */
5192 CXCompletionChunk_Placeholder,
5193 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005194 * Informative text that should be displayed but never inserted as
Douglas Gregor9eb77012009-11-07 00:00:49 +00005195 * part of the template.
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005196 *
Douglas Gregor9eb77012009-11-07 00:00:49 +00005197 * An "informative" chunk contains annotations that can be displayed to
5198 * help the user decide whether a particular code-completion result is the
5199 * right option, but which is not part of the actual template to be inserted
5200 * by code completion.
5201 */
5202 CXCompletionChunk_Informative,
5203 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005204 * Text that describes the current parameter when code-completion is
Douglas Gregor9eb77012009-11-07 00:00:49 +00005205 * referring to function call, message send, or template specialization.
5206 *
5207 * A "current parameter" chunk occurs when code-completion is providing
5208 * information about a parameter corresponding to the argument at the
5209 * code-completion point. For example, given a function
5210 *
5211 * \code
5212 * int add(int x, int y);
5213 * \endcode
5214 *
5215 * and the source code \c add(, where the code-completion point is after the
5216 * "(", the code-completion string will contain a "current parameter" chunk
5217 * for "int x", indicating that the current argument will initialize that
5218 * parameter. After typing further, to \c add(17, (where the code-completion
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005219 * point is after the ","), the code-completion string will contain a
Alexander Kornienko2a8c18d2018-04-06 15:14:32 +00005220 * "current parameter" chunk to "int y".
Douglas Gregor9eb77012009-11-07 00:00:49 +00005221 */
5222 CXCompletionChunk_CurrentParameter,
5223 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005224 * A left parenthesis ('('), used to initiate a function call or
Douglas Gregor9eb77012009-11-07 00:00:49 +00005225 * signal the beginning of a function parameter list.
5226 */
5227 CXCompletionChunk_LeftParen,
5228 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005229 * A right parenthesis (')'), used to finish a function call or
Douglas Gregor9eb77012009-11-07 00:00:49 +00005230 * signal the end of a function parameter list.
5231 */
5232 CXCompletionChunk_RightParen,
5233 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005234 * A left bracket ('[').
Douglas Gregor9eb77012009-11-07 00:00:49 +00005235 */
5236 CXCompletionChunk_LeftBracket,
5237 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005238 * A right bracket (']').
Douglas Gregor9eb77012009-11-07 00:00:49 +00005239 */
5240 CXCompletionChunk_RightBracket,
5241 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005242 * A left brace ('{').
Douglas Gregor9eb77012009-11-07 00:00:49 +00005243 */
5244 CXCompletionChunk_LeftBrace,
5245 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005246 * A right brace ('}').
Douglas Gregor9eb77012009-11-07 00:00:49 +00005247 */
5248 CXCompletionChunk_RightBrace,
5249 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005250 * A left angle bracket ('<').
Douglas Gregor9eb77012009-11-07 00:00:49 +00005251 */
5252 CXCompletionChunk_LeftAngle,
5253 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005254 * A right angle bracket ('>').
Douglas Gregor9eb77012009-11-07 00:00:49 +00005255 */
5256 CXCompletionChunk_RightAngle,
5257 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005258 * A comma separator (',').
Douglas Gregor9eb77012009-11-07 00:00:49 +00005259 */
Douglas Gregorb3fa9192009-12-18 18:53:37 +00005260 CXCompletionChunk_Comma,
5261 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005262 * Text that specifies the result type of a given result.
Douglas Gregorb3fa9192009-12-18 18:53:37 +00005263 *
5264 * This special kind of informative chunk is not meant to be inserted into
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005265 * the text buffer. Rather, it is meant to illustrate the type that an
Douglas Gregorb3fa9192009-12-18 18:53:37 +00005266 * expression using the given completion string would have.
5267 */
Douglas Gregor504a6ae2010-01-10 23:08:15 +00005268 CXCompletionChunk_ResultType,
5269 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005270 * A colon (':').
Douglas Gregor504a6ae2010-01-10 23:08:15 +00005271 */
5272 CXCompletionChunk_Colon,
5273 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005274 * A semicolon (';').
Douglas Gregor504a6ae2010-01-10 23:08:15 +00005275 */
5276 CXCompletionChunk_SemiColon,
5277 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005278 * An '=' sign.
Douglas Gregor504a6ae2010-01-10 23:08:15 +00005279 */
5280 CXCompletionChunk_Equal,
5281 /**
5282 * Horizontal space (' ').
5283 */
5284 CXCompletionChunk_HorizontalSpace,
5285 /**
Alex Lorenz6c2898a2017-04-06 14:03:25 +00005286 * Vertical space ('\\n'), after which it is generally a good idea to
Douglas Gregor504a6ae2010-01-10 23:08:15 +00005287 * perform indentation.
5288 */
5289 CXCompletionChunk_VerticalSpace
Douglas Gregor9eb77012009-11-07 00:00:49 +00005290};
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005291
Douglas Gregor9eb77012009-11-07 00:00:49 +00005292/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005293 * Determine the kind of a particular chunk within a completion string.
Douglas Gregor9eb77012009-11-07 00:00:49 +00005294 *
5295 * \param completion_string the completion string to query.
5296 *
5297 * \param chunk_number the 0-based index of the chunk in the completion string.
5298 *
5299 * \returns the kind of the chunk at the index \c chunk_number.
5300 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005301CINDEX_LINKAGE enum CXCompletionChunkKind
Douglas Gregor9eb77012009-11-07 00:00:49 +00005302clang_getCompletionChunkKind(CXCompletionString completion_string,
5303 unsigned chunk_number);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005304
Douglas Gregor9eb77012009-11-07 00:00:49 +00005305/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005306 * Retrieve the text associated with a particular chunk within a
Douglas Gregor9eb77012009-11-07 00:00:49 +00005307 * completion string.
5308 *
5309 * \param completion_string the completion string to query.
5310 *
5311 * \param chunk_number the 0-based index of the chunk in the completion string.
5312 *
5313 * \returns the text associated with the chunk at index \c chunk_number.
5314 */
Michael Kruse7520cf02020-03-25 09:26:14 -05005315CINDEX_LINKAGE CXString clang_getCompletionChunkText(
5316 CXCompletionString completion_string, unsigned chunk_number);
Douglas Gregor9eb77012009-11-07 00:00:49 +00005317
5318/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005319 * Retrieve the completion string associated with a particular chunk
Douglas Gregor9eb77012009-11-07 00:00:49 +00005320 * within a completion string.
5321 *
5322 * \param completion_string the completion string to query.
5323 *
5324 * \param chunk_number the 0-based index of the chunk in the completion string.
5325 *
5326 * \returns the completion string associated with the chunk at index
Erik Verbruggen98ea7f62011-10-14 15:31:08 +00005327 * \c chunk_number.
Douglas Gregor9eb77012009-11-07 00:00:49 +00005328 */
Michael Kruse7520cf02020-03-25 09:26:14 -05005329CINDEX_LINKAGE CXCompletionString clang_getCompletionChunkCompletionString(
5330 CXCompletionString completion_string, unsigned chunk_number);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005331
Douglas Gregor9eb77012009-11-07 00:00:49 +00005332/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005333 * Retrieve the number of chunks in the given code-completion string.
Douglas Gregor9eb77012009-11-07 00:00:49 +00005334 */
5335CINDEX_LINKAGE unsigned
5336clang_getNumCompletionChunks(CXCompletionString completion_string);
5337
5338/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005339 * Determine the priority of this code completion.
Douglas Gregora2db7932010-05-26 22:00:08 +00005340 *
Fangrui Song6907ce22018-07-30 19:24:48 +00005341 * The priority of a code completion indicates how likely it is that this
Douglas Gregora2db7932010-05-26 22:00:08 +00005342 * particular completion is the completion that the user will select. The
5343 * priority is selected by various internal heuristics.
5344 *
5345 * \param completion_string The completion string to query.
5346 *
5347 * \returns The priority of this completion string. Smaller values indicate
5348 * higher-priority (more likely) completions.
5349 */
5350CINDEX_LINKAGE unsigned
5351clang_getCompletionPriority(CXCompletionString completion_string);
Fangrui Song6907ce22018-07-30 19:24:48 +00005352
Douglas Gregora2db7932010-05-26 22:00:08 +00005353/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005354 * Determine the availability of the entity that this code-completion
Douglas Gregorf757a122010-08-23 23:00:57 +00005355 * string refers to.
5356 *
5357 * \param completion_string The completion string to query.
5358 *
5359 * \returns The availability of the completion string.
5360 */
Fangrui Song6907ce22018-07-30 19:24:48 +00005361CINDEX_LINKAGE enum CXAvailabilityKind
Douglas Gregorf757a122010-08-23 23:00:57 +00005362clang_getCompletionAvailability(CXCompletionString completion_string);
5363
5364/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005365 * Retrieve the number of annotations associated with the given
Erik Verbruggen98ea7f62011-10-14 15:31:08 +00005366 * completion string.
5367 *
5368 * \param completion_string the completion string to query.
5369 *
5370 * \returns the number of annotations associated with the given completion
5371 * string.
5372 */
5373CINDEX_LINKAGE unsigned
5374clang_getCompletionNumAnnotations(CXCompletionString completion_string);
5375
5376/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005377 * Retrieve the annotation associated with the given completion string.
Erik Verbruggen98ea7f62011-10-14 15:31:08 +00005378 *
5379 * \param completion_string the completion string to query.
5380 *
5381 * \param annotation_number the 0-based index of the annotation of the
5382 * completion string.
5383 *
5384 * \returns annotation string associated with the completion at index
5385 * \c annotation_number, or a NULL string if that annotation is not available.
5386 */
Michael Kruse7520cf02020-03-25 09:26:14 -05005387CINDEX_LINKAGE CXString clang_getCompletionAnnotation(
5388 CXCompletionString completion_string, unsigned annotation_number);
Erik Verbruggen98ea7f62011-10-14 15:31:08 +00005389
5390/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005391 * Retrieve the parent context of the given completion string.
Douglas Gregor78254c82012-03-27 23:34:16 +00005392 *
Fangrui Song6907ce22018-07-30 19:24:48 +00005393 * The parent context of a completion string is the semantic parent of
Douglas Gregor78254c82012-03-27 23:34:16 +00005394 * the declaration (if any) that the code completion represents. For example,
5395 * a code completion for an Objective-C method would have the method's class
5396 * or protocol as its context.
5397 *
5398 * \param completion_string The code completion string whose parent is
5399 * being queried.
5400 *
Argyrios Kyrtzidis9ae39562012-09-26 16:39:56 +00005401 * \param kind DEPRECATED: always set to CXCursor_NotImplemented if non-NULL.
Douglas Gregor78254c82012-03-27 23:34:16 +00005402 *
James Dennett574cb4c2012-06-15 05:41:51 +00005403 * \returns The name of the completion parent, e.g., "NSObject" if
Douglas Gregor78254c82012-03-27 23:34:16 +00005404 * the completion string represents a method in the NSObject class.
5405 */
Michael Kruse7520cf02020-03-25 09:26:14 -05005406CINDEX_LINKAGE CXString clang_getCompletionParent(
5407 CXCompletionString completion_string, enum CXCursorKind *kind);
Dmitri Gribenko3292d062012-07-02 17:35:10 +00005408
5409/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005410 * Retrieve the brief documentation comment attached to the declaration
Dmitri Gribenko3292d062012-07-02 17:35:10 +00005411 * that corresponds to the given completion string.
5412 */
5413CINDEX_LINKAGE CXString
5414clang_getCompletionBriefComment(CXCompletionString completion_string);
5415
Douglas Gregor78254c82012-03-27 23:34:16 +00005416/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005417 * Retrieve a completion string for an arbitrary declaration or macro
Douglas Gregor3f35bb22011-08-04 20:04:59 +00005418 * definition cursor.
5419 *
5420 * \param cursor The cursor to query.
5421 *
5422 * \returns A non-context-sensitive completion string for declaration and macro
5423 * definition cursors, or NULL for other kinds of cursors.
5424 */
5425CINDEX_LINKAGE CXCompletionString
5426clang_getCursorCompletionString(CXCursor cursor);
Fangrui Song6907ce22018-07-30 19:24:48 +00005427
Douglas Gregor3f35bb22011-08-04 20:04:59 +00005428/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005429 * Contains the results of code-completion.
Douglas Gregorf72b6ac2009-12-18 16:20:58 +00005430 *
5431 * This data structure contains the results of code completion, as
Douglas Gregor6a9580282010-10-11 21:51:20 +00005432 * produced by \c clang_codeCompleteAt(). Its contents must be freed by
Douglas Gregorf72b6ac2009-12-18 16:20:58 +00005433 * \c clang_disposeCodeCompleteResults.
5434 */
5435typedef struct {
5436 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005437 * The code-completion results.
Douglas Gregorf72b6ac2009-12-18 16:20:58 +00005438 */
5439 CXCompletionResult *Results;
5440
5441 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005442 * The number of code-completion results stored in the
Douglas Gregorf72b6ac2009-12-18 16:20:58 +00005443 * \c Results array.
5444 */
5445 unsigned NumResults;
5446} CXCodeCompleteResults;
5447
5448/**
Ivan Donchevskii3957e482018-06-13 12:37:08 +00005449 * Retrieve the number of fix-its for the given completion index.
5450 *
5451 * Calling this makes sense only if CXCodeComplete_IncludeCompletionsWithFixIts
5452 * option was set.
5453 *
5454 * \param results The structure keeping all completion results
5455 *
5456 * \param completion_index The index of the completion
5457 *
5458 * \return The number of fix-its which must be applied before the completion at
5459 * completion_index can be applied
5460 */
5461CINDEX_LINKAGE unsigned
5462clang_getCompletionNumFixIts(CXCodeCompleteResults *results,
5463 unsigned completion_index);
5464
5465/**
5466 * Fix-its that *must* be applied before inserting the text for the
5467 * corresponding completion.
5468 *
5469 * By default, clang_codeCompleteAt() only returns completions with empty
5470 * fix-its. Extra completions with non-empty fix-its should be explicitly
5471 * requested by setting CXCodeComplete_IncludeCompletionsWithFixIts.
5472 *
5473 * For the clients to be able to compute position of the cursor after applying
5474 * fix-its, the following conditions are guaranteed to hold for
5475 * replacement_range of the stored fix-its:
5476 * - Ranges in the fix-its are guaranteed to never contain the completion
5477 * point (or identifier under completion point, if any) inside them, except
5478 * at the start or at the end of the range.
5479 * - If a fix-it range starts or ends with completion point (or starts or
5480 * ends after the identifier under completion point), it will contain at
5481 * least one character. It allows to unambiguously recompute completion
5482 * point after applying the fix-it.
5483 *
5484 * The intuition is that provided fix-its change code around the identifier we
5485 * complete, but are not allowed to touch the identifier itself or the
5486 * completion point. One example of completions with corrections are the ones
5487 * replacing '.' with '->' and vice versa:
5488 *
5489 * std::unique_ptr<std::vector<int>> vec_ptr;
5490 * In 'vec_ptr.^', one of the completions is 'push_back', it requires
5491 * replacing '.' with '->'.
5492 * In 'vec_ptr->^', one of the completions is 'release', it requires
5493 * replacing '->' with '.'.
5494 *
5495 * \param results The structure keeping all completion results
5496 *
5497 * \param completion_index The index of the completion
5498 *
5499 * \param fixit_index The index of the fix-it for the completion at
5500 * completion_index
5501 *
5502 * \param replacement_range The fix-it range that must be replaced before the
5503 * completion at completion_index can be applied
5504 *
5505 * \returns The fix-it string that must replace the code at replacement_range
5506 * before the completion at completion_index can be applied
5507 */
5508CINDEX_LINKAGE CXString clang_getCompletionFixIt(
5509 CXCodeCompleteResults *results, unsigned completion_index,
5510 unsigned fixit_index, CXSourceRange *replacement_range);
5511
5512/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005513 * Flags that can be passed to \c clang_codeCompleteAt() to
Douglas Gregorb68bc592010-08-05 09:09:23 +00005514 * modify its behavior.
5515 *
5516 * The enumerators in this enumeration can be bitwise-OR'd together to
5517 * provide multiple options to \c clang_codeCompleteAt().
5518 */
5519enum CXCodeComplete_Flags {
5520 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005521 * Whether to include macros within the set of code
Douglas Gregorb68bc592010-08-05 09:09:23 +00005522 * completions returned.
5523 */
5524 CXCodeComplete_IncludeMacros = 0x01,
5525
5526 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005527 * Whether to include code patterns for language constructs
Douglas Gregorb68bc592010-08-05 09:09:23 +00005528 * within the set of code completions, e.g., for loops.
5529 */
Dmitri Gribenko3292d062012-07-02 17:35:10 +00005530 CXCodeComplete_IncludeCodePatterns = 0x02,
5531
5532 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005533 * Whether to include brief documentation within the set of code
Dmitri Gribenko3292d062012-07-02 17:35:10 +00005534 * completions returned.
5535 */
Sam McCallbb2cf632018-01-12 14:51:47 +00005536 CXCodeComplete_IncludeBriefComments = 0x04,
5537
5538 /**
Sam McCallabdcc612018-01-24 17:50:20 +00005539 * Whether to speed up completion by omitting top- or namespace-level entities
5540 * defined in the preamble. There's no guarantee any particular entity is
5541 * omitted. This may be useful if the headers are indexed externally.
Sam McCallbb2cf632018-01-12 14:51:47 +00005542 */
Ivan Donchevskii3957e482018-06-13 12:37:08 +00005543 CXCodeComplete_SkipPreamble = 0x08,
5544
5545 /**
5546 * Whether to include completions with small
5547 * fix-its, e.g. change '.' to '->' on member access, etc.
5548 */
5549 CXCodeComplete_IncludeCompletionsWithFixIts = 0x10
Douglas Gregorb68bc592010-08-05 09:09:23 +00005550};
5551
5552/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005553 * Bits that represent the context under which completion is occurring.
Douglas Gregor21325842011-07-07 16:03:39 +00005554 *
5555 * The enumerators in this enumeration may be bitwise-OR'd together if multiple
5556 * contexts are occurring simultaneously.
5557 */
5558enum CXCompletionContext {
5559 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005560 * The context for completions is unexposed, as only Clang results
Douglas Gregor21325842011-07-07 16:03:39 +00005561 * should be included. (This is equivalent to having no context bits set.)
5562 */
5563 CXCompletionContext_Unexposed = 0,
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 any possible type should be included in the results.
Douglas Gregor21325842011-07-07 16:03:39 +00005567 */
5568 CXCompletionContext_AnyType = 1 << 0,
Fangrui Song6907ce22018-07-30 19:24:48 +00005569
Douglas Gregor21325842011-07-07 16:03:39 +00005570 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005571 * Completions for any possible value (variables, function calls, etc.)
Douglas Gregor21325842011-07-07 16:03:39 +00005572 * should be included in the results.
5573 */
5574 CXCompletionContext_AnyValue = 1 << 1,
5575 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005576 * Completions for values that resolve to an Objective-C object should
Douglas Gregor21325842011-07-07 16:03:39 +00005577 * be included in the results.
5578 */
5579 CXCompletionContext_ObjCObjectValue = 1 << 2,
5580 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005581 * Completions for values that resolve to an Objective-C selector
Douglas Gregor21325842011-07-07 16:03:39 +00005582 * should be included in the results.
5583 */
5584 CXCompletionContext_ObjCSelectorValue = 1 << 3,
5585 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005586 * Completions for values that resolve to a C++ class type should be
Douglas Gregor21325842011-07-07 16:03:39 +00005587 * included in the results.
5588 */
5589 CXCompletionContext_CXXClassTypeValue = 1 << 4,
Fangrui Song6907ce22018-07-30 19:24:48 +00005590
Douglas Gregor21325842011-07-07 16:03:39 +00005591 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005592 * Completions for fields of the member being accessed using the dot
Douglas Gregor21325842011-07-07 16:03:39 +00005593 * operator should be included in the results.
5594 */
5595 CXCompletionContext_DotMemberAccess = 1 << 5,
5596 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005597 * Completions for fields of the member being accessed using the arrow
Douglas Gregor21325842011-07-07 16:03:39 +00005598 * operator should be included in the results.
5599 */
5600 CXCompletionContext_ArrowMemberAccess = 1 << 6,
5601 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005602 * Completions for properties of the Objective-C object being accessed
Douglas Gregor21325842011-07-07 16:03:39 +00005603 * using the dot operator should be included in the results.
5604 */
5605 CXCompletionContext_ObjCPropertyAccess = 1 << 7,
Fangrui Song6907ce22018-07-30 19:24:48 +00005606
Douglas Gregor21325842011-07-07 16:03:39 +00005607 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005608 * Completions for enum tags should be included in the results.
Douglas Gregor21325842011-07-07 16:03:39 +00005609 */
5610 CXCompletionContext_EnumTag = 1 << 8,
5611 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005612 * Completions for union tags should be included in the results.
Douglas Gregor21325842011-07-07 16:03:39 +00005613 */
5614 CXCompletionContext_UnionTag = 1 << 9,
5615 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005616 * Completions for struct tags should be included in the results.
Douglas Gregor21325842011-07-07 16:03:39 +00005617 */
5618 CXCompletionContext_StructTag = 1 << 10,
Fangrui Song6907ce22018-07-30 19:24:48 +00005619
Douglas Gregor21325842011-07-07 16:03:39 +00005620 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005621 * Completions for C++ class names should be included in the results.
Douglas Gregor21325842011-07-07 16:03:39 +00005622 */
5623 CXCompletionContext_ClassTag = 1 << 11,
5624 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005625 * Completions for C++ namespaces and namespace aliases should be
Douglas Gregor21325842011-07-07 16:03:39 +00005626 * included in the results.
5627 */
5628 CXCompletionContext_Namespace = 1 << 12,
5629 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005630 * Completions for C++ nested name specifiers should be included in
Douglas Gregor21325842011-07-07 16:03:39 +00005631 * the results.
5632 */
5633 CXCompletionContext_NestedNameSpecifier = 1 << 13,
Fangrui Song6907ce22018-07-30 19:24:48 +00005634
Douglas Gregor21325842011-07-07 16:03:39 +00005635 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005636 * Completions for Objective-C interfaces (classes) should be included
Douglas Gregor21325842011-07-07 16:03:39 +00005637 * in the results.
5638 */
5639 CXCompletionContext_ObjCInterface = 1 << 14,
5640 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005641 * Completions for Objective-C protocols should be included in
Douglas Gregor21325842011-07-07 16:03:39 +00005642 * the results.
5643 */
5644 CXCompletionContext_ObjCProtocol = 1 << 15,
5645 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005646 * Completions for Objective-C categories should be included in
Douglas Gregor21325842011-07-07 16:03:39 +00005647 * the results.
5648 */
5649 CXCompletionContext_ObjCCategory = 1 << 16,
5650 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005651 * Completions for Objective-C instance messages should be included
Douglas Gregor21325842011-07-07 16:03:39 +00005652 * in the results.
5653 */
5654 CXCompletionContext_ObjCInstanceMessage = 1 << 17,
5655 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005656 * Completions for Objective-C class messages should be included in
Douglas Gregor21325842011-07-07 16:03:39 +00005657 * the results.
5658 */
5659 CXCompletionContext_ObjCClassMessage = 1 << 18,
5660 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005661 * Completions for Objective-C selector names should be included in
Douglas Gregor21325842011-07-07 16:03:39 +00005662 * the results.
5663 */
5664 CXCompletionContext_ObjCSelectorName = 1 << 19,
Fangrui Song6907ce22018-07-30 19:24:48 +00005665
Douglas Gregor21325842011-07-07 16:03:39 +00005666 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005667 * Completions for preprocessor macro names should be included in
Douglas Gregor21325842011-07-07 16:03:39 +00005668 * the results.
5669 */
5670 CXCompletionContext_MacroName = 1 << 20,
Fangrui Song6907ce22018-07-30 19:24:48 +00005671
Douglas Gregor21325842011-07-07 16:03:39 +00005672 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005673 * Natural language completions should be included in the results.
Douglas Gregor21325842011-07-07 16:03:39 +00005674 */
5675 CXCompletionContext_NaturalLanguage = 1 << 21,
Fangrui Song6907ce22018-07-30 19:24:48 +00005676
Douglas Gregor21325842011-07-07 16:03:39 +00005677 /**
Sam McCall3d8051a2018-09-18 08:40:41 +00005678 * #include file completions should be included in the results.
5679 */
5680 CXCompletionContext_IncludedFile = 1 << 22,
5681
5682 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005683 * The current context is unknown, so set all contexts.
Douglas Gregor21325842011-07-07 16:03:39 +00005684 */
Sam McCall3d8051a2018-09-18 08:40:41 +00005685 CXCompletionContext_Unknown = ((1 << 23) - 1)
Douglas Gregor21325842011-07-07 16:03:39 +00005686};
Fangrui Song6907ce22018-07-30 19:24:48 +00005687
Douglas Gregor21325842011-07-07 16:03:39 +00005688/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005689 * Returns a default set of code-completion options that can be
Fangrui Song6907ce22018-07-30 19:24:48 +00005690 * passed to\c clang_codeCompleteAt().
Douglas Gregorb68bc592010-08-05 09:09:23 +00005691 */
5692CINDEX_LINKAGE unsigned clang_defaultCodeCompleteOptions(void);
5693
5694/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005695 * Perform code completion at a given location in a translation unit.
Douglas Gregor8e984da2010-08-04 16:47:14 +00005696 *
5697 * This function performs code completion at a particular file, line, and
5698 * column within source code, providing results that suggest potential
5699 * code snippets based on the context of the completion. The basic model
5700 * for code completion is that Clang will parse a complete source file,
5701 * performing syntax checking up to the location where code-completion has
5702 * been requested. At that point, a special code-completion token is passed
5703 * to the parser, which recognizes this token and determines, based on the
5704 * current location in the C/Objective-C/C++ grammar and the state of
5705 * semantic analysis, what completions to provide. These completions are
5706 * returned via a new \c CXCodeCompleteResults structure.
5707 *
5708 * Code completion itself is meant to be triggered by the client when the
5709 * user types punctuation characters or whitespace, at which point the
5710 * code-completion location will coincide with the cursor. For example, if \c p
5711 * is a pointer, code-completion might be triggered after the "-" and then
Alexander Kornienko2a8c18d2018-04-06 15:14:32 +00005712 * after the ">" in \c p->. When the code-completion location is after the ">",
Douglas Gregor8e984da2010-08-04 16:47:14 +00005713 * the completion results will provide, e.g., the members of the struct that
5714 * "p" points to. The client is responsible for placing the cursor at the
5715 * beginning of the token currently being typed, then filtering the results
5716 * based on the contents of the token. For example, when code-completing for
5717 * the expression \c p->get, the client should provide the location just after
5718 * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the
5719 * client can filter the results based on the current token text ("get"), only
5720 * showing those results that start with "get". The intent of this interface
5721 * is to separate the relatively high-latency acquisition of code-completion
5722 * results from the filtering of results on a per-character basis, which must
5723 * have a lower latency.
5724 *
5725 * \param TU The translation unit in which code-completion should
5726 * occur. The source files for this translation unit need not be
5727 * completely up-to-date (and the contents of those source files may
5728 * be overridden via \p unsaved_files). Cursors referring into the
5729 * translation unit may be invalidated by this invocation.
5730 *
5731 * \param complete_filename The name of the source file where code
5732 * completion should be performed. This filename may be any file
5733 * included in the translation unit.
5734 *
5735 * \param complete_line The line at which code-completion should occur.
5736 *
5737 * \param complete_column The column at which code-completion should occur.
5738 * Note that the column should point just after the syntactic construct that
5739 * initiated code completion, and not in the middle of a lexical token.
5740 *
Vedant Kumarcbfe7bb2016-03-23 23:51:36 +00005741 * \param unsaved_files the Files that have not yet been saved to disk
Douglas Gregor8e984da2010-08-04 16:47:14 +00005742 * but may be required for parsing or code completion, including the
5743 * contents of those files. The contents and name of these files (as
5744 * specified by CXUnsavedFile) are copied when necessary, so the
5745 * client only needs to guarantee their validity until the call to
5746 * this function returns.
5747 *
5748 * \param num_unsaved_files The number of unsaved file entries in \p
5749 * unsaved_files.
5750 *
Douglas Gregorb68bc592010-08-05 09:09:23 +00005751 * \param options Extra options that control the behavior of code
5752 * completion, expressed as a bitwise OR of the enumerators of the
Fangrui Song6907ce22018-07-30 19:24:48 +00005753 * CXCodeComplete_Flags enumeration. The
Douglas Gregorb68bc592010-08-05 09:09:23 +00005754 * \c clang_defaultCodeCompleteOptions() function returns a default set
5755 * of code-completion options.
5756 *
Douglas Gregor8e984da2010-08-04 16:47:14 +00005757 * \returns If successful, a new \c CXCodeCompleteResults structure
5758 * containing code-completion results, which should eventually be
5759 * freed with \c clang_disposeCodeCompleteResults(). If code
5760 * completion fails, returns NULL.
5761 */
5762CINDEX_LINKAGE
Michael Kruse7520cf02020-03-25 09:26:14 -05005763CXCodeCompleteResults *
5764clang_codeCompleteAt(CXTranslationUnit TU, const char *complete_filename,
5765 unsigned complete_line, unsigned complete_column,
5766 struct CXUnsavedFile *unsaved_files,
5767 unsigned num_unsaved_files, unsigned options);
Douglas Gregor8e984da2010-08-04 16:47:14 +00005768
5769/**
Fangrui Song6907ce22018-07-30 19:24:48 +00005770 * Sort the code-completion results in case-insensitive alphabetical
Douglas Gregor49f67ce2010-08-26 13:48:20 +00005771 * order.
5772 *
5773 * \param Results The set of results to sort.
5774 * \param NumResults The number of results in \p Results.
5775 */
5776CINDEX_LINKAGE
5777void clang_sortCodeCompletionResults(CXCompletionResult *Results,
5778 unsigned NumResults);
Fangrui Song6907ce22018-07-30 19:24:48 +00005779
Douglas Gregor49f67ce2010-08-26 13:48:20 +00005780/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005781 * Free the given set of code-completion results.
Douglas Gregorf72b6ac2009-12-18 16:20:58 +00005782 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005783CINDEX_LINKAGE
Douglas Gregorf72b6ac2009-12-18 16:20:58 +00005784void clang_disposeCodeCompleteResults(CXCodeCompleteResults *Results);
Fangrui Song6907ce22018-07-30 19:24:48 +00005785
Douglas Gregor52606ff2010-01-20 01:10:47 +00005786/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005787 * Determine the number of diagnostics produced prior to the
Douglas Gregor33cdd812010-02-18 18:08:43 +00005788 * location where code completion was performed.
5789 */
Ted Kremenekd071c602010-03-13 02:50:34 +00005790CINDEX_LINKAGE
Douglas Gregor33cdd812010-02-18 18:08:43 +00005791unsigned clang_codeCompleteGetNumDiagnostics(CXCodeCompleteResults *Results);
5792
5793/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005794 * Retrieve a diagnostic associated with the given code completion.
Douglas Gregor33cdd812010-02-18 18:08:43 +00005795 *
James Dennett574cb4c2012-06-15 05:41:51 +00005796 * \param Results the code completion results to query.
Douglas Gregor33cdd812010-02-18 18:08:43 +00005797 * \param Index the zero-based diagnostic number to retrieve.
5798 *
5799 * \returns the requested diagnostic. This diagnostic must be freed
5800 * via a call to \c clang_disposeDiagnostic().
5801 */
Ted Kremenekd071c602010-03-13 02:50:34 +00005802CINDEX_LINKAGE
Douglas Gregor33cdd812010-02-18 18:08:43 +00005803CXDiagnostic clang_codeCompleteGetDiagnostic(CXCodeCompleteResults *Results,
5804 unsigned Index);
5805
5806/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005807 * Determines what completions are appropriate for the context
Douglas Gregor21325842011-07-07 16:03:39 +00005808 * the given code completion.
Fangrui Song6907ce22018-07-30 19:24:48 +00005809 *
Douglas Gregor21325842011-07-07 16:03:39 +00005810 * \param Results the code completion results to query
5811 *
5812 * \returns the kinds of completions that are appropriate for use
5813 * along with the given code completion results.
5814 */
5815CINDEX_LINKAGE
Michael Kruse7520cf02020-03-25 09:26:14 -05005816unsigned long long
5817clang_codeCompleteGetContexts(CXCodeCompleteResults *Results);
Douglas Gregor63745d52011-07-21 01:05:26 +00005818
5819/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005820 * Returns the cursor kind for the container for the current code
Douglas Gregor63745d52011-07-21 01:05:26 +00005821 * completion context. The container is only guaranteed to be set for
5822 * contexts where a container exists (i.e. member accesses or Objective-C
5823 * message sends); if there is not a container, this function will return
5824 * CXCursor_InvalidCode.
5825 *
5826 * \param Results the code completion results to query
5827 *
5828 * \param IsIncomplete on return, this value will be false if Clang has complete
5829 * information about the container. If Clang does not have complete
5830 * information, this value will be true.
5831 *
5832 * \returns the container kind, or CXCursor_InvalidCode if there is not a
5833 * container
5834 */
5835CINDEX_LINKAGE
Michael Kruse7520cf02020-03-25 09:26:14 -05005836enum CXCursorKind
5837clang_codeCompleteGetContainerKind(CXCodeCompleteResults *Results,
5838 unsigned *IsIncomplete);
Douglas Gregor63745d52011-07-21 01:05:26 +00005839
5840/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005841 * Returns the USR for the container for the current code completion
Douglas Gregor63745d52011-07-21 01:05:26 +00005842 * context. If there is not a container for the current context, this
5843 * function will return the empty string.
5844 *
5845 * \param Results the code completion results to query
5846 *
5847 * \returns the USR for the container
5848 */
5849CINDEX_LINKAGE
5850CXString clang_codeCompleteGetContainerUSR(CXCodeCompleteResults *Results);
NAKAMURA Takumiaa13f942015-12-09 07:52:46 +00005851
Douglas Gregorea777402011-07-26 15:24:30 +00005852/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005853 * Returns the currently-entered selector for an Objective-C message
Douglas Gregorea777402011-07-26 15:24:30 +00005854 * send, formatted like "initWithFoo:bar:". Only guaranteed to return a
5855 * non-empty string for CXCompletionContext_ObjCInstanceMessage and
5856 * CXCompletionContext_ObjCClassMessage.
5857 *
5858 * \param Results the code completion results to query
5859 *
5860 * \returns the selector (or partial selector) that has been entered thus far
5861 * for an Objective-C message send.
5862 */
5863CINDEX_LINKAGE
5864CXString clang_codeCompleteGetObjCSelector(CXCodeCompleteResults *Results);
Fangrui Song6907ce22018-07-30 19:24:48 +00005865
Douglas Gregor21325842011-07-07 16:03:39 +00005866/**
Douglas Gregor52606ff2010-01-20 01:10:47 +00005867 * @}
5868 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005869
Ted Kremenekc0f3f722010-01-22 22:44:15 +00005870/**
5871 * \defgroup CINDEX_MISC Miscellaneous utility functions
5872 *
5873 * @{
5874 */
Ted Kremenek3e315a22010-01-23 17:51:23 +00005875
5876/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005877 * Return a version string, suitable for showing to a user, but not
Ted Kremenek3e315a22010-01-23 17:51:23 +00005878 * intended to be parsed (the format is not guaranteed to be stable).
5879 */
NAKAMURA Takumieacd6672013-01-10 02:12:38 +00005880CINDEX_LINKAGE CXString clang_getClangVersion(void);
Ted Kremenekc0f3f722010-01-22 22:44:15 +00005881
Ted Kremenek1ec7b332011-03-18 23:05:39 +00005882/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005883 * Enable/disable crash recovery.
Ted Kremenek1ec7b332011-03-18 23:05:39 +00005884 *
James Dennett574cb4c2012-06-15 05:41:51 +00005885 * \param isEnabled Flag to indicate if crash recovery is enabled. A non-zero
5886 * value enables crash recovery, while 0 disables it.
Ted Kremenek1ec7b332011-03-18 23:05:39 +00005887 */
5888CINDEX_LINKAGE void clang_toggleCrashRecovery(unsigned isEnabled);
Fangrui Song6907ce22018-07-30 19:24:48 +00005889
Michael Kruse7520cf02020-03-25 09:26:14 -05005890/**
5891 * Visitor invoked for each file in a translation unit
5892 * (used with clang_getInclusions()).
5893 *
5894 * This visitor function will be invoked by clang_getInclusions() for each
5895 * file included (either at the top-level or by \#include directives) within
5896 * a translation unit. The first argument is the file being included, and
5897 * the second and third arguments provide the inclusion stack. The
5898 * array is sorted in order of immediate inclusion. For example,
5899 * the first element refers to the location that included 'included_file'.
5900 */
Ted Kremenek0b86e3a2010-01-26 19:31:51 +00005901typedef void (*CXInclusionVisitor)(CXFile included_file,
Michael Kruse7520cf02020-03-25 09:26:14 -05005902 CXSourceLocation *inclusion_stack,
Ted Kremenek0b86e3a2010-01-26 19:31:51 +00005903 unsigned include_len,
5904 CXClientData client_data);
5905
5906/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005907 * Visit the set of preprocessor inclusions in a translation unit.
Ted Kremenek0b86e3a2010-01-26 19:31:51 +00005908 * The visitor function is called with the provided data for every included
5909 * file. This does not include headers included by the PCH file (unless one
5910 * is inspecting the inclusions in the PCH file itself).
5911 */
5912CINDEX_LINKAGE void clang_getInclusions(CXTranslationUnit tu,
5913 CXInclusionVisitor visitor,
5914 CXClientData client_data);
5915
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005916typedef enum {
Michael Kruse7520cf02020-03-25 09:26:14 -05005917 CXEval_Int = 1,
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005918 CXEval_Float = 2,
5919 CXEval_ObjCStrLiteral = 3,
5920 CXEval_StrLiteral = 4,
5921 CXEval_CFStr = 5,
5922 CXEval_Other = 6,
5923
5924 CXEval_UnExposed = 0
5925
Michael Kruse7520cf02020-03-25 09:26:14 -05005926} CXEvalResultKind;
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005927
5928/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005929 * Evaluation result of a cursor
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005930 */
Michael Kruse7520cf02020-03-25 09:26:14 -05005931typedef void *CXEvalResult;
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005932
5933/**
Fangrui Song6907ce22018-07-30 19:24:48 +00005934 * If cursor is a statement declaration tries to evaluate the
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005935 * statement and if its variable, tries to evaluate its initializer,
5936 * into its corresponding type.
5937 */
5938CINDEX_LINKAGE CXEvalResult clang_Cursor_Evaluate(CXCursor C);
5939
5940/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005941 * Returns the kind of the evaluated result.
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005942 */
Argyrios Kyrtzidisa851d7e2016-01-16 03:01:20 +00005943CINDEX_LINKAGE CXEvalResultKind clang_EvalResult_getKind(CXEvalResult E);
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005944
5945/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005946 * Returns the evaluation result as integer if the
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005947 * kind is Int.
5948 */
Argyrios Kyrtzidisa851d7e2016-01-16 03:01:20 +00005949CINDEX_LINKAGE int clang_EvalResult_getAsInt(CXEvalResult E);
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005950
5951/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005952 * Returns the evaluation result as a long long integer if the
Argyrios Kyrtzidis5dda1122016-12-01 23:41:27 +00005953 * kind is Int. This prevents overflows that may happen if the result is
5954 * returned with clang_EvalResult_getAsInt.
5955 */
5956CINDEX_LINKAGE long long clang_EvalResult_getAsLongLong(CXEvalResult E);
5957
5958/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005959 * Returns a non-zero value if the kind is Int and the evaluation
Argyrios Kyrtzidis5dda1122016-12-01 23:41:27 +00005960 * result resulted in an unsigned integer.
5961 */
5962CINDEX_LINKAGE unsigned clang_EvalResult_isUnsignedInt(CXEvalResult E);
5963
5964/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005965 * Returns the evaluation result as an unsigned integer if
Argyrios Kyrtzidis5dda1122016-12-01 23:41:27 +00005966 * the kind is Int and clang_EvalResult_isUnsignedInt is non-zero.
5967 */
Michael Kruse7520cf02020-03-25 09:26:14 -05005968CINDEX_LINKAGE unsigned long long
5969clang_EvalResult_getAsUnsigned(CXEvalResult E);
Argyrios Kyrtzidis5dda1122016-12-01 23:41:27 +00005970
5971/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005972 * Returns the evaluation result as double if the
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005973 * kind is double.
5974 */
Argyrios Kyrtzidisa851d7e2016-01-16 03:01:20 +00005975CINDEX_LINKAGE double clang_EvalResult_getAsDouble(CXEvalResult E);
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005976
5977/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005978 * Returns the evaluation result as a constant string if the
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005979 * kind is other than Int or float. User must not free this pointer,
5980 * instead call clang_EvalResult_dispose on the CXEvalResult returned
5981 * by clang_Cursor_Evaluate.
5982 */
Michael Kruse7520cf02020-03-25 09:26:14 -05005983CINDEX_LINKAGE const char *clang_EvalResult_getAsStr(CXEvalResult E);
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005984
5985/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005986 * Disposes the created Eval memory.
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005987 */
Argyrios Kyrtzidisa851d7e2016-01-16 03:01:20 +00005988CINDEX_LINKAGE void clang_EvalResult_dispose(CXEvalResult E);
Ted Kremenek0b86e3a2010-01-26 19:31:51 +00005989/**
Ted Kremenekc0f3f722010-01-22 22:44:15 +00005990 * @}
5991 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005992
Argyrios Kyrtzidisf89cc692011-07-11 20:15:00 +00005993/** \defgroup CINDEX_REMAPPING Remapping functions
5994 *
5995 * @{
5996 */
5997
5998/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005999 * A remapping of original source files and their translated files.
Argyrios Kyrtzidisf89cc692011-07-11 20:15:00 +00006000 */
6001typedef void *CXRemapping;
6002
6003/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006004 * Retrieve a remapping.
Argyrios Kyrtzidisf89cc692011-07-11 20:15:00 +00006005 *
6006 * \param path the path that contains metadata about remappings.
6007 *
6008 * \returns the requested remapping. This remapping must be freed
6009 * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
6010 */
6011CINDEX_LINKAGE CXRemapping clang_getRemappings(const char *path);
6012
6013/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006014 * Retrieve a remapping.
Ted Kremenekf7639e12012-03-06 20:06:33 +00006015 *
6016 * \param filePaths pointer to an array of file paths containing remapping info.
6017 *
6018 * \param numFiles number of file paths.
6019 *
6020 * \returns the requested remapping. This remapping must be freed
6021 * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
6022 */
6023CINDEX_LINKAGE
6024CXRemapping clang_getRemappingsFromFileList(const char **filePaths,
6025 unsigned numFiles);
6026
6027/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006028 * Determine the number of remappings.
Argyrios Kyrtzidisf89cc692011-07-11 20:15:00 +00006029 */
6030CINDEX_LINKAGE unsigned clang_remap_getNumFiles(CXRemapping);
6031
6032/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006033 * Get the original and the associated filename from the remapping.
Fangrui Song6907ce22018-07-30 19:24:48 +00006034 *
Argyrios Kyrtzidisf89cc692011-07-11 20:15:00 +00006035 * \param original If non-NULL, will be set to the original filename.
6036 *
6037 * \param transformed If non-NULL, will be set to the filename that the original
6038 * is associated with.
6039 */
6040CINDEX_LINKAGE void clang_remap_getFilenames(CXRemapping, unsigned index,
Michael Kruse7520cf02020-03-25 09:26:14 -05006041 CXString *original,
6042 CXString *transformed);
Argyrios Kyrtzidisf89cc692011-07-11 20:15:00 +00006043
6044/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006045 * Dispose the remapping.
Argyrios Kyrtzidisf89cc692011-07-11 20:15:00 +00006046 */
6047CINDEX_LINKAGE void clang_remap_dispose(CXRemapping);
6048
6049/**
6050 * @}
6051 */
6052
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00006053/** \defgroup CINDEX_HIGH Higher level API functions
6054 *
6055 * @{
6056 */
6057
Michael Kruse7520cf02020-03-25 09:26:14 -05006058enum CXVisitorResult { CXVisit_Break, CXVisit_Continue };
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00006059
Saleem Abdulrasoolec988b72016-05-24 01:23:24 +00006060typedef struct CXCursorAndRangeVisitor {
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00006061 void *context;
6062 enum CXVisitorResult (*visit)(void *context, CXCursor, CXSourceRange);
6063} CXCursorAndRangeVisitor;
6064
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00006065typedef enum {
6066 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006067 * Function returned successfully.
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00006068 */
6069 CXResult_Success = 0,
6070 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006071 * One of the parameters was invalid for the function.
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00006072 */
6073 CXResult_Invalid = 1,
6074 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006075 * The function was terminated by a callback (e.g. it returned
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00006076 * CXVisit_Break)
6077 */
6078 CXResult_VisitBreak = 2
6079
6080} CXResult;
6081
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00006082/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006083 * Find references of a declaration in a specific file.
Fangrui Song6907ce22018-07-30 19:24:48 +00006084 *
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00006085 * \param cursor pointing to a declaration or a reference of one.
6086 *
6087 * \param file to search for references.
6088 *
6089 * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
6090 * each reference found.
6091 * The CXSourceRange will point inside the file; if the reference is inside
6092 * a macro (and not a macro argument) the CXSourceRange will be invalid.
Argyrios Kyrtzidis951f61f2013-03-08 20:42:33 +00006093 *
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00006094 * \returns one of the CXResult enumerators.
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00006095 */
Michael Kruse7520cf02020-03-25 09:26:14 -05006096CINDEX_LINKAGE CXResult clang_findReferencesInFile(
6097 CXCursor cursor, CXFile file, CXCursorAndRangeVisitor visitor);
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00006098
Argyrios Kyrtzidis503c83a2013-03-08 02:32:34 +00006099/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006100 * Find #import/#include directives in a specific file.
Argyrios Kyrtzidis503c83a2013-03-08 02:32:34 +00006101 *
6102 * \param TU translation unit containing the file to query.
6103 *
6104 * \param file to search for #import/#include directives.
6105 *
6106 * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
6107 * each directive found.
Argyrios Kyrtzidis951f61f2013-03-08 20:42:33 +00006108 *
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00006109 * \returns one of the CXResult enumerators.
Argyrios Kyrtzidis503c83a2013-03-08 02:32:34 +00006110 */
Michael Kruse7520cf02020-03-25 09:26:14 -05006111CINDEX_LINKAGE CXResult clang_findIncludesInFile(
6112 CXTranslationUnit TU, CXFile file, CXCursorAndRangeVisitor visitor);
Argyrios Kyrtzidis503c83a2013-03-08 02:32:34 +00006113
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00006114#ifdef __has_feature
Michael Kruse7520cf02020-03-25 09:26:14 -05006115#if __has_feature(blocks)
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00006116
Michael Kruse7520cf02020-03-25 09:26:14 -05006117typedef enum CXVisitorResult (^CXCursorAndRangeVisitorBlock)(CXCursor,
6118 CXSourceRange);
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00006119
6120CINDEX_LINKAGE
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00006121CXResult clang_findReferencesInFileWithBlock(CXCursor, CXFile,
6122 CXCursorAndRangeVisitorBlock);
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00006123
Argyrios Kyrtzidis503c83a2013-03-08 02:32:34 +00006124CINDEX_LINKAGE
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00006125CXResult clang_findIncludesInFileWithBlock(CXTranslationUnit, CXFile,
6126 CXCursorAndRangeVisitorBlock);
Argyrios Kyrtzidis503c83a2013-03-08 02:32:34 +00006127
Michael Kruse7520cf02020-03-25 09:26:14 -05006128#endif
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00006129#endif
6130
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006131/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006132 * The client's data object that is associated with a CXFile.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006133 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006134typedef void *CXIdxClientFile;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006135
6136/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006137 * The client's data object that is associated with a semantic entity.
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006138 */
6139typedef void *CXIdxClientEntity;
6140
6141/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006142 * The client's data object that is associated with a semantic container
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006143 * of entities.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006144 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006145typedef void *CXIdxClientContainer;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006146
6147/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006148 * The client's data object that is associated with an AST file (PCH
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006149 * or module).
6150 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006151typedef void *CXIdxClientASTFile;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006152
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006153/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006154 * Source location passed to index callbacks.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006155 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006156typedef struct {
6157 void *ptr_data[2];
6158 unsigned int_data;
6159} CXIdxLoc;
6160
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006161/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006162 * Data for ppIncludedFile callback.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006163 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006164typedef struct {
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006165 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006166 * Location of '#' in the \#include/\#import directive.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006167 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006168 CXIdxLoc hashLoc;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006169 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006170 * Filename as written in the \#include/\#import directive.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006171 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006172 const char *filename;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006173 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006174 * The actual file that the \#include/\#import directive resolved to.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006175 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006176 CXFile file;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006177 int isImport;
6178 int isAngled;
Argyrios Kyrtzidis5e2ec482012-10-18 00:17:05 +00006179 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006180 * Non-zero if the directive was automatically turned into a module
Argyrios Kyrtzidis5e2ec482012-10-18 00:17:05 +00006181 * import.
6182 */
6183 int isModuleImport;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006184} CXIdxIncludedFileInfo;
6185
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006186/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006187 * Data for IndexerCallbacks#importedASTFile.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006188 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006189typedef struct {
Argyrios Kyrtzidis472eda02012-10-02 16:10:38 +00006190 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006191 * Top level AST file containing the imported PCH, module or submodule.
Argyrios Kyrtzidis472eda02012-10-02 16:10:38 +00006192 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006193 CXFile file;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006194 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006195 * The imported module or NULL if the AST file is a PCH.
Argyrios Kyrtzidisdc78f3e2012-10-05 00:22:40 +00006196 */
6197 CXModule module;
6198 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006199 * Location where the file is imported. Applicable only for modules.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006200 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006201 CXIdxLoc loc;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006202 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006203 * Non-zero if an inclusion directive was automatically turned into
Argyrios Kyrtzidisdc78f3e2012-10-05 00:22:40 +00006204 * a module import. Applicable only for modules.
Argyrios Kyrtzidis472eda02012-10-02 16:10:38 +00006205 */
Argyrios Kyrtzidis184b1442012-10-03 21:05:44 +00006206 int isImplicit;
Argyrios Kyrtzidis472eda02012-10-02 16:10:38 +00006207
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006208} CXIdxImportedASTFileInfo;
6209
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006210typedef enum {
Michael Kruse7520cf02020-03-25 09:26:14 -05006211 CXIdxEntity_Unexposed = 0,
6212 CXIdxEntity_Typedef = 1,
6213 CXIdxEntity_Function = 2,
6214 CXIdxEntity_Variable = 3,
6215 CXIdxEntity_Field = 4,
6216 CXIdxEntity_EnumConstant = 5,
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006217
Michael Kruse7520cf02020-03-25 09:26:14 -05006218 CXIdxEntity_ObjCClass = 6,
6219 CXIdxEntity_ObjCProtocol = 7,
6220 CXIdxEntity_ObjCCategory = 8,
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006221
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00006222 CXIdxEntity_ObjCInstanceMethod = 9,
Michael Kruse7520cf02020-03-25 09:26:14 -05006223 CXIdxEntity_ObjCClassMethod = 10,
6224 CXIdxEntity_ObjCProperty = 11,
6225 CXIdxEntity_ObjCIvar = 12,
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006226
Michael Kruse7520cf02020-03-25 09:26:14 -05006227 CXIdxEntity_Enum = 13,
6228 CXIdxEntity_Struct = 14,
6229 CXIdxEntity_Union = 15,
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006230
Michael Kruse7520cf02020-03-25 09:26:14 -05006231 CXIdxEntity_CXXClass = 16,
6232 CXIdxEntity_CXXNamespace = 17,
6233 CXIdxEntity_CXXNamespaceAlias = 18,
6234 CXIdxEntity_CXXStaticVariable = 19,
6235 CXIdxEntity_CXXStaticMethod = 20,
6236 CXIdxEntity_CXXInstanceMethod = 21,
6237 CXIdxEntity_CXXConstructor = 22,
6238 CXIdxEntity_CXXDestructor = 23,
Joao Matose9a3ed42012-08-31 22:18:20 +00006239 CXIdxEntity_CXXConversionFunction = 24,
Michael Kruse7520cf02020-03-25 09:26:14 -05006240 CXIdxEntity_CXXTypeAlias = 25,
6241 CXIdxEntity_CXXInterface = 26
Joao Matose9a3ed42012-08-31 22:18:20 +00006242
6243} CXIdxEntityKind;
6244
Argyrios Kyrtzidis52002882011-12-07 20:44:12 +00006245typedef enum {
6246 CXIdxEntityLang_None = 0,
Michael Kruse7520cf02020-03-25 09:26:14 -05006247 CXIdxEntityLang_C = 1,
Argyrios Kyrtzidis52002882011-12-07 20:44:12 +00006248 CXIdxEntityLang_ObjC = 2,
Michael Kruse7520cf02020-03-25 09:26:14 -05006249 CXIdxEntityLang_CXX = 3,
6250 CXIdxEntityLang_Swift = 4
Argyrios Kyrtzidis52002882011-12-07 20:44:12 +00006251} CXIdxEntityLanguage;
6252
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006253/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006254 * Extra C++ template information for an entity. This can apply to:
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006255 * CXIdxEntity_Function
6256 * CXIdxEntity_CXXClass
6257 * CXIdxEntity_CXXStaticMethod
6258 * CXIdxEntity_CXXInstanceMethod
6259 * CXIdxEntity_CXXConstructor
6260 * CXIdxEntity_CXXConversionFunction
6261 * CXIdxEntity_CXXTypeAlias
6262 */
6263typedef enum {
Michael Kruse7520cf02020-03-25 09:26:14 -05006264 CXIdxEntity_NonTemplate = 0,
6265 CXIdxEntity_Template = 1,
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006266 CXIdxEntity_TemplatePartialSpecialization = 2,
6267 CXIdxEntity_TemplateSpecialization = 3
6268} CXIdxEntityCXXTemplateKind;
6269
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00006270typedef enum {
Michael Kruse7520cf02020-03-25 09:26:14 -05006271 CXIdxAttr_Unexposed = 0,
6272 CXIdxAttr_IBAction = 1,
6273 CXIdxAttr_IBOutlet = 2,
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00006274 CXIdxAttr_IBOutletCollection = 3
6275} CXIdxAttrKind;
6276
6277typedef struct {
6278 CXIdxAttrKind kind;
6279 CXCursor cursor;
6280 CXIdxLoc loc;
6281} CXIdxAttrInfo;
6282
6283typedef struct {
Argyrios Kyrtzidis4d873b72011-12-15 00:05:00 +00006284 CXIdxEntityKind kind;
6285 CXIdxEntityCXXTemplateKind templateKind;
6286 CXIdxEntityLanguage lang;
6287 const char *name;
6288 const char *USR;
6289 CXCursor cursor;
6290 const CXIdxAttrInfo *const *attributes;
6291 unsigned numAttributes;
6292} CXIdxEntityInfo;
6293
6294typedef struct {
6295 CXCursor cursor;
6296} CXIdxContainerInfo;
6297
6298typedef struct {
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00006299 const CXIdxAttrInfo *attrInfo;
6300 const CXIdxEntityInfo *objcClass;
6301 CXCursor classCursor;
6302 CXIdxLoc classLoc;
6303} CXIdxIBOutletCollectionAttrInfo;
6304
Michael Kruse7520cf02020-03-25 09:26:14 -05006305typedef enum { CXIdxDeclFlag_Skipped = 0x1 } CXIdxDeclInfoFlags;
Argyrios Kyrtzidis8b71bc72012-12-06 19:41:16 +00006306
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006307typedef struct {
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006308 const CXIdxEntityInfo *entityInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006309 CXCursor cursor;
6310 CXIdxLoc loc;
Argyrios Kyrtzidis663c8ec2011-12-07 20:44:19 +00006311 const CXIdxContainerInfo *semanticContainer;
6312 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006313 * Generally same as #semanticContainer but can be different in
Argyrios Kyrtzidis663c8ec2011-12-07 20:44:19 +00006314 * cases like out-of-line C++ member functions.
6315 */
6316 const CXIdxContainerInfo *lexicalContainer;
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006317 int isRedeclaration;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006318 int isDefinition;
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00006319 int isContainer;
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006320 const CXIdxContainerInfo *declAsContainer;
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00006321 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006322 * Whether the declaration exists in code or was created implicitly
Nico Weber7deebef2014-04-24 03:17:47 +00006323 * by the compiler, e.g. implicit Objective-C methods for properties.
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00006324 */
6325 int isImplicit;
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00006326 const CXIdxAttrInfo *const *attributes;
6327 unsigned numAttributes;
Argyrios Kyrtzidis8b71bc72012-12-06 19:41:16 +00006328
6329 unsigned flags;
6330
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006331} CXIdxDeclInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006332
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006333typedef enum {
6334 CXIdxObjCContainer_ForwardRef = 0,
6335 CXIdxObjCContainer_Interface = 1,
6336 CXIdxObjCContainer_Implementation = 2
6337} CXIdxObjCContainerKind;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006338
6339typedef struct {
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006340 const CXIdxDeclInfo *declInfo;
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006341 CXIdxObjCContainerKind kind;
6342} CXIdxObjCContainerDeclInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006343
6344typedef struct {
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006345 const CXIdxEntityInfo *base;
6346 CXCursor cursor;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006347 CXIdxLoc loc;
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006348} CXIdxBaseClassInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006349
6350typedef struct {
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006351 const CXIdxEntityInfo *protocol;
6352 CXCursor cursor;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006353 CXIdxLoc loc;
6354} CXIdxObjCProtocolRefInfo;
6355
6356typedef struct {
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006357 const CXIdxObjCProtocolRefInfo *const *protocols;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006358 unsigned numProtocols;
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00006359} CXIdxObjCProtocolRefListInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006360
6361typedef struct {
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00006362 const CXIdxObjCContainerDeclInfo *containerInfo;
6363 const CXIdxBaseClassInfo *superInfo;
6364 const CXIdxObjCProtocolRefListInfo *protocols;
6365} CXIdxObjCInterfaceDeclInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006366
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006367typedef struct {
Argyrios Kyrtzidis9b9f7a92011-12-13 18:47:45 +00006368 const CXIdxObjCContainerDeclInfo *containerInfo;
6369 const CXIdxEntityInfo *objcClass;
6370 CXCursor classCursor;
6371 CXIdxLoc classLoc;
6372 const CXIdxObjCProtocolRefListInfo *protocols;
6373} CXIdxObjCCategoryDeclInfo;
6374
6375typedef struct {
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006376 const CXIdxDeclInfo *declInfo;
Argyrios Kyrtzidis93db2922012-02-28 17:50:33 +00006377 const CXIdxEntityInfo *getter;
6378 const CXIdxEntityInfo *setter;
6379} CXIdxObjCPropertyDeclInfo;
6380
6381typedef struct {
6382 const CXIdxDeclInfo *declInfo;
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006383 const CXIdxBaseClassInfo *const *bases;
6384 unsigned numBases;
6385} CXIdxCXXClassDeclInfo;
6386
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006387/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006388 * Data for IndexerCallbacks#indexEntityReference.
Fangrui Song31b97192018-02-12 17:42:09 +00006389 *
6390 * This may be deprecated in a future version as this duplicates
6391 * the \c CXSymbolRole_Implicit bit in \c CXSymbolRole.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006392 */
Argyrios Kyrtzidis0c7735e52011-10-18 15:50:50 +00006393typedef enum {
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006394 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006395 * The entity is referenced directly in user's code.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006396 */
Argyrios Kyrtzidis0c7735e52011-10-18 15:50:50 +00006397 CXIdxEntityRef_Direct = 1,
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006398 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006399 * An implicit reference, e.g. a reference of an Objective-C method
Nico Weber7deebef2014-04-24 03:17:47 +00006400 * via the dot syntax.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006401 */
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00006402 CXIdxEntityRef_Implicit = 2
Argyrios Kyrtzidis0c7735e52011-10-18 15:50:50 +00006403} CXIdxEntityRefKind;
6404
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006405/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006406 * Roles that are attributed to symbol occurrences.
Fangrui Song31b97192018-02-12 17:42:09 +00006407 *
6408 * Internal: this currently mirrors low 9 bits of clang::index::SymbolRole with
6409 * higher bits zeroed. These high bits may be exposed in the future.
6410 */
6411typedef enum {
6412 CXSymbolRole_None = 0,
6413 CXSymbolRole_Declaration = 1 << 0,
6414 CXSymbolRole_Definition = 1 << 1,
6415 CXSymbolRole_Reference = 1 << 2,
6416 CXSymbolRole_Read = 1 << 3,
6417 CXSymbolRole_Write = 1 << 4,
6418 CXSymbolRole_Call = 1 << 5,
6419 CXSymbolRole_Dynamic = 1 << 6,
6420 CXSymbolRole_AddressOf = 1 << 7,
6421 CXSymbolRole_Implicit = 1 << 8
6422} CXSymbolRole;
6423
6424/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006425 * Data for IndexerCallbacks#indexEntityReference.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006426 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006427typedef struct {
Argyrios Kyrtzidis663c8ec2011-12-07 20:44:19 +00006428 CXIdxEntityRefKind kind;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006429 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006430 * Reference cursor.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006431 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006432 CXCursor cursor;
6433 CXIdxLoc loc;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006434 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006435 * The entity that gets referenced.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006436 */
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006437 const CXIdxEntityInfo *referencedEntity;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006438 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006439 * Immediate "parent" of the reference. For example:
Fangrui Song6907ce22018-07-30 19:24:48 +00006440 *
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006441 * \code
6442 * Foo *var;
6443 * \endcode
Fangrui Song6907ce22018-07-30 19:24:48 +00006444 *
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006445 * The parent of reference of type 'Foo' is the variable 'var'.
Argyrios Kyrtzidis25cb0ff2011-12-13 18:47:41 +00006446 * For references inside statement bodies of functions/methods,
6447 * the parentEntity will be the function/method.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006448 */
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006449 const CXIdxEntityInfo *parentEntity;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006450 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006451 * Lexical container context of the reference.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006452 */
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006453 const CXIdxContainerInfo *container;
Fangrui Song31b97192018-02-12 17:42:09 +00006454 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006455 * Sets of symbol roles of the reference.
Fangrui Song31b97192018-02-12 17:42:09 +00006456 */
6457 CXSymbolRole role;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006458} CXIdxEntityRefInfo;
6459
James Dennett574cb4c2012-06-15 05:41:51 +00006460/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006461 * A group of callbacks used by #clang_indexSourceFile and
James Dennett574cb4c2012-06-15 05:41:51 +00006462 * #clang_indexTranslationUnit.
6463 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006464typedef struct {
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006465 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006466 * Called periodically to check whether indexing should be aborted.
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006467 * Should return 0 to continue, and non-zero to abort.
6468 */
6469 int (*abortQuery)(CXClientData client_data, void *reserved);
6470
6471 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006472 * Called at the end of indexing; passes the complete diagnostic set.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006473 */
Michael Kruse7520cf02020-03-25 09:26:14 -05006474 void (*diagnostic)(CXClientData client_data, CXDiagnosticSet, void *reserved);
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006475
Michael Kruse7520cf02020-03-25 09:26:14 -05006476 CXIdxClientFile (*enteredMainFile)(CXClientData client_data, CXFile mainFile,
6477 void *reserved);
Fangrui Song6907ce22018-07-30 19:24:48 +00006478
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006479 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006480 * Called when a file gets \#included/\#imported.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006481 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006482 CXIdxClientFile (*ppIncludedFile)(CXClientData client_data,
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006483 const CXIdxIncludedFileInfo *);
Fangrui Song6907ce22018-07-30 19:24:48 +00006484
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006485 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006486 * Called when a AST file (PCH or module) gets imported.
Fangrui Song6907ce22018-07-30 19:24:48 +00006487 *
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006488 * AST files will not get indexed (there will not be callbacks to index all
6489 * the entities in an AST file). The recommended action is that, if the AST
Argyrios Kyrtzidis472eda02012-10-02 16:10:38 +00006490 * file is not already indexed, to initiate a new indexing job specific to
6491 * the AST file.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006492 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006493 CXIdxClientASTFile (*importedASTFile)(CXClientData client_data,
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006494 const CXIdxImportedASTFileInfo *);
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006495
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006496 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006497 * Called at the beginning of indexing a translation unit.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006498 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006499 CXIdxClientContainer (*startedTranslationUnit)(CXClientData client_data,
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006500 void *reserved);
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006501
Michael Kruse7520cf02020-03-25 09:26:14 -05006502 void (*indexDeclaration)(CXClientData client_data, const CXIdxDeclInfo *);
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006503
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006504 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006505 * Called to index a reference of an entity.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006506 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006507 void (*indexEntityReference)(CXClientData client_data,
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006508 const CXIdxEntityRefInfo *);
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006509
6510} IndexerCallbacks;
6511
NAKAMURA Takumiaacef7e2011-11-11 02:51:09 +00006512CINDEX_LINKAGE int clang_index_isEntityObjCContainerKind(CXIdxEntityKind);
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006513CINDEX_LINKAGE const CXIdxObjCContainerDeclInfo *
6514clang_index_getObjCContainerDeclInfo(const CXIdxDeclInfo *);
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006515
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006516CINDEX_LINKAGE const CXIdxObjCInterfaceDeclInfo *
6517clang_index_getObjCInterfaceDeclInfo(const CXIdxDeclInfo *);
6518
NAKAMURA Takumiaacef7e2011-11-11 02:51:09 +00006519CINDEX_LINKAGE
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006520const CXIdxObjCCategoryDeclInfo *
6521clang_index_getObjCCategoryDeclInfo(const CXIdxDeclInfo *);
6522
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00006523CINDEX_LINKAGE const CXIdxObjCProtocolRefListInfo *
6524clang_index_getObjCProtocolRefListInfo(const CXIdxDeclInfo *);
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006525
Argyrios Kyrtzidis93db2922012-02-28 17:50:33 +00006526CINDEX_LINKAGE const CXIdxObjCPropertyDeclInfo *
6527clang_index_getObjCPropertyDeclInfo(const CXIdxDeclInfo *);
6528
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00006529CINDEX_LINKAGE const CXIdxIBOutletCollectionAttrInfo *
6530clang_index_getIBOutletCollectionAttrInfo(const CXIdxAttrInfo *);
6531
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006532CINDEX_LINKAGE const CXIdxCXXClassDeclInfo *
6533clang_index_getCXXClassDeclInfo(const CXIdxDeclInfo *);
6534
6535/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006536 * For retrieving a custom CXIdxClientContainer attached to a
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006537 * container.
6538 */
6539CINDEX_LINKAGE CXIdxClientContainer
6540clang_index_getClientContainer(const CXIdxContainerInfo *);
6541
6542/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006543 * For setting a custom CXIdxClientContainer attached to a
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006544 * container.
6545 */
Michael Kruse7520cf02020-03-25 09:26:14 -05006546CINDEX_LINKAGE void clang_index_setClientContainer(const CXIdxContainerInfo *,
6547 CXIdxClientContainer);
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006548
6549/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006550 * For retrieving a custom CXIdxClientEntity attached to an entity.
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006551 */
6552CINDEX_LINKAGE CXIdxClientEntity
6553clang_index_getClientEntity(const CXIdxEntityInfo *);
6554
6555/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006556 * For setting a custom CXIdxClientEntity attached to an entity.
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006557 */
Michael Kruse7520cf02020-03-25 09:26:14 -05006558CINDEX_LINKAGE void clang_index_setClientEntity(const CXIdxEntityInfo *,
6559 CXIdxClientEntity);
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006560
6561/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006562 * An indexing action/session, to be applied to one or multiple
Argyrios Kyrtzidis8b71bc72012-12-06 19:41:16 +00006563 * translation units.
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006564 */
6565typedef void *CXIndexAction;
6566
6567/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006568 * An indexing action/session, to be applied to one or multiple
Argyrios Kyrtzidis8b71bc72012-12-06 19:41:16 +00006569 * translation units.
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006570 *
6571 * \param CIdx The index object with which the index action will be associated.
6572 */
6573CINDEX_LINKAGE CXIndexAction clang_IndexAction_create(CXIndex CIdx);
6574
6575/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006576 * Destroy the given index action.
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006577 *
6578 * The index action must not be destroyed until all of the translation units
6579 * created within that index action have been destroyed.
6580 */
6581CINDEX_LINKAGE void clang_IndexAction_dispose(CXIndexAction);
6582
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006583typedef enum {
6584 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006585 * Used to indicate that no special indexing options are needed.
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006586 */
6587 CXIndexOpt_None = 0x0,
Fangrui Song6907ce22018-07-30 19:24:48 +00006588
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006589 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006590 * Used to indicate that IndexerCallbacks#indexEntityReference should
James Dennett574cb4c2012-06-15 05:41:51 +00006591 * be invoked for only one reference of an entity per source file that does
6592 * not also include a declaration/definition of the entity.
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006593 */
Argyrios Kyrtzidisfb7d1452012-01-14 00:11:49 +00006594 CXIndexOpt_SuppressRedundantRefs = 0x1,
6595
6596 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006597 * Function-local symbols should be indexed. If this is not set
Argyrios Kyrtzidisfb7d1452012-01-14 00:11:49 +00006598 * function-local symbols will be ignored.
6599 */
Argyrios Kyrtzidis7e747952012-02-14 22:23:11 +00006600 CXIndexOpt_IndexFunctionLocalSymbols = 0x2,
6601
6602 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006603 * Implicit function/class template instantiations should be indexed.
Argyrios Kyrtzidis7e747952012-02-14 22:23:11 +00006604 * If this is not set, implicit instantiations will be ignored.
6605 */
Argyrios Kyrtzidis6c9ed7d2012-03-27 21:38:03 +00006606 CXIndexOpt_IndexImplicitTemplateInstantiations = 0x4,
6607
6608 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006609 * Suppress all compiler warnings when parsing for indexing.
Argyrios Kyrtzidis6c9ed7d2012-03-27 21:38:03 +00006610 */
Argyrios Kyrtzidis8b71bc72012-12-06 19:41:16 +00006611 CXIndexOpt_SuppressWarnings = 0x8,
6612
6613 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006614 * Skip a function/method body that was already parsed during an
Nico Weber7deebef2014-04-24 03:17:47 +00006615 * indexing session associated with a \c CXIndexAction object.
Argyrios Kyrtzidis8b71bc72012-12-06 19:41:16 +00006616 * Bodies in system headers are always skipped.
6617 */
6618 CXIndexOpt_SkipParsedBodiesInSession = 0x10
6619
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006620} CXIndexOptFlags;
6621
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006622/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006623 * Index the given source file and the translation unit corresponding
James Dennett574cb4c2012-06-15 05:41:51 +00006624 * to that file via callbacks implemented through #IndexerCallbacks.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006625 *
6626 * \param client_data pointer data supplied by the client, which will
6627 * be passed to the invoked callbacks.
6628 *
6629 * \param index_callbacks Pointer to indexing callbacks that the client
6630 * implements.
6631 *
James Dennett574cb4c2012-06-15 05:41:51 +00006632 * \param index_callbacks_size Size of #IndexerCallbacks structure that gets
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006633 * passed in index_callbacks.
6634 *
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006635 * \param index_options A bitmask of options that affects how indexing is
6636 * performed. This should be a bitwise OR of the CXIndexOpt_XXX flags.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006637 *
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00006638 * \param[out] out_TU pointer to store a \c CXTranslationUnit that can be
6639 * reused after indexing is finished. Set to \c NULL if you do not require it.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006640 *
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00006641 * \returns 0 on success or if there were errors from which the compiler could
Eric Christopher2c4555a2015-06-19 01:52:53 +00006642 * recover. If there is a failure from which there is no recovery, returns
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00006643 * a non-zero \c CXErrorCode.
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006644 *
James Dennett574cb4c2012-06-15 05:41:51 +00006645 * The rest of the parameters are the same as #clang_parseTranslationUnit.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006646 */
Michael Kruse7520cf02020-03-25 09:26:14 -05006647CINDEX_LINKAGE int clang_indexSourceFile(
6648 CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks,
6649 unsigned index_callbacks_size, unsigned index_options,
6650 const char *source_filename, const char *const *command_line_args,
6651 int num_command_line_args, struct CXUnsavedFile *unsaved_files,
6652 unsigned num_unsaved_files, CXTranslationUnit *out_TU, unsigned TU_options);
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006653
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006654/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006655 * Same as clang_indexSourceFile but requires a full command line
Benjamin Kramerc02670e2015-11-18 16:14:27 +00006656 * for \c command_line_args including argv[0]. This is useful if the standard
6657 * library paths are relative to the binary.
6658 */
6659CINDEX_LINKAGE int clang_indexSourceFileFullArgv(
6660 CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks,
6661 unsigned index_callbacks_size, unsigned index_options,
6662 const char *source_filename, const char *const *command_line_args,
6663 int num_command_line_args, struct CXUnsavedFile *unsaved_files,
6664 unsigned num_unsaved_files, CXTranslationUnit *out_TU, unsigned TU_options);
6665
6666/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006667 * Index the given translation unit via callbacks implemented through
James Dennett574cb4c2012-06-15 05:41:51 +00006668 * #IndexerCallbacks.
Fangrui Song6907ce22018-07-30 19:24:48 +00006669 *
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006670 * The order of callback invocations is not guaranteed to be the same as
6671 * when indexing a source file. The high level order will be:
Fangrui Song6907ce22018-07-30 19:24:48 +00006672 *
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006673 * -Preprocessor callbacks invocations
6674 * -Declaration/reference callbacks invocations
6675 * -Diagnostic callback invocations
6676 *
James Dennett574cb4c2012-06-15 05:41:51 +00006677 * The parameters are the same as #clang_indexSourceFile.
Fangrui Song6907ce22018-07-30 19:24:48 +00006678 *
Eric Christopher2c4555a2015-06-19 01:52:53 +00006679 * \returns If there is a failure from which there is no recovery, returns
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006680 * non-zero, otherwise returns 0.
6681 */
Michael Kruse7520cf02020-03-25 09:26:14 -05006682CINDEX_LINKAGE int clang_indexTranslationUnit(
6683 CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks,
6684 unsigned index_callbacks_size, unsigned index_options, CXTranslationUnit);
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006685
6686/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006687 * Retrieve the CXIdxFile, file, line, column, and offset represented by
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006688 * the given CXIdxLoc.
6689 *
6690 * If the location refers into a macro expansion, retrieves the
6691 * location of the macro expansion and if it refers into a macro argument
6692 * retrieves the location of the argument.
6693 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006694CINDEX_LINKAGE void clang_indexLoc_getFileLocation(CXIdxLoc loc,
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006695 CXIdxClientFile *indexFile,
Michael Kruse7520cf02020-03-25 09:26:14 -05006696 CXFile *file, unsigned *line,
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006697 unsigned *column,
6698 unsigned *offset);
6699
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006700/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006701 * Retrieve the CXSourceLocation represented by the given CXIdxLoc.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006702 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006703CINDEX_LINKAGE
6704CXSourceLocation clang_indexLoc_getCXSourceLocation(CXIdxLoc loc);
6705
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00006706/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006707 * Visitor invoked for each field found by a traversal.
Argyrios Kyrtzidis2bff5162015-04-13 16:55:04 +00006708 *
6709 * This visitor function will be invoked for each field found by
6710 * \c clang_Type_visitFields. Its first argument is the cursor being
6711 * visited, its second argument is the client data provided to
6712 * \c clang_Type_visitFields.
6713 *
6714 * The visitor should return one of the \c CXVisitorResult values
6715 * to direct \c clang_Type_visitFields.
6716 */
6717typedef enum CXVisitorResult (*CXFieldVisitor)(CXCursor C,
6718 CXClientData client_data);
6719
6720/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006721 * Visit the fields of a particular type.
Argyrios Kyrtzidis2bff5162015-04-13 16:55:04 +00006722 *
6723 * This function visits all the direct fields of the given cursor,
6724 * invoking the given \p visitor function with the cursors of each
6725 * visited field. The traversal may be ended prematurely, if
6726 * the visitor returns \c CXFieldVisit_Break.
6727 *
6728 * \param T the record type whose field may be visited.
6729 *
6730 * \param visitor the visitor function that will be invoked for each
6731 * field of \p T.
6732 *
6733 * \param client_data pointer data supplied by the client, which will
6734 * be passed to the visitor each time it is invoked.
6735 *
6736 * \returns a non-zero value if the traversal was terminated
6737 * prematurely by the visitor returning \c CXFieldVisit_Break.
6738 */
Michael Kruse7520cf02020-03-25 09:26:14 -05006739CINDEX_LINKAGE unsigned clang_Type_visitFields(CXType T, CXFieldVisitor visitor,
Argyrios Kyrtzidis2bff5162015-04-13 16:55:04 +00006740 CXClientData client_data);
6741
Argyrios Kyrtzidis2bff5162015-04-13 16:55:04 +00006742/**
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00006743 * @}
6744 */
6745
Douglas Gregor6007cf22010-01-22 22:29:16 +00006746/**
6747 * @}
6748 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00006749
Duncan P. N. Exon Smith8c484052019-11-14 13:57:57 -08006750LLVM_CLANG_C_EXTERN_C_END
6751
Ted Kremenekb60d87c2009-08-26 22:36:44 +00006752#endif