blob: efb96f3cc5b6bf1d69b086b94460f1796c4f76d3 [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
Nikolai Kosjar8edd8da2019-06-11 14:14:24 +000036#define CINDEX_VERSION_MINOR 59
Ivan Donchevskii65c766e2018-01-03 10:40:11 +000037
38#define CINDEX_VERSION_ENCODE(major, minor) ( \
39 ((major) * 10000) \
Argyrios Kyrtzidis5b216ed2012-10-29 23:24:44 +000040 + ((minor) * 1))
41
42#define CINDEX_VERSION CINDEX_VERSION_ENCODE( \
43 CINDEX_VERSION_MAJOR, \
44 CINDEX_VERSION_MINOR )
45
46#define CINDEX_VERSION_STRINGIZE_(major, minor) \
47 #major"."#minor
48#define CINDEX_VERSION_STRINGIZE(major, minor) \
49 CINDEX_VERSION_STRINGIZE_(major, minor)
50
51#define CINDEX_VERSION_STRING CINDEX_VERSION_STRINGIZE( \
52 CINDEX_VERSION_MAJOR, \
53 CINDEX_VERSION_MINOR)
54
Duncan P. N. Exon Smith8c484052019-11-14 13:57:57 -080055LLVM_CLANG_C_EXTERN_C_BEGIN
Ted Kremenekb60d87c2009-08-26 22:36:44 +000056
Douglas Gregor4a4e0eb2011-02-23 17:45:25 +000057/** \defgroup CINDEX libclang: C Interface to Clang
Douglas Gregor52606ff2010-01-20 01:10:47 +000058 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +000059 * The C Interface to Clang provides a relatively small API that exposes
Douglas Gregorc8e390c2010-01-20 22:45:41 +000060 * facilities for parsing source code into an abstract syntax tree (AST),
61 * loading already-parsed ASTs, traversing the AST, associating
62 * physical source locations with elements within the AST, and other
63 * facilities that support Clang-based development tools.
Douglas Gregor52606ff2010-01-20 01:10:47 +000064 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +000065 * This C interface to Clang will never provide all of the information
Douglas Gregorc8e390c2010-01-20 22:45:41 +000066 * representation stored in Clang's C++ AST, nor should it: the intent is to
67 * maintain an API that is relatively stable from one release to the next,
68 * providing only the basic functionality needed to support development tools.
Daniel Dunbar62ebf252010-01-24 02:54:26 +000069 *
70 * To avoid namespace pollution, data types are prefixed with "CX" and
Douglas Gregorc8e390c2010-01-20 22:45:41 +000071 * functions are prefixed with "clang_".
Douglas Gregor52606ff2010-01-20 01:10:47 +000072 *
73 * @{
74 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +000075
Douglas Gregor802f12f2010-01-20 22:28:27 +000076/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000077 * An "index" that consists of a set of translation units that would
Douglas Gregor802f12f2010-01-20 22:28:27 +000078 * typically be linked together into an executable or library.
79 */
80typedef void *CXIndex;
Steve Naroffd5e8e862009-08-27 19:51:58 +000081
Douglas Gregor802f12f2010-01-20 22:28:27 +000082/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000083 * An opaque type representing target information for a given translation
Emilio Cobos Alvarez485ad422017-04-28 15:56:39 +000084 * unit.
85 */
86typedef struct CXTargetInfoImpl *CXTargetInfo;
87
88/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000089 * A single translation unit, which resides in an index.
Douglas Gregor802f12f2010-01-20 22:28:27 +000090 */
Ted Kremenek7df92ae2010-11-17 23:24:11 +000091typedef struct CXTranslationUnitImpl *CXTranslationUnit;
Steve Naroffd5e8e862009-08-27 19:51:58 +000092
Douglas Gregor802f12f2010-01-20 22:28:27 +000093/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000094 * Opaque pointer representing client data that will be passed through
Douglas Gregor6007cf22010-01-22 22:29:16 +000095 * to various callbacks and visitors.
Douglas Gregor802f12f2010-01-20 22:28:27 +000096 */
Douglas Gregor6007cf22010-01-22 22:29:16 +000097typedef void *CXClientData;
Daniel Dunbar62ebf252010-01-24 02:54:26 +000098
Douglas Gregor9485bf92009-12-02 09:21:34 +000099/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000100 * Provides the contents of a file that has not yet been saved to disk.
Douglas Gregor9485bf92009-12-02 09:21:34 +0000101 *
102 * Each CXUnsavedFile instance provides the name of a file on the
103 * system along with the current contents of that file that have not
104 * yet been saved to disk.
105 */
106struct CXUnsavedFile {
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000107 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000108 * The file whose contents have not yet been saved.
Douglas Gregor9485bf92009-12-02 09:21:34 +0000109 *
110 * This file must already exist in the file system.
111 */
112 const char *Filename;
113
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000114 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000115 * A buffer containing the unsaved contents of this file.
Douglas Gregor9485bf92009-12-02 09:21:34 +0000116 */
117 const char *Contents;
118
119 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000120 * The length of the unsaved contents of this buffer.
Douglas Gregor9485bf92009-12-02 09:21:34 +0000121 */
122 unsigned long Length;
123};
124
Peter Collingbourne5caf5af2010-08-24 00:31:37 +0000125/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000126 * Describes the availability of a particular entity, which indicates
Peter Collingbourne5caf5af2010-08-24 00:31:37 +0000127 * whether the use of this entity will result in a warning or error due to
128 * it being deprecated or unavailable.
129 */
Douglas Gregorf757a122010-08-23 23:00:57 +0000130enum CXAvailabilityKind {
Peter Collingbourne5caf5af2010-08-24 00:31:37 +0000131 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000132 * The entity is available.
Peter Collingbourne5caf5af2010-08-24 00:31:37 +0000133 */
Douglas Gregorf757a122010-08-23 23:00:57 +0000134 CXAvailability_Available,
Peter Collingbourne5caf5af2010-08-24 00:31:37 +0000135 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000136 * The entity is available, but has been deprecated (and its use is
Peter Collingbourne5caf5af2010-08-24 00:31:37 +0000137 * not recommended).
138 */
Douglas Gregorf757a122010-08-23 23:00:57 +0000139 CXAvailability_Deprecated,
Peter Collingbourne5caf5af2010-08-24 00:31:37 +0000140 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000141 * The entity is not available; any use of it will be an error.
Peter Collingbourne5caf5af2010-08-24 00:31:37 +0000142 */
Erik Verbruggen2e657ff2011-10-06 07:27:49 +0000143 CXAvailability_NotAvailable,
144 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000145 * The entity is available, but not accessible; any use of it will be
Erik Verbruggen2e657ff2011-10-06 07:27:49 +0000146 * an error.
147 */
148 CXAvailability_NotAccessible
Douglas Gregorf757a122010-08-23 23:00:57 +0000149};
Douglas Gregord6225d32012-05-08 00:14:45 +0000150
151/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000152 * Describes a version number of the form major.minor.subminor.
Douglas Gregord6225d32012-05-08 00:14:45 +0000153 */
154typedef struct CXVersion {
155 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000156 * The major version number, e.g., the '10' in '10.7.3'. A negative
Douglas Gregord6225d32012-05-08 00:14:45 +0000157 * value indicates that there is no version number at all.
158 */
159 int Major;
160 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000161 * The minor version number, e.g., the '7' in '10.7.3'. This value
Fangrui Song6907ce22018-07-30 19:24:48 +0000162 * will be negative if no minor version number was provided, e.g., for
Douglas Gregord6225d32012-05-08 00:14:45 +0000163 * version '10'.
164 */
165 int Minor;
166 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000167 * The subminor version number, e.g., the '3' in '10.7.3'. This value
Douglas Gregord6225d32012-05-08 00:14:45 +0000168 * will be negative if no minor or subminor version number was provided,
169 * e.g., in version '10' or '10.7'.
170 */
171 int Subminor;
172} CXVersion;
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000173
174/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000175 * Describes the exception specification of a cursor.
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000176 *
177 * A negative value indicates that the cursor is not a function declaration.
178 */
179enum CXCursor_ExceptionSpecificationKind {
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000180 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000181 * The cursor has no exception specification.
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000182 */
183 CXCursor_ExceptionSpecificationKind_None,
184
185 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000186 * The cursor has exception specification throw()
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000187 */
188 CXCursor_ExceptionSpecificationKind_DynamicNone,
189
190 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000191 * The cursor has exception specification throw(T1, T2)
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000192 */
193 CXCursor_ExceptionSpecificationKind_Dynamic,
194
195 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000196 * The cursor has exception specification throw(...).
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000197 */
198 CXCursor_ExceptionSpecificationKind_MSAny,
199
200 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000201 * The cursor has exception specification basic noexcept.
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000202 */
203 CXCursor_ExceptionSpecificationKind_BasicNoexcept,
204
205 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000206 * The cursor has exception specification computed noexcept.
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000207 */
208 CXCursor_ExceptionSpecificationKind_ComputedNoexcept,
209
210 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000211 * The exception specification has not yet been evaluated.
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000212 */
213 CXCursor_ExceptionSpecificationKind_Unevaluated,
214
215 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000216 * The exception specification has not yet been instantiated.
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000217 */
218 CXCursor_ExceptionSpecificationKind_Uninstantiated,
219
220 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000221 * The exception specification has not been parsed yet.
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000222 */
Erich Keaned02f4a12019-05-30 17:31:54 +0000223 CXCursor_ExceptionSpecificationKind_Unparsed,
224
225 /**
226 * The cursor has a __declspec(nothrow) exception specification.
227 */
228 CXCursor_ExceptionSpecificationKind_NoThrow
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000229};
230
Douglas Gregor802f12f2010-01-20 22:28:27 +0000231/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000232 * Provides a shared context for creating translation units.
James Dennett574cb4c2012-06-15 05:41:51 +0000233 *
234 * It provides two options:
Steve Naroff531e2842009-10-20 14:46:24 +0000235 *
236 * - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local"
237 * declarations (when loading any new translation units). A "local" declaration
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000238 * is one that belongs in the translation unit itself and not in a precompiled
Steve Naroff531e2842009-10-20 14:46:24 +0000239 * header that was used by the translation unit. If zero, all declarations
240 * will be enumerated.
241 *
Steve Naroffbb4568a2009-10-20 16:36:34 +0000242 * Here is an example:
243 *
James Dennett574cb4c2012-06-15 05:41:51 +0000244 * \code
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000245 * // excludeDeclsFromPCH = 1, displayDiagnostics=1
246 * Idx = clang_createIndex(1, 1);
Steve Naroffbb4568a2009-10-20 16:36:34 +0000247 *
248 * // IndexTest.pch was produced with the following command:
249 * // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch"
250 * TU = clang_createTranslationUnit(Idx, "IndexTest.pch");
251 *
252 * // This will load all the symbols from 'IndexTest.pch'
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000253 * clang_visitChildren(clang_getTranslationUnitCursor(TU),
Douglas Gregor990b5762010-01-20 21:37:00 +0000254 * TranslationUnitVisitor, 0);
Steve Naroffbb4568a2009-10-20 16:36:34 +0000255 * clang_disposeTranslationUnit(TU);
256 *
257 * // This will load all the symbols from 'IndexTest.c', excluding symbols
258 * // from 'IndexTest.pch'.
Daniel Dunbard0159262010-01-25 00:43:14 +0000259 * char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" };
260 * TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args,
261 * 0, 0);
Douglas Gregorfed36b12010-01-20 23:57:43 +0000262 * clang_visitChildren(clang_getTranslationUnitCursor(TU),
263 * TranslationUnitVisitor, 0);
Steve Naroffbb4568a2009-10-20 16:36:34 +0000264 * clang_disposeTranslationUnit(TU);
James Dennett574cb4c2012-06-15 05:41:51 +0000265 * \endcode
Steve Naroffbb4568a2009-10-20 16:36:34 +0000266 *
267 * This process of creating the 'pch', loading it separately, and using it (via
268 * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks
269 * (which gives the indexer the same performance benefit as the compiler).
Steve Naroff531e2842009-10-20 14:46:24 +0000270 */
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000271CINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH,
272 int displayDiagnostics);
Ted Kremenekd071c602010-03-13 02:50:34 +0000273
Douglas Gregor408bb742010-02-08 23:03:06 +0000274/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000275 * Destroy the given index.
Douglas Gregor408bb742010-02-08 23:03:06 +0000276 *
277 * The index must not be destroyed until all of the translation units created
278 * within that index have been destroyed.
279 */
Daniel Dunbar11089662009-12-03 01:54:28 +0000280CINDEX_LINKAGE void clang_disposeIndex(CXIndex index);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000281
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000282typedef enum {
283 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000284 * Used to indicate that no special CXIndex options are needed.
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000285 */
286 CXGlobalOpt_None = 0x0,
287
288 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000289 * Used to indicate that threads that libclang creates for indexing
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000290 * purposes should use background priority.
James Dennett574cb4c2012-06-15 05:41:51 +0000291 *
292 * Affects #clang_indexSourceFile, #clang_indexTranslationUnit,
293 * #clang_parseTranslationUnit, #clang_saveTranslationUnit.
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000294 */
295 CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1,
296
297 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000298 * Used to indicate that threads that libclang creates for editing
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000299 * purposes should use background priority.
James Dennett574cb4c2012-06-15 05:41:51 +0000300 *
301 * Affects #clang_reparseTranslationUnit, #clang_codeCompleteAt,
302 * #clang_annotateTokens
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000303 */
304 CXGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2,
305
306 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000307 * Used to indicate that all threads that libclang creates should use
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000308 * background priority.
309 */
310 CXGlobalOpt_ThreadBackgroundPriorityForAll =
311 CXGlobalOpt_ThreadBackgroundPriorityForIndexing |
312 CXGlobalOpt_ThreadBackgroundPriorityForEditing
313
314} CXGlobalOptFlags;
315
316/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000317 * Sets general options associated with a CXIndex.
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000318 *
319 * For example:
320 * \code
321 * CXIndex idx = ...;
322 * clang_CXIndex_setGlobalOptions(idx,
323 * clang_CXIndex_getGlobalOptions(idx) |
324 * CXGlobalOpt_ThreadBackgroundPriorityForIndexing);
325 * \endcode
326 *
327 * \param options A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags.
328 */
329CINDEX_LINKAGE void clang_CXIndex_setGlobalOptions(CXIndex, unsigned options);
330
331/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000332 * Gets the general options associated with a CXIndex.
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000333 *
334 * \returns A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags that
335 * are associated with the given CXIndex object.
336 */
337CINDEX_LINKAGE unsigned clang_CXIndex_getGlobalOptions(CXIndex);
338
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000339/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000340 * Sets the invocation emission path option in a CXIndex.
Alex Lorenz08615792017-12-04 21:56:36 +0000341 *
342 * The invocation emission path specifies a path which will contain log
343 * files for certain libclang invocations. A null value (default) implies that
344 * libclang invocations are not logged..
345 */
346CINDEX_LINKAGE void
347clang_CXIndex_setInvocationEmissionPathOption(CXIndex, const char *Path);
348
349/**
Douglas Gregor6007cf22010-01-22 22:29:16 +0000350 * \defgroup CINDEX_FILES File manipulation routines
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000351 *
352 * @{
353 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000354
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000355/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000356 * A particular source file that is part of a translation unit.
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000357 */
358typedef void *CXFile;
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 complete file and path name of the given file.
Steve Naroff6231f182009-10-27 14:35:18 +0000362 */
Ted Kremenekc560b682010-02-17 00:41:20 +0000363CINDEX_LINKAGE CXString clang_getFileName(CXFile SFile);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000364
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000365/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000366 * Retrieve the last modification time of the given file.
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000367 */
Douglas Gregor249c1212009-10-31 15:48:08 +0000368CINDEX_LINKAGE time_t clang_getFileTime(CXFile SFile);
Steve Naroff6231f182009-10-27 14:35:18 +0000369
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000370/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000371 * Uniquely identifies a CXFile, that refers to the same underlying file,
Argyrios Kyrtzidisac08b262013-01-26 04:52:52 +0000372 * across an indexing session.
373 */
374typedef struct {
375 unsigned long long data[3];
376} CXFileUniqueID;
377
378/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000379 * Retrieve the unique ID for the given \c file.
Argyrios Kyrtzidisac08b262013-01-26 04:52:52 +0000380 *
381 * \param file the file to get the ID for.
382 * \param outID stores the returned CXFileUniqueID.
383 * \returns If there was a failure getting the unique ID, returns non-zero,
384 * otherwise returns 0.
385*/
386CINDEX_LINKAGE int clang_getFileUniqueID(CXFile file, CXFileUniqueID *outID);
387
388/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000389 * Determine whether the given header is guarded against
Douglas Gregor37aa4932011-05-04 00:14:37 +0000390 * multiple inclusions, either with the conventional
James Dennett574cb4c2012-06-15 05:41:51 +0000391 * \#ifndef/\#define/\#endif macro guards or with \#pragma once.
Douglas Gregor37aa4932011-05-04 00:14:37 +0000392 */
Fangrui Song6907ce22018-07-30 19:24:48 +0000393CINDEX_LINKAGE unsigned
Douglas Gregor37aa4932011-05-04 00:14:37 +0000394clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu, CXFile file);
395
396/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000397 * Retrieve a file handle within the given translation unit.
Douglas Gregor816fd362010-01-22 21:44:22 +0000398 *
399 * \param tu the translation unit
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000400 *
Samuel Antao4c8035b2016-12-12 18:00:20 +0000401 * \param file_name the name of the file.
Douglas Gregor816fd362010-01-22 21:44:22 +0000402 *
403 * \returns the file handle for the named file in the translation unit \p tu,
404 * or a NULL file handle if the file was not a part of this translation unit.
405 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000406CINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu,
Douglas Gregor816fd362010-01-22 21:44:22 +0000407 const char *file_name);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000408
Douglas Gregor816fd362010-01-22 21:44:22 +0000409/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000410 * Retrieve the buffer associated with the given file.
Erik Verbruggen3afa3ce2017-12-06 09:02:52 +0000411 *
412 * \param tu the translation unit
413 *
414 * \param file the file for which to retrieve the buffer.
415 *
416 * \param size [out] if non-NULL, will be set to the size of the buffer.
417 *
418 * \returns a pointer to the buffer in memory that holds the contents of
419 * \p file, or a NULL pointer when the file is not loaded.
420 */
421CINDEX_LINKAGE const char *clang_getFileContents(CXTranslationUnit tu,
422 CXFile file, size_t *size);
423
424/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000425 * Returns non-zero if the \c file1 and \c file2 point to the same file,
Argyrios Kyrtzidisac3997e2014-08-16 00:26:19 +0000426 * or they are both NULL.
427 */
428CINDEX_LINKAGE int clang_File_isEqual(CXFile file1, CXFile file2);
429
430/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000431 * Returns the real path name of \c file.
Fangrui Songe46ac5f2018-04-07 20:50:35 +0000432 *
433 * An empty string may be returned. Use \c clang_getFileName() in that case.
434 */
435CINDEX_LINKAGE CXString clang_File_tryGetRealPathName(CXFile file);
436
437/**
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000438 * @}
439 */
440
441/**
442 * \defgroup CINDEX_LOCATIONS Physical source locations
443 *
444 * Clang represents physical source locations in its abstract syntax tree in
445 * great detail, with file, line, and column information for the majority of
446 * the tokens parsed in the source code. These data types and functions are
447 * used to represent source location information, either for a particular
448 * point in the program or for a range of points in the program, and extract
449 * specific location information from those data types.
450 *
451 * @{
452 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000453
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000454/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000455 * Identifies a specific source location within a translation
Douglas Gregor4f46e782010-01-19 21:36:55 +0000456 * unit.
457 *
Chandler Carruth4aa01ef2011-08-31 16:53:37 +0000458 * Use clang_getExpansionLocation() or clang_getSpellingLocation()
Douglas Gregor229bebd2010-11-09 06:24:54 +0000459 * to map a source location to a particular file, line, and column.
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000460 */
461typedef struct {
Argyrios Kyrtzidis49d9d0292013-01-11 22:29:47 +0000462 const void *ptr_data[2];
Douglas Gregor4f46e782010-01-19 21:36:55 +0000463 unsigned int_data;
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000464} CXSourceLocation;
Ted Kremeneka44d99c2010-01-05 23:18:49 +0000465
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000466/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000467 * Identifies a half-open character range in the source code.
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000468 *
Douglas Gregor4f46e782010-01-19 21:36:55 +0000469 * Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the
470 * starting and end locations from a source range, respectively.
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000471 */
472typedef struct {
Argyrios Kyrtzidis49d9d0292013-01-11 22:29:47 +0000473 const void *ptr_data[2];
Douglas Gregor4f46e782010-01-19 21:36:55 +0000474 unsigned begin_int_data;
475 unsigned end_int_data;
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000476} CXSourceRange;
Ted Kremeneka44d99c2010-01-05 23:18:49 +0000477
Douglas Gregor4f46e782010-01-19 21:36:55 +0000478/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000479 * Retrieve a NULL (invalid) source location.
Douglas Gregor816fd362010-01-22 21:44:22 +0000480 */
NAKAMURA Takumieacd6672013-01-10 02:12:38 +0000481CINDEX_LINKAGE CXSourceLocation clang_getNullLocation(void);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000482
Douglas Gregor816fd362010-01-22 21:44:22 +0000483/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000484 * Determine whether two source locations, which must refer into
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000485 * the same translation unit, refer to exactly the same point in the source
Douglas Gregor816fd362010-01-22 21:44:22 +0000486 * code.
487 *
488 * \returns non-zero if the source locations refer to the same location, zero
489 * if they refer to different locations.
490 */
491CINDEX_LINKAGE unsigned clang_equalLocations(CXSourceLocation loc1,
492 CXSourceLocation loc2);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000493
Douglas Gregor816fd362010-01-22 21:44:22 +0000494/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000495 * Retrieves the source location associated with a given file/line/column
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000496 * in a particular translation unit.
Douglas Gregor816fd362010-01-22 21:44:22 +0000497 */
498CINDEX_LINKAGE CXSourceLocation clang_getLocation(CXTranslationUnit tu,
499 CXFile file,
500 unsigned line,
501 unsigned column);
David Chisnall2e16ac52010-10-15 17:07:39 +0000502/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000503 * Retrieves the source location associated with a given character offset
David Chisnall2e16ac52010-10-15 17:07:39 +0000504 * in a particular translation unit.
505 */
506CINDEX_LINKAGE CXSourceLocation clang_getLocationForOffset(CXTranslationUnit tu,
507 CXFile file,
508 unsigned offset);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000509
Douglas Gregor816fd362010-01-22 21:44:22 +0000510/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000511 * Returns non-zero if the given source location is in a system header.
Argyrios Kyrtzidis25f7af12013-04-12 17:06:51 +0000512 */
513CINDEX_LINKAGE int clang_Location_isInSystemHeader(CXSourceLocation location);
514
515/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000516 * Returns non-zero if the given source location is in the main file of
Stefanus Du Toitdb51c632013-08-08 17:48:14 +0000517 * the corresponding translation unit.
518 */
519CINDEX_LINKAGE int clang_Location_isFromMainFile(CXSourceLocation location);
520
521/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000522 * Retrieve a NULL (invalid) source range.
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000523 */
NAKAMURA Takumieacd6672013-01-10 02:12:38 +0000524CINDEX_LINKAGE CXSourceRange clang_getNullRange(void);
Ted Kremenekd071c602010-03-13 02:50:34 +0000525
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000526/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000527 * Retrieve a source range given the beginning and ending source
Douglas Gregor816fd362010-01-22 21:44:22 +0000528 * locations.
529 */
530CINDEX_LINKAGE CXSourceRange clang_getRange(CXSourceLocation begin,
531 CXSourceLocation end);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000532
Douglas Gregor816fd362010-01-22 21:44:22 +0000533/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000534 * Determine whether two ranges are equivalent.
Douglas Gregor757e38b2011-07-23 19:35:14 +0000535 *
536 * \returns non-zero if the ranges are the same, zero if they differ.
537 */
538CINDEX_LINKAGE unsigned clang_equalRanges(CXSourceRange range1,
539 CXSourceRange range2);
540
541/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000542 * Returns non-zero if \p range is null.
Argyrios Kyrtzidise7e42912011-09-28 18:14:21 +0000543 */
Erik Verbruggend610b0f2011-10-06 12:11:57 +0000544CINDEX_LINKAGE int clang_Range_isNull(CXSourceRange range);
Argyrios Kyrtzidise7e42912011-09-28 18:14:21 +0000545
546/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000547 * Retrieve the file, line, column, and offset represented by
Douglas Gregor9bd6db52010-01-26 19:19:08 +0000548 * the given source location.
Douglas Gregor4f46e782010-01-19 21:36:55 +0000549 *
Chandler Carruth4aa01ef2011-08-31 16:53:37 +0000550 * If the location refers into a macro expansion, retrieves the
551 * location of the macro expansion.
Douglas Gregor229bebd2010-11-09 06:24:54 +0000552 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000553 * \param location the location within a source file that will be decomposed
554 * into its parts.
Douglas Gregor4f46e782010-01-19 21:36:55 +0000555 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000556 * \param file [out] if non-NULL, will be set to the file to which the given
Douglas Gregor4f46e782010-01-19 21:36:55 +0000557 * source location points.
558 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000559 * \param line [out] if non-NULL, will be set to the line to which the given
Douglas Gregor4f46e782010-01-19 21:36:55 +0000560 * source location points.
561 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000562 * \param column [out] if non-NULL, will be set to the column to which the given
563 * source location points.
Douglas Gregor9bd6db52010-01-26 19:19:08 +0000564 *
565 * \param offset [out] if non-NULL, will be set to the offset into the
566 * buffer to which the given source location points.
Douglas Gregor4f46e782010-01-19 21:36:55 +0000567 */
Chandler Carruth4aa01ef2011-08-31 16:53:37 +0000568CINDEX_LINKAGE void clang_getExpansionLocation(CXSourceLocation location,
569 CXFile *file,
570 unsigned *line,
571 unsigned *column,
572 unsigned *offset);
573
574/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000575 * Retrieve the file, line and column represented by the given source
Vassil Vassilev4b8e29d2017-04-06 10:05:46 +0000576 * location, as specified in a # line directive.
Argyrios Kyrtzidis91672b32011-09-13 21:49:08 +0000577 *
578 * Example: given the following source code in a file somefile.c
579 *
James Dennett574cb4c2012-06-15 05:41:51 +0000580 * \code
Argyrios Kyrtzidis91672b32011-09-13 21:49:08 +0000581 * #123 "dummy.c" 1
582 *
583 * static int func(void)
584 * {
585 * return 0;
586 * }
James Dennett574cb4c2012-06-15 05:41:51 +0000587 * \endcode
Argyrios Kyrtzidis91672b32011-09-13 21:49:08 +0000588 *
589 * the location information returned by this function would be
590 *
591 * File: dummy.c Line: 124 Column: 12
592 *
593 * whereas clang_getExpansionLocation would have returned
594 *
595 * File: somefile.c Line: 3 Column: 12
596 *
597 * \param location the location within a source file that will be decomposed
598 * into its parts.
599 *
600 * \param filename [out] if non-NULL, will be set to the filename of the
601 * source location. Note that filenames returned will be for "virtual" files,
602 * which don't necessarily exist on the machine running clang - e.g. when
603 * parsing preprocessed output obtained from a different environment. If
604 * a non-NULL value is passed in, remember to dispose of the returned value
605 * using \c clang_disposeString() once you've finished with it. For an invalid
606 * source location, an empty string is returned.
607 *
608 * \param line [out] if non-NULL, will be set to the line number of the
609 * source location. For an invalid source location, zero is returned.
610 *
611 * \param column [out] if non-NULL, will be set to the column number of the
612 * source location. For an invalid source location, zero is returned.
613 */
614CINDEX_LINKAGE void clang_getPresumedLocation(CXSourceLocation location,
615 CXString *filename,
616 unsigned *line,
617 unsigned *column);
618
619/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000620 * Legacy API to retrieve the file, line, column, and offset represented
Chandler Carruth4aa01ef2011-08-31 16:53:37 +0000621 * by the given source location.
622 *
623 * This interface has been replaced by the newer interface
James Dennett574cb4c2012-06-15 05:41:51 +0000624 * #clang_getExpansionLocation(). See that interface's documentation for
Chandler Carruth4aa01ef2011-08-31 16:53:37 +0000625 * details.
626 */
Douglas Gregor4f46e782010-01-19 21:36:55 +0000627CINDEX_LINKAGE void clang_getInstantiationLocation(CXSourceLocation location,
628 CXFile *file,
629 unsigned *line,
Douglas Gregor9bd6db52010-01-26 19:19:08 +0000630 unsigned *column,
631 unsigned *offset);
Douglas Gregor47751d62010-01-26 03:07:15 +0000632
633/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000634 * Retrieve the file, line, column, and offset represented by
Douglas Gregor229bebd2010-11-09 06:24:54 +0000635 * the given source location.
636 *
637 * If the location refers into a macro instantiation, return where the
638 * location was originally spelled in the source file.
639 *
640 * \param location the location within a source file that will be decomposed
641 * into its parts.
642 *
643 * \param file [out] if non-NULL, will be set to the file to which the given
644 * source location points.
645 *
646 * \param line [out] if non-NULL, will be set to the line to which the given
647 * source location points.
648 *
649 * \param column [out] if non-NULL, will be set to the column to which the given
650 * source location points.
651 *
652 * \param offset [out] if non-NULL, will be set to the offset into the
653 * buffer to which the given source location points.
654 */
655CINDEX_LINKAGE void clang_getSpellingLocation(CXSourceLocation location,
656 CXFile *file,
657 unsigned *line,
658 unsigned *column,
659 unsigned *offset);
660
661/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000662 * Retrieve the file, line, column, and offset represented by
Argyrios Kyrtzidis56be7162013-01-04 18:30:13 +0000663 * the given source location.
664 *
665 * If the location refers into a macro expansion, return where the macro was
666 * expanded or where the macro argument was written, if the location points at
667 * a macro argument.
668 *
669 * \param location the location within a source file that will be decomposed
670 * into its parts.
671 *
672 * \param file [out] if non-NULL, will be set to the file to which the given
673 * source location points.
674 *
675 * \param line [out] if non-NULL, will be set to the line to which the given
676 * source location points.
677 *
678 * \param column [out] if non-NULL, will be set to the column to which the given
679 * source location points.
680 *
681 * \param offset [out] if non-NULL, will be set to the offset into the
682 * buffer to which the given source location points.
683 */
684CINDEX_LINKAGE void clang_getFileLocation(CXSourceLocation location,
685 CXFile *file,
686 unsigned *line,
687 unsigned *column,
688 unsigned *offset);
689
690/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000691 * Retrieve a source location representing the first character within a
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000692 * source range.
Douglas Gregor4f46e782010-01-19 21:36:55 +0000693 */
694CINDEX_LINKAGE CXSourceLocation clang_getRangeStart(CXSourceRange range);
695
696/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000697 * Retrieve a source location representing the last character within a
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000698 * source range.
Douglas Gregor4f46e782010-01-19 21:36:55 +0000699 */
700CINDEX_LINKAGE CXSourceLocation clang_getRangeEnd(CXSourceRange range);
701
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000702/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000703 * Identifies an array of ranges.
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000704 */
705typedef struct {
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000706 /** The number of ranges in the \c ranges array. */
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000707 unsigned count;
708 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000709 * An array of \c CXSourceRanges.
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000710 */
711 CXSourceRange *ranges;
Argyrios Kyrtzidis0e282ef2013-12-06 18:55:45 +0000712} CXSourceRangeList;
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000713
714/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000715 * Retrieve all ranges that were skipped by the preprocessor.
Argyrios Kyrtzidis0e282ef2013-12-06 18:55:45 +0000716 *
717 * The preprocessor will skip lines when they are surrounded by an
718 * if/ifdef/ifndef directive whose condition does not evaluate to true.
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000719 */
Argyrios Kyrtzidis0e282ef2013-12-06 18:55:45 +0000720CINDEX_LINKAGE CXSourceRangeList *clang_getSkippedRanges(CXTranslationUnit tu,
721 CXFile file);
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000722
723/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000724 * Retrieve all ranges from all files that were skipped by the
Cameron Desrochersd8091282016-08-18 15:43:55 +0000725 * preprocessor.
726 *
727 * The preprocessor will skip lines when they are surrounded by an
728 * if/ifdef/ifndef directive whose condition does not evaluate to true.
729 */
730CINDEX_LINKAGE CXSourceRangeList *clang_getAllSkippedRanges(CXTranslationUnit tu);
731
732/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000733 * Destroy the given \c CXSourceRangeList.
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000734 */
Argyrios Kyrtzidis0e282ef2013-12-06 18:55:45 +0000735CINDEX_LINKAGE void clang_disposeSourceRangeList(CXSourceRangeList *ranges);
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000736
737/**
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000738 * @}
739 */
Douglas Gregor6007cf22010-01-22 22:29:16 +0000740
741/**
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000742 * \defgroup CINDEX_DIAG Diagnostic reporting
743 *
744 * @{
745 */
746
747/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000748 * Describes the severity of a particular diagnostic.
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000749 */
750enum CXDiagnosticSeverity {
751 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000752 * A diagnostic that has been suppressed, e.g., by a command-line
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000753 * option.
754 */
755 CXDiagnostic_Ignored = 0,
Ted Kremenekd071c602010-03-13 02:50:34 +0000756
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000757 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000758 * This diagnostic is a note that should be attached to the
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000759 * previous (non-note) diagnostic.
760 */
761 CXDiagnostic_Note = 1,
762
763 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000764 * This diagnostic indicates suspicious code that may not be
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000765 * wrong.
766 */
767 CXDiagnostic_Warning = 2,
768
769 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000770 * This diagnostic indicates that the code is ill-formed.
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000771 */
772 CXDiagnostic_Error = 3,
773
774 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000775 * This diagnostic indicates that the code is ill-formed such
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000776 * that future parser recovery is unlikely to produce useful
777 * results.
778 */
779 CXDiagnostic_Fatal = 4
780};
781
782/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000783 * A single diagnostic, containing the diagnostic's severity,
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000784 * location, text, source ranges, and fix-it hints.
785 */
786typedef void *CXDiagnostic;
787
788/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000789 * A group of CXDiagnostics.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000790 */
791typedef void *CXDiagnosticSet;
Fangrui Song6907ce22018-07-30 19:24:48 +0000792
Ted Kremenekd010ba42011-11-10 08:43:12 +0000793/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000794 * Determine the number of diagnostics in a CXDiagnosticSet.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000795 */
796CINDEX_LINKAGE unsigned clang_getNumDiagnosticsInSet(CXDiagnosticSet Diags);
797
798/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000799 * Retrieve a diagnostic associated with the given CXDiagnosticSet.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000800 *
James Dennett574cb4c2012-06-15 05:41:51 +0000801 * \param Diags the CXDiagnosticSet to query.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000802 * \param Index the zero-based diagnostic number to retrieve.
803 *
804 * \returns the requested diagnostic. This diagnostic must be freed
805 * via a call to \c clang_disposeDiagnostic().
806 */
807CINDEX_LINKAGE CXDiagnostic clang_getDiagnosticInSet(CXDiagnosticSet Diags,
Fangrui Song6907ce22018-07-30 19:24:48 +0000808 unsigned Index);
Ted Kremenekd010ba42011-11-10 08:43:12 +0000809
Ted Kremenekd010ba42011-11-10 08:43:12 +0000810/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000811 * Describes the kind of error that occurred (if any) in a call to
Ted Kremenekd010ba42011-11-10 08:43:12 +0000812 * \c clang_loadDiagnostics.
813 */
814enum CXLoadDiag_Error {
815 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000816 * Indicates that no error occurred.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000817 */
818 CXLoadDiag_None = 0,
Fangrui Song6907ce22018-07-30 19:24:48 +0000819
Ted Kremenekd010ba42011-11-10 08:43:12 +0000820 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000821 * Indicates that an unknown error occurred while attempting to
Ted Kremenekd010ba42011-11-10 08:43:12 +0000822 * deserialize diagnostics.
823 */
824 CXLoadDiag_Unknown = 1,
Fangrui Song6907ce22018-07-30 19:24:48 +0000825
Ted Kremenekd010ba42011-11-10 08:43:12 +0000826 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000827 * Indicates that the file containing the serialized diagnostics
Ted Kremenekd010ba42011-11-10 08:43:12 +0000828 * could not be opened.
829 */
830 CXLoadDiag_CannotLoad = 2,
Fangrui Song6907ce22018-07-30 19:24:48 +0000831
Ted Kremenekd010ba42011-11-10 08:43:12 +0000832 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000833 * Indicates that the serialized diagnostics file is invalid or
James Dennett574cb4c2012-06-15 05:41:51 +0000834 * corrupt.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000835 */
836 CXLoadDiag_InvalidFile = 3
837};
Fangrui Song6907ce22018-07-30 19:24:48 +0000838
Ted Kremenekd010ba42011-11-10 08:43:12 +0000839/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000840 * Deserialize a set of diagnostics from a Clang diagnostics bitcode
James Dennett574cb4c2012-06-15 05:41:51 +0000841 * file.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000842 *
James Dennett574cb4c2012-06-15 05:41:51 +0000843 * \param file The name of the file to deserialize.
844 * \param error A pointer to a enum value recording if there was a problem
Ted Kremenekd010ba42011-11-10 08:43:12 +0000845 * deserializing the diagnostics.
James Dennett574cb4c2012-06-15 05:41:51 +0000846 * \param errorString A pointer to a CXString for recording the error string
Ted Kremenekd010ba42011-11-10 08:43:12 +0000847 * if the file was not successfully loaded.
848 *
849 * \returns A loaded CXDiagnosticSet if successful, and NULL otherwise. These
James Dennett574cb4c2012-06-15 05:41:51 +0000850 * diagnostics should be released using clang_disposeDiagnosticSet().
Ted Kremenekd010ba42011-11-10 08:43:12 +0000851 */
852CINDEX_LINKAGE CXDiagnosticSet clang_loadDiagnostics(const char *file,
853 enum CXLoadDiag_Error *error,
854 CXString *errorString);
855
856/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000857 * Release a CXDiagnosticSet and all of its contained diagnostics.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000858 */
859CINDEX_LINKAGE void clang_disposeDiagnosticSet(CXDiagnosticSet Diags);
860
861/**
Fangrui Song6907ce22018-07-30 19:24:48 +0000862 * Retrieve the child diagnostics of a CXDiagnostic.
James Dennett574cb4c2012-06-15 05:41:51 +0000863 *
864 * This CXDiagnosticSet does not need to be released by
Sylvestre Ledrud29d97c2013-11-17 09:46:45 +0000865 * clang_disposeDiagnosticSet.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000866 */
867CINDEX_LINKAGE CXDiagnosticSet clang_getChildDiagnostics(CXDiagnostic D);
868
869/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000870 * Determine the number of diagnostics produced for the given
Douglas Gregor33cdd812010-02-18 18:08:43 +0000871 * translation unit.
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000872 */
Douglas Gregor33cdd812010-02-18 18:08:43 +0000873CINDEX_LINKAGE unsigned clang_getNumDiagnostics(CXTranslationUnit Unit);
874
875/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000876 * Retrieve a diagnostic associated with the given translation unit.
Douglas Gregor33cdd812010-02-18 18:08:43 +0000877 *
878 * \param Unit the translation unit to query.
879 * \param Index the zero-based diagnostic number to retrieve.
880 *
881 * \returns the requested diagnostic. This diagnostic must be freed
882 * via a call to \c clang_disposeDiagnostic().
883 */
884CINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit,
885 unsigned Index);
886
887/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000888 * Retrieve the complete set of diagnostics associated with a
Ted Kremenekb4a8b052011-12-09 22:28:32 +0000889 * translation unit.
890 *
891 * \param Unit the translation unit to query.
892 */
893CINDEX_LINKAGE CXDiagnosticSet
Fangrui Song6907ce22018-07-30 19:24:48 +0000894 clang_getDiagnosticSetFromTU(CXTranslationUnit Unit);
Ted Kremenekb4a8b052011-12-09 22:28:32 +0000895
896/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000897 * Destroy a diagnostic.
Douglas Gregor33cdd812010-02-18 18:08:43 +0000898 */
899CINDEX_LINKAGE void clang_disposeDiagnostic(CXDiagnostic Diagnostic);
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000900
901/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000902 * Options to control the display of diagnostics.
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000903 *
904 * The values in this enum are meant to be combined to customize the
Sylvestre Ledrud29d97c2013-11-17 09:46:45 +0000905 * behavior of \c clang_formatDiagnostic().
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000906 */
907enum CXDiagnosticDisplayOptions {
908 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000909 * Display the source-location information where the
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000910 * diagnostic was located.
911 *
912 * When set, diagnostics will be prefixed by the file, line, and
913 * (optionally) column to which the diagnostic refers. For example,
914 *
915 * \code
916 * test.c:28: warning: extra tokens at end of #endif directive
917 * \endcode
918 *
919 * This option corresponds to the clang flag \c -fshow-source-location.
920 */
921 CXDiagnostic_DisplaySourceLocation = 0x01,
922
923 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000924 * If displaying the source-location information of the
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000925 * diagnostic, also include the column number.
926 *
927 * This option corresponds to the clang flag \c -fshow-column.
928 */
929 CXDiagnostic_DisplayColumn = 0x02,
930
931 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000932 * If displaying the source-location information of the
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000933 * diagnostic, also include information about source ranges in a
934 * machine-parsable format.
935 *
Ted Kremenekd071c602010-03-13 02:50:34 +0000936 * This option corresponds to the clang flag
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000937 * \c -fdiagnostics-print-source-range-info.
938 */
Douglas Gregora750e8e2010-11-19 16:18:16 +0000939 CXDiagnostic_DisplaySourceRanges = 0x04,
Fangrui Song6907ce22018-07-30 19:24:48 +0000940
Douglas Gregora750e8e2010-11-19 16:18:16 +0000941 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000942 * Display the option name associated with this diagnostic, if any.
Douglas Gregora750e8e2010-11-19 16:18:16 +0000943 *
944 * The option name displayed (e.g., -Wconversion) will be placed in brackets
945 * after the diagnostic text. This option corresponds to the clang flag
946 * \c -fdiagnostics-show-option.
947 */
948 CXDiagnostic_DisplayOption = 0x08,
Fangrui Song6907ce22018-07-30 19:24:48 +0000949
Douglas Gregora750e8e2010-11-19 16:18:16 +0000950 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000951 * Display the category number associated with this diagnostic, if any.
Douglas Gregora750e8e2010-11-19 16:18:16 +0000952 *
953 * The category number is displayed within brackets after the diagnostic text.
Fangrui Song6907ce22018-07-30 19:24:48 +0000954 * This option corresponds to the clang flag
Douglas Gregora750e8e2010-11-19 16:18:16 +0000955 * \c -fdiagnostics-show-category=id.
956 */
957 CXDiagnostic_DisplayCategoryId = 0x10,
958
959 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000960 * Display the category name associated with this diagnostic, if any.
Douglas Gregora750e8e2010-11-19 16:18:16 +0000961 *
962 * The category name is displayed within brackets after the diagnostic text.
Fangrui Song6907ce22018-07-30 19:24:48 +0000963 * This option corresponds to the clang flag
Douglas Gregora750e8e2010-11-19 16:18:16 +0000964 * \c -fdiagnostics-show-category=name.
965 */
966 CXDiagnostic_DisplayCategoryName = 0x20
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000967};
968
969/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000970 * Format the given diagnostic in a manner that is suitable for display.
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000971 *
Douglas Gregord770f732010-02-22 23:17:23 +0000972 * This routine will format the given diagnostic to a string, rendering
Ted Kremenekd071c602010-03-13 02:50:34 +0000973 * the diagnostic according to the various options given. The
974 * \c clang_defaultDiagnosticDisplayOptions() function returns the set of
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000975 * options that most closely mimics the behavior of the clang compiler.
976 *
977 * \param Diagnostic The diagnostic to print.
978 *
Ted Kremenekd071c602010-03-13 02:50:34 +0000979 * \param Options A set of options that control the diagnostic display,
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000980 * created by combining \c CXDiagnosticDisplayOptions values.
Douglas Gregord770f732010-02-22 23:17:23 +0000981 *
982 * \returns A new string containing for formatted diagnostic.
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000983 */
Douglas Gregord770f732010-02-22 23:17:23 +0000984CINDEX_LINKAGE CXString clang_formatDiagnostic(CXDiagnostic Diagnostic,
985 unsigned Options);
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000986
987/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000988 * Retrieve the set of display options most similar to the
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000989 * default behavior of the clang compiler.
990 *
991 * \returns A set of display options suitable for use with \c
Sylvestre Ledrud29d97c2013-11-17 09:46:45 +0000992 * clang_formatDiagnostic().
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000993 */
994CINDEX_LINKAGE unsigned clang_defaultDiagnosticDisplayOptions(void);
995
996/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000997 * Determine the severity of the given diagnostic.
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000998 */
Ted Kremenekd071c602010-03-13 02:50:34 +0000999CINDEX_LINKAGE enum CXDiagnosticSeverity
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001000clang_getDiagnosticSeverity(CXDiagnostic);
1001
1002/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001003 * Retrieve the source location of the given diagnostic.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001004 *
1005 * This location is where Clang would print the caret ('^') when
1006 * displaying the diagnostic on the command line.
1007 */
1008CINDEX_LINKAGE CXSourceLocation clang_getDiagnosticLocation(CXDiagnostic);
1009
1010/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001011 * Retrieve the text of the given diagnostic.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001012 */
1013CINDEX_LINKAGE CXString clang_getDiagnosticSpelling(CXDiagnostic);
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +00001014
1015/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001016 * Retrieve the name of the command-line option that enabled this
Douglas Gregora750e8e2010-11-19 16:18:16 +00001017 * diagnostic.
1018 *
1019 * \param Diag The diagnostic to be queried.
1020 *
1021 * \param Disable If non-NULL, will be set to the option that disables this
1022 * diagnostic (if any).
1023 *
1024 * \returns A string that contains the command-line option used to enable this
Fangrui Song6907ce22018-07-30 19:24:48 +00001025 * warning, such as "-Wconversion" or "-pedantic".
Douglas Gregora750e8e2010-11-19 16:18:16 +00001026 */
1027CINDEX_LINKAGE CXString clang_getDiagnosticOption(CXDiagnostic Diag,
1028 CXString *Disable);
1029
1030/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001031 * Retrieve the category number for this diagnostic.
Douglas Gregora750e8e2010-11-19 16:18:16 +00001032 *
1033 * Diagnostics can be categorized into groups along with other, related
Fangrui Song6907ce22018-07-30 19:24:48 +00001034 * diagnostics (e.g., diagnostics under the same warning flag). This routine
Douglas Gregora750e8e2010-11-19 16:18:16 +00001035 * retrieves the category number for the given diagnostic.
1036 *
1037 * \returns The number of the category that contains this diagnostic, or zero
1038 * if this diagnostic is uncategorized.
1039 */
1040CINDEX_LINKAGE unsigned clang_getDiagnosticCategory(CXDiagnostic);
1041
1042/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001043 * Retrieve the name of a particular diagnostic category. This
Ted Kremenek26a6d492012-04-12 00:03:31 +00001044 * is now deprecated. Use clang_getDiagnosticCategoryText()
1045 * instead.
Douglas Gregora750e8e2010-11-19 16:18:16 +00001046 *
Fangrui Song6907ce22018-07-30 19:24:48 +00001047 * \param Category A diagnostic category number, as returned by
Douglas Gregora750e8e2010-11-19 16:18:16 +00001048 * \c clang_getDiagnosticCategory().
1049 *
1050 * \returns The name of the given diagnostic category.
1051 */
Ted Kremenek26a6d492012-04-12 00:03:31 +00001052CINDEX_DEPRECATED CINDEX_LINKAGE
1053CXString clang_getDiagnosticCategoryName(unsigned Category);
1054
1055/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001056 * Retrieve the diagnostic category text for a given diagnostic.
Ted Kremenek26a6d492012-04-12 00:03:31 +00001057 *
Ted Kremenek26a6d492012-04-12 00:03:31 +00001058 * \returns The text of the given diagnostic category.
1059 */
1060CINDEX_LINKAGE CXString clang_getDiagnosticCategoryText(CXDiagnostic);
Fangrui Song6907ce22018-07-30 19:24:48 +00001061
Douglas Gregora750e8e2010-11-19 16:18:16 +00001062/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001063 * Determine the number of source ranges associated with the given
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +00001064 * diagnostic.
1065 */
1066CINDEX_LINKAGE unsigned clang_getDiagnosticNumRanges(CXDiagnostic);
Ted Kremenekd071c602010-03-13 02:50:34 +00001067
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001068/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001069 * Retrieve a source range associated with the diagnostic.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001070 *
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +00001071 * A diagnostic's source ranges highlight important elements in the source
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001072 * code. On the command line, Clang displays source ranges by
Ted Kremenekd071c602010-03-13 02:50:34 +00001073 * underlining them with '~' characters.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001074 *
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +00001075 * \param Diagnostic the diagnostic whose range is being extracted.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001076 *
Ted Kremenekd071c602010-03-13 02:50:34 +00001077 * \param Range the zero-based index specifying which range to
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001078 *
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +00001079 * \returns the requested source range.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001080 */
Ted Kremenekd071c602010-03-13 02:50:34 +00001081CINDEX_LINKAGE CXSourceRange clang_getDiagnosticRange(CXDiagnostic Diagnostic,
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +00001082 unsigned Range);
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001083
1084/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001085 * Determine the number of fix-it hints associated with the
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001086 * given diagnostic.
1087 */
1088CINDEX_LINKAGE unsigned clang_getDiagnosticNumFixIts(CXDiagnostic Diagnostic);
1089
1090/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001091 * Retrieve the replacement information for a given fix-it.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001092 *
Douglas Gregor836ec942010-02-19 18:16:06 +00001093 * Fix-its are described in terms of a source range whose contents
1094 * should be replaced by a string. This approach generalizes over
1095 * three kinds of operations: removal of source code (the range covers
1096 * the code to be removed and the replacement string is empty),
1097 * replacement of source code (the range covers the code to be
1098 * replaced and the replacement string provides the new code), and
1099 * insertion (both the start and end of the range point at the
1100 * insertion location, and the replacement string provides the text to
1101 * insert).
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001102 *
Douglas Gregor836ec942010-02-19 18:16:06 +00001103 * \param Diagnostic The diagnostic whose fix-its are being queried.
1104 *
1105 * \param FixIt The zero-based index of the fix-it.
1106 *
1107 * \param ReplacementRange The source range whose contents will be
1108 * replaced with the returned replacement string. Note that source
1109 * ranges are half-open ranges [a, b), so the source code should be
1110 * replaced from a and up to (but not including) b.
1111 *
1112 * \returns A string containing text that should be replace the source
1113 * code indicated by the \c ReplacementRange.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001114 */
Ted Kremenekd071c602010-03-13 02:50:34 +00001115CINDEX_LINKAGE CXString clang_getDiagnosticFixIt(CXDiagnostic Diagnostic,
Douglas Gregor836ec942010-02-19 18:16:06 +00001116 unsigned FixIt,
1117 CXSourceRange *ReplacementRange);
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001118
1119/**
1120 * @}
1121 */
1122
1123/**
1124 * \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation
1125 *
1126 * The routines in this group provide the ability to create and destroy
1127 * translation units from files, either by parsing the contents of the files or
1128 * by reading in a serialized representation of a translation unit.
1129 *
1130 * @{
1131 */
Ted Kremenekd071c602010-03-13 02:50:34 +00001132
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001133/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001134 * Get the original translation unit source file name.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001135 */
1136CINDEX_LINKAGE CXString
1137clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit);
1138
1139/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001140 * Return the CXTranslationUnit for a given source file and the provided
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001141 * command line arguments one would pass to the compiler.
1142 *
1143 * Note: The 'source_filename' argument is optional. If the caller provides a
1144 * NULL pointer, the name of the source file is expected to reside in the
1145 * specified command line arguments.
1146 *
1147 * Note: When encountered in 'clang_command_line_args', the following options
1148 * are ignored:
1149 *
1150 * '-c'
1151 * '-emit-ast'
1152 * '-fsyntax-only'
James Dennett574cb4c2012-06-15 05:41:51 +00001153 * '-o \<output file>' (both '-o' and '\<output file>' are ignored)
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001154 *
Ted Kremenekbd4972442010-11-08 04:28:51 +00001155 * \param CIdx The index object with which the translation unit will be
1156 * associated.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001157 *
James Dennett574cb4c2012-06-15 05:41:51 +00001158 * \param source_filename The name of the source file to load, or NULL if the
Ted Kremenekbd4972442010-11-08 04:28:51 +00001159 * source file is included in \p clang_command_line_args.
1160 *
1161 * \param num_clang_command_line_args The number of command-line arguments in
1162 * \p clang_command_line_args.
1163 *
1164 * \param clang_command_line_args The command-line arguments that would be
1165 * passed to the \c clang executable if it were being invoked out-of-process.
1166 * These command-line options will be parsed and will affect how the translation
1167 * unit is parsed. Note that the following options are ignored: '-c',
James Dennett574cb4c2012-06-15 05:41:51 +00001168 * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001169 *
1170 * \param num_unsaved_files the number of unsaved file entries in \p
1171 * unsaved_files.
1172 *
1173 * \param unsaved_files the files that have not yet been saved to disk
1174 * but may be required for code completion, including the contents of
Ted Kremenekde24a942010-04-12 18:47:26 +00001175 * those files. The contents and name of these files (as specified by
1176 * CXUnsavedFile) are copied when necessary, so the client only needs to
1177 * guarantee their validity until the call to this function returns.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001178 */
1179CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnitFromSourceFile(
1180 CXIndex CIdx,
1181 const char *source_filename,
1182 int num_clang_command_line_args,
Douglas Gregor57879fa2010-09-01 16:43:19 +00001183 const char * const *clang_command_line_args,
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001184 unsigned num_unsaved_files,
Douglas Gregor33cdd812010-02-18 18:08:43 +00001185 struct CXUnsavedFile *unsaved_files);
Ted Kremenekd071c602010-03-13 02:50:34 +00001186
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001187/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001188 * Same as \c clang_createTranslationUnit2, but returns
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001189 * the \c CXTranslationUnit instead of an error code. In case of an error this
1190 * routine returns a \c NULL \c CXTranslationUnit, without further detailed
1191 * error codes.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001192 */
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001193CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnit(
1194 CXIndex CIdx,
1195 const char *ast_filename);
1196
1197/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001198 * Create a translation unit from an AST file (\c -emit-ast).
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001199 *
1200 * \param[out] out_TU A non-NULL pointer to store the created
1201 * \c CXTranslationUnit.
1202 *
1203 * \returns Zero on success, otherwise returns an error code.
1204 */
1205CINDEX_LINKAGE enum CXErrorCode clang_createTranslationUnit2(
1206 CXIndex CIdx,
1207 const char *ast_filename,
1208 CXTranslationUnit *out_TU);
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001209
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001210/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001211 * Flags that control the creation of translation units.
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001212 *
1213 * The enumerators in this enumeration type are meant to be bitwise
1214 * ORed together to specify which options should be used when
1215 * constructing the translation unit.
1216 */
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001217enum CXTranslationUnit_Flags {
1218 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001219 * Used to indicate that no special translation-unit options are
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001220 * needed.
1221 */
1222 CXTranslationUnit_None = 0x0,
1223
1224 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001225 * Used to indicate that the parser should construct a "detailed"
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001226 * preprocessing record, including all macro definitions and instantiations.
1227 *
1228 * Constructing a detailed preprocessing record requires more memory
1229 * and time to parse, since the information contained in the record
1230 * is usually not retained. However, it can be useful for
1231 * applications that require more detailed information about the
1232 * behavior of the preprocessor.
1233 */
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001234 CXTranslationUnit_DetailedPreprocessingRecord = 0x01,
1235
1236 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001237 * Used to indicate that the translation unit is incomplete.
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001238 *
Douglas Gregor4a47bca2010-08-09 22:28:58 +00001239 * When a translation unit is considered "incomplete", semantic
1240 * analysis that is typically performed at the end of the
1241 * translation unit will be suppressed. For example, this suppresses
1242 * the completion of tentative declarations in C and of
1243 * instantiation of implicitly-instantiation function templates in
1244 * C++. This option is typically used when parsing a header with the
1245 * intent of producing a precompiled header.
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001246 */
Douglas Gregor4a47bca2010-08-09 22:28:58 +00001247 CXTranslationUnit_Incomplete = 0x02,
Fangrui Song6907ce22018-07-30 19:24:48 +00001248
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001249 /**
Fangrui Song6907ce22018-07-30 19:24:48 +00001250 * Used to indicate that the translation unit should be built with an
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001251 * implicit precompiled header for the preamble.
1252 *
1253 * An implicit precompiled header is used as an optimization when a
1254 * particular translation unit is likely to be reparsed many times
1255 * when the sources aren't changing that often. In this case, an
1256 * implicit precompiled header will be built containing all of the
1257 * initial includes at the top of the main file (what we refer to as
1258 * the "preamble" of the file). In subsequent parses, if the
1259 * preamble or the files in it have not changed, \c
1260 * clang_reparseTranslationUnit() will re-use the implicit
1261 * precompiled header to improve parsing performance.
1262 */
Douglas Gregorde051182010-08-11 15:58:42 +00001263 CXTranslationUnit_PrecompiledPreamble = 0x04,
Fangrui Song6907ce22018-07-30 19:24:48 +00001264
Douglas Gregorde051182010-08-11 15:58:42 +00001265 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001266 * Used to indicate that the translation unit should cache some
Douglas Gregorde051182010-08-11 15:58:42 +00001267 * code-completion results with each reparse of the source file.
1268 *
1269 * Caching of code-completion results is a performance optimization that
1270 * introduces some overhead to reparsing but improves the performance of
1271 * code-completion operations.
1272 */
Douglas Gregorf5a18542010-10-27 17:24:53 +00001273 CXTranslationUnit_CacheCompletionResults = 0x08,
Argyrios Kyrtzidis0db720f2012-10-11 16:05:00 +00001274
Douglas Gregorf5a18542010-10-27 17:24:53 +00001275 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001276 * Used to indicate that the translation unit will be serialized with
Argyrios Kyrtzidis0db720f2012-10-11 16:05:00 +00001277 * \c clang_saveTranslationUnit.
Douglas Gregorf5a18542010-10-27 17:24:53 +00001278 *
Argyrios Kyrtzidis0db720f2012-10-11 16:05:00 +00001279 * This option is typically used when parsing a header with the intent of
1280 * producing a precompiled header.
Douglas Gregorf5a18542010-10-27 17:24:53 +00001281 */
Argyrios Kyrtzidis0db720f2012-10-11 16:05:00 +00001282 CXTranslationUnit_ForSerialization = 0x10,
Douglas Gregorf5a18542010-10-27 17:24:53 +00001283
1284 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001285 * DEPRECATED: Enabled chained precompiled preambles in C++.
Douglas Gregorf5a18542010-10-27 17:24:53 +00001286 *
1287 * Note: this is a *temporary* option that is available only while
Douglas Gregor2ed0ee12011-08-25 22:54:01 +00001288 * we are testing C++ precompiled preamble support. It is deprecated.
Douglas Gregorf5a18542010-10-27 17:24:53 +00001289 */
Erik Verbruggen6e922512012-04-12 10:11:59 +00001290 CXTranslationUnit_CXXChainedPCH = 0x20,
1291
1292 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001293 * Used to indicate that function/method bodies should be skipped while
Erik Verbruggen6e922512012-04-12 10:11:59 +00001294 * parsing.
1295 *
1296 * This option can be used to search for declarations/definitions while
1297 * ignoring the usages.
1298 */
Dmitri Gribenko3292d062012-07-02 17:35:10 +00001299 CXTranslationUnit_SkipFunctionBodies = 0x40,
1300
1301 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001302 * Used to indicate that brief documentation comments should be
Dmitri Gribenko3292d062012-07-02 17:35:10 +00001303 * included into the set of code completions returned from this translation
1304 * unit.
1305 */
Benjamin Kramer5c248d82015-12-15 09:30:31 +00001306 CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 0x80,
1307
1308 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001309 * Used to indicate that the precompiled preamble should be created on
Benjamin Kramer5c248d82015-12-15 09:30:31 +00001310 * the first parse. Otherwise it will be created on the first reparse. This
1311 * trades runtime on the first parse (serializing the preamble takes time) for
1312 * reduced runtime on the second parse (can now reuse the preamble).
1313 */
Manuel Klimek016c0242016-03-01 10:56:19 +00001314 CXTranslationUnit_CreatePreambleOnFirstParse = 0x100,
1315
1316 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001317 * Do not stop processing when fatal errors are encountered.
Manuel Klimek016c0242016-03-01 10:56:19 +00001318 *
1319 * When fatal errors are encountered while parsing a translation unit,
1320 * semantic analysis is typically stopped early when compiling code. A common
1321 * source for fatal errors are unresolvable include files. For the
1322 * purposes of an IDE, this is undesirable behavior and as much information
1323 * as possible should be reported. Use this flag to enable this behavior.
1324 */
Argyrios Kyrtzidis735e92c2017-06-09 01:20:48 +00001325 CXTranslationUnit_KeepGoing = 0x200,
1326
Ivan Donchevskiif70d28b2018-05-17 09:15:22 +00001327 /**
1328 * Sets the preprocessor in a mode for parsing a single file only.
1329 */
Ivan Donchevskii6e895282018-05-17 09:24:37 +00001330 CXTranslationUnit_SingleFileParse = 0x400,
1331
1332 /**
Ivan Donchevskii3957e482018-06-13 12:37:08 +00001333 * Used in combination with CXTranslationUnit_SkipFunctionBodies to
Ivan Donchevskii6e895282018-05-17 09:24:37 +00001334 * constrain the skipping of function bodies to the preamble.
1335 *
1336 * The function bodies of the main file are not skipped.
1337 */
Michael Wu153085d2018-08-03 04:21:25 +00001338 CXTranslationUnit_LimitSkipFunctionBodiesToPreamble = 0x800,
1339
1340 /**
1341 * Used to indicate that attributed types should be included in CXType.
1342 */
Michael Wu40ff1052018-08-03 05:20:23 +00001343 CXTranslationUnit_IncludeAttributedTypes = 0x1000,
1344
1345 /**
1346 * Used to indicate that implicit attributes should be visited.
1347 */
Nikolai Kosjar8edd8da2019-06-11 14:14:24 +00001348 CXTranslationUnit_VisitImplicitAttributes = 0x2000,
1349
1350 /**
1351 * Used to indicate that non-errors from included files should be ignored.
1352 *
1353 * If set, clang_getDiagnosticSetFromTU() will not report e.g. warnings from
1354 * included files anymore. This speeds up clang_getDiagnosticSetFromTU() for
1355 * the case where these warnings are not of interest, as for an IDE for
1356 * example, which typically shows only the diagnostics in the main file.
1357 */
Evgeny Mankov2ed2e622019-08-27 22:15:32 +00001358 CXTranslationUnit_IgnoreNonErrorsFromIncludedFiles = 0x4000,
1359
1360 /**
1361 * Tells the preprocessor not to skip excluded conditional blocks.
1362 */
Vitaly Buka712a9b02019-08-28 01:04:50 +00001363 CXTranslationUnit_RetainExcludedConditionalBlocks = 0x8000
Ivan Donchevskiif70d28b2018-05-17 09:15:22 +00001364};
1365
1366/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001367 * Returns the set of flags that is suitable for parsing a translation
Douglas Gregor4a47bca2010-08-09 22:28:58 +00001368 * unit that is being edited.
1369 *
1370 * The set of flags returned provide options for \c clang_parseTranslationUnit()
1371 * to indicate that the translation unit is likely to be reparsed many times,
1372 * either explicitly (via \c clang_reparseTranslationUnit()) or implicitly
1373 * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag
Fangrui Song6907ce22018-07-30 19:24:48 +00001374 * set contains an unspecified set of optimizations (e.g., the precompiled
Douglas Gregor4a47bca2010-08-09 22:28:58 +00001375 * preamble) geared toward improving the performance of these routines. The
1376 * set of optimizations enabled may change from one version to the next.
1377 */
Douglas Gregorde051182010-08-11 15:58:42 +00001378CINDEX_LINKAGE unsigned clang_defaultEditingTranslationUnitOptions(void);
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001379
1380/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001381 * Same as \c clang_parseTranslationUnit2, but returns
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001382 * the \c CXTranslationUnit instead of an error code. In case of an error this
1383 * routine returns a \c NULL \c CXTranslationUnit, without further detailed
1384 * error codes.
1385 */
1386CINDEX_LINKAGE CXTranslationUnit
1387clang_parseTranslationUnit(CXIndex CIdx,
1388 const char *source_filename,
1389 const char *const *command_line_args,
1390 int num_command_line_args,
1391 struct CXUnsavedFile *unsaved_files,
1392 unsigned num_unsaved_files,
1393 unsigned options);
1394
Douglas Gregor4a47bca2010-08-09 22:28:58 +00001395/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001396 * Parse the given source file and the translation unit corresponding
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001397 * to that file.
1398 *
1399 * This routine is the main entry point for the Clang C API, providing the
1400 * ability to parse a source file into a translation unit that can then be
1401 * queried by other functions in the API. This routine accepts a set of
1402 * command-line arguments so that the compilation can be configured in the same
1403 * way that the compiler is configured on the command line.
1404 *
Fangrui Song6907ce22018-07-30 19:24:48 +00001405 * \param CIdx The index object with which the translation unit will be
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001406 * associated.
1407 *
1408 * \param source_filename The name of the source file to load, or NULL if the
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001409 * source file is included in \c command_line_args.
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001410 *
1411 * \param command_line_args The command-line arguments that would be
1412 * passed to the \c clang executable if it were being invoked out-of-process.
1413 * These command-line options will be parsed and will affect how the translation
Fangrui Song6907ce22018-07-30 19:24:48 +00001414 * unit is parsed. Note that the following options are ignored: '-c',
James Dennett574cb4c2012-06-15 05:41:51 +00001415 * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001416 *
1417 * \param num_command_line_args The number of command-line arguments in
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001418 * \c command_line_args.
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001419 *
1420 * \param unsaved_files the files that have not yet been saved to disk
Douglas Gregor8e984da2010-08-04 16:47:14 +00001421 * but may be required for parsing, including the contents of
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001422 * those files. The contents and name of these files (as specified by
1423 * CXUnsavedFile) are copied when necessary, so the client only needs to
1424 * guarantee their validity until the call to this function returns.
1425 *
1426 * \param num_unsaved_files the number of unsaved file entries in \p
1427 * unsaved_files.
1428 *
1429 * \param options A bitmask of options that affects how the translation unit
1430 * is managed but not its compilation. This should be a bitwise OR of the
1431 * CXTranslationUnit_XXX flags.
1432 *
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001433 * \param[out] out_TU A non-NULL pointer to store the created
1434 * \c CXTranslationUnit, describing the parsed code and containing any
1435 * diagnostics produced by the compiler.
1436 *
1437 * \returns Zero on success, otherwise returns an error code.
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001438 */
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001439CINDEX_LINKAGE enum CXErrorCode
1440clang_parseTranslationUnit2(CXIndex CIdx,
1441 const char *source_filename,
1442 const char *const *command_line_args,
1443 int num_command_line_args,
1444 struct CXUnsavedFile *unsaved_files,
1445 unsigned num_unsaved_files,
1446 unsigned options,
1447 CXTranslationUnit *out_TU);
1448
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001449/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001450 * Same as clang_parseTranslationUnit2 but requires a full command line
Benjamin Kramerc02670e2015-11-18 16:14:27 +00001451 * for \c command_line_args including argv[0]. This is useful if the standard
1452 * library paths are relative to the binary.
1453 */
1454CINDEX_LINKAGE enum CXErrorCode clang_parseTranslationUnit2FullArgv(
1455 CXIndex CIdx, const char *source_filename,
1456 const char *const *command_line_args, int num_command_line_args,
1457 struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files,
1458 unsigned options, CXTranslationUnit *out_TU);
1459
1460/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001461 * Flags that control how translation units are saved.
Douglas Gregor6bb92ec2010-08-13 15:35:05 +00001462 *
1463 * The enumerators in this enumeration type are meant to be bitwise
1464 * ORed together to specify which options should be used when
1465 * saving the translation unit.
1466 */
1467enum CXSaveTranslationUnit_Flags {
1468 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001469 * Used to indicate that no special saving options are needed.
Douglas Gregor6bb92ec2010-08-13 15:35:05 +00001470 */
1471 CXSaveTranslationUnit_None = 0x0
1472};
1473
1474/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001475 * Returns the set of flags that is suitable for saving a translation
Douglas Gregor6bb92ec2010-08-13 15:35:05 +00001476 * unit.
1477 *
1478 * The set of flags returned provide options for
1479 * \c clang_saveTranslationUnit() by default. The returned flag
1480 * set contains an unspecified set of options that save translation units with
1481 * the most commonly-requested data.
1482 */
1483CINDEX_LINKAGE unsigned clang_defaultSaveOptions(CXTranslationUnit TU);
1484
1485/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001486 * Describes the kind of error that occurred (if any) in a call to
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001487 * \c clang_saveTranslationUnit().
1488 */
1489enum CXSaveError {
1490 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001491 * Indicates that no error occurred while saving a translation unit.
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001492 */
1493 CXSaveError_None = 0,
Fangrui Song6907ce22018-07-30 19:24:48 +00001494
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001495 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001496 * Indicates that an unknown error occurred while attempting to save
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001497 * the file.
1498 *
Fangrui Song6907ce22018-07-30 19:24:48 +00001499 * This error typically indicates that file I/O failed when attempting to
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001500 * write the file.
1501 */
1502 CXSaveError_Unknown = 1,
Fangrui Song6907ce22018-07-30 19:24:48 +00001503
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001504 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001505 * Indicates that errors during translation prevented this attempt
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001506 * to save the translation unit.
Fangrui Song6907ce22018-07-30 19:24:48 +00001507 *
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001508 * Errors that prevent the translation unit from being saved can be
1509 * extracted using \c clang_getNumDiagnostics() and \c clang_getDiagnostic().
1510 */
1511 CXSaveError_TranslationErrors = 2,
Fangrui Song6907ce22018-07-30 19:24:48 +00001512
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001513 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001514 * Indicates that the translation unit to be saved was somehow
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001515 * invalid (e.g., NULL).
1516 */
1517 CXSaveError_InvalidTU = 3
1518};
Fangrui Song6907ce22018-07-30 19:24:48 +00001519
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001520/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001521 * Saves a translation unit into a serialized representation of
Douglas Gregore9386682010-08-13 05:36:37 +00001522 * that translation unit on disk.
1523 *
1524 * Any translation unit that was parsed without error can be saved
1525 * into a file. The translation unit can then be deserialized into a
1526 * new \c CXTranslationUnit with \c clang_createTranslationUnit() or,
1527 * if it is an incomplete translation unit that corresponds to a
1528 * header, used as a precompiled header when parsing other translation
1529 * units.
1530 *
1531 * \param TU The translation unit to save.
Douglas Gregor6bb92ec2010-08-13 15:35:05 +00001532 *
Douglas Gregore9386682010-08-13 05:36:37 +00001533 * \param FileName The file to which the translation unit will be saved.
1534 *
Douglas Gregor6bb92ec2010-08-13 15:35:05 +00001535 * \param options A bitmask of options that affects how the translation unit
1536 * is saved. This should be a bitwise OR of the
1537 * CXSaveTranslationUnit_XXX flags.
1538 *
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001539 * \returns A value that will match one of the enumerators of the CXSaveError
Fangrui Song6907ce22018-07-30 19:24:48 +00001540 * enumeration. Zero (CXSaveError_None) indicates that the translation unit was
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001541 * saved successfully, while a non-zero value indicates that a problem occurred.
Douglas Gregore9386682010-08-13 05:36:37 +00001542 */
1543CINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU,
Douglas Gregor6bb92ec2010-08-13 15:35:05 +00001544 const char *FileName,
1545 unsigned options);
Douglas Gregore9386682010-08-13 05:36:37 +00001546
1547/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001548 * Suspend a translation unit in order to free memory associated with it.
Erik Verbruggen346066b2017-05-30 14:25:54 +00001549 *
1550 * A suspended translation unit uses significantly less memory but on the other
1551 * side does not support any other calls than \c clang_reparseTranslationUnit
1552 * to resume it or \c clang_disposeTranslationUnit to dispose it completely.
1553 */
1554CINDEX_LINKAGE unsigned clang_suspendTranslationUnit(CXTranslationUnit);
1555
1556/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001557 * Destroy the specified CXTranslationUnit object.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001558 */
1559CINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit);
Ted Kremenekd071c602010-03-13 02:50:34 +00001560
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001561/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001562 * Flags that control the reparsing of translation units.
Douglas Gregorde051182010-08-11 15:58:42 +00001563 *
1564 * The enumerators in this enumeration type are meant to be bitwise
1565 * ORed together to specify which options should be used when
1566 * reparsing the translation unit.
1567 */
1568enum CXReparse_Flags {
1569 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001570 * Used to indicate that no special reparsing options are needed.
Douglas Gregorde051182010-08-11 15:58:42 +00001571 */
1572 CXReparse_None = 0x0
1573};
Fangrui Song6907ce22018-07-30 19:24:48 +00001574
Douglas Gregorde051182010-08-11 15:58:42 +00001575/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001576 * Returns the set of flags that is suitable for reparsing a translation
Douglas Gregorde051182010-08-11 15:58:42 +00001577 * unit.
1578 *
1579 * The set of flags returned provide options for
1580 * \c clang_reparseTranslationUnit() by default. The returned flag
1581 * set contains an unspecified set of optimizations geared toward common uses
Fangrui Song6907ce22018-07-30 19:24:48 +00001582 * of reparsing. The set of optimizations enabled may change from one version
Douglas Gregorde051182010-08-11 15:58:42 +00001583 * to the next.
1584 */
1585CINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU);
1586
1587/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001588 * Reparse the source files that produced this translation unit.
Douglas Gregoraa21cc42010-07-19 21:46:24 +00001589 *
1590 * This routine can be used to re-parse the source files that originally
1591 * created the given translation unit, for example because those source files
1592 * have changed (either on disk or as passed via \p unsaved_files). The
1593 * source code will be reparsed with the same command-line options as it
Fangrui Song6907ce22018-07-30 19:24:48 +00001594 * was originally parsed.
Douglas Gregoraa21cc42010-07-19 21:46:24 +00001595 *
1596 * Reparsing a translation unit invalidates all cursors and source locations
1597 * that refer into that translation unit. This makes reparsing a translation
1598 * unit semantically equivalent to destroying the translation unit and then
1599 * creating a new translation unit with the same command-line arguments.
Fangrui Song6907ce22018-07-30 19:24:48 +00001600 * However, it may be more efficient to reparse a translation
Douglas Gregoraa21cc42010-07-19 21:46:24 +00001601 * unit using this routine.
1602 *
1603 * \param TU The translation unit whose contents will be re-parsed. The
Fangrui Song6907ce22018-07-30 19:24:48 +00001604 * translation unit must originally have been built with
Douglas Gregoraa21cc42010-07-19 21:46:24 +00001605 * \c clang_createTranslationUnitFromSourceFile().
1606 *
1607 * \param num_unsaved_files The number of unsaved file entries in \p
1608 * unsaved_files.
1609 *
1610 * \param unsaved_files The files that have not yet been saved to disk
1611 * but may be required for parsing, including the contents of
1612 * those files. The contents and name of these files (as specified by
1613 * CXUnsavedFile) are copied when necessary, so the client only needs to
1614 * guarantee their validity until the call to this function returns.
Fangrui Song6907ce22018-07-30 19:24:48 +00001615 *
Douglas Gregorde051182010-08-11 15:58:42 +00001616 * \param options A bitset of options composed of the flags in CXReparse_Flags.
1617 * The function \c clang_defaultReparseOptions() produces a default set of
1618 * options recommended for most uses, based on the translation unit.
1619 *
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001620 * \returns 0 if the sources could be reparsed. A non-zero error code will be
Douglas Gregoraa21cc42010-07-19 21:46:24 +00001621 * returned if reparsing was impossible, such that the translation unit is
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001622 * invalid. In such cases, the only valid call for \c TU is
1623 * \c clang_disposeTranslationUnit(TU). The error codes returned by this
1624 * routine are described by the \c CXErrorCode enum.
Douglas Gregoraa21cc42010-07-19 21:46:24 +00001625 */
1626CINDEX_LINKAGE int clang_reparseTranslationUnit(CXTranslationUnit TU,
1627 unsigned num_unsaved_files,
Douglas Gregorde051182010-08-11 15:58:42 +00001628 struct CXUnsavedFile *unsaved_files,
1629 unsigned options);
Ted Kremenek83f642e2011-04-18 22:47:10 +00001630
1631/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001632 * Categorizes how memory is being used by a translation unit.
Ted Kremenek83f642e2011-04-18 22:47:10 +00001633 */
Ted Kremenek23324122011-04-20 16:41:07 +00001634enum CXTUResourceUsageKind {
1635 CXTUResourceUsage_AST = 1,
1636 CXTUResourceUsage_Identifiers = 2,
1637 CXTUResourceUsage_Selectors = 3,
1638 CXTUResourceUsage_GlobalCompletionResults = 4,
Ted Kremenek21735e62011-04-28 04:10:31 +00001639 CXTUResourceUsage_SourceManagerContentCache = 5,
Ted Kremenekf5df0ce2011-04-28 04:53:38 +00001640 CXTUResourceUsage_AST_SideTables = 6,
Ted Kremenek8d587902011-04-28 20:36:42 +00001641 CXTUResourceUsage_SourceManager_Membuffer_Malloc = 7,
Ted Kremenek5e1ed7b2011-04-28 23:46:20 +00001642 CXTUResourceUsage_SourceManager_Membuffer_MMap = 8,
Fangrui Song6907ce22018-07-30 19:24:48 +00001643 CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc = 9,
1644 CXTUResourceUsage_ExternalASTSource_Membuffer_MMap = 10,
Ted Kremenek2160a0d2011-05-04 01:38:46 +00001645 CXTUResourceUsage_Preprocessor = 11,
1646 CXTUResourceUsage_PreprocessingRecord = 12,
Ted Kremenek120992a2011-07-26 23:46:06 +00001647 CXTUResourceUsage_SourceManager_DataStructures = 13,
Ted Kremenekfbcce6f2011-07-26 23:46:11 +00001648 CXTUResourceUsage_Preprocessor_HeaderSearch = 14,
Ted Kremenek23324122011-04-20 16:41:07 +00001649 CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST,
1650 CXTUResourceUsage_MEMORY_IN_BYTES_END =
Ted Kremenekfbcce6f2011-07-26 23:46:11 +00001651 CXTUResourceUsage_Preprocessor_HeaderSearch,
Ted Kremenek23324122011-04-20 16:41:07 +00001652
1653 CXTUResourceUsage_First = CXTUResourceUsage_AST,
Ted Kremenekfbcce6f2011-07-26 23:46:11 +00001654 CXTUResourceUsage_Last = CXTUResourceUsage_Preprocessor_HeaderSearch
Ted Kremenek83f642e2011-04-18 22:47:10 +00001655};
1656
1657/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001658 * Returns the human-readable null-terminated C string that represents
Ted Kremenek23324122011-04-20 16:41:07 +00001659 * the name of the memory category. This string should never be freed.
Ted Kremenek83f642e2011-04-18 22:47:10 +00001660 */
1661CINDEX_LINKAGE
Ted Kremenek23324122011-04-20 16:41:07 +00001662const char *clang_getTUResourceUsageName(enum CXTUResourceUsageKind kind);
Ted Kremenek83f642e2011-04-18 22:47:10 +00001663
Ted Kremenek23324122011-04-20 16:41:07 +00001664typedef struct CXTUResourceUsageEntry {
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001665 /* The memory usage category. */
Fangrui Song6907ce22018-07-30 19:24:48 +00001666 enum CXTUResourceUsageKind kind;
1667 /* Amount of resources used.
Ted Kremenek23324122011-04-20 16:41:07 +00001668 The units will depend on the resource kind. */
Ted Kremenek83f642e2011-04-18 22:47:10 +00001669 unsigned long amount;
Ted Kremenek23324122011-04-20 16:41:07 +00001670} CXTUResourceUsageEntry;
Ted Kremenek83f642e2011-04-18 22:47:10 +00001671
1672/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001673 * The memory usage of a CXTranslationUnit, broken into categories.
Ted Kremenek83f642e2011-04-18 22:47:10 +00001674 */
Ted Kremenek23324122011-04-20 16:41:07 +00001675typedef struct CXTUResourceUsage {
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001676 /* Private data member, used for queries. */
Ted Kremenek83f642e2011-04-18 22:47:10 +00001677 void *data;
1678
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001679 /* The number of entries in the 'entries' array. */
Ted Kremenek83f642e2011-04-18 22:47:10 +00001680 unsigned numEntries;
1681
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001682 /* An array of key-value pairs, representing the breakdown of memory
Ted Kremenek83f642e2011-04-18 22:47:10 +00001683 usage. */
Ted Kremenek23324122011-04-20 16:41:07 +00001684 CXTUResourceUsageEntry *entries;
Ted Kremenek83f642e2011-04-18 22:47:10 +00001685
Ted Kremenek23324122011-04-20 16:41:07 +00001686} CXTUResourceUsage;
Ted Kremenek83f642e2011-04-18 22:47:10 +00001687
1688/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001689 * Return the memory usage of a translation unit. This object
Ted Kremenek23324122011-04-20 16:41:07 +00001690 * should be released with clang_disposeCXTUResourceUsage().
Ted Kremenek83f642e2011-04-18 22:47:10 +00001691 */
Ted Kremenek23324122011-04-20 16:41:07 +00001692CINDEX_LINKAGE CXTUResourceUsage clang_getCXTUResourceUsage(CXTranslationUnit TU);
Ted Kremenek83f642e2011-04-18 22:47:10 +00001693
Ted Kremenek23324122011-04-20 16:41:07 +00001694CINDEX_LINKAGE void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage);
Ted Kremenek83f642e2011-04-18 22:47:10 +00001695
Douglas Gregoraa21cc42010-07-19 21:46:24 +00001696/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001697 * Get target information for this translation unit.
Emilio Cobos Alvarez485ad422017-04-28 15:56:39 +00001698 *
1699 * The CXTargetInfo object cannot outlive the CXTranslationUnit object.
1700 */
1701CINDEX_LINKAGE CXTargetInfo
1702clang_getTranslationUnitTargetInfo(CXTranslationUnit CTUnit);
1703
1704/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001705 * Destroy the CXTargetInfo object.
Emilio Cobos Alvarez485ad422017-04-28 15:56:39 +00001706 */
1707CINDEX_LINKAGE void
1708clang_TargetInfo_dispose(CXTargetInfo Info);
1709
1710/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001711 * Get the normalized target triple as a string.
Emilio Cobos Alvarez485ad422017-04-28 15:56:39 +00001712 *
1713 * Returns the empty string in case of any error.
1714 */
1715CINDEX_LINKAGE CXString
1716clang_TargetInfo_getTriple(CXTargetInfo Info);
1717
1718/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001719 * Get the pointer width of the target in bits.
Emilio Cobos Alvarez485ad422017-04-28 15:56:39 +00001720 *
1721 * Returns -1 in case of error.
1722 */
1723CINDEX_LINKAGE int
1724clang_TargetInfo_getPointerWidth(CXTargetInfo Info);
1725
1726/**
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001727 * @}
1728 */
Ted Kremenekd071c602010-03-13 02:50:34 +00001729
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001730/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001731 * Describes the kind of entity that a cursor refers to.
Douglas Gregor6007cf22010-01-22 22:29:16 +00001732 */
1733enum CXCursorKind {
1734 /* Declarations */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001735 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001736 * A declaration whose specific kind is not exposed via this
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001737 * interface.
Douglas Gregor6007cf22010-01-22 22:29:16 +00001738 *
1739 * Unexposed declarations have the same operations as any other kind
1740 * of declaration; one can extract their location information,
1741 * spelling, find their definitions, etc. However, the specific kind
1742 * of the declaration is not reported.
1743 */
1744 CXCursor_UnexposedDecl = 1,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001745 /** A C or C++ struct. */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001746 CXCursor_StructDecl = 2,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001747 /** A C or C++ union. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001748 CXCursor_UnionDecl = 3,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001749 /** A C++ class. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001750 CXCursor_ClassDecl = 4,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001751 /** An enumeration. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001752 CXCursor_EnumDecl = 5,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001753 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001754 * A field (in C) or non-static data member (in C++) in a
Douglas Gregor6007cf22010-01-22 22:29:16 +00001755 * struct, union, or C++ class.
1756 */
1757 CXCursor_FieldDecl = 6,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001758 /** An enumerator constant. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001759 CXCursor_EnumConstantDecl = 7,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001760 /** A function. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001761 CXCursor_FunctionDecl = 8,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001762 /** A variable. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001763 CXCursor_VarDecl = 9,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001764 /** A function or method parameter. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001765 CXCursor_ParmDecl = 10,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001766 /** An Objective-C \@interface. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001767 CXCursor_ObjCInterfaceDecl = 11,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001768 /** An Objective-C \@interface for a category. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001769 CXCursor_ObjCCategoryDecl = 12,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001770 /** An Objective-C \@protocol declaration. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001771 CXCursor_ObjCProtocolDecl = 13,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001772 /** An Objective-C \@property declaration. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001773 CXCursor_ObjCPropertyDecl = 14,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001774 /** An Objective-C instance variable. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001775 CXCursor_ObjCIvarDecl = 15,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001776 /** An Objective-C instance method. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001777 CXCursor_ObjCInstanceMethodDecl = 16,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001778 /** An Objective-C class method. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001779 CXCursor_ObjCClassMethodDecl = 17,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001780 /** An Objective-C \@implementation. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001781 CXCursor_ObjCImplementationDecl = 18,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001782 /** An Objective-C \@implementation for a category. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001783 CXCursor_ObjCCategoryImplDecl = 19,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001784 /** A typedef. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001785 CXCursor_TypedefDecl = 20,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001786 /** A C++ class method. */
Ted Kremenek225b8e32010-04-13 23:39:06 +00001787 CXCursor_CXXMethod = 21,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001788 /** A C++ namespace. */
Ted Kremenekbd67fb22010-05-06 23:38:21 +00001789 CXCursor_Namespace = 22,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001790 /** A linkage specification, e.g. 'extern "C"'. */
Ted Kremenekb80cba52010-05-07 01:04:29 +00001791 CXCursor_LinkageSpec = 23,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001792 /** A C++ constructor. */
Douglas Gregor12bca222010-08-31 14:41:23 +00001793 CXCursor_Constructor = 24,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001794 /** A C++ destructor. */
Douglas Gregor12bca222010-08-31 14:41:23 +00001795 CXCursor_Destructor = 25,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001796 /** A C++ conversion function. */
Douglas Gregor12bca222010-08-31 14:41:23 +00001797 CXCursor_ConversionFunction = 26,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001798 /** A C++ template type parameter. */
Douglas Gregor713602b2010-08-31 17:01:39 +00001799 CXCursor_TemplateTypeParameter = 27,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001800 /** A C++ non-type template parameter. */
Douglas Gregor713602b2010-08-31 17:01:39 +00001801 CXCursor_NonTypeTemplateParameter = 28,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001802 /** A C++ template template parameter. */
Douglas Gregor713602b2010-08-31 17:01:39 +00001803 CXCursor_TemplateTemplateParameter = 29,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001804 /** A C++ function template. */
Douglas Gregor713602b2010-08-31 17:01:39 +00001805 CXCursor_FunctionTemplate = 30,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001806 /** A C++ class template. */
Douglas Gregor1fbaeb12010-08-31 19:02:00 +00001807 CXCursor_ClassTemplate = 31,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001808 /** A C++ class template partial specialization. */
Douglas Gregorf96abb22010-08-31 19:31:58 +00001809 CXCursor_ClassTemplatePartialSpecialization = 32,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001810 /** A C++ namespace alias declaration. */
Douglas Gregora89314e2010-08-31 23:48:11 +00001811 CXCursor_NamespaceAlias = 33,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001812 /** A C++ using directive. */
Douglas Gregor01a430132010-09-01 03:07:18 +00001813 CXCursor_UsingDirective = 34,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001814 /** A C++ using declaration. */
Douglas Gregora9aa29c2010-09-01 19:52:22 +00001815 CXCursor_UsingDeclaration = 35,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001816 /** A C++ alias declaration */
Richard Smithdda56e42011-04-15 14:24:37 +00001817 CXCursor_TypeAliasDecl = 36,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001818 /** An Objective-C \@synthesize definition. */
Douglas Gregor4cd65962011-06-03 23:08:58 +00001819 CXCursor_ObjCSynthesizeDecl = 37,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001820 /** An Objective-C \@dynamic definition. */
Douglas Gregor4cd65962011-06-03 23:08:58 +00001821 CXCursor_ObjCDynamicDecl = 38,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001822 /** An access specifier. */
Argyrios Kyrtzidis12afd702011-09-30 17:58:23 +00001823 CXCursor_CXXAccessSpecifier = 39,
Douglas Gregor4c362d52011-10-05 19:00:14 +00001824
Ted Kremenek08de5c12010-05-19 21:51:10 +00001825 CXCursor_FirstDecl = CXCursor_UnexposedDecl,
Argyrios Kyrtzidis12afd702011-09-30 17:58:23 +00001826 CXCursor_LastDecl = CXCursor_CXXAccessSpecifier,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001827
Douglas Gregor6007cf22010-01-22 22:29:16 +00001828 /* References */
1829 CXCursor_FirstRef = 40, /* Decl references */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001830 CXCursor_ObjCSuperClassRef = 40,
Douglas Gregor6007cf22010-01-22 22:29:16 +00001831 CXCursor_ObjCProtocolRef = 41,
1832 CXCursor_ObjCClassRef = 42,
1833 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001834 * A reference to a type declaration.
Douglas Gregor6007cf22010-01-22 22:29:16 +00001835 *
1836 * A type reference occurs anywhere where a type is named but not
1837 * declared. For example, given:
1838 *
1839 * \code
1840 * typedef unsigned size_type;
1841 * size_type size;
1842 * \endcode
1843 *
1844 * The typedef is a declaration of size_type (CXCursor_TypedefDecl),
1845 * while the type of the variable "size" is referenced. The cursor
1846 * referenced by the type of size is the typedef for size_type.
1847 */
1848 CXCursor_TypeRef = 43,
Ted Kremenekae9e2212010-08-27 21:34:58 +00001849 CXCursor_CXXBaseSpecifier = 44,
Fangrui Song6907ce22018-07-30 19:24:48 +00001850 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001851 * A reference to a class template, function template, template
Douglas Gregorf3af3112010-09-09 21:42:20 +00001852 * template parameter, or class template partial specialization.
Douglas Gregora23e8f72010-08-31 20:37:03 +00001853 */
1854 CXCursor_TemplateRef = 45,
Douglas Gregora89314e2010-08-31 23:48:11 +00001855 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001856 * A reference to a namespace or namespace alias.
Douglas Gregora89314e2010-08-31 23:48:11 +00001857 */
1858 CXCursor_NamespaceRef = 46,
Douglas Gregorf3af3112010-09-09 21:42:20 +00001859 /**
Fangrui Song6907ce22018-07-30 19:24:48 +00001860 * A reference to a member of a struct, union, or class that occurs in
Douglas Gregora93ab662010-09-10 00:22:18 +00001861 * some non-expression context, e.g., a designated initializer.
Douglas Gregorf3af3112010-09-09 21:42:20 +00001862 */
1863 CXCursor_MemberRef = 47,
Douglas Gregora93ab662010-09-10 00:22:18 +00001864 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001865 * A reference to a labeled statement.
Douglas Gregora93ab662010-09-10 00:22:18 +00001866 *
Fangrui Song6907ce22018-07-30 19:24:48 +00001867 * This cursor kind is used to describe the jump to "start_over" in the
Douglas Gregora93ab662010-09-10 00:22:18 +00001868 * goto statement in the following example:
1869 *
1870 * \code
1871 * start_over:
1872 * ++counter;
1873 *
1874 * goto start_over;
1875 * \endcode
1876 *
1877 * A label reference cursor refers to a label statement.
1878 */
1879 CXCursor_LabelRef = 48,
Fangrui Song6907ce22018-07-30 19:24:48 +00001880
Douglas Gregor16a2bdd2010-09-13 22:52:57 +00001881 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001882 * A reference to a set of overloaded functions or function templates
Douglas Gregor16a2bdd2010-09-13 22:52:57 +00001883 * that has not yet been resolved to a specific function or function template.
1884 *
1885 * An overloaded declaration reference cursor occurs in C++ templates where
1886 * a dependent name refers to a function. For example:
1887 *
1888 * \code
1889 * template<typename T> void swap(T&, T&);
1890 *
1891 * struct X { ... };
1892 * void swap(X&, X&);
1893 *
1894 * template<typename T>
1895 * void reverse(T* first, T* last) {
1896 * while (first < last - 1) {
1897 * swap(*first, *--last);
1898 * ++first;
1899 * }
1900 * }
1901 *
1902 * struct Y { };
1903 * void swap(Y&, Y&);
1904 * \endcode
1905 *
1906 * Here, the identifier "swap" is associated with an overloaded declaration
1907 * reference. In the template definition, "swap" refers to either of the two
1908 * "swap" functions declared above, so both results will be available. At
1909 * instantiation time, "swap" may also refer to other functions found via
1910 * argument-dependent lookup (e.g., the "swap" function at the end of the
1911 * example).
1912 *
Fangrui Song6907ce22018-07-30 19:24:48 +00001913 * The functions \c clang_getNumOverloadedDecls() and
Douglas Gregor16a2bdd2010-09-13 22:52:57 +00001914 * \c clang_getOverloadedDecl() can be used to retrieve the definitions
1915 * referenced by this cursor.
1916 */
1917 CXCursor_OverloadedDeclRef = 49,
Fangrui Song6907ce22018-07-30 19:24:48 +00001918
Douglas Gregor30093832012-02-15 00:54:55 +00001919 /**
Fangrui Song6907ce22018-07-30 19:24:48 +00001920 * A reference to a variable that occurs in some non-expression
Douglas Gregor30093832012-02-15 00:54:55 +00001921 * context, e.g., a C++ lambda capture list.
1922 */
1923 CXCursor_VariableRef = 50,
Fangrui Song6907ce22018-07-30 19:24:48 +00001924
Douglas Gregor30093832012-02-15 00:54:55 +00001925 CXCursor_LastRef = CXCursor_VariableRef,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001926
Douglas Gregor6007cf22010-01-22 22:29:16 +00001927 /* Error conditions */
1928 CXCursor_FirstInvalid = 70,
1929 CXCursor_InvalidFile = 70,
1930 CXCursor_NoDeclFound = 71,
1931 CXCursor_NotImplemented = 72,
Ted Kremeneke184ac52010-03-19 20:39:03 +00001932 CXCursor_InvalidCode = 73,
1933 CXCursor_LastInvalid = CXCursor_InvalidCode,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001934
Douglas Gregor6007cf22010-01-22 22:29:16 +00001935 /* Expressions */
1936 CXCursor_FirstExpr = 100,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001937
Douglas Gregor6007cf22010-01-22 22:29:16 +00001938 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001939 * An expression whose specific kind is not exposed via this
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001940 * interface.
Douglas Gregor6007cf22010-01-22 22:29:16 +00001941 *
1942 * Unexposed expressions have the same operations as any other kind
1943 * of expression; one can extract their location information,
1944 * spelling, children, etc. However, the specific kind of the
1945 * expression is not reported.
1946 */
1947 CXCursor_UnexposedExpr = 100,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001948
Douglas Gregor6007cf22010-01-22 22:29:16 +00001949 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001950 * An expression that refers to some value declaration, such
Nico Weber7deebef2014-04-24 03:17:47 +00001951 * as a function, variable, or enumerator.
Douglas Gregor6007cf22010-01-22 22:29:16 +00001952 */
1953 CXCursor_DeclRefExpr = 101,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001954
Douglas Gregor6007cf22010-01-22 22:29:16 +00001955 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001956 * An expression that refers to a member of a struct, union,
Douglas Gregor6007cf22010-01-22 22:29:16 +00001957 * class, Objective-C class, etc.
1958 */
1959 CXCursor_MemberRefExpr = 102,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001960
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001961 /** An expression that calls a function. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001962 CXCursor_CallExpr = 103,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001963
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001964 /** An expression that sends a message to an Objective-C
Douglas Gregor6007cf22010-01-22 22:29:16 +00001965 object or class. */
1966 CXCursor_ObjCMessageExpr = 104,
Ted Kremenek33b9a422010-04-11 21:47:37 +00001967
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001968 /** An expression that represents a block literal. */
Ted Kremenek33b9a422010-04-11 21:47:37 +00001969 CXCursor_BlockExpr = 105,
1970
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001971 /** An integer literal.
Douglas Gregor4c362d52011-10-05 19:00:14 +00001972 */
1973 CXCursor_IntegerLiteral = 106,
1974
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001975 /** A floating point number literal.
Douglas Gregor4c362d52011-10-05 19:00:14 +00001976 */
1977 CXCursor_FloatingLiteral = 107,
1978
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001979 /** An imaginary number literal.
Douglas Gregor4c362d52011-10-05 19:00:14 +00001980 */
1981 CXCursor_ImaginaryLiteral = 108,
1982
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001983 /** A string literal.
Douglas Gregor4c362d52011-10-05 19:00:14 +00001984 */
1985 CXCursor_StringLiteral = 109,
1986
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001987 /** A character literal.
Douglas Gregor4c362d52011-10-05 19:00:14 +00001988 */
1989 CXCursor_CharacterLiteral = 110,
1990
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001991 /** A parenthesized expression, e.g. "(1)".
Douglas Gregor4c362d52011-10-05 19:00:14 +00001992 *
1993 * This AST node is only formed if full location information is requested.
1994 */
1995 CXCursor_ParenExpr = 111,
1996
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00001997 /** This represents the unary-expression's (except sizeof and
Douglas Gregor4c362d52011-10-05 19:00:14 +00001998 * alignof).
1999 */
2000 CXCursor_UnaryOperator = 112,
2001
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002002 /** [C99 6.5.2.1] Array Subscripting.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002003 */
2004 CXCursor_ArraySubscriptExpr = 113,
2005
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002006 /** A builtin binary operation expression such as "x + y" or
Douglas Gregor4c362d52011-10-05 19:00:14 +00002007 * "x <= y".
2008 */
2009 CXCursor_BinaryOperator = 114,
2010
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002011 /** Compound assignment such as "+=".
Douglas Gregor4c362d52011-10-05 19:00:14 +00002012 */
2013 CXCursor_CompoundAssignOperator = 115,
2014
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002015 /** The ?: ternary operator.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002016 */
2017 CXCursor_ConditionalOperator = 116,
2018
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002019 /** An explicit cast in C (C99 6.5.4) or a C-style cast in C++
Douglas Gregor4c362d52011-10-05 19:00:14 +00002020 * (C++ [expr.cast]), which uses the syntax (Type)expr.
2021 *
2022 * For example: (int)f.
2023 */
2024 CXCursor_CStyleCastExpr = 117,
2025
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002026 /** [C99 6.5.2.5]
Douglas Gregor4c362d52011-10-05 19:00:14 +00002027 */
2028 CXCursor_CompoundLiteralExpr = 118,
2029
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002030 /** Describes an C or C++ initializer list.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002031 */
2032 CXCursor_InitListExpr = 119,
2033
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002034 /** The GNU address of label extension, representing &&label.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002035 */
2036 CXCursor_AddrLabelExpr = 120,
2037
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002038 /** This is the GNU Statement Expression extension: ({int X=4; X;})
Douglas Gregor4c362d52011-10-05 19:00:14 +00002039 */
2040 CXCursor_StmtExpr = 121,
2041
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002042 /** Represents a C11 generic selection.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002043 */
2044 CXCursor_GenericSelectionExpr = 122,
2045
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002046 /** Implements the GNU __null extension, which is a name for a null
Douglas Gregor4c362d52011-10-05 19:00:14 +00002047 * pointer constant that has integral type (e.g., int or long) and is the same
2048 * size and alignment as a pointer.
2049 *
2050 * The __null extension is typically only used by system headers, which define
2051 * NULL as __null in C++ rather than using 0 (which is an integer that may not
2052 * match the size of a pointer).
2053 */
2054 CXCursor_GNUNullExpr = 123,
2055
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002056 /** C++'s static_cast<> expression.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002057 */
2058 CXCursor_CXXStaticCastExpr = 124,
2059
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002060 /** C++'s dynamic_cast<> expression.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002061 */
2062 CXCursor_CXXDynamicCastExpr = 125,
2063
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002064 /** C++'s reinterpret_cast<> expression.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002065 */
2066 CXCursor_CXXReinterpretCastExpr = 126,
2067
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002068 /** C++'s const_cast<> expression.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002069 */
2070 CXCursor_CXXConstCastExpr = 127,
2071
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002072 /** Represents an explicit C++ type conversion that uses "functional"
Douglas Gregor4c362d52011-10-05 19:00:14 +00002073 * notion (C++ [expr.type.conv]).
2074 *
2075 * Example:
2076 * \code
2077 * x = int(0.5);
2078 * \endcode
2079 */
2080 CXCursor_CXXFunctionalCastExpr = 128,
2081
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002082 /** A C++ typeid expression (C++ [expr.typeid]).
Douglas Gregor4c362d52011-10-05 19:00:14 +00002083 */
2084 CXCursor_CXXTypeidExpr = 129,
2085
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002086 /** [C++ 2.13.5] C++ Boolean Literal.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002087 */
2088 CXCursor_CXXBoolLiteralExpr = 130,
2089
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002090 /** [C++0x 2.14.7] C++ Pointer Literal.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002091 */
2092 CXCursor_CXXNullPtrLiteralExpr = 131,
2093
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002094 /** Represents the "this" expression in C++
Douglas Gregor4c362d52011-10-05 19:00:14 +00002095 */
2096 CXCursor_CXXThisExpr = 132,
2097
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002098 /** [C++ 15] C++ Throw Expression.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002099 *
2100 * This handles 'throw' and 'throw' assignment-expression. When
2101 * assignment-expression isn't present, Op will be null.
2102 */
2103 CXCursor_CXXThrowExpr = 133,
2104
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002105 /** A new expression for memory allocation and constructor calls, e.g:
Douglas Gregor4c362d52011-10-05 19:00:14 +00002106 * "new CXXNewExpr(foo)".
2107 */
2108 CXCursor_CXXNewExpr = 134,
2109
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002110 /** A delete expression for memory deallocation and destructor calls,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002111 * e.g. "delete[] pArray".
2112 */
2113 CXCursor_CXXDeleteExpr = 135,
2114
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002115 /** A unary expression. (noexcept, sizeof, or other traits)
Douglas Gregor4c362d52011-10-05 19:00:14 +00002116 */
2117 CXCursor_UnaryExpr = 136,
2118
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002119 /** An Objective-C string literal i.e. @"foo".
Douglas Gregor4c362d52011-10-05 19:00:14 +00002120 */
2121 CXCursor_ObjCStringLiteral = 137,
2122
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002123 /** An Objective-C \@encode expression.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002124 */
2125 CXCursor_ObjCEncodeExpr = 138,
2126
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002127 /** An Objective-C \@selector expression.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002128 */
2129 CXCursor_ObjCSelectorExpr = 139,
2130
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002131 /** An Objective-C \@protocol expression.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002132 */
2133 CXCursor_ObjCProtocolExpr = 140,
2134
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002135 /** An Objective-C "bridged" cast expression, which casts between
Douglas Gregor4c362d52011-10-05 19:00:14 +00002136 * Objective-C pointers and C pointers, transferring ownership in the process.
2137 *
2138 * \code
2139 * NSString *str = (__bridge_transfer NSString *)CFCreateString();
2140 * \endcode
2141 */
2142 CXCursor_ObjCBridgedCastExpr = 141,
2143
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002144 /** Represents a C++0x pack expansion that produces a sequence of
Douglas Gregor4c362d52011-10-05 19:00:14 +00002145 * expressions.
2146 *
2147 * A pack expansion expression contains a pattern (which itself is an
2148 * expression) followed by an ellipsis. For example:
2149 *
2150 * \code
2151 * template<typename F, typename ...Types>
2152 * void forward(F f, Types &&...args) {
2153 * f(static_cast<Types&&>(args)...);
2154 * }
2155 * \endcode
2156 */
2157 CXCursor_PackExpansionExpr = 142,
2158
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002159 /** Represents an expression that computes the length of a parameter
Douglas Gregor4c362d52011-10-05 19:00:14 +00002160 * pack.
2161 *
2162 * \code
2163 * template<typename ...Types>
2164 * struct count {
2165 * static const unsigned value = sizeof...(Types);
2166 * };
2167 * \endcode
2168 */
2169 CXCursor_SizeOfPackExpr = 143,
2170
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002171 /* Represents a C++ lambda expression that produces a local function
Douglas Gregor30093832012-02-15 00:54:55 +00002172 * object.
2173 *
2174 * \code
2175 * void abssort(float *x, unsigned N) {
2176 * std::sort(x, x + N,
2177 * [](float a, float b) {
2178 * return std::abs(a) < std::abs(b);
2179 * });
2180 * }
2181 * \endcode
2182 */
2183 CXCursor_LambdaExpr = 144,
Fangrui Song6907ce22018-07-30 19:24:48 +00002184
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002185 /** Objective-c Boolean Literal.
Ted Kremenek77006f62012-03-06 20:06:06 +00002186 */
2187 CXCursor_ObjCBoolLiteralExpr = 145,
2188
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002189 /** Represents the "self" expression in an Objective-C method.
Argyrios Kyrtzidisc2233be2013-04-23 17:57:17 +00002190 */
2191 CXCursor_ObjCSelfExpr = 146,
2192
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002193 /** OpenMP 4.0 [2.4, Array Section].
Alexey Bataev1a3320e2015-08-25 14:24:04 +00002194 */
2195 CXCursor_OMPArraySectionExpr = 147,
2196
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002197 /** Represents an @available(...) check.
Erik Pilkington29099de2016-07-16 00:35:23 +00002198 */
2199 CXCursor_ObjCAvailabilityCheckExpr = 148,
2200
Leonard Chandb01c3a2018-06-20 17:19:40 +00002201 /**
2202 * Fixed point literal
2203 */
2204 CXCursor_FixedPointLiteral = 149,
2205
2206 CXCursor_LastExpr = CXCursor_FixedPointLiteral,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002207
Douglas Gregor6007cf22010-01-22 22:29:16 +00002208 /* Statements */
2209 CXCursor_FirstStmt = 200,
2210 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002211 * A statement whose specific kind is not exposed via this
Douglas Gregor6007cf22010-01-22 22:29:16 +00002212 * interface.
2213 *
2214 * Unexposed statements have the same operations as any other kind of
2215 * statement; one can extract their location information, spelling,
2216 * children, etc. However, the specific kind of the statement is not
2217 * reported.
2218 */
2219 CXCursor_UnexposedStmt = 200,
Fangrui Song6907ce22018-07-30 19:24:48 +00002220
2221 /** A labelled statement in a function.
Douglas Gregora93ab662010-09-10 00:22:18 +00002222 *
Fangrui Song6907ce22018-07-30 19:24:48 +00002223 * This cursor kind is used to describe the "start_over:" label statement in
Douglas Gregora93ab662010-09-10 00:22:18 +00002224 * the following example:
2225 *
2226 * \code
2227 * start_over:
2228 * ++counter;
2229 * \endcode
2230 *
2231 */
2232 CXCursor_LabelStmt = 201,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002233
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002234 /** A group of statements like { stmt stmt }.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002235 *
2236 * This cursor kind is used to describe compound statements, e.g. function
2237 * bodies.
2238 */
2239 CXCursor_CompoundStmt = 202,
2240
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002241 /** A case statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002242 */
2243 CXCursor_CaseStmt = 203,
2244
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002245 /** A default statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002246 */
2247 CXCursor_DefaultStmt = 204,
2248
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002249 /** An if statement
Douglas Gregor4c362d52011-10-05 19:00:14 +00002250 */
2251 CXCursor_IfStmt = 205,
2252
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002253 /** A switch statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002254 */
2255 CXCursor_SwitchStmt = 206,
2256
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002257 /** A while statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002258 */
2259 CXCursor_WhileStmt = 207,
2260
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002261 /** A do statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002262 */
2263 CXCursor_DoStmt = 208,
2264
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002265 /** A for statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002266 */
2267 CXCursor_ForStmt = 209,
2268
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002269 /** A goto statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002270 */
2271 CXCursor_GotoStmt = 210,
2272
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002273 /** An indirect goto statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002274 */
2275 CXCursor_IndirectGotoStmt = 211,
2276
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002277 /** A continue statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002278 */
2279 CXCursor_ContinueStmt = 212,
2280
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002281 /** A break statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002282 */
2283 CXCursor_BreakStmt = 213,
2284
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002285 /** A return statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002286 */
2287 CXCursor_ReturnStmt = 214,
2288
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002289 /** A GCC inline assembly statement extension.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002290 */
Chad Rosierde70e0e2012-08-25 00:11:56 +00002291 CXCursor_GCCAsmStmt = 215,
Argyrios Kyrtzidis5eae0732012-09-24 19:27:20 +00002292 CXCursor_AsmStmt = CXCursor_GCCAsmStmt,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002293
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002294 /** Objective-C's overall \@try-\@catch-\@finally statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002295 */
2296 CXCursor_ObjCAtTryStmt = 216,
2297
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002298 /** Objective-C's \@catch statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002299 */
2300 CXCursor_ObjCAtCatchStmt = 217,
2301
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002302 /** Objective-C's \@finally statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002303 */
2304 CXCursor_ObjCAtFinallyStmt = 218,
2305
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002306 /** Objective-C's \@throw statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002307 */
2308 CXCursor_ObjCAtThrowStmt = 219,
2309
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002310 /** Objective-C's \@synchronized statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002311 */
2312 CXCursor_ObjCAtSynchronizedStmt = 220,
2313
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002314 /** Objective-C's autorelease pool statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002315 */
2316 CXCursor_ObjCAutoreleasePoolStmt = 221,
2317
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002318 /** Objective-C's collection statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002319 */
2320 CXCursor_ObjCForCollectionStmt = 222,
2321
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002322 /** C++'s catch statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002323 */
2324 CXCursor_CXXCatchStmt = 223,
2325
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002326 /** C++'s try statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002327 */
2328 CXCursor_CXXTryStmt = 224,
2329
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002330 /** C++'s for (* : *) statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002331 */
2332 CXCursor_CXXForRangeStmt = 225,
2333
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002334 /** Windows Structured Exception Handling's try statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002335 */
2336 CXCursor_SEHTryStmt = 226,
2337
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002338 /** Windows Structured Exception Handling's except statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002339 */
2340 CXCursor_SEHExceptStmt = 227,
2341
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002342 /** Windows Structured Exception Handling's finally statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002343 */
2344 CXCursor_SEHFinallyStmt = 228,
2345
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002346 /** A MS inline assembly statement extension.
Chad Rosier32503022012-06-11 20:47:18 +00002347 */
2348 CXCursor_MSAsmStmt = 229,
2349
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002350 /** The null statement ";": C99 6.8.3p3.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002351 *
2352 * This cursor kind is used to describe the null statement.
2353 */
2354 CXCursor_NullStmt = 230,
2355
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002356 /** Adaptor class for mixing declarations with statements and
Douglas Gregor4c362d52011-10-05 19:00:14 +00002357 * expressions.
2358 */
2359 CXCursor_DeclStmt = 231,
2360
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002361 /** OpenMP parallel directive.
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002362 */
2363 CXCursor_OMPParallelDirective = 232,
2364
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002365 /** OpenMP SIMD directive.
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002366 */
2367 CXCursor_OMPSimdDirective = 233,
2368
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002369 /** OpenMP for directive.
Alexey Bataevf29276e2014-06-18 04:14:57 +00002370 */
2371 CXCursor_OMPForDirective = 234,
2372
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002373 /** OpenMP sections directive.
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002374 */
2375 CXCursor_OMPSectionsDirective = 235,
2376
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002377 /** OpenMP section directive.
Alexey Bataev1e0498a2014-06-26 08:21:58 +00002378 */
2379 CXCursor_OMPSectionDirective = 236,
2380
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002381 /** OpenMP single directive.
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00002382 */
2383 CXCursor_OMPSingleDirective = 237,
2384
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002385 /** OpenMP parallel for directive.
Alexey Bataev4acb8592014-07-07 13:01:15 +00002386 */
2387 CXCursor_OMPParallelForDirective = 238,
2388
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002389 /** OpenMP parallel sections directive.
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002390 */
2391 CXCursor_OMPParallelSectionsDirective = 239,
2392
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002393 /** OpenMP task directive.
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002394 */
2395 CXCursor_OMPTaskDirective = 240,
2396
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002397 /** OpenMP master directive.
Alexander Musman80c22892014-07-17 08:54:58 +00002398 */
2399 CXCursor_OMPMasterDirective = 241,
2400
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002401 /** OpenMP critical directive.
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002402 */
2403 CXCursor_OMPCriticalDirective = 242,
2404
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002405 /** OpenMP taskyield directive.
Alexey Bataev68446b72014-07-18 07:47:19 +00002406 */
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002407 CXCursor_OMPTaskyieldDirective = 243,
Alexey Bataev68446b72014-07-18 07:47:19 +00002408
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002409 /** OpenMP barrier directive.
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00002410 */
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002411 CXCursor_OMPBarrierDirective = 244,
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00002412
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002413 /** OpenMP taskwait directive.
Alexey Bataev2df347a2014-07-18 10:17:07 +00002414 */
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002415 CXCursor_OMPTaskwaitDirective = 245,
Alexey Bataev2df347a2014-07-18 10:17:07 +00002416
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002417 /** OpenMP flush directive.
Alexey Bataev6125da92014-07-21 11:26:11 +00002418 */
2419 CXCursor_OMPFlushDirective = 246,
Alexey Bataev0162e452014-07-22 10:10:35 +00002420
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002421 /** Windows Structured Exception Handling's leave statement.
Reid Klecknerba764482014-07-24 18:22:15 +00002422 */
2423 CXCursor_SEHLeaveStmt = 247,
2424
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002425 /** OpenMP ordered directive.
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002426 */
Reid Klecknerba764482014-07-24 18:22:15 +00002427 CXCursor_OMPOrderedDirective = 248,
Alexey Bataev6125da92014-07-21 11:26:11 +00002428
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002429 /** OpenMP atomic directive.
Alexey Bataev0162e452014-07-22 10:10:35 +00002430 */
Reid Klecknerba764482014-07-24 18:22:15 +00002431 CXCursor_OMPAtomicDirective = 249,
Alexey Bataev0162e452014-07-22 10:10:35 +00002432
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002433 /** OpenMP for SIMD directive.
Alexander Musmanf82886e2014-09-18 05:12:34 +00002434 */
2435 CXCursor_OMPForSimdDirective = 250,
2436
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002437 /** OpenMP parallel for SIMD directive.
Alexander Musmane4e893b2014-09-23 09:33:00 +00002438 */
2439 CXCursor_OMPParallelForSimdDirective = 251,
2440
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002441 /** OpenMP target directive.
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002442 */
Alexander Musmane4e893b2014-09-23 09:33:00 +00002443 CXCursor_OMPTargetDirective = 252,
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002444
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002445 /** OpenMP teams directive.
Alexey Bataev13314bf2014-10-09 04:18:56 +00002446 */
2447 CXCursor_OMPTeamsDirective = 253,
2448
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002449 /** OpenMP taskgroup directive.
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002450 */
Michael Wong65f367f2015-07-21 13:44:28 +00002451 CXCursor_OMPTaskgroupDirective = 254,
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002452
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002453 /** OpenMP cancellation point directive.
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002454 */
Michael Wong65f367f2015-07-21 13:44:28 +00002455 CXCursor_OMPCancellationPointDirective = 255,
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002456
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002457 /** OpenMP cancel directive.
Alexey Bataev80909872015-07-02 11:25:17 +00002458 */
Michael Wong65f367f2015-07-21 13:44:28 +00002459 CXCursor_OMPCancelDirective = 256,
Alexey Bataev80909872015-07-02 11:25:17 +00002460
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002461 /** OpenMP target data directive.
Michael Wong65f367f2015-07-21 13:44:28 +00002462 */
2463 CXCursor_OMPTargetDataDirective = 257,
2464
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002465 /** OpenMP taskloop directive.
Alexey Bataev49f6e782015-12-01 04:18:41 +00002466 */
2467 CXCursor_OMPTaskLoopDirective = 258,
2468
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002469 /** OpenMP taskloop simd directive.
Alexey Bataev0a6ed842015-12-03 09:40:15 +00002470 */
2471 CXCursor_OMPTaskLoopSimdDirective = 259,
2472
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002473 /** OpenMP distribute directive.
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00002474 */
2475 CXCursor_OMPDistributeDirective = 260,
2476
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002477 /** OpenMP target enter data directive.
Samuel Antaodf67fc42016-01-19 19:15:56 +00002478 */
2479 CXCursor_OMPTargetEnterDataDirective = 261,
2480
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002481 /** OpenMP target exit data directive.
Samuel Antao72590762016-01-19 20:04:50 +00002482 */
2483 CXCursor_OMPTargetExitDataDirective = 262,
2484
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002485 /** OpenMP target parallel directive.
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002486 */
2487 CXCursor_OMPTargetParallelDirective = 263,
2488
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002489 /** OpenMP target parallel for directive.
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00002490 */
2491 CXCursor_OMPTargetParallelForDirective = 264,
2492
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002493 /** OpenMP target update directive.
Samuel Antao686c70c2016-05-26 17:30:50 +00002494 */
2495 CXCursor_OMPTargetUpdateDirective = 265,
2496
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002497 /** OpenMP distribute parallel for directive.
Carlo Bertolli9925f152016-06-27 14:55:37 +00002498 */
2499 CXCursor_OMPDistributeParallelForDirective = 266,
2500
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002501 /** OpenMP distribute parallel for simd directive.
Kelvin Li4a39add2016-07-05 05:00:15 +00002502 */
2503 CXCursor_OMPDistributeParallelForSimdDirective = 267,
2504
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002505 /** OpenMP distribute simd directive.
Kelvin Li787f3fc2016-07-06 04:45:38 +00002506 */
2507 CXCursor_OMPDistributeSimdDirective = 268,
2508
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002509 /** OpenMP target parallel for simd directive.
Kelvin Lia579b912016-07-14 02:54:56 +00002510 */
2511 CXCursor_OMPTargetParallelForSimdDirective = 269,
2512
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002513 /** OpenMP target simd directive.
Kelvin Li986330c2016-07-20 22:57:10 +00002514 */
2515 CXCursor_OMPTargetSimdDirective = 270,
2516
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002517 /** OpenMP teams distribute directive.
Kelvin Li02532872016-08-05 14:37:37 +00002518 */
2519 CXCursor_OMPTeamsDistributeDirective = 271,
2520
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002521 /** OpenMP teams distribute simd directive.
Kelvin Li4e325f72016-10-25 12:50:55 +00002522 */
2523 CXCursor_OMPTeamsDistributeSimdDirective = 272,
2524
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002525 /** OpenMP teams distribute parallel for simd directive.
Kelvin Li579e41c2016-11-30 23:51:03 +00002526 */
2527 CXCursor_OMPTeamsDistributeParallelForSimdDirective = 273,
2528
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002529 /** OpenMP teams distribute parallel for directive.
Kelvin Li7ade93f2016-12-09 03:24:30 +00002530 */
2531 CXCursor_OMPTeamsDistributeParallelForDirective = 274,
2532
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002533 /** OpenMP target teams directive.
Kelvin Libf594a52016-12-17 05:48:59 +00002534 */
2535 CXCursor_OMPTargetTeamsDirective = 275,
2536
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002537 /** OpenMP target teams distribute directive.
Kelvin Li83c451e2016-12-25 04:52:54 +00002538 */
2539 CXCursor_OMPTargetTeamsDistributeDirective = 276,
2540
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002541 /** OpenMP target teams distribute parallel for directive.
Kelvin Li80e8f562016-12-29 22:16:30 +00002542 */
2543 CXCursor_OMPTargetTeamsDistributeParallelForDirective = 277,
2544
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002545 /** OpenMP target teams distribute parallel for simd directive.
Kelvin Li1851df52017-01-03 05:23:48 +00002546 */
2547 CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective = 278,
2548
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002549 /** OpenMP target teams distribute simd directive.
Kelvin Lida681182017-01-10 18:08:18 +00002550 */
2551 CXCursor_OMPTargetTeamsDistributeSimdDirective = 279,
2552
Erik Pilkingtoneee944e2019-07-02 18:28:13 +00002553 /** C++2a std::bit_cast expression.
2554 */
2555 CXCursor_BuiltinBitCastExpr = 280,
2556
Alexey Bataev60e51c42019-10-10 20:13:02 +00002557 /** OpenMP master taskloop directive.
2558 */
2559 CXCursor_OMPMasterTaskLoopDirective = 281,
2560
Alexey Bataev5bbcead2019-10-14 17:17:41 +00002561 /** OpenMP parallel master taskloop directive.
2562 */
2563 CXCursor_OMPParallelMasterTaskLoopDirective = 282,
Alexey Bataev60e51c42019-10-10 20:13:02 +00002564
Alexey Bataevb8552ab2019-10-18 16:47:35 +00002565 /** OpenMP master taskloop simd directive.
2566 */
2567 CXCursor_OMPMasterTaskLoopSimdDirective = 283,
2568
Alexey Bataev14a388f2019-10-25 10:27:13 -04002569 /** OpenMP parallel master taskloop simd directive.
2570 */
2571 CXCursor_OMPParallelMasterTaskLoopSimdDirective = 284,
Alexey Bataevb8552ab2019-10-18 16:47:35 +00002572
cchen47d60942019-12-05 13:43:48 -05002573 /** OpenMP parallel master directive.
2574 */
2575 CXCursor_OMPParallelMasterDirective = 285,
2576
2577 CXCursor_LastStmt = CXCursor_OMPParallelMasterDirective,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002578
Douglas Gregor6007cf22010-01-22 22:29:16 +00002579 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002580 * Cursor that represents the translation unit itself.
Douglas Gregor6007cf22010-01-22 22:29:16 +00002581 *
2582 * The translation unit cursor exists primarily to act as the root
2583 * cursor for traversing the contents of a translation unit.
2584 */
Ted Kremenekbff31432010-02-18 03:09:07 +00002585 CXCursor_TranslationUnit = 300,
2586
Bill Wendling44426052012-12-20 19:22:21 +00002587 /* Attributes */
Ted Kremenekbff31432010-02-18 03:09:07 +00002588 CXCursor_FirstAttr = 400,
2589 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002590 * An attribute whose specific kind is not exposed via this
Ted Kremenekbff31432010-02-18 03:09:07 +00002591 * interface.
2592 */
2593 CXCursor_UnexposedAttr = 400,
2594
2595 CXCursor_IBActionAttr = 401,
2596 CXCursor_IBOutletAttr = 402,
Ted Kremenek26bde772010-05-19 17:38:06 +00002597 CXCursor_IBOutletCollectionAttr = 403,
Argyrios Kyrtzidis2cb4e3c2011-09-13 17:39:31 +00002598 CXCursor_CXXFinalAttr = 404,
2599 CXCursor_CXXOverrideAttr = 405,
Erik Verbruggenca98f2a2011-10-13 09:41:32 +00002600 CXCursor_AnnotateAttr = 406,
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00002601 CXCursor_AsmLabelAttr = 407,
Argyrios Kyrtzidis16834f12013-09-25 00:14:38 +00002602 CXCursor_PackedAttr = 408,
Joey Gouly81228382014-05-01 15:41:58 +00002603 CXCursor_PureAttr = 409,
2604 CXCursor_ConstAttr = 410,
2605 CXCursor_NoDuplicateAttr = 411,
Eli Bendersky2581e662014-05-28 19:29:58 +00002606 CXCursor_CUDAConstantAttr = 412,
2607 CXCursor_CUDADeviceAttr = 413,
2608 CXCursor_CUDAGlobalAttr = 414,
2609 CXCursor_CUDAHostAttr = 415,
Eli Bendersky9b071472014-08-08 14:59:00 +00002610 CXCursor_CUDASharedAttr = 416,
Saleem Abdulrasool79c69712015-09-05 18:53:43 +00002611 CXCursor_VisibilityAttr = 417,
Saleem Abdulrasool8aa0b802015-12-10 18:45:18 +00002612 CXCursor_DLLExport = 418,
2613 CXCursor_DLLImport = 419,
Michael Wud092d0b2018-08-03 05:03:22 +00002614 CXCursor_NSReturnsRetained = 420,
2615 CXCursor_NSReturnsNotRetained = 421,
2616 CXCursor_NSReturnsAutoreleased = 422,
2617 CXCursor_NSConsumesSelf = 423,
2618 CXCursor_NSConsumed = 424,
2619 CXCursor_ObjCException = 425,
2620 CXCursor_ObjCNSObject = 426,
2621 CXCursor_ObjCIndependentClass = 427,
2622 CXCursor_ObjCPreciseLifetime = 428,
2623 CXCursor_ObjCReturnsInnerPointer = 429,
2624 CXCursor_ObjCRequiresSuper = 430,
2625 CXCursor_ObjCRootClass = 431,
2626 CXCursor_ObjCSubclassingRestricted = 432,
2627 CXCursor_ObjCExplicitProtocolImpl = 433,
2628 CXCursor_ObjCDesignatedInitializer = 434,
2629 CXCursor_ObjCRuntimeVisible = 435,
2630 CXCursor_ObjCBoxable = 436,
Michael Wu58d837d2018-08-03 05:55:40 +00002631 CXCursor_FlagEnum = 437,
Sven van Haastregtdc2c9302019-02-11 11:00:56 +00002632 CXCursor_ConvergentAttr = 438,
Emilio Cobos Alvarez0a3fe502019-02-25 21:24:52 +00002633 CXCursor_WarnUnusedAttr = 439,
2634 CXCursor_WarnUnusedResultAttr = 440,
Emilio Cobos Alvarezcd741272019-03-13 16:16:54 +00002635 CXCursor_AlignedAttr = 441,
2636 CXCursor_LastAttr = CXCursor_AlignedAttr,
Eli Bendersky2581e662014-05-28 19:29:58 +00002637
Douglas Gregor92a524f2010-03-18 00:42:48 +00002638 /* Preprocessing */
2639 CXCursor_PreprocessingDirective = 500,
Douglas Gregor06d6d322010-03-18 18:04:21 +00002640 CXCursor_MacroDefinition = 501,
Chandler Carruth9e4704a2011-07-14 08:41:15 +00002641 CXCursor_MacroExpansion = 502,
2642 CXCursor_MacroInstantiation = CXCursor_MacroExpansion,
Douglas Gregor796d76a2010-10-20 22:00:55 +00002643 CXCursor_InclusionDirective = 503,
Douglas Gregor92a524f2010-03-18 00:42:48 +00002644 CXCursor_FirstPreprocessing = CXCursor_PreprocessingDirective,
Argyrios Kyrtzidis50e5b1d2012-10-05 00:22:24 +00002645 CXCursor_LastPreprocessing = CXCursor_InclusionDirective,
2646
2647 /* Extra Declarations */
2648 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002649 * A module import declaration.
Argyrios Kyrtzidis50e5b1d2012-10-05 00:22:24 +00002650 */
2651 CXCursor_ModuleImportDecl = 600,
Sergey Kalinichev8f3b1872015-11-15 13:48:32 +00002652 CXCursor_TypeAliasTemplateDecl = 601,
Olivier Goffart81978012016-06-09 16:15:55 +00002653 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002654 * A static_assert or _Static_assert node
Olivier Goffart81978012016-06-09 16:15:55 +00002655 */
2656 CXCursor_StaticAssert = 602,
Olivier Goffartd211c642016-11-04 06:29:27 +00002657 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002658 * a friend declaration.
Olivier Goffartd211c642016-11-04 06:29:27 +00002659 */
2660 CXCursor_FriendDecl = 603,
Argyrios Kyrtzidis50e5b1d2012-10-05 00:22:24 +00002661 CXCursor_FirstExtraDecl = CXCursor_ModuleImportDecl,
Olivier Goffartd211c642016-11-04 06:29:27 +00002662 CXCursor_LastExtraDecl = CXCursor_FriendDecl,
Francisco Lopes da Silva975a9f62015-01-21 16:24:11 +00002663
2664 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002665 * A code completion overload candidate.
Francisco Lopes da Silva975a9f62015-01-21 16:24:11 +00002666 */
2667 CXCursor_OverloadCandidate = 700
Douglas Gregor6007cf22010-01-22 22:29:16 +00002668};
2669
2670/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002671 * A cursor representing some element in the abstract syntax tree for
Douglas Gregor6007cf22010-01-22 22:29:16 +00002672 * a translation unit.
2673 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002674 * The cursor abstraction unifies the different kinds of entities in a
Douglas Gregor6007cf22010-01-22 22:29:16 +00002675 * program--declaration, statements, expressions, references to declarations,
2676 * etc.--under a single "cursor" abstraction with a common set of operations.
2677 * Common operation for a cursor include: getting the physical location in
2678 * a source file where the cursor points, getting the name associated with a
2679 * cursor, and retrieving cursors for any child nodes of a particular cursor.
2680 *
2681 * Cursors can be produced in two specific ways.
2682 * clang_getTranslationUnitCursor() produces a cursor for a translation unit,
2683 * from which one can use clang_visitChildren() to explore the rest of the
2684 * translation unit. clang_getCursor() maps from a physical source location
2685 * to the entity that resides at that location, allowing one to map from the
2686 * source code into the AST.
2687 */
2688typedef struct {
2689 enum CXCursorKind kind;
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00002690 int xdata;
Dmitri Gribenkoba2f7462013-01-11 21:01:49 +00002691 const void *data[3];
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002692} CXCursor;
Douglas Gregor6007cf22010-01-22 22:29:16 +00002693
2694/**
2695 * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations
2696 *
2697 * @{
2698 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002699
Douglas Gregor6007cf22010-01-22 22:29:16 +00002700/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002701 * Retrieve the NULL cursor, which represents no entity.
Douglas Gregor6007cf22010-01-22 22:29:16 +00002702 */
2703CINDEX_LINKAGE CXCursor clang_getNullCursor(void);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002704
Douglas Gregor6007cf22010-01-22 22:29:16 +00002705/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002706 * Retrieve the cursor that represents the given translation unit.
Douglas Gregor6007cf22010-01-22 22:29:16 +00002707 *
2708 * The translation unit cursor can be used to start traversing the
2709 * various declarations within the given translation unit.
2710 */
2711CINDEX_LINKAGE CXCursor clang_getTranslationUnitCursor(CXTranslationUnit);
2712
2713/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002714 * Determine whether two cursors are equivalent.
Douglas Gregor6007cf22010-01-22 22:29:16 +00002715 */
2716CINDEX_LINKAGE unsigned clang_equalCursors(CXCursor, CXCursor);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002717
Douglas Gregor6007cf22010-01-22 22:29:16 +00002718/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002719 * Returns non-zero if \p cursor is null.
Argyrios Kyrtzidisd6e9fa52011-09-27 00:30:30 +00002720 */
Dmitri Gribenko8994e0c2012-09-13 13:11:20 +00002721CINDEX_LINKAGE int clang_Cursor_isNull(CXCursor cursor);
Argyrios Kyrtzidisd6e9fa52011-09-27 00:30:30 +00002722
2723/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002724 * Compute a hash value for the given cursor.
Douglas Gregor06a3f302010-11-20 00:09:34 +00002725 */
2726CINDEX_LINKAGE unsigned clang_hashCursor(CXCursor);
Fangrui Song6907ce22018-07-30 19:24:48 +00002727
Douglas Gregor06a3f302010-11-20 00:09:34 +00002728/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002729 * Retrieve the kind of the given cursor.
Douglas Gregor6007cf22010-01-22 22:29:16 +00002730 */
2731CINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor);
2732
2733/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002734 * Determine whether the given cursor kind represents a declaration.
Ivan Donchevskii65c766e2018-01-03 10:40:11 +00002735 */
2736CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind);
2737
2738/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002739 * Determine whether the given declaration is invalid.
Ivan Donchevskii08ff9102018-01-04 10:59:50 +00002740 *
2741 * A declaration is invalid if it could not be parsed successfully.
2742 *
2743 * \returns non-zero if the cursor represents a declaration and it is
2744 * invalid, otherwise NULL.
2745 */
2746CINDEX_LINKAGE unsigned clang_isInvalidDeclaration(CXCursor);
2747
2748/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002749 * Determine whether the given cursor kind represents a simple
Ivan Donchevskii65c766e2018-01-03 10:40:11 +00002750 * reference.
Douglas Gregor6007cf22010-01-22 22:29:16 +00002751 *
2752 * Note that other kinds of cursors (such as expressions) can also refer to
2753 * other cursors. Use clang_getCursorReferenced() to determine whether a
2754 * particular cursor refers to another entity.
2755 */
2756CINDEX_LINKAGE unsigned clang_isReference(enum CXCursorKind);
2757
2758/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002759 * Determine whether the given cursor kind represents an expression.
Douglas Gregor6007cf22010-01-22 22:29:16 +00002760 */
2761CINDEX_LINKAGE unsigned clang_isExpression(enum CXCursorKind);
2762
2763/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002764 * Determine whether the given cursor kind represents a statement.
Douglas Gregor6007cf22010-01-22 22:29:16 +00002765 */
2766CINDEX_LINKAGE unsigned clang_isStatement(enum CXCursorKind);
2767
2768/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002769 * Determine whether the given cursor kind represents an attribute.
Douglas Gregora98034a2011-07-06 03:00:34 +00002770 */
2771CINDEX_LINKAGE unsigned clang_isAttribute(enum CXCursorKind);
2772
2773/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002774 * Determine whether the given cursor has any attributes.
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00002775 */
2776CINDEX_LINKAGE unsigned clang_Cursor_hasAttrs(CXCursor C);
2777
2778/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002779 * Determine whether the given cursor kind represents an invalid
Douglas Gregor6007cf22010-01-22 22:29:16 +00002780 * cursor.
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002781 */
Douglas Gregor6007cf22010-01-22 22:29:16 +00002782CINDEX_LINKAGE unsigned clang_isInvalid(enum CXCursorKind);
2783
2784/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002785 * Determine whether the given cursor kind represents a translation
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002786 * unit.
Douglas Gregor6007cf22010-01-22 22:29:16 +00002787 */
2788CINDEX_LINKAGE unsigned clang_isTranslationUnit(enum CXCursorKind);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002789
Ted Kremenekff9021b2010-03-08 21:17:29 +00002790/***
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002791 * Determine whether the given cursor represents a preprocessing
Douglas Gregor92a524f2010-03-18 00:42:48 +00002792 * element, such as a preprocessor directive or macro instantiation.
2793 */
2794CINDEX_LINKAGE unsigned clang_isPreprocessing(enum CXCursorKind);
Fangrui Song6907ce22018-07-30 19:24:48 +00002795
Douglas Gregor92a524f2010-03-18 00:42:48 +00002796/***
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002797 * Determine whether the given cursor represents a currently
Ted Kremenekff9021b2010-03-08 21:17:29 +00002798 * unexposed piece of the AST (e.g., CXCursor_UnexposedStmt).
2799 */
2800CINDEX_LINKAGE unsigned clang_isUnexposed(enum CXCursorKind);
2801
Douglas Gregor6007cf22010-01-22 22:29:16 +00002802/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002803 * Describe the linkage of the entity referred to by a cursor.
Ted Kremenekfb4961d2010-03-03 06:36:57 +00002804 */
2805enum CXLinkageKind {
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002806 /** This value indicates that no linkage information is available
Ted Kremenekfb4961d2010-03-03 06:36:57 +00002807 * for a provided CXCursor. */
2808 CXLinkage_Invalid,
2809 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002810 * This is the linkage for variables, parameters, and so on that
Ted Kremenekfb4961d2010-03-03 06:36:57 +00002811 * have automatic storage. This covers normal (non-extern) local variables.
2812 */
2813 CXLinkage_NoLinkage,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002814 /** This is the linkage for static variables and static functions. */
Ted Kremenekfb4961d2010-03-03 06:36:57 +00002815 CXLinkage_Internal,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002816 /** This is the linkage for entities with external linkage that live
Ted Kremenekfb4961d2010-03-03 06:36:57 +00002817 * in C++ anonymous namespaces.*/
2818 CXLinkage_UniqueExternal,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002819 /** This is the linkage for entities with true, external linkage. */
Ted Kremenekfb4961d2010-03-03 06:36:57 +00002820 CXLinkage_External
2821};
2822
2823/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002824 * Determine the linkage of the entity referred to by a given cursor.
Ted Kremenekfb4961d2010-03-03 06:36:57 +00002825 */
2826CINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor);
2827
Ehsan Akhgarib743de72016-05-31 15:55:51 +00002828enum CXVisibilityKind {
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002829 /** This value indicates that no visibility information is available
Ehsan Akhgarib743de72016-05-31 15:55:51 +00002830 * for a provided CXCursor. */
2831 CXVisibility_Invalid,
2832
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002833 /** Symbol not seen by the linker. */
Ehsan Akhgarib743de72016-05-31 15:55:51 +00002834 CXVisibility_Hidden,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002835 /** Symbol seen by the linker but resolves to a symbol inside this object. */
Ehsan Akhgarib743de72016-05-31 15:55:51 +00002836 CXVisibility_Protected,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002837 /** Symbol seen by the linker and acts like a normal symbol. */
Ehsan Akhgarib743de72016-05-31 15:55:51 +00002838 CXVisibility_Default
2839};
2840
2841/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002842 * Describe the visibility of the entity referred to by a cursor.
Ehsan Akhgarib743de72016-05-31 15:55:51 +00002843 *
2844 * This returns the default visibility if not explicitly specified by
2845 * a visibility attribute. The default visibility may be changed by
2846 * commandline arguments.
2847 *
2848 * \param cursor The cursor to query.
2849 *
2850 * \returns The visibility of the cursor.
2851 */
2852CINDEX_LINKAGE enum CXVisibilityKind clang_getCursorVisibility(CXCursor cursor);
2853
Ehsan Akhgari93697fa2015-11-23 19:56:46 +00002854/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002855 * Determine the availability of the entity that this cursor refers to,
Douglas Gregord6225d32012-05-08 00:14:45 +00002856 * taking the current target platform into account.
Douglas Gregorf757a122010-08-23 23:00:57 +00002857 *
2858 * \param cursor The cursor to query.
2859 *
2860 * \returns The availability of the cursor.
2861 */
Fangrui Song6907ce22018-07-30 19:24:48 +00002862CINDEX_LINKAGE enum CXAvailabilityKind
Douglas Gregorf757a122010-08-23 23:00:57 +00002863clang_getCursorAvailability(CXCursor cursor);
2864
2865/**
Douglas Gregord6225d32012-05-08 00:14:45 +00002866 * Describes the availability of a given entity on a particular platform, e.g.,
2867 * a particular class might only be available on Mac OS 10.7 or newer.
2868 */
2869typedef struct CXPlatformAvailability {
2870 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002871 * A string that describes the platform for which this structure
Douglas Gregord6225d32012-05-08 00:14:45 +00002872 * provides availability information.
2873 *
Manman Renccf25bb2016-06-28 20:55:30 +00002874 * Possible values are "ios" or "macos".
Douglas Gregord6225d32012-05-08 00:14:45 +00002875 */
2876 CXString Platform;
2877 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002878 * The version number in which this entity was introduced.
Douglas Gregord6225d32012-05-08 00:14:45 +00002879 */
2880 CXVersion Introduced;
2881 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002882 * The version number in which this entity was deprecated (but is
Douglas Gregord6225d32012-05-08 00:14:45 +00002883 * still available).
2884 */
2885 CXVersion Deprecated;
2886 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002887 * The version number in which this entity was obsoleted, and therefore
Douglas Gregord6225d32012-05-08 00:14:45 +00002888 * is no longer available.
2889 */
2890 CXVersion Obsoleted;
2891 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002892 * Whether the entity is unconditionally unavailable on this platform.
Douglas Gregord6225d32012-05-08 00:14:45 +00002893 */
2894 int Unavailable;
2895 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002896 * An optional message to provide to a user of this API, e.g., to
Douglas Gregord6225d32012-05-08 00:14:45 +00002897 * suggest replacement APIs.
2898 */
2899 CXString Message;
2900} CXPlatformAvailability;
2901
2902/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002903 * Determine the availability of the entity that this cursor refers to
Douglas Gregord6225d32012-05-08 00:14:45 +00002904 * on any platforms for which availability information is known.
2905 *
2906 * \param cursor The cursor to query.
2907 *
Fangrui Song6907ce22018-07-30 19:24:48 +00002908 * \param always_deprecated If non-NULL, will be set to indicate whether the
Douglas Gregord6225d32012-05-08 00:14:45 +00002909 * entity is deprecated on all platforms.
2910 *
Fangrui Song6907ce22018-07-30 19:24:48 +00002911 * \param deprecated_message If non-NULL, will be set to the message text
Douglas Gregord6225d32012-05-08 00:14:45 +00002912 * provided along with the unconditional deprecation of this entity. The client
2913 * is responsible for deallocating this string.
2914 *
James Dennett574cb4c2012-06-15 05:41:51 +00002915 * \param always_unavailable If non-NULL, will be set to indicate whether the
Douglas Gregord6225d32012-05-08 00:14:45 +00002916 * entity is unavailable on all platforms.
2917 *
2918 * \param unavailable_message If non-NULL, will be set to the message text
Fangrui Song6907ce22018-07-30 19:24:48 +00002919 * provided along with the unconditional unavailability of this entity. The
Douglas Gregord6225d32012-05-08 00:14:45 +00002920 * client is responsible for deallocating this string.
2921 *
2922 * \param availability If non-NULL, an array of CXPlatformAvailability instances
2923 * that will be populated with platform availability information, up to either
2924 * the number of platforms for which availability information is available (as
2925 * returned by this function) or \c availability_size, whichever is smaller.
2926 *
Fangrui Song6907ce22018-07-30 19:24:48 +00002927 * \param availability_size The number of elements available in the
Douglas Gregord6225d32012-05-08 00:14:45 +00002928 * \c availability array.
2929 *
2930 * \returns The number of platforms (N) for which availability information is
2931 * available (which is unrelated to \c availability_size).
2932 *
Fangrui Song6907ce22018-07-30 19:24:48 +00002933 * Note that the client is responsible for calling
2934 * \c clang_disposeCXPlatformAvailability to free each of the
2935 * platform-availability structures returned. There are
Douglas Gregord6225d32012-05-08 00:14:45 +00002936 * \c min(N, availability_size) such structures.
2937 */
2938CINDEX_LINKAGE int
2939clang_getCursorPlatformAvailability(CXCursor cursor,
2940 int *always_deprecated,
2941 CXString *deprecated_message,
2942 int *always_unavailable,
2943 CXString *unavailable_message,
2944 CXPlatformAvailability *availability,
2945 int availability_size);
2946
2947/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002948 * Free the memory associated with a \c CXPlatformAvailability structure.
Douglas Gregord6225d32012-05-08 00:14:45 +00002949 */
2950CINDEX_LINKAGE void
2951clang_disposeCXPlatformAvailability(CXPlatformAvailability *availability);
Fangrui Song6907ce22018-07-30 19:24:48 +00002952
Douglas Gregord6225d32012-05-08 00:14:45 +00002953/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002954 * Describe the "language" of the entity referred to by a cursor.
Ted Kremenek4ed29252010-04-12 21:22:16 +00002955 */
Reid Kleckner9e3bc722013-12-30 17:48:49 +00002956enum CXLanguageKind {
Ted Kremenekee457512010-04-14 20:58:32 +00002957 CXLanguage_Invalid = 0,
Ted Kremenek4ed29252010-04-12 21:22:16 +00002958 CXLanguage_C,
2959 CXLanguage_ObjC,
Ted Kremenekee457512010-04-14 20:58:32 +00002960 CXLanguage_CPlusPlus
Ted Kremenek4ed29252010-04-12 21:22:16 +00002961};
2962
2963/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002964 * Determine the "language" of the entity referred to by a given cursor.
Ted Kremenek4ed29252010-04-12 21:22:16 +00002965 */
2966CINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor);
2967
Argyrios Kyrtzidisd6e9fa52011-09-27 00:30:30 +00002968/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002969 * Describe the "thread-local storage (TLS) kind" of the declaration
Saleem Abdulrasool50bc5652017-09-13 02:15:09 +00002970 * referred to by a cursor.
2971 */
2972enum CXTLSKind {
2973 CXTLS_None = 0,
2974 CXTLS_Dynamic,
2975 CXTLS_Static
2976};
2977
2978/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002979 * Determine the "thread-local storage (TLS) kind" of the declaration
Saleem Abdulrasool50bc5652017-09-13 02:15:09 +00002980 * referred to by a cursor.
2981 */
2982CINDEX_LINKAGE enum CXTLSKind clang_getCursorTLSKind(CXCursor cursor);
2983
2984/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002985 * Returns the translation unit that a cursor originated from.
Argyrios Kyrtzidisd6e9fa52011-09-27 00:30:30 +00002986 */
2987CINDEX_LINKAGE CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor);
2988
Ted Kremenekc0b98662013-04-24 07:17:12 +00002989/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002990 * A fast container representing a set of CXCursors.
Ted Kremenekc0b98662013-04-24 07:17:12 +00002991 */
2992typedef struct CXCursorSetImpl *CXCursorSet;
2993
2994/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00002995 * Creates an empty CXCursorSet.
Ted Kremenekc0b98662013-04-24 07:17:12 +00002996 */
2997CINDEX_LINKAGE CXCursorSet clang_createCXCursorSet(void);
2998
2999/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003000 * Disposes a CXCursorSet and releases its associated memory.
Ted Kremenekc0b98662013-04-24 07:17:12 +00003001 */
3002CINDEX_LINKAGE void clang_disposeCXCursorSet(CXCursorSet cset);
3003
3004/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003005 * Queries a CXCursorSet to see if it contains a specific CXCursor.
Ted Kremenekc0b98662013-04-24 07:17:12 +00003006 *
3007 * \returns non-zero if the set contains the specified cursor.
3008*/
3009CINDEX_LINKAGE unsigned clang_CXCursorSet_contains(CXCursorSet cset,
3010 CXCursor cursor);
3011
3012/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003013 * Inserts a CXCursor into a CXCursorSet.
Ted Kremenekc0b98662013-04-24 07:17:12 +00003014 *
3015 * \returns zero if the CXCursor was already in the set, and non-zero otherwise.
3016*/
3017CINDEX_LINKAGE unsigned clang_CXCursorSet_insert(CXCursorSet cset,
3018 CXCursor cursor);
3019
Douglas Gregor0576ce72010-09-22 21:22:29 +00003020/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003021 * Determine the semantic parent of the given cursor.
Douglas Gregor0576ce72010-09-22 21:22:29 +00003022 *
3023 * The semantic parent of a cursor is the cursor that semantically contains
3024 * the given \p cursor. For many declarations, the lexical and semantic parents
Fangrui Song6907ce22018-07-30 19:24:48 +00003025 * are equivalent (the lexical parent is returned by
Douglas Gregor0576ce72010-09-22 21:22:29 +00003026 * \c clang_getCursorLexicalParent()). They diverge when declarations or
3027 * definitions are provided out-of-line. For example:
3028 *
3029 * \code
3030 * class C {
3031 * void f();
3032 * };
3033 *
3034 * void C::f() { }
3035 * \endcode
3036 *
Nico Weber7deebef2014-04-24 03:17:47 +00003037 * In the out-of-line definition of \c C::f, the semantic parent is
Douglas Gregor0576ce72010-09-22 21:22:29 +00003038 * the class \c C, of which this function is a member. The lexical parent is
3039 * the place where the declaration actually occurs in the source code; in this
Nico Weber7deebef2014-04-24 03:17:47 +00003040 * case, the definition occurs in the translation unit. In general, the
Douglas Gregor0576ce72010-09-22 21:22:29 +00003041 * lexical parent for a given entity can change without affecting the semantics
3042 * of the program, and the lexical parent of different declarations of the
3043 * same entity may be different. Changing the semantic parent of a declaration,
3044 * on the other hand, can have a major impact on semantics, and redeclarations
3045 * of a particular entity should all have the same semantic context.
3046 *
3047 * In the example above, both declarations of \c C::f have \c C as their
3048 * semantic context, while the lexical context of the first \c C::f is \c C
3049 * and the lexical context of the second \c C::f is the translation unit.
Douglas Gregor7ecd19e2010-12-21 07:55:45 +00003050 *
3051 * For global declarations, the semantic parent is the translation unit.
Douglas Gregor0576ce72010-09-22 21:22:29 +00003052 */
3053CINDEX_LINKAGE CXCursor clang_getCursorSemanticParent(CXCursor cursor);
3054
3055/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003056 * Determine the lexical parent of the given cursor.
Douglas Gregor0576ce72010-09-22 21:22:29 +00003057 *
3058 * The lexical parent of a cursor is the cursor in which the given \p cursor
3059 * was actually written. For many declarations, the lexical and semantic parents
Fangrui Song6907ce22018-07-30 19:24:48 +00003060 * are equivalent (the semantic parent is returned by
Douglas Gregor0576ce72010-09-22 21:22:29 +00003061 * \c clang_getCursorSemanticParent()). They diverge when declarations or
3062 * definitions are provided out-of-line. For example:
3063 *
3064 * \code
3065 * class C {
3066 * void f();
3067 * };
3068 *
3069 * void C::f() { }
3070 * \endcode
3071 *
Nico Weber7deebef2014-04-24 03:17:47 +00003072 * In the out-of-line definition of \c C::f, the semantic parent is
Douglas Gregor0576ce72010-09-22 21:22:29 +00003073 * the class \c C, of which this function is a member. The lexical parent is
3074 * the place where the declaration actually occurs in the source code; in this
Nico Weber7deebef2014-04-24 03:17:47 +00003075 * case, the definition occurs in the translation unit. In general, the
Douglas Gregor0576ce72010-09-22 21:22:29 +00003076 * lexical parent for a given entity can change without affecting the semantics
3077 * of the program, and the lexical parent of different declarations of the
3078 * same entity may be different. Changing the semantic parent of a declaration,
3079 * on the other hand, can have a major impact on semantics, and redeclarations
3080 * of a particular entity should all have the same semantic context.
3081 *
3082 * In the example above, both declarations of \c C::f have \c C as their
3083 * semantic context, while the lexical context of the first \c C::f is \c C
3084 * and the lexical context of the second \c C::f is the translation unit.
Douglas Gregor7ecd19e2010-12-21 07:55:45 +00003085 *
3086 * For declarations written in the global scope, the lexical parent is
3087 * the translation unit.
Douglas Gregor0576ce72010-09-22 21:22:29 +00003088 */
3089CINDEX_LINKAGE CXCursor clang_getCursorLexicalParent(CXCursor cursor);
Douglas Gregor99a26af2010-10-01 20:25:15 +00003090
3091/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003092 * Determine the set of methods that are overridden by the given
Douglas Gregor99a26af2010-10-01 20:25:15 +00003093 * method.
3094 *
3095 * In both Objective-C and C++, a method (aka virtual member function,
3096 * in C++) can override a virtual method in a base class. For
3097 * Objective-C, a method is said to override any method in the class's
Argyrios Kyrtzidisbfb24252012-03-08 00:20:03 +00003098 * base class, its protocols, or its categories' protocols, that has the same
3099 * selector and is of the same kind (class or instance).
3100 * If no such method exists, the search continues to the class's superclass,
3101 * its protocols, and its categories, and so on. A method from an Objective-C
3102 * implementation is considered to override the same methods as its
3103 * corresponding method in the interface.
Douglas Gregor99a26af2010-10-01 20:25:15 +00003104 *
3105 * For C++, a virtual member function overrides any virtual member
3106 * function with the same signature that occurs in its base
3107 * classes. With multiple inheritance, a virtual member function can
3108 * override several virtual member functions coming from different
3109 * base classes.
3110 *
3111 * In all cases, this function determines the immediate overridden
3112 * method, rather than all of the overridden methods. For example, if
3113 * a method is originally declared in a class A, then overridden in B
3114 * (which in inherits from A) and also in C (which inherited from B),
3115 * then the only overridden method returned from this function when
3116 * invoked on C's method will be B's method. The client may then
3117 * invoke this function again, given the previously-found overridden
3118 * methods, to map out the complete method-override set.
3119 *
3120 * \param cursor A cursor representing an Objective-C or C++
3121 * method. This routine will compute the set of methods that this
3122 * method overrides.
Fangrui Song6907ce22018-07-30 19:24:48 +00003123 *
Douglas Gregor99a26af2010-10-01 20:25:15 +00003124 * \param overridden A pointer whose pointee will be replaced with a
3125 * pointer to an array of cursors, representing the set of overridden
3126 * methods. If there are no overridden methods, the pointee will be
Fangrui Song6907ce22018-07-30 19:24:48 +00003127 * set to NULL. The pointee must be freed via a call to
Douglas Gregor99a26af2010-10-01 20:25:15 +00003128 * \c clang_disposeOverriddenCursors().
3129 *
3130 * \param num_overridden A pointer to the number of overridden
3131 * functions, will be set to the number of overridden functions in the
3132 * array pointed to by \p overridden.
3133 */
Fangrui Song6907ce22018-07-30 19:24:48 +00003134CINDEX_LINKAGE void clang_getOverriddenCursors(CXCursor cursor,
Douglas Gregor99a26af2010-10-01 20:25:15 +00003135 CXCursor **overridden,
3136 unsigned *num_overridden);
3137
3138/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003139 * Free the set of overridden cursors returned by \c
Douglas Gregor99a26af2010-10-01 20:25:15 +00003140 * clang_getOverriddenCursors().
3141 */
3142CINDEX_LINKAGE void clang_disposeOverriddenCursors(CXCursor *overridden);
3143
Ted Kremenek4ed29252010-04-12 21:22:16 +00003144/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003145 * Retrieve the file that is included by the given inclusion directive
Douglas Gregor796d76a2010-10-20 22:00:55 +00003146 * cursor.
3147 */
3148CINDEX_LINKAGE CXFile clang_getIncludedFile(CXCursor cursor);
Fangrui Song6907ce22018-07-30 19:24:48 +00003149
Douglas Gregor796d76a2010-10-20 22:00:55 +00003150/**
Douglas Gregor6007cf22010-01-22 22:29:16 +00003151 * @}
3152 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003153
Douglas Gregor6007cf22010-01-22 22:29:16 +00003154/**
3155 * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code
3156 *
3157 * Cursors represent a location within the Abstract Syntax Tree (AST). These
3158 * routines help map between cursors and the physical locations where the
3159 * described entities occur in the source code. The mapping is provided in
3160 * both directions, so one can map from source code to the AST and back.
3161 *
3162 * @{
Steve Naroffa1c72842009-08-28 15:28:48 +00003163 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003164
Steve Naroff20bad0b2009-10-21 13:56:23 +00003165/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003166 * Map a source location to the cursor that describes the entity at that
Douglas Gregor816fd362010-01-22 21:44:22 +00003167 * location in the source code.
3168 *
3169 * clang_getCursor() maps an arbitrary source location within a translation
3170 * unit down to the most specific cursor that describes the entity at that
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003171 * location. For example, given an expression \c x + y, invoking
Douglas Gregor816fd362010-01-22 21:44:22 +00003172 * clang_getCursor() with a source location pointing to "x" will return the
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003173 * cursor for "x"; similarly for "y". If the cursor points anywhere between
Douglas Gregor816fd362010-01-22 21:44:22 +00003174 * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor()
3175 * will return a cursor referring to the "+" expression.
3176 *
3177 * \returns a cursor representing the entity at the given source location, or
3178 * a NULL cursor if no such entity can be found.
Steve Naroff20bad0b2009-10-21 13:56:23 +00003179 */
Douglas Gregor816fd362010-01-22 21:44:22 +00003180CINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, CXSourceLocation);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003181
Douglas Gregor66a58812010-01-18 22:46:11 +00003182/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003183 * Retrieve the physical location of the source constructor referenced
Douglas Gregor66a58812010-01-18 22:46:11 +00003184 * by the given cursor.
3185 *
3186 * The location of a declaration is typically the location of the name of that
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003187 * declaration, where the name of that declaration would occur if it is
3188 * unnamed, or some keyword that introduces that particular declaration.
3189 * The location of a reference is where that reference occurs within the
Douglas Gregor66a58812010-01-18 22:46:11 +00003190 * source code.
3191 */
3192CINDEX_LINKAGE CXSourceLocation clang_getCursorLocation(CXCursor);
Douglas Gregor6007cf22010-01-22 22:29:16 +00003193
Douglas Gregor6b8232f2010-01-19 19:34:47 +00003194/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003195 * Retrieve the physical extent of the source construct referenced by
Douglas Gregor33c34ac2010-01-19 00:34:46 +00003196 * the given cursor.
3197 *
3198 * The extent of a cursor starts with the file/line/column pointing at the
3199 * first character within the source construct that the cursor refers to and
Nico Weber7deebef2014-04-24 03:17:47 +00003200 * ends with the last character within that source construct. For a
Douglas Gregor33c34ac2010-01-19 00:34:46 +00003201 * declaration, the extent covers the declaration itself. For a reference,
3202 * the extent covers the location of the reference (e.g., where the referenced
3203 * entity was actually used).
3204 */
3205CINDEX_LINKAGE CXSourceRange clang_getCursorExtent(CXCursor);
Douglas Gregorad27e8b2010-01-19 01:20:04 +00003206
Douglas Gregor6007cf22010-01-22 22:29:16 +00003207/**
3208 * @}
3209 */
Fangrui Song6907ce22018-07-30 19:24:48 +00003210
Douglas Gregor6007cf22010-01-22 22:29:16 +00003211/**
Ted Kremenek6bca9842010-05-14 21:29:26 +00003212 * \defgroup CINDEX_TYPES Type information for CXCursors
3213 *
3214 * @{
3215 */
3216
3217/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003218 * Describes the kind of type
Ted Kremenek6bca9842010-05-14 21:29:26 +00003219 */
3220enum CXTypeKind {
3221 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003222 * Represents an invalid type (e.g., where no type is available).
Ted Kremenek6bca9842010-05-14 21:29:26 +00003223 */
3224 CXType_Invalid = 0,
3225
3226 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003227 * A type whose specific kind is not exposed via this
Ted Kremenek6bca9842010-05-14 21:29:26 +00003228 * interface.
3229 */
3230 CXType_Unexposed = 1,
3231
3232 /* Builtin types */
3233 CXType_Void = 2,
3234 CXType_Bool = 3,
3235 CXType_Char_U = 4,
3236 CXType_UChar = 5,
3237 CXType_Char16 = 6,
3238 CXType_Char32 = 7,
3239 CXType_UShort = 8,
3240 CXType_UInt = 9,
3241 CXType_ULong = 10,
3242 CXType_ULongLong = 11,
3243 CXType_UInt128 = 12,
3244 CXType_Char_S = 13,
3245 CXType_SChar = 14,
3246 CXType_WChar = 15,
3247 CXType_Short = 16,
3248 CXType_Int = 17,
3249 CXType_Long = 18,
3250 CXType_LongLong = 19,
3251 CXType_Int128 = 20,
3252 CXType_Float = 21,
3253 CXType_Double = 22,
3254 CXType_LongDouble = 23,
3255 CXType_NullPtr = 24,
3256 CXType_Overload = 25,
3257 CXType_Dependent = 26,
3258 CXType_ObjCId = 27,
3259 CXType_ObjCClass = 28,
3260 CXType_ObjCSel = 29,
Nemanja Ivanovicbb1ea2d2016-05-09 08:52:33 +00003261 CXType_Float128 = 30,
Joey Gouly6ea21852017-02-10 15:51:11 +00003262 CXType_Half = 31,
Sjoerd Meijercc623ad2017-09-08 15:15:00 +00003263 CXType_Float16 = 32,
Leonard Chanf921d852018-06-04 16:07:52 +00003264 CXType_ShortAccum = 33,
3265 CXType_Accum = 34,
3266 CXType_LongAccum = 35,
3267 CXType_UShortAccum = 36,
3268 CXType_UAccum = 37,
3269 CXType_ULongAccum = 38,
Ted Kremenek6bca9842010-05-14 21:29:26 +00003270 CXType_FirstBuiltin = CXType_Void,
Leonard Chanf921d852018-06-04 16:07:52 +00003271 CXType_LastBuiltin = CXType_ULongAccum,
Ted Kremenek6bca9842010-05-14 21:29:26 +00003272
3273 CXType_Complex = 100,
3274 CXType_Pointer = 101,
3275 CXType_BlockPointer = 102,
3276 CXType_LValueReference = 103,
3277 CXType_RValueReference = 104,
3278 CXType_Record = 105,
3279 CXType_Enum = 106,
3280 CXType_Typedef = 107,
3281 CXType_ObjCInterface = 108,
Ted Kremenekc1508872010-06-21 20:15:39 +00003282 CXType_ObjCObjectPointer = 109,
3283 CXType_FunctionNoProto = 110,
Argyrios Kyrtzidis2b0cf602011-09-27 17:44:34 +00003284 CXType_FunctionProto = 111,
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003285 CXType_ConstantArray = 112,
Argyrios Kyrtzidis0661a712013-07-23 17:36:21 +00003286 CXType_Vector = 113,
3287 CXType_IncompleteArray = 114,
3288 CXType_VariableArray = 115,
Argyrios Kyrtzidis7a4253b2013-10-03 16:19:23 +00003289 CXType_DependentSizedArray = 116,
Sergey Kalinichevc0151202015-11-15 13:10:10 +00003290 CXType_MemberPointer = 117,
Sergey Kalinichev69770ae2016-05-03 06:58:29 +00003291 CXType_Auto = 118,
3292
3293 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003294 * Represents a type that was referred to using an elaborated type keyword.
Sergey Kalinichev69770ae2016-05-03 06:58:29 +00003295 *
3296 * E.g., struct S, or via a qualified name, e.g., N::M::type, or both.
3297 */
Sven van Haastregtcc4f1e42017-05-23 10:36:43 +00003298 CXType_Elaborated = 119,
3299
3300 /* OpenCL PipeType. */
3301 CXType_Pipe = 120,
3302
3303 /* OpenCL builtin types. */
3304 CXType_OCLImage1dRO = 121,
3305 CXType_OCLImage1dArrayRO = 122,
3306 CXType_OCLImage1dBufferRO = 123,
3307 CXType_OCLImage2dRO = 124,
3308 CXType_OCLImage2dArrayRO = 125,
3309 CXType_OCLImage2dDepthRO = 126,
3310 CXType_OCLImage2dArrayDepthRO = 127,
3311 CXType_OCLImage2dMSAARO = 128,
3312 CXType_OCLImage2dArrayMSAARO = 129,
3313 CXType_OCLImage2dMSAADepthRO = 130,
3314 CXType_OCLImage2dArrayMSAADepthRO = 131,
3315 CXType_OCLImage3dRO = 132,
3316 CXType_OCLImage1dWO = 133,
3317 CXType_OCLImage1dArrayWO = 134,
3318 CXType_OCLImage1dBufferWO = 135,
3319 CXType_OCLImage2dWO = 136,
3320 CXType_OCLImage2dArrayWO = 137,
3321 CXType_OCLImage2dDepthWO = 138,
3322 CXType_OCLImage2dArrayDepthWO = 139,
3323 CXType_OCLImage2dMSAAWO = 140,
3324 CXType_OCLImage2dArrayMSAAWO = 141,
3325 CXType_OCLImage2dMSAADepthWO = 142,
3326 CXType_OCLImage2dArrayMSAADepthWO = 143,
3327 CXType_OCLImage3dWO = 144,
3328 CXType_OCLImage1dRW = 145,
3329 CXType_OCLImage1dArrayRW = 146,
3330 CXType_OCLImage1dBufferRW = 147,
3331 CXType_OCLImage2dRW = 148,
3332 CXType_OCLImage2dArrayRW = 149,
3333 CXType_OCLImage2dDepthRW = 150,
3334 CXType_OCLImage2dArrayDepthRW = 151,
3335 CXType_OCLImage2dMSAARW = 152,
3336 CXType_OCLImage2dArrayMSAARW = 153,
3337 CXType_OCLImage2dMSAADepthRW = 154,
3338 CXType_OCLImage2dArrayMSAADepthRW = 155,
3339 CXType_OCLImage3dRW = 156,
3340 CXType_OCLSampler = 157,
3341 CXType_OCLEvent = 158,
3342 CXType_OCLQueue = 159,
Michael Wu9c852612018-08-03 03:03:20 +00003343 CXType_OCLReserveID = 160,
3344
Michael Wuced99b92018-08-03 04:02:40 +00003345 CXType_ObjCObject = 161,
Michael Wu153085d2018-08-03 04:21:25 +00003346 CXType_ObjCTypeParam = 162,
Andrew Savonichev3fee3512018-11-08 11:25:41 +00003347 CXType_Attributed = 163,
3348
3349 CXType_OCLIntelSubgroupAVCMcePayload = 164,
3350 CXType_OCLIntelSubgroupAVCImePayload = 165,
3351 CXType_OCLIntelSubgroupAVCRefPayload = 166,
3352 CXType_OCLIntelSubgroupAVCSicPayload = 167,
3353 CXType_OCLIntelSubgroupAVCMceResult = 168,
3354 CXType_OCLIntelSubgroupAVCImeResult = 169,
3355 CXType_OCLIntelSubgroupAVCRefResult = 170,
3356 CXType_OCLIntelSubgroupAVCSicResult = 171,
3357 CXType_OCLIntelSubgroupAVCImeResultSingleRefStreamout = 172,
3358 CXType_OCLIntelSubgroupAVCImeResultDualRefStreamout = 173,
3359 CXType_OCLIntelSubgroupAVCImeSingleRefStreamin = 174,
3360
Sven van Haastregtc9945cc2019-04-17 09:08:50 +00003361 CXType_OCLIntelSubgroupAVCImeDualRefStreamin = 175,
3362
3363 CXType_ExtVector = 176
Ted Kremenek6bca9842010-05-14 21:29:26 +00003364};
3365
3366/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003367 * Describes the calling convention of a function type
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003368 */
3369enum CXCallingConv {
3370 CXCallingConv_Default = 0,
3371 CXCallingConv_C = 1,
3372 CXCallingConv_X86StdCall = 2,
3373 CXCallingConv_X86FastCall = 3,
3374 CXCallingConv_X86ThisCall = 4,
3375 CXCallingConv_X86Pascal = 5,
3376 CXCallingConv_AAPCS = 6,
3377 CXCallingConv_AAPCS_VFP = 7,
Erich Keane757d3172016-11-02 18:29:35 +00003378 CXCallingConv_X86RegCall = 8,
Guy Benyeif0a014b2012-12-25 08:53:55 +00003379 CXCallingConv_IntelOclBicc = 9,
Martin Storsjo022e7822017-07-17 20:49:45 +00003380 CXCallingConv_Win64 = 10,
Nikolai Bozhenovce25d412017-08-08 14:13:50 +00003381 /* Alias for compatibility with older versions of API. */
3382 CXCallingConv_X86_64Win64 = CXCallingConv_Win64,
Charles Davisb5a214e2013-08-30 04:39:01 +00003383 CXCallingConv_X86_64SysV = 11,
Reid Klecknerd7857f02014-10-24 17:42:17 +00003384 CXCallingConv_X86VectorCall = 12,
John McCall477f2bb2016-03-03 06:39:32 +00003385 CXCallingConv_Swift = 13,
Roman Levenstein35aa5ce2016-03-16 18:00:46 +00003386 CXCallingConv_PreserveMost = 14,
3387 CXCallingConv_PreserveAll = 15,
Sander de Smalen44a22532018-11-26 16:38:37 +00003388 CXCallingConv_AArch64VectorCall = 16,
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003389
3390 CXCallingConv_Invalid = 100,
3391 CXCallingConv_Unexposed = 200
3392};
3393
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003394/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003395 * The type of an element in the abstract syntax tree.
Ted Kremenek6bca9842010-05-14 21:29:26 +00003396 *
3397 */
3398typedef struct {
3399 enum CXTypeKind kind;
3400 void *data[2];
3401} CXType;
3402
3403/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003404 * Retrieve the type of a CXCursor (if any).
Ted Kremenek6bca9842010-05-14 21:29:26 +00003405 */
3406CINDEX_LINKAGE CXType clang_getCursorType(CXCursor C);
3407
3408/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003409 * Pretty-print the underlying type using the rules of the
Dmitri Gribenko00353722013-02-15 21:15:49 +00003410 * language of the translation unit from which it came.
3411 *
3412 * If the type is invalid, an empty string is returned.
3413 */
3414CINDEX_LINKAGE CXString clang_getTypeSpelling(CXType CT);
3415
3416/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003417 * Retrieve the underlying type of a typedef declaration.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003418 *
3419 * If the cursor does not reference a typedef declaration, an invalid type is
3420 * returned.
3421 */
3422CINDEX_LINKAGE CXType clang_getTypedefDeclUnderlyingType(CXCursor C);
3423
3424/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003425 * Retrieve the integer type of an enum declaration.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003426 *
3427 * If the cursor does not reference an enum declaration, an invalid type is
3428 * returned.
3429 */
3430CINDEX_LINKAGE CXType clang_getEnumDeclIntegerType(CXCursor C);
3431
3432/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003433 * Retrieve the integer value of an enum constant declaration as a signed
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003434 * long long.
3435 *
3436 * If the cursor does not reference an enum constant declaration, LLONG_MIN is returned.
3437 * Since this is also potentially a valid constant value, the kind of the cursor
3438 * must be verified before calling this function.
3439 */
3440CINDEX_LINKAGE long long clang_getEnumConstantDeclValue(CXCursor C);
3441
3442/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003443 * Retrieve the integer value of an enum constant declaration as an unsigned
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003444 * long long.
3445 *
3446 * If the cursor does not reference an enum constant declaration, ULLONG_MAX is returned.
3447 * Since this is also potentially a valid constant value, the kind of the cursor
3448 * must be verified before calling this function.
3449 */
3450CINDEX_LINKAGE unsigned long long clang_getEnumConstantDeclUnsignedValue(CXCursor C);
3451
3452/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003453 * Retrieve the bit width of a bit field declaration as an integer.
Dmitri Gribenkob506ba12012-12-04 15:13:46 +00003454 *
3455 * If a cursor that is not a bit field declaration is passed in, -1 is returned.
3456 */
3457CINDEX_LINKAGE int clang_getFieldDeclBitWidth(CXCursor C);
3458
3459/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003460 * Retrieve the number of non-variadic arguments associated with a given
Argyrios Kyrtzidis0c27e4b2012-04-11 19:32:19 +00003461 * cursor.
3462 *
Argyrios Kyrtzidisb2792972013-04-01 17:38:59 +00003463 * The number of arguments can be determined for calls as well as for
3464 * declarations of functions or methods. For other cursors -1 is returned.
Argyrios Kyrtzidis0c27e4b2012-04-11 19:32:19 +00003465 */
3466CINDEX_LINKAGE int clang_Cursor_getNumArguments(CXCursor C);
3467
3468/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003469 * Retrieve the argument cursor of a function or method.
Argyrios Kyrtzidis0c27e4b2012-04-11 19:32:19 +00003470 *
Argyrios Kyrtzidisb2792972013-04-01 17:38:59 +00003471 * The argument cursor can be determined for calls as well as for declarations
3472 * of functions or methods. For other cursors and for invalid indices, an
3473 * invalid cursor is returned.
Argyrios Kyrtzidis0c27e4b2012-04-11 19:32:19 +00003474 */
3475CINDEX_LINKAGE CXCursor clang_Cursor_getArgument(CXCursor C, unsigned i);
3476
3477/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003478 * Describes the kind of a template argument.
Eli Benderskyc27a0c42014-10-10 20:01:05 +00003479 *
3480 * See the definition of llvm::clang::TemplateArgument::ArgKind for full
3481 * element descriptions.
3482 */
3483enum CXTemplateArgumentKind {
3484 CXTemplateArgumentKind_Null,
3485 CXTemplateArgumentKind_Type,
3486 CXTemplateArgumentKind_Declaration,
3487 CXTemplateArgumentKind_NullPtr,
3488 CXTemplateArgumentKind_Integral,
3489 CXTemplateArgumentKind_Template,
3490 CXTemplateArgumentKind_TemplateExpansion,
3491 CXTemplateArgumentKind_Expression,
3492 CXTemplateArgumentKind_Pack,
3493 /* Indicates an error case, preventing the kind from being deduced. */
3494 CXTemplateArgumentKind_Invalid
3495};
3496
3497/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003498 *Returns the number of template args of a function decl representing a
Eli Benderskyc27a0c42014-10-10 20:01:05 +00003499 * template specialization.
3500 *
3501 * If the argument cursor cannot be converted into a template function
3502 * declaration, -1 is returned.
3503 *
3504 * For example, for the following declaration and specialization:
3505 * template <typename T, int kInt, bool kBool>
3506 * void foo() { ... }
3507 *
3508 * template <>
3509 * void foo<float, -7, true>();
3510 *
3511 * The value 3 would be returned from this call.
3512 */
3513CINDEX_LINKAGE int clang_Cursor_getNumTemplateArguments(CXCursor C);
3514
3515/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003516 * Retrieve the kind of the I'th template argument of the CXCursor C.
Eli Benderskyc27a0c42014-10-10 20:01:05 +00003517 *
3518 * If the argument CXCursor does not represent a FunctionDecl, an invalid
3519 * template argument kind is returned.
3520 *
3521 * For example, for the following declaration and specialization:
3522 * template <typename T, int kInt, bool kBool>
3523 * void foo() { ... }
3524 *
3525 * template <>
3526 * void foo<float, -7, true>();
3527 *
3528 * For I = 0, 1, and 2, Type, Integral, and Integral will be returned,
3529 * respectively.
3530 */
3531CINDEX_LINKAGE enum CXTemplateArgumentKind clang_Cursor_getTemplateArgumentKind(
3532 CXCursor C, unsigned I);
3533
3534/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003535 * Retrieve a CXType representing the type of a TemplateArgument of a
Eli Benderskyc27a0c42014-10-10 20:01:05 +00003536 * function decl representing a template specialization.
3537 *
3538 * If the argument CXCursor does not represent a FunctionDecl whose I'th
3539 * template argument has a kind of CXTemplateArgKind_Integral, an invalid type
3540 * is returned.
3541 *
3542 * For example, for the following declaration and specialization:
3543 * template <typename T, int kInt, bool kBool>
3544 * void foo() { ... }
3545 *
3546 * template <>
3547 * void foo<float, -7, true>();
3548 *
3549 * If called with I = 0, "float", will be returned.
3550 * Invalid types will be returned for I == 1 or 2.
3551 */
3552CINDEX_LINKAGE CXType clang_Cursor_getTemplateArgumentType(CXCursor C,
3553 unsigned I);
3554
3555/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003556 * Retrieve the value of an Integral TemplateArgument (of a function
Eli Benderskyc27a0c42014-10-10 20:01:05 +00003557 * decl representing a template specialization) as a signed long long.
3558 *
3559 * It is undefined to call this function on a CXCursor that does not represent a
3560 * FunctionDecl or whose I'th template argument is not an integral value.
3561 *
3562 * For example, for the following declaration and specialization:
3563 * template <typename T, int kInt, bool kBool>
3564 * void foo() { ... }
3565 *
3566 * template <>
3567 * void foo<float, -7, true>();
3568 *
3569 * If called with I = 1 or 2, -7 or true will be returned, respectively.
3570 * For I == 0, this function's behavior is undefined.
3571 */
3572CINDEX_LINKAGE long long clang_Cursor_getTemplateArgumentValue(CXCursor C,
3573 unsigned I);
3574
3575/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003576 * Retrieve the value of an Integral TemplateArgument (of a function
Eli Benderskyc27a0c42014-10-10 20:01:05 +00003577 * decl representing a template specialization) as an unsigned long long.
3578 *
3579 * It is undefined to call this function on a CXCursor that does not represent a
3580 * FunctionDecl or whose I'th template argument is not an integral value.
3581 *
3582 * For example, for the following declaration and specialization:
3583 * template <typename T, int kInt, bool kBool>
3584 * void foo() { ... }
3585 *
3586 * template <>
3587 * void foo<float, 2147483649, true>();
3588 *
3589 * If called with I = 1 or 2, 2147483649 or true will be returned, respectively.
3590 * For I == 0, this function's behavior is undefined.
3591 */
3592CINDEX_LINKAGE unsigned long long clang_Cursor_getTemplateArgumentUnsignedValue(
3593 CXCursor C, unsigned I);
3594
3595/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003596 * Determine whether two CXTypes represent the same type.
Ted Kremenek6bca9842010-05-14 21:29:26 +00003597 *
James Dennett574cb4c2012-06-15 05:41:51 +00003598 * \returns non-zero if the CXTypes represent the same type and
3599 * zero otherwise.
Ted Kremenek6bca9842010-05-14 21:29:26 +00003600 */
3601CINDEX_LINKAGE unsigned clang_equalTypes(CXType A, CXType B);
3602
3603/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003604 * Return the canonical type for a CXType.
Ted Kremenek6bca9842010-05-14 21:29:26 +00003605 *
3606 * Clang's type system explicitly models typedefs and all the ways
3607 * a specific type can be represented. The canonical type is the underlying
3608 * type with all the "sugar" removed. For example, if 'T' is a typedef
3609 * for 'int', the canonical type for 'T' would be 'int'.
3610 */
3611CINDEX_LINKAGE CXType clang_getCanonicalType(CXType T);
3612
3613/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003614 * Determine whether a CXType has the "const" qualifier set,
James Dennett574cb4c2012-06-15 05:41:51 +00003615 * without looking through typedefs that may have added "const" at a
3616 * different level.
Douglas Gregor56a63802011-01-27 16:27:11 +00003617 */
3618CINDEX_LINKAGE unsigned clang_isConstQualifiedType(CXType T);
3619
3620/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003621 * Determine whether a CXCursor that is a macro, is
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00003622 * function like.
3623 */
3624CINDEX_LINKAGE unsigned clang_Cursor_isMacroFunctionLike(CXCursor C);
3625
3626/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003627 * Determine whether a CXCursor that is a macro, is a
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00003628 * builtin one.
3629 */
3630CINDEX_LINKAGE unsigned clang_Cursor_isMacroBuiltin(CXCursor C);
3631
3632/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003633 * Determine whether a CXCursor that is a function declaration, is an
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00003634 * inline declaration.
3635 */
3636CINDEX_LINKAGE unsigned clang_Cursor_isFunctionInlined(CXCursor C);
3637
3638/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003639 * Determine whether a CXType has the "volatile" qualifier set,
James Dennett574cb4c2012-06-15 05:41:51 +00003640 * without looking through typedefs that may have added "volatile" at
3641 * a different level.
Douglas Gregor56a63802011-01-27 16:27:11 +00003642 */
3643CINDEX_LINKAGE unsigned clang_isVolatileQualifiedType(CXType T);
3644
3645/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003646 * Determine whether a CXType has the "restrict" qualifier set,
James Dennett574cb4c2012-06-15 05:41:51 +00003647 * without looking through typedefs that may have added "restrict" at a
3648 * different level.
Douglas Gregor56a63802011-01-27 16:27:11 +00003649 */
3650CINDEX_LINKAGE unsigned clang_isRestrictQualifiedType(CXType T);
3651
3652/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003653 * Returns the address space of the given type.
Sven van Haastregte8910422017-06-08 14:22:04 +00003654 */
3655CINDEX_LINKAGE unsigned clang_getAddressSpace(CXType T);
3656
3657/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003658 * Returns the typedef name of the given type.
Sven van Haastregte8910422017-06-08 14:22:04 +00003659 */
3660CINDEX_LINKAGE CXString clang_getTypedefName(CXType CT);
3661
3662/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003663 * For pointer types, returns the type of the pointee.
Ted Kremenek6bca9842010-05-14 21:29:26 +00003664 */
3665CINDEX_LINKAGE CXType clang_getPointeeType(CXType T);
3666
3667/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003668 * Return the cursor for the declaration of the given type.
Ted Kremenek6bca9842010-05-14 21:29:26 +00003669 */
3670CINDEX_LINKAGE CXCursor clang_getTypeDeclaration(CXType T);
3671
David Chisnall50e4eba2010-12-30 14:05:53 +00003672/**
3673 * Returns the Objective-C type encoding for the specified declaration.
3674 */
3675CINDEX_LINKAGE CXString clang_getDeclObjCTypeEncoding(CXCursor C);
Ted Kremenek6bca9842010-05-14 21:29:26 +00003676
3677/**
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00003678 * Returns the Objective-C type encoding for the specified CXType.
3679 */
Fangrui Song6907ce22018-07-30 19:24:48 +00003680CINDEX_LINKAGE CXString clang_Type_getObjCEncoding(CXType type);
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00003681
3682/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003683 * Retrieve the spelling of a given CXTypeKind.
Ted Kremenek6bca9842010-05-14 21:29:26 +00003684 */
3685CINDEX_LINKAGE CXString clang_getTypeKindSpelling(enum CXTypeKind K);
3686
3687/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003688 * Retrieve the calling convention associated with a function type.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003689 *
3690 * If a non-function type is passed in, CXCallingConv_Invalid is returned.
3691 */
3692CINDEX_LINKAGE enum CXCallingConv clang_getFunctionTypeCallingConv(CXType T);
3693
3694/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003695 * Retrieve the return type associated with a function type.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003696 *
3697 * If a non-function type is passed in, an invalid type is returned.
Ted Kremenekc1508872010-06-21 20:15:39 +00003698 */
3699CINDEX_LINKAGE CXType clang_getResultType(CXType T);
3700
3701/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003702 * Retrieve the exception specification type associated with a function type.
Richard Smitheedb0c92018-05-11 19:46:31 +00003703 * This is a value of type CXCursor_ExceptionSpecificationKind.
Jonathan Coe0a5b03b2017-06-27 22:54:56 +00003704 *
3705 * If a non-function type is passed in, an error code of -1 is returned.
3706 */
3707CINDEX_LINKAGE int clang_getExceptionSpecificationType(CXType T);
3708
3709/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003710 * Retrieve the number of non-variadic parameters associated with a
James Dennett574cb4c2012-06-15 05:41:51 +00003711 * function type.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003712 *
Argyrios Kyrtzidis0c27e4b2012-04-11 19:32:19 +00003713 * If a non-function type is passed in, -1 is returned.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003714 */
Argyrios Kyrtzidis0c27e4b2012-04-11 19:32:19 +00003715CINDEX_LINKAGE int clang_getNumArgTypes(CXType T);
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003716
3717/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003718 * Retrieve the type of a parameter of a function type.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003719 *
James Dennett574cb4c2012-06-15 05:41:51 +00003720 * If a non-function type is passed in or the function does not have enough
3721 * parameters, an invalid type is returned.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003722 */
3723CINDEX_LINKAGE CXType clang_getArgType(CXType T, unsigned i);
3724
3725/**
Michael Wu9c852612018-08-03 03:03:20 +00003726 * Retrieves the base type of the ObjCObjectType.
3727 *
3728 * If the type is not an ObjC object, an invalid type is returned.
3729 */
3730CINDEX_LINKAGE CXType clang_Type_getObjCObjectBaseType(CXType T);
3731
3732/**
3733 * Retrieve the number of protocol references associated with an ObjC object/id.
3734 *
3735 * If the type is not an ObjC object, 0 is returned.
3736 */
3737CINDEX_LINKAGE unsigned clang_Type_getNumObjCProtocolRefs(CXType T);
3738
3739/**
3740 * Retrieve the decl for a protocol reference for an ObjC object/id.
3741 *
3742 * If the type is not an ObjC object or there are not enough protocol
3743 * references, an invalid cursor is returned.
3744 */
3745CINDEX_LINKAGE CXCursor clang_Type_getObjCProtocolDecl(CXType T, unsigned i);
3746
3747/**
Nico Weber87e80e52020-02-14 15:18:50 -05003748 * Retrieve the number of type arguments associated with an ObjC object.
Michael Wu9c852612018-08-03 03:03:20 +00003749 *
3750 * If the type is not an ObjC object, 0 is returned.
3751 */
3752CINDEX_LINKAGE unsigned clang_Type_getNumObjCTypeArgs(CXType T);
3753
3754/**
3755 * Retrieve a type argument associated with an ObjC object.
3756 *
3757 * If the type is not an ObjC or the index is not valid,
3758 * an invalid type is returned.
3759 */
3760CINDEX_LINKAGE CXType clang_Type_getObjCTypeArg(CXType T, unsigned i);
3761
3762/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003763 * Return 1 if the CXType is a variadic function type, and 0 otherwise.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003764 */
3765CINDEX_LINKAGE unsigned clang_isFunctionTypeVariadic(CXType T);
3766
3767/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003768 * Retrieve the return type associated with a given cursor.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003769 *
3770 * This only returns a valid type if the cursor refers to a function or method.
Ted Kremenekc62ab8d2010-06-21 20:48:56 +00003771 */
3772CINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C);
3773
3774/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003775 * Retrieve the exception specification type associated with a given cursor.
Richard Smitheedb0c92018-05-11 19:46:31 +00003776 * This is a value of type CXCursor_ExceptionSpecificationKind.
Jonathan Coe0a5b03b2017-06-27 22:54:56 +00003777 *
3778 * This only returns a valid result if the cursor refers to a function or method.
3779 */
3780CINDEX_LINKAGE int clang_getCursorExceptionSpecificationType(CXCursor C);
3781
3782/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003783 * Return 1 if the CXType is a POD (plain old data) type, and 0
Ted Kremenek0c7476a2010-07-30 00:14:11 +00003784 * otherwise.
3785 */
3786CINDEX_LINKAGE unsigned clang_isPODType(CXType T);
3787
3788/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003789 * Return the element type of an array, complex, or vector type.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003790 *
3791 * If a type is passed in that is not an array, complex, or vector type,
3792 * an invalid type is returned.
3793 */
3794CINDEX_LINKAGE CXType clang_getElementType(CXType T);
3795
3796/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003797 * Return the number of elements of an array or vector type.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003798 *
3799 * If a type is passed in that is not an array or vector type,
3800 * -1 is returned.
3801 */
3802CINDEX_LINKAGE long long clang_getNumElements(CXType T);
3803
3804/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003805 * Return the element type of an array type.
Argyrios Kyrtzidis2b0cf602011-09-27 17:44:34 +00003806 *
3807 * If a non-array type is passed in, an invalid type is returned.
3808 */
3809CINDEX_LINKAGE CXType clang_getArrayElementType(CXType T);
3810
3811/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003812 * Return the array size of a constant array.
Argyrios Kyrtzidis2b0cf602011-09-27 17:44:34 +00003813 *
3814 * If a non-array type is passed in, -1 is returned.
3815 */
3816CINDEX_LINKAGE long long clang_getArraySize(CXType T);
3817
3818/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003819 * Retrieve the type named by the qualified-id.
Sergey Kalinichev69770ae2016-05-03 06:58:29 +00003820 *
3821 * If a non-elaborated type is passed in, an invalid type is returned.
3822 */
3823CINDEX_LINKAGE CXType clang_Type_getNamedType(CXType T);
3824
3825/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003826 * Determine if a typedef is 'transparent' tag.
Argyrios Kyrtzidis3b25c912017-03-21 16:56:02 +00003827 *
3828 * A typedef is considered 'transparent' if it shares a name and spelling
3829 * location with its underlying tag type, as is the case with the NS_ENUM macro.
3830 *
3831 * \returns non-zero if transparent and zero otherwise.
3832 */
3833CINDEX_LINKAGE unsigned clang_Type_isTransparentTagTypedef(CXType T);
3834
Michael Wu7649e622018-08-03 04:38:04 +00003835enum CXTypeNullabilityKind {
3836 /**
3837 * Values of this type can never be null.
3838 */
3839 CXTypeNullability_NonNull = 0,
3840 /**
3841 * Values of this type can be null.
3842 */
3843 CXTypeNullability_Nullable = 1,
3844 /**
3845 * Whether values of this type can be null is (explicitly)
3846 * unspecified. This captures a (fairly rare) case where we
3847 * can't conclude anything about the nullability of the type even
3848 * though it has been considered.
3849 */
3850 CXTypeNullability_Unspecified = 2,
3851 /**
3852 * Nullability is not applicable to this type.
3853 */
3854 CXTypeNullability_Invalid = 3
3855};
3856
3857/**
3858 * Retrieve the nullability kind of a pointer type.
3859 */
3860CINDEX_LINKAGE enum CXTypeNullabilityKind clang_Type_getNullability(CXType T);
3861
Argyrios Kyrtzidis3b25c912017-03-21 16:56:02 +00003862/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003863 * List the possible error codes for \c clang_Type_getSizeOf,
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003864 * \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf and
3865 * \c clang_Cursor_getOffsetOf.
3866 *
3867 * A value of this enumeration type can be returned if the target type is not
3868 * a valid argument to sizeof, alignof or offsetof.
3869 */
3870enum CXTypeLayoutError {
3871 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003872 * Type is of kind CXType_Invalid.
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003873 */
3874 CXTypeLayoutError_Invalid = -1,
3875 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003876 * The type is an incomplete Type.
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003877 */
3878 CXTypeLayoutError_Incomplete = -2,
3879 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003880 * The type is a dependent Type.
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003881 */
3882 CXTypeLayoutError_Dependent = -3,
3883 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003884 * The type is not a constant size type.
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003885 */
3886 CXTypeLayoutError_NotConstantSize = -4,
3887 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003888 * The Field name is not valid for this record.
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003889 */
Emilio Cobos Alvarez0d76dc22019-02-26 15:04:18 +00003890 CXTypeLayoutError_InvalidFieldName = -5,
3891 /**
3892 * The type is undeduced.
3893 */
3894 CXTypeLayoutError_Undeduced = -6
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003895};
3896
3897/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003898 * Return the alignment of a type in bytes as per C++[expr.alignof]
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003899 * standard.
3900 *
3901 * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
3902 * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
3903 * is returned.
3904 * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
3905 * returned.
3906 * If the type declaration is not a constant size type,
3907 * CXTypeLayoutError_NotConstantSize is returned.
3908 */
3909CINDEX_LINKAGE long long clang_Type_getAlignOf(CXType T);
3910
3911/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003912 * Return the class type of an member pointer type.
Argyrios Kyrtzidis7a4253b2013-10-03 16:19:23 +00003913 *
3914 * If a non-member-pointer type is passed in, an invalid type is returned.
3915 */
3916CINDEX_LINKAGE CXType clang_Type_getClassType(CXType T);
3917
3918/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003919 * Return the size of a type in bytes as per C++[expr.sizeof] standard.
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003920 *
3921 * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
3922 * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
3923 * is returned.
3924 * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
3925 * returned.
3926 */
3927CINDEX_LINKAGE long long clang_Type_getSizeOf(CXType T);
3928
3929/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003930 * Return the offset of a field named S in a record of type T in bits
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003931 * as it would be returned by __offsetof__ as per C++11[18.2p4]
3932 *
3933 * If the cursor is not a record field declaration, CXTypeLayoutError_Invalid
3934 * is returned.
3935 * If the field's type declaration is an incomplete type,
3936 * CXTypeLayoutError_Incomplete is returned.
3937 * If the field's type declaration is a dependent type,
3938 * CXTypeLayoutError_Dependent is returned.
3939 * If the field's name S is not found,
3940 * CXTypeLayoutError_InvalidFieldName is returned.
3941 */
3942CINDEX_LINKAGE long long clang_Type_getOffsetOf(CXType T, const char *S);
3943
Argyrios Kyrtzidis2bff5162015-04-13 16:55:04 +00003944/**
Michael Wu153085d2018-08-03 04:21:25 +00003945 * Return the type that was modified by this attributed type.
3946 *
3947 * If the type is not an attributed type, an invalid type is returned.
3948 */
3949CINDEX_LINKAGE CXType clang_Type_getModifiedType(CXType T);
3950
3951/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003952 * Return the offset of the field represented by the Cursor.
Argyrios Kyrtzidis2bff5162015-04-13 16:55:04 +00003953 *
3954 * If the cursor is not a field declaration, -1 is returned.
3955 * If the cursor semantic parent is not a record field declaration,
3956 * CXTypeLayoutError_Invalid is returned.
3957 * If the field's type declaration is an incomplete type,
3958 * CXTypeLayoutError_Incomplete is returned.
3959 * If the field's type declaration is a dependent type,
3960 * CXTypeLayoutError_Dependent is returned.
3961 * If the field's name S is not found,
3962 * CXTypeLayoutError_InvalidFieldName is returned.
3963 */
3964CINDEX_LINKAGE long long clang_Cursor_getOffsetOfField(CXCursor C);
3965
3966/**
Ivan Donchevskii50be5732019-04-29 13:44:07 +00003967 * Determine whether the given cursor represents an anonymous
3968 * tag or namespace
3969 */
3970CINDEX_LINKAGE unsigned clang_Cursor_isAnonymous(CXCursor C);
3971
3972/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003973 * Determine whether the given cursor represents an anonymous record
Argyrios Kyrtzidis2bff5162015-04-13 16:55:04 +00003974 * declaration.
3975 */
Ivan Donchevskii50be5732019-04-29 13:44:07 +00003976CINDEX_LINKAGE unsigned clang_Cursor_isAnonymousRecordDecl(CXCursor C);
Argyrios Kyrtzidis2bff5162015-04-13 16:55:04 +00003977
Nikolai Kosjarcfe1ab92019-05-10 13:58:34 +00003978/**
3979 * Determine whether the given cursor represents an inline namespace
3980 * declaration.
3981 */
3982CINDEX_LINKAGE unsigned clang_Cursor_isInlineNamespace(CXCursor C);
3983
Argyrios Kyrtzidisadff3ae2013-10-11 19:58:38 +00003984enum CXRefQualifierKind {
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003985 /** No ref-qualifier was provided. */
Argyrios Kyrtzidisadff3ae2013-10-11 19:58:38 +00003986 CXRefQualifier_None = 0,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003987 /** An lvalue ref-qualifier was provided (\c &). */
Argyrios Kyrtzidisadff3ae2013-10-11 19:58:38 +00003988 CXRefQualifier_LValue,
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003989 /** An rvalue ref-qualifier was provided (\c &&). */
Argyrios Kyrtzidisadff3ae2013-10-11 19:58:38 +00003990 CXRefQualifier_RValue
3991};
3992
3993/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00003994 * Returns the number of template arguments for given template
Argyrios Kyrtzidis35f5aab2016-11-15 20:51:46 +00003995 * specialization, or -1 if type \c T is not a template specialization.
Dmitri Gribenko6ede6ab2014-02-27 16:05:05 +00003996 */
3997CINDEX_LINKAGE int clang_Type_getNumTemplateArguments(CXType T);
3998
3999/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004000 * Returns the type template argument of a template class specialization
Dmitri Gribenko6ede6ab2014-02-27 16:05:05 +00004001 * at given index.
4002 *
4003 * This function only returns template type arguments and does not handle
4004 * template template arguments or variadic packs.
4005 */
4006CINDEX_LINKAGE CXType clang_Type_getTemplateArgumentAsType(CXType T, unsigned i);
4007
4008/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004009 * Retrieve the ref-qualifier kind of a function or method.
Argyrios Kyrtzidisadff3ae2013-10-11 19:58:38 +00004010 *
4011 * The ref-qualifier is returned for C++ functions or methods. For other types
4012 * or non-C++ declarations, CXRefQualifier_None is returned.
4013 */
4014CINDEX_LINKAGE enum CXRefQualifierKind clang_Type_getCXXRefQualifier(CXType T);
4015
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00004016/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004017 * Returns non-zero if the cursor specifies a Record member that is a
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00004018 * bitfield.
4019 */
4020CINDEX_LINKAGE unsigned clang_Cursor_isBitField(CXCursor C);
4021
4022/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004023 * Returns 1 if the base class specified by the cursor with kind
Ted Kremenekae9e2212010-08-27 21:34:58 +00004024 * CX_CXXBaseSpecifier is virtual.
4025 */
4026CINDEX_LINKAGE unsigned clang_isVirtualBase(CXCursor);
Fangrui Song6907ce22018-07-30 19:24:48 +00004027
Ted Kremenekae9e2212010-08-27 21:34:58 +00004028/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004029 * Represents the C++ access control level to a base class for a
Ted Kremenekae9e2212010-08-27 21:34:58 +00004030 * cursor with kind CX_CXXBaseSpecifier.
4031 */
4032enum CX_CXXAccessSpecifier {
4033 CX_CXXInvalidAccessSpecifier,
4034 CX_CXXPublic,
4035 CX_CXXProtected,
4036 CX_CXXPrivate
4037};
4038
4039/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004040 * Returns the access control level for the referenced object.
Argyrios Kyrtzidisf6464082013-04-11 17:31:13 +00004041 *
Argyrios Kyrtzidis1ab09cc2013-04-11 17:02:10 +00004042 * If the cursor refers to a C++ declaration, its access control level within its
4043 * parent scope is returned. Otherwise, if the cursor refers to a base specifier or
4044 * access specifier, the specifier itself is returned.
Ted Kremenekae9e2212010-08-27 21:34:58 +00004045 */
4046CINDEX_LINKAGE enum CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor);
4047
4048/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004049 * Represents the storage classes as declared in the source. CX_SC_Invalid
Chad Rosierdb1cc7f2014-12-05 15:50:44 +00004050 * was added for the case that the passed cursor in not a declaration.
Argyrios Kyrtzidis4e0854f2014-10-15 17:05:31 +00004051 */
4052enum CX_StorageClass {
4053 CX_SC_Invalid,
4054 CX_SC_None,
4055 CX_SC_Extern,
4056 CX_SC_Static,
4057 CX_SC_PrivateExtern,
4058 CX_SC_OpenCLWorkGroupLocal,
4059 CX_SC_Auto,
4060 CX_SC_Register
4061};
4062
4063/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004064 * Returns the storage class for a function or variable declaration.
Argyrios Kyrtzidis4e0854f2014-10-15 17:05:31 +00004065 *
4066 * If the passed in Cursor is not a function or variable declaration,
4067 * CX_SC_Invalid is returned else the storage class.
4068 */
4069CINDEX_LINKAGE enum CX_StorageClass clang_Cursor_getStorageClass(CXCursor);
4070
4071/**
Fangrui Song6907ce22018-07-30 19:24:48 +00004072 * Determine the number of overloaded declarations referenced by a
Douglas Gregor16a2bdd2010-09-13 22:52:57 +00004073 * \c CXCursor_OverloadedDeclRef cursor.
4074 *
4075 * \param cursor The cursor whose overloaded declarations are being queried.
4076 *
4077 * \returns The number of overloaded declarations referenced by \c cursor. If it
4078 * is not a \c CXCursor_OverloadedDeclRef cursor, returns 0.
4079 */
4080CINDEX_LINKAGE unsigned clang_getNumOverloadedDecls(CXCursor cursor);
4081
4082/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004083 * Retrieve a cursor for one of the overloaded declarations referenced
Douglas Gregor16a2bdd2010-09-13 22:52:57 +00004084 * by a \c CXCursor_OverloadedDeclRef cursor.
4085 *
4086 * \param cursor The cursor whose overloaded declarations are being queried.
4087 *
4088 * \param index The zero-based index into the set of overloaded declarations in
4089 * the cursor.
4090 *
Fangrui Song6907ce22018-07-30 19:24:48 +00004091 * \returns A cursor representing the declaration referenced by the given
4092 * \c cursor at the specified \c index. If the cursor does not have an
Douglas Gregor16a2bdd2010-09-13 22:52:57 +00004093 * associated set of overloaded declarations, or if the index is out of bounds,
4094 * returns \c clang_getNullCursor();
4095 */
Fangrui Song6907ce22018-07-30 19:24:48 +00004096CINDEX_LINKAGE CXCursor clang_getOverloadedDecl(CXCursor cursor,
Douglas Gregor16a2bdd2010-09-13 22:52:57 +00004097 unsigned index);
Fangrui Song6907ce22018-07-30 19:24:48 +00004098
Douglas Gregor16a2bdd2010-09-13 22:52:57 +00004099/**
Ted Kremenek6bca9842010-05-14 21:29:26 +00004100 * @}
4101 */
Fangrui Song6907ce22018-07-30 19:24:48 +00004102
Ted Kremeneka5940822010-08-26 01:42:22 +00004103/**
Ted Kremenek2c2c5f32010-08-27 21:34:51 +00004104 * \defgroup CINDEX_ATTRIBUTES Information for attributes
Ted Kremeneka5940822010-08-26 01:42:22 +00004105 *
4106 * @{
4107 */
4108
Ted Kremeneka5940822010-08-26 01:42:22 +00004109/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004110 * For cursors representing an iboutletcollection attribute,
Ted Kremeneka5940822010-08-26 01:42:22 +00004111 * this function returns the collection element type.
4112 *
4113 */
4114CINDEX_LINKAGE CXType clang_getIBOutletCollectionType(CXCursor);
4115
4116/**
4117 * @}
4118 */
Ted Kremenek6bca9842010-05-14 21:29:26 +00004119
4120/**
Douglas Gregor6007cf22010-01-22 22:29:16 +00004121 * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors
4122 *
4123 * These routines provide the ability to traverse the abstract syntax tree
4124 * using cursors.
4125 *
4126 * @{
4127 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004128
Douglas Gregor6007cf22010-01-22 22:29:16 +00004129/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004130 * Describes how the traversal of the children of a particular
Douglas Gregor6007cf22010-01-22 22:29:16 +00004131 * cursor should proceed after visiting a particular child cursor.
4132 *
4133 * A value of this enumeration type should be returned by each
4134 * \c CXCursorVisitor to indicate how clang_visitChildren() proceed.
4135 */
4136enum CXChildVisitResult {
4137 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004138 * Terminates the cursor traversal.
Douglas Gregor6007cf22010-01-22 22:29:16 +00004139 */
4140 CXChildVisit_Break,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004141 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004142 * Continues the cursor traversal with the next sibling of
Douglas Gregor6007cf22010-01-22 22:29:16 +00004143 * the cursor just visited, without visiting its children.
4144 */
4145 CXChildVisit_Continue,
4146 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004147 * Recursively traverse the children of this cursor, using
Douglas Gregor6007cf22010-01-22 22:29:16 +00004148 * the same visitor and client data.
4149 */
4150 CXChildVisit_Recurse
4151};
4152
4153/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004154 * Visitor invoked for each cursor found by a traversal.
Douglas Gregor6007cf22010-01-22 22:29:16 +00004155 *
4156 * This visitor function will be invoked for each cursor found by
4157 * clang_visitCursorChildren(). Its first argument is the cursor being
4158 * visited, its second argument is the parent visitor for that cursor,
4159 * and its third argument is the client data provided to
4160 * clang_visitCursorChildren().
4161 *
4162 * The visitor should return one of the \c CXChildVisitResult values
4163 * to direct clang_visitCursorChildren().
4164 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004165typedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor,
4166 CXCursor parent,
Douglas Gregor6007cf22010-01-22 22:29:16 +00004167 CXClientData client_data);
4168
4169/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004170 * Visit the children of a particular cursor.
Douglas Gregor6007cf22010-01-22 22:29:16 +00004171 *
4172 * This function visits all the direct children of the given cursor,
4173 * invoking the given \p visitor function with the cursors of each
4174 * visited child. The traversal may be recursive, if the visitor returns
4175 * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if
4176 * the visitor returns \c CXChildVisit_Break.
4177 *
Douglas Gregor6007cf22010-01-22 22:29:16 +00004178 * \param parent the cursor whose child may be visited. All kinds of
Daniel Dunbarb9999fd2010-01-24 04:10:31 +00004179 * cursors can be visited, including invalid cursors (which, by
Douglas Gregor6007cf22010-01-22 22:29:16 +00004180 * definition, have no children).
4181 *
4182 * \param visitor the visitor function that will be invoked for each
4183 * child of \p parent.
4184 *
4185 * \param client_data pointer data supplied by the client, which will
4186 * be passed to the visitor each time it is invoked.
4187 *
4188 * \returns a non-zero value if the traversal was terminated
4189 * prematurely by the visitor returning \c CXChildVisit_Break.
4190 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004191CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent,
Douglas Gregor6007cf22010-01-22 22:29:16 +00004192 CXCursorVisitor visitor,
4193 CXClientData client_data);
David Chisnallb2aa0ef2010-11-03 14:12:26 +00004194#ifdef __has_feature
4195# if __has_feature(blocks)
4196/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004197 * Visitor invoked for each cursor found by a traversal.
David Chisnallb2aa0ef2010-11-03 14:12:26 +00004198 *
4199 * This visitor block will be invoked for each cursor found by
4200 * clang_visitChildrenWithBlock(). Its first argument is the cursor being
4201 * visited, its second argument is the parent visitor for that cursor.
4202 *
4203 * The visitor should return one of the \c CXChildVisitResult values
4204 * to direct clang_visitChildrenWithBlock().
4205 */
Fangrui Song6907ce22018-07-30 19:24:48 +00004206typedef enum CXChildVisitResult
David Chisnallb2aa0ef2010-11-03 14:12:26 +00004207 (^CXCursorVisitorBlock)(CXCursor cursor, CXCursor parent);
4208
4209/**
4210 * Visits the children of a cursor using the specified block. Behaves
4211 * identically to clang_visitChildren() in all other respects.
4212 */
Argyrios Kyrtzidisa0a35d72016-02-07 18:21:28 +00004213CINDEX_LINKAGE unsigned clang_visitChildrenWithBlock(CXCursor parent,
4214 CXCursorVisitorBlock block);
David Chisnallb2aa0ef2010-11-03 14:12:26 +00004215# endif
4216#endif
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004217
Douglas Gregor6007cf22010-01-22 22:29:16 +00004218/**
4219 * @}
4220 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004221
Douglas Gregor6007cf22010-01-22 22:29:16 +00004222/**
4223 * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST
4224 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004225 * These routines provide the ability to determine references within and
Douglas Gregor6007cf22010-01-22 22:29:16 +00004226 * across translation units, by providing the names of the entities referenced
4227 * by cursors, follow reference cursors to the declarations they reference,
4228 * and associate declarations with their definitions.
4229 *
4230 * @{
4231 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004232
Douglas Gregor6007cf22010-01-22 22:29:16 +00004233/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004234 * Retrieve a Unified Symbol Resolution (USR) for the entity referenced
Douglas Gregor6007cf22010-01-22 22:29:16 +00004235 * by the given cursor.
4236 *
4237 * A Unified Symbol Resolution (USR) is a string that identifies a particular
4238 * entity (function, class, variable, etc.) within a program. USRs can be
4239 * compared across translation units to determine, e.g., when references in
4240 * one translation refer to an entity defined in another translation unit.
4241 */
4242CINDEX_LINKAGE CXString clang_getCursorUSR(CXCursor);
4243
4244/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004245 * Construct a USR for a specified Objective-C class.
Ted Kremenekd071c602010-03-13 02:50:34 +00004246 */
4247CINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name);
4248
4249/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004250 * Construct a USR for a specified Objective-C category.
Ted Kremenekd071c602010-03-13 02:50:34 +00004251 */
4252CINDEX_LINKAGE CXString
Ted Kremenekbc1a67b2010-03-15 17:38:58 +00004253 clang_constructUSR_ObjCCategory(const char *class_name,
Ted Kremenekd071c602010-03-13 02:50:34 +00004254 const char *category_name);
4255
4256/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004257 * Construct a USR for a specified Objective-C protocol.
Ted Kremenekd071c602010-03-13 02:50:34 +00004258 */
4259CINDEX_LINKAGE CXString
4260 clang_constructUSR_ObjCProtocol(const char *protocol_name);
4261
Ted Kremenekd071c602010-03-13 02:50:34 +00004262/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004263 * Construct a USR for a specified Objective-C instance variable and
Ted Kremenekd071c602010-03-13 02:50:34 +00004264 * the USR for its containing class.
4265 */
4266CINDEX_LINKAGE CXString clang_constructUSR_ObjCIvar(const char *name,
4267 CXString classUSR);
4268
4269/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004270 * Construct a USR for a specified Objective-C method and
Ted Kremenekd071c602010-03-13 02:50:34 +00004271 * the USR for its containing class.
4272 */
4273CINDEX_LINKAGE CXString clang_constructUSR_ObjCMethod(const char *name,
4274 unsigned isInstanceMethod,
4275 CXString classUSR);
4276
4277/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004278 * Construct a USR for a specified Objective-C property and the USR
Ted Kremenekd071c602010-03-13 02:50:34 +00004279 * for its containing class.
4280 */
4281CINDEX_LINKAGE CXString clang_constructUSR_ObjCProperty(const char *property,
4282 CXString classUSR);
4283
4284/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004285 * Retrieve a name for the entity referenced by this cursor.
Douglas Gregor6007cf22010-01-22 22:29:16 +00004286 */
4287CINDEX_LINKAGE CXString clang_getCursorSpelling(CXCursor);
4288
Douglas Gregor97c75712010-10-02 22:49:11 +00004289/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004290 * Retrieve a range for a piece that forms the cursors spelling name.
Argyrios Kyrtzidis191a6a82012-03-30 20:58:35 +00004291 * Most of the times there is only one range for the complete spelling but for
Nico Weber7deebef2014-04-24 03:17:47 +00004292 * Objective-C methods and Objective-C message expressions, there are multiple
4293 * pieces for each selector identifier.
Fangrui Song6907ce22018-07-30 19:24:48 +00004294 *
Argyrios Kyrtzidis191a6a82012-03-30 20:58:35 +00004295 * \param pieceIndex the index of the spelling name piece. If this is greater
4296 * than the actual number of pieces, it will return a NULL (invalid) range.
Fangrui Song6907ce22018-07-30 19:24:48 +00004297 *
Argyrios Kyrtzidis191a6a82012-03-30 20:58:35 +00004298 * \param options Reserved.
4299 */
4300CINDEX_LINKAGE CXSourceRange clang_Cursor_getSpellingNameRange(CXCursor,
4301 unsigned pieceIndex,
4302 unsigned options);
4303
4304/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004305 * Opaque pointer representing a policy that controls pretty printing
Jonathan Coe45ef5032018-01-16 10:19:56 +00004306 * for \c clang_getCursorPrettyPrinted.
4307 */
4308typedef void *CXPrintingPolicy;
4309
4310/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004311 * Properties for the printing policy.
Jonathan Coe45ef5032018-01-16 10:19:56 +00004312 *
4313 * See \c clang::PrintingPolicy for more information.
4314 */
4315enum CXPrintingPolicyProperty {
4316 CXPrintingPolicy_Indentation,
4317 CXPrintingPolicy_SuppressSpecifiers,
4318 CXPrintingPolicy_SuppressTagKeyword,
4319 CXPrintingPolicy_IncludeTagDefinition,
4320 CXPrintingPolicy_SuppressScope,
4321 CXPrintingPolicy_SuppressUnwrittenScope,
4322 CXPrintingPolicy_SuppressInitializers,
4323 CXPrintingPolicy_ConstantArraySizeAsWritten,
4324 CXPrintingPolicy_AnonymousTagLocations,
4325 CXPrintingPolicy_SuppressStrongLifetime,
4326 CXPrintingPolicy_SuppressLifetimeQualifiers,
4327 CXPrintingPolicy_SuppressTemplateArgsInCXXConstructors,
4328 CXPrintingPolicy_Bool,
4329 CXPrintingPolicy_Restrict,
4330 CXPrintingPolicy_Alignof,
4331 CXPrintingPolicy_UnderscoreAlignof,
4332 CXPrintingPolicy_UseVoidForZeroParams,
4333 CXPrintingPolicy_TerseOutput,
4334 CXPrintingPolicy_PolishForDeclaration,
4335 CXPrintingPolicy_Half,
4336 CXPrintingPolicy_MSWChar,
4337 CXPrintingPolicy_IncludeNewlines,
4338 CXPrintingPolicy_MSVCFormatting,
4339 CXPrintingPolicy_ConstantsAsWritten,
4340 CXPrintingPolicy_SuppressImplicitBase,
4341 CXPrintingPolicy_FullyQualifiedName,
4342
4343 CXPrintingPolicy_LastProperty = CXPrintingPolicy_FullyQualifiedName
4344};
4345
4346/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004347 * Get a property value for the given printing policy.
Jonathan Coe45ef5032018-01-16 10:19:56 +00004348 */
Ivan Donchevskii4cab0fe2018-01-16 12:11:59 +00004349CINDEX_LINKAGE unsigned
Jonathan Coe45ef5032018-01-16 10:19:56 +00004350clang_PrintingPolicy_getProperty(CXPrintingPolicy Policy,
4351 enum CXPrintingPolicyProperty Property);
4352
4353/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004354 * Set a property value for the given printing policy.
Jonathan Coe45ef5032018-01-16 10:19:56 +00004355 */
Ivan Donchevskii4cab0fe2018-01-16 12:11:59 +00004356CINDEX_LINKAGE void clang_PrintingPolicy_setProperty(CXPrintingPolicy Policy,
4357 enum CXPrintingPolicyProperty Property,
4358 unsigned Value);
Jonathan Coe45ef5032018-01-16 10:19:56 +00004359
4360/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004361 * Retrieve the default policy for the cursor.
Jonathan Coe45ef5032018-01-16 10:19:56 +00004362 *
4363 * The policy should be released after use with \c
4364 * clang_PrintingPolicy_dispose.
4365 */
4366CINDEX_LINKAGE CXPrintingPolicy clang_getCursorPrintingPolicy(CXCursor);
4367
4368/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004369 * Release a printing policy.
Jonathan Coe45ef5032018-01-16 10:19:56 +00004370 */
4371CINDEX_LINKAGE void clang_PrintingPolicy_dispose(CXPrintingPolicy Policy);
4372
4373/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004374 * Pretty print declarations.
Jonathan Coe45ef5032018-01-16 10:19:56 +00004375 *
4376 * \param Cursor The cursor representing a declaration.
4377 *
4378 * \param Policy The policy to control the entities being printed. If
4379 * NULL, a default policy is used.
4380 *
4381 * \returns The pretty printed declaration or the empty string for
4382 * other cursors.
4383 */
4384CINDEX_LINKAGE CXString clang_getCursorPrettyPrinted(CXCursor Cursor,
4385 CXPrintingPolicy Policy);
4386
4387/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004388 * Retrieve the display name for the entity referenced by this cursor.
Douglas Gregor97c75712010-10-02 22:49:11 +00004389 *
4390 * The display name contains extra information that helps identify the cursor,
Fangrui Song6907ce22018-07-30 19:24:48 +00004391 * such as the parameters of a function or template or the arguments of a
Douglas Gregor97c75712010-10-02 22:49:11 +00004392 * class template specialization.
4393 */
4394CINDEX_LINKAGE CXString clang_getCursorDisplayName(CXCursor);
Fangrui Song6907ce22018-07-30 19:24:48 +00004395
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004396/** For a cursor that is a reference, retrieve a cursor representing the
Douglas Gregorad27e8b2010-01-19 01:20:04 +00004397 * entity that it references.
4398 *
4399 * Reference cursors refer to other entities in the AST. For example, an
4400 * Objective-C superclass reference cursor refers to an Objective-C class.
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004401 * This function produces the cursor for the Objective-C class from the
Douglas Gregorad27e8b2010-01-19 01:20:04 +00004402 * cursor for the superclass reference. If the input cursor is a declaration or
4403 * definition, it returns that declaration or definition unchanged.
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004404 * Otherwise, returns the NULL cursor.
Douglas Gregorad27e8b2010-01-19 01:20:04 +00004405 */
4406CINDEX_LINKAGE CXCursor clang_getCursorReferenced(CXCursor);
Douglas Gregor6b8232f2010-01-19 19:34:47 +00004407
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004408/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004409 * For a cursor that is either a reference to or a declaration
Douglas Gregor6b8232f2010-01-19 19:34:47 +00004410 * of some entity, retrieve a cursor that describes the definition of
4411 * that entity.
4412 *
4413 * Some entities can be declared multiple times within a translation
4414 * unit, but only one of those declarations can also be a
4415 * definition. For example, given:
4416 *
4417 * \code
4418 * int f(int, int);
4419 * int g(int x, int y) { return f(x, y); }
4420 * int f(int a, int b) { return a + b; }
4421 * int f(int, int);
4422 * \endcode
4423 *
4424 * there are three declarations of the function "f", but only the
4425 * second one is a definition. The clang_getCursorDefinition()
4426 * function will take any cursor pointing to a declaration of "f"
4427 * (the first or fourth lines of the example) or a cursor referenced
4428 * that uses "f" (the call to "f' inside "g") and will return a
4429 * declaration cursor pointing to the definition (the second "f"
4430 * declaration).
4431 *
4432 * If given a cursor for which there is no corresponding definition,
4433 * e.g., because there is no definition of that entity within this
4434 * translation unit, returns a NULL cursor.
4435 */
4436CINDEX_LINKAGE CXCursor clang_getCursorDefinition(CXCursor);
4437
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004438/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004439 * Determine whether the declaration pointed to by this cursor
Douglas Gregor6b8232f2010-01-19 19:34:47 +00004440 * is also a definition of that entity.
4441 */
4442CINDEX_LINKAGE unsigned clang_isCursorDefinition(CXCursor);
4443
Douglas Gregor6007cf22010-01-22 22:29:16 +00004444/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004445 * Retrieve the canonical cursor corresponding to the given cursor.
Douglas Gregorfec4dc92010-11-19 23:44:15 +00004446 *
4447 * In the C family of languages, many kinds of entities can be declared several
4448 * times within a single translation unit. For example, a structure type can
4449 * be forward-declared (possibly multiple times) and later defined:
4450 *
4451 * \code
4452 * struct X;
4453 * struct X;
4454 * struct X {
4455 * int member;
4456 * };
4457 * \endcode
4458 *
Fangrui Song6907ce22018-07-30 19:24:48 +00004459 * The declarations and the definition of \c X are represented by three
4460 * different cursors, all of which are declarations of the same underlying
Douglas Gregorfec4dc92010-11-19 23:44:15 +00004461 * entity. One of these cursor is considered the "canonical" cursor, which
Fangrui Song6907ce22018-07-30 19:24:48 +00004462 * is effectively the representative for the underlying entity. One can
Douglas Gregorfec4dc92010-11-19 23:44:15 +00004463 * determine if two cursors are declarations of the same underlying entity by
4464 * comparing their canonical cursors.
4465 *
4466 * \returns The canonical cursor for the entity referred to by the given cursor.
4467 */
4468CINDEX_LINKAGE CXCursor clang_getCanonicalCursor(CXCursor);
4469
Argyrios Kyrtzidis210f29f2012-03-30 22:15:48 +00004470/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004471 * If the cursor points to a selector identifier in an Objective-C
Nico Weber7deebef2014-04-24 03:17:47 +00004472 * method or message expression, this returns the selector index.
Argyrios Kyrtzidis210f29f2012-03-30 22:15:48 +00004473 *
James Dennett574cb4c2012-06-15 05:41:51 +00004474 * After getting a cursor with #clang_getCursor, this can be called to
Argyrios Kyrtzidis210f29f2012-03-30 22:15:48 +00004475 * determine if the location points to a selector identifier.
4476 *
Nico Weber7deebef2014-04-24 03:17:47 +00004477 * \returns The selector index if the cursor is an Objective-C method or message
Argyrios Kyrtzidis210f29f2012-03-30 22:15:48 +00004478 * expression and the cursor is pointing to a selector identifier, or -1
4479 * otherwise.
4480 */
4481CINDEX_LINKAGE int clang_Cursor_getObjCSelectorIndex(CXCursor);
4482
Douglas Gregorfec4dc92010-11-19 23:44:15 +00004483/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004484 * Given a cursor pointing to a C++ method call or an Objective-C
Nico Weber7deebef2014-04-24 03:17:47 +00004485 * message, returns non-zero if the method/message is "dynamic", meaning:
Fangrui Song6907ce22018-07-30 19:24:48 +00004486 *
Argyrios Kyrtzidisb6df68212012-07-02 23:54:36 +00004487 * For a C++ method: the call is virtual.
Nico Weber7deebef2014-04-24 03:17:47 +00004488 * For an Objective-C message: the receiver is an object instance, not 'super'
4489 * or a specific class.
Fangrui Song6907ce22018-07-30 19:24:48 +00004490 *
Argyrios Kyrtzidisb6df68212012-07-02 23:54:36 +00004491 * If the method/message is "static" or the cursor does not point to a
4492 * method/message, it will return zero.
4493 */
4494CINDEX_LINKAGE int clang_Cursor_isDynamicCall(CXCursor C);
4495
4496/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004497 * Given a cursor pointing to an Objective-C message or property
Argyrios Kyrtzidis2a684862017-04-27 17:23:04 +00004498 * reference, or C++ method call, returns the CXType of the receiver.
Argyrios Kyrtzidisb26a24c2012-11-01 02:01:34 +00004499 */
4500CINDEX_LINKAGE CXType clang_Cursor_getReceiverType(CXCursor C);
4501
4502/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004503 * Property attributes for a \c CXCursor_ObjCPropertyDecl.
Argyrios Kyrtzidis9adfd8a2013-04-18 22:15:49 +00004504 */
4505typedef enum {
4506 CXObjCPropertyAttr_noattr = 0x00,
4507 CXObjCPropertyAttr_readonly = 0x01,
4508 CXObjCPropertyAttr_getter = 0x02,
4509 CXObjCPropertyAttr_assign = 0x04,
4510 CXObjCPropertyAttr_readwrite = 0x08,
4511 CXObjCPropertyAttr_retain = 0x10,
4512 CXObjCPropertyAttr_copy = 0x20,
4513 CXObjCPropertyAttr_nonatomic = 0x40,
4514 CXObjCPropertyAttr_setter = 0x80,
4515 CXObjCPropertyAttr_atomic = 0x100,
4516 CXObjCPropertyAttr_weak = 0x200,
4517 CXObjCPropertyAttr_strong = 0x400,
Manman Ren04fd4d82016-05-31 23:22:04 +00004518 CXObjCPropertyAttr_unsafe_unretained = 0x800,
Manman Ren400e4c32016-06-03 23:11:41 +00004519 CXObjCPropertyAttr_class = 0x1000
Argyrios Kyrtzidis9adfd8a2013-04-18 22:15:49 +00004520} CXObjCPropertyAttrKind;
4521
4522/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004523 * Given a cursor that represents a property declaration, return the
Argyrios Kyrtzidis9adfd8a2013-04-18 22:15:49 +00004524 * associated property attributes. The bits are formed from
4525 * \c CXObjCPropertyAttrKind.
4526 *
4527 * \param reserved Reserved for future use, pass 0.
4528 */
4529CINDEX_LINKAGE unsigned clang_Cursor_getObjCPropertyAttributes(CXCursor C,
4530 unsigned reserved);
4531
4532/**
Michael Wu6e88f532018-08-03 05:38:29 +00004533 * Given a cursor that represents a property declaration, return the
4534 * name of the method that implements the getter.
4535 */
4536CINDEX_LINKAGE CXString clang_Cursor_getObjCPropertyGetterName(CXCursor C);
4537
4538/**
4539 * Given a cursor that represents a property declaration, return the
4540 * name of the method that implements the setter, if any.
4541 */
4542CINDEX_LINKAGE CXString clang_Cursor_getObjCPropertySetterName(CXCursor C);
4543
4544/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004545 * 'Qualifiers' written next to the return and parameter types in
Nico Weber7deebef2014-04-24 03:17:47 +00004546 * Objective-C method declarations.
Argyrios Kyrtzidis9d9bc012013-04-18 23:29:12 +00004547 */
4548typedef enum {
4549 CXObjCDeclQualifier_None = 0x0,
4550 CXObjCDeclQualifier_In = 0x1,
4551 CXObjCDeclQualifier_Inout = 0x2,
4552 CXObjCDeclQualifier_Out = 0x4,
4553 CXObjCDeclQualifier_Bycopy = 0x8,
4554 CXObjCDeclQualifier_Byref = 0x10,
4555 CXObjCDeclQualifier_Oneway = 0x20
4556} CXObjCDeclQualifierKind;
4557
4558/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004559 * Given a cursor that represents an Objective-C method or parameter
Nico Weber7deebef2014-04-24 03:17:47 +00004560 * declaration, return the associated Objective-C qualifiers for the return
4561 * type or the parameter respectively. The bits are formed from
4562 * CXObjCDeclQualifierKind.
Argyrios Kyrtzidis9d9bc012013-04-18 23:29:12 +00004563 */
4564CINDEX_LINKAGE unsigned clang_Cursor_getObjCDeclQualifiers(CXCursor C);
4565
4566/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004567 * Given a cursor that represents an Objective-C method or property
Alex Lorenz6c2898a2017-04-06 14:03:25 +00004568 * declaration, return non-zero if the declaration was affected by "\@optional".
4569 * Returns zero if the cursor is not such a declaration or it is "\@required".
Argyrios Kyrtzidis7b50fc52013-07-05 20:44:37 +00004570 */
4571CINDEX_LINKAGE unsigned clang_Cursor_isObjCOptional(CXCursor C);
4572
4573/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004574 * Returns non-zero if the given cursor is a variadic function or method.
Argyrios Kyrtzidis23814e42013-04-18 23:53:05 +00004575 */
4576CINDEX_LINKAGE unsigned clang_Cursor_isVariadic(CXCursor C);
4577
4578/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004579 * Returns non-zero if the given cursor points to a symbol marked with
Argyrios Kyrtzidis0381cc72017-05-10 15:10:36 +00004580 * external_source_symbol attribute.
4581 *
4582 * \param language If non-NULL, and the attribute is present, will be set to
4583 * the 'language' string from the attribute.
4584 *
4585 * \param definedIn If non-NULL, and the attribute is present, will be set to
4586 * the 'definedIn' string from the attribute.
4587 *
4588 * \param isGenerated If non-NULL, and the attribute is present, will be set to
Argyrios Kyrtzidis8b337c02017-05-10 15:48:16 +00004589 * non-zero if the 'generated_declaration' is set in the attribute.
Argyrios Kyrtzidis0381cc72017-05-10 15:10:36 +00004590 */
4591CINDEX_LINKAGE unsigned clang_Cursor_isExternalSymbol(CXCursor C,
4592 CXString *language, CXString *definedIn,
4593 unsigned *isGenerated);
4594
4595/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004596 * Given a cursor that represents a declaration, return the associated
Dmitri Gribenkoaab83832012-06-20 00:34:58 +00004597 * comment's source range. The range may include multiple consecutive comments
4598 * with whitespace in between.
4599 */
4600CINDEX_LINKAGE CXSourceRange clang_Cursor_getCommentRange(CXCursor C);
4601
4602/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004603 * Given a cursor that represents a declaration, return the associated
Dmitri Gribenkoaab83832012-06-20 00:34:58 +00004604 * comment text, including comment markers.
4605 */
4606CINDEX_LINKAGE CXString clang_Cursor_getRawCommentText(CXCursor C);
4607
4608/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004609 * Given a cursor that represents a documentable entity (e.g.,
4610 * declaration), return the associated \paragraph; otherwise return the
Dmitri Gribenko5e4fe002012-07-20 21:34:34 +00004611 * first paragraph.
Dmitri Gribenko5188c4b2012-06-26 20:39:18 +00004612 */
4613CINDEX_LINKAGE CXString clang_Cursor_getBriefCommentText(CXCursor C);
4614
4615/**
Dmitri Gribenko5e4fe002012-07-20 21:34:34 +00004616 * @}
4617 */
4618
Eli Bendersky44a206f2014-07-31 18:04:56 +00004619/** \defgroup CINDEX_MANGLE Name Mangling API Functions
4620 *
4621 * @{
4622 */
4623
4624/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004625 * Retrieve the CXString representing the mangled name of the cursor.
Eli Bendersky44a206f2014-07-31 18:04:56 +00004626 */
4627CINDEX_LINKAGE CXString clang_Cursor_getMangling(CXCursor);
4628
4629/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004630 * Retrieve the CXStrings representing the mangled symbols of the C++
Saleem Abdulrasool60034432015-11-12 03:57:22 +00004631 * constructor or destructor at the cursor.
4632 */
4633CINDEX_LINKAGE CXStringSet *clang_Cursor_getCXXManglings(CXCursor);
4634
4635/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004636 * Retrieve the CXStrings representing the mangled symbols of the ObjC
Dave Lee1a532c92017-09-22 16:58:57 +00004637 * class interface or implementation at the cursor.
4638 */
4639CINDEX_LINKAGE CXStringSet *clang_Cursor_getObjCManglings(CXCursor);
4640
4641/**
Eli Bendersky44a206f2014-07-31 18:04:56 +00004642 * @}
4643 */
4644
Dmitri Gribenko5e4fe002012-07-20 21:34:34 +00004645/**
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004646 * \defgroup CINDEX_MODULE Module introspection
4647 *
4648 * The functions in this group provide access to information about modules.
4649 *
4650 * @{
4651 */
4652
4653typedef void *CXModule;
4654
4655/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004656 * Given a CXCursor_ModuleImportDecl cursor, return the associated module.
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004657 */
4658CINDEX_LINKAGE CXModule clang_Cursor_getModule(CXCursor C);
4659
4660/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004661 * Given a CXFile header file, return the module that contains it, if one
Argyrios Kyrtzidisf6d49c32014-05-14 23:14:37 +00004662 * exists.
4663 */
4664CINDEX_LINKAGE CXModule clang_getModuleForFile(CXTranslationUnit, CXFile);
4665
4666/**
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004667 * \param Module a module object.
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004668 *
Argyrios Kyrtzidis12fdb9e2013-04-26 22:47:49 +00004669 * \returns the module file where the provided module object came from.
4670 */
4671CINDEX_LINKAGE CXFile clang_Module_getASTFile(CXModule Module);
4672
4673/**
4674 * \param Module a module object.
4675 *
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004676 * \returns the parent of a sub-module or NULL if the given module is top-level,
4677 * e.g. for 'std.vector' it will return the 'std' module.
4678 */
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004679CINDEX_LINKAGE CXModule clang_Module_getParent(CXModule Module);
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004680
4681/**
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004682 * \param Module a module object.
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004683 *
4684 * \returns the name of the module, e.g. for the 'std.vector' sub-module it
4685 * will return "vector".
4686 */
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004687CINDEX_LINKAGE CXString clang_Module_getName(CXModule Module);
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004688
4689/**
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004690 * \param Module a module object.
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004691 *
4692 * \returns the full name of the module, e.g. "std.vector".
4693 */
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004694CINDEX_LINKAGE CXString clang_Module_getFullName(CXModule Module);
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004695
4696/**
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004697 * \param Module a module object.
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004698 *
Argyrios Kyrtzidis884337f2014-05-15 04:44:25 +00004699 * \returns non-zero if the module is a system one.
4700 */
4701CINDEX_LINKAGE int clang_Module_isSystem(CXModule Module);
4702
4703/**
4704 * \param Module a module object.
4705 *
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004706 * \returns the number of top level headers associated with this module.
4707 */
Argyrios Kyrtzidis3c5305c2013-03-13 21:13:43 +00004708CINDEX_LINKAGE unsigned clang_Module_getNumTopLevelHeaders(CXTranslationUnit,
4709 CXModule Module);
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004710
4711/**
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004712 * \param Module a module object.
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004713 *
4714 * \param Index top level header index (zero-based).
4715 *
4716 * \returns the specified top level header associated with the module.
4717 */
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004718CINDEX_LINKAGE
Argyrios Kyrtzidis3c5305c2013-03-13 21:13:43 +00004719CXFile clang_Module_getTopLevelHeader(CXTranslationUnit,
4720 CXModule Module, unsigned Index);
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004721
4722/**
4723 * @}
4724 */
4725
4726/**
Ted Kremenek9cfe9e62010-05-17 20:06:56 +00004727 * \defgroup CINDEX_CPP C++ AST introspection
4728 *
4729 * The routines in this group provide access information in the ASTs specific
4730 * to C++ language features.
4731 *
4732 * @{
4733 */
4734
4735/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004736 * Determine if a C++ constructor is a converting constructor.
Jonathan Coe29565352016-04-27 12:48:25 +00004737 */
4738CINDEX_LINKAGE unsigned clang_CXXConstructor_isConvertingConstructor(CXCursor C);
4739
4740/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004741 * Determine if a C++ constructor is a copy constructor.
Jonathan Coe29565352016-04-27 12:48:25 +00004742 */
4743CINDEX_LINKAGE unsigned clang_CXXConstructor_isCopyConstructor(CXCursor C);
4744
4745/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004746 * Determine if a C++ constructor is the default constructor.
Jonathan Coe29565352016-04-27 12:48:25 +00004747 */
4748CINDEX_LINKAGE unsigned clang_CXXConstructor_isDefaultConstructor(CXCursor C);
4749
4750/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004751 * Determine if a C++ constructor is a move constructor.
Jonathan Coe29565352016-04-27 12:48:25 +00004752 */
4753CINDEX_LINKAGE unsigned clang_CXXConstructor_isMoveConstructor(CXCursor C);
4754
4755/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004756 * Determine if a C++ field is declared 'mutable'.
Saleem Abdulrasool6ea75db2015-10-27 15:50:22 +00004757 */
4758CINDEX_LINKAGE unsigned clang_CXXField_isMutable(CXCursor C);
4759
4760/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004761 * Determine if a C++ method is declared '= default'.
Jonathan Coe29565352016-04-27 12:48:25 +00004762 */
4763CINDEX_LINKAGE unsigned clang_CXXMethod_isDefaulted(CXCursor C);
4764
4765/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004766 * Determine if a C++ member function or member function template is
Dmitri Gribenko62770be2013-05-17 18:38:35 +00004767 * pure virtual.
4768 */
4769CINDEX_LINKAGE unsigned clang_CXXMethod_isPureVirtual(CXCursor C);
4770
4771/**
Fangrui Song6907ce22018-07-30 19:24:48 +00004772 * Determine if a C++ member function or member function template is
Douglas Gregorf11309e2010-08-31 22:12:17 +00004773 * declared 'static'.
Ted Kremenek9cfe9e62010-05-17 20:06:56 +00004774 */
4775CINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C);
4776
4777/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004778 * Determine if a C++ member function or member function template is
Douglas Gregor9519d922011-05-12 15:17:24 +00004779 * explicitly declared 'virtual' or if it overrides a virtual method from
4780 * one of the base classes.
4781 */
4782CINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual(CXCursor C);
4783
4784/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004785 * Determine if a C++ record is abstract, i.e. whether a class or struct
Alex Lorenz34ccadc2017-12-14 22:01:50 +00004786 * has a pure virtual member function.
4787 */
4788CINDEX_LINKAGE unsigned clang_CXXRecord_isAbstract(CXCursor C);
4789
4790/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004791 * Determine if an enum declaration refers to a scoped enum.
Alex Lorenzff7f42e2017-07-12 11:35:11 +00004792 */
4793CINDEX_LINKAGE unsigned clang_EnumDecl_isScoped(CXCursor C);
4794
4795/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004796 * Determine if a C++ member function or member function template is
Dmitri Gribenkoe570ede2014-04-07 14:59:13 +00004797 * declared 'const'.
4798 */
4799CINDEX_LINKAGE unsigned clang_CXXMethod_isConst(CXCursor C);
4800
4801/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004802 * Given a cursor that represents a template, determine
Douglas Gregorf11309e2010-08-31 22:12:17 +00004803 * the cursor kind of the specializations would be generated by instantiating
4804 * the template.
4805 *
4806 * This routine can be used to determine what flavor of function template,
4807 * class template, or class template partial specialization is stored in the
4808 * cursor. For example, it can describe whether a class template cursor is
4809 * declared with "struct", "class" or "union".
4810 *
4811 * \param C The cursor to query. This cursor should represent a template
4812 * declaration.
4813 *
4814 * \returns The cursor kind of the specializations that would be generated
4815 * by instantiating the template \p C. If \p C is not a template, returns
4816 * \c CXCursor_NoDeclFound.
4817 */
4818CINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind(CXCursor C);
Fangrui Song6907ce22018-07-30 19:24:48 +00004819
Douglas Gregorf11309e2010-08-31 22:12:17 +00004820/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004821 * Given a cursor that may represent a specialization or instantiation
Douglas Gregord3f48bd2010-09-02 00:07:54 +00004822 * of a template, retrieve the cursor that represents the template that it
4823 * specializes or from which it was instantiated.
4824 *
Fangrui Song6907ce22018-07-30 19:24:48 +00004825 * This routine determines the template involved both for explicit
Douglas Gregord3f48bd2010-09-02 00:07:54 +00004826 * specializations of templates and for implicit instantiations of the template,
4827 * both of which are referred to as "specializations". For a class template
Fangrui Song6907ce22018-07-30 19:24:48 +00004828 * specialization (e.g., \c std::vector<bool>), this routine will return
Douglas Gregord3f48bd2010-09-02 00:07:54 +00004829 * either the primary template (\c std::vector) or, if the specialization was
4830 * instantiated from a class template partial specialization, the class template
4831 * partial specialization. For a class template partial specialization and a
4832 * function template specialization (including instantiations), this
4833 * this routine will return the specialized template.
4834 *
4835 * For members of a class template (e.g., member functions, member classes, or
Fangrui Song6907ce22018-07-30 19:24:48 +00004836 * static data members), returns the specialized or instantiated member.
Douglas Gregord3f48bd2010-09-02 00:07:54 +00004837 * Although not strictly "templates" in the C++ language, members of class
4838 * templates have the same notions of specializations and instantiations that
4839 * templates do, so this routine treats them similarly.
4840 *
4841 * \param C A cursor that may be a specialization of a template or a member
4842 * of a template.
4843 *
Fangrui Song6907ce22018-07-30 19:24:48 +00004844 * \returns If the given cursor is a specialization or instantiation of a
Douglas Gregord3f48bd2010-09-02 00:07:54 +00004845 * template or a member thereof, the template or member that it specializes or
4846 * from which it was instantiated. Otherwise, returns a NULL cursor.
4847 */
4848CINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate(CXCursor C);
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004849
4850/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004851 * Given a cursor that references something else, return the source range
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004852 * covering that reference.
4853 *
4854 * \param C A cursor pointing to a member reference, a declaration reference, or
4855 * an operator call.
Fangrui Song6907ce22018-07-30 19:24:48 +00004856 * \param NameFlags A bitset with three independent flags:
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004857 * CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and
4858 * CXNameRange_WantSinglePiece.
Fangrui Song6907ce22018-07-30 19:24:48 +00004859 * \param PieceIndex For contiguous names or when passing the flag
4860 * CXNameRange_WantSinglePiece, only one piece with index 0 is
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004861 * available. When the CXNameRange_WantSinglePiece flag is not passed for a
Benjamin Kramer474261a2012-06-02 10:20:41 +00004862 * non-contiguous names, this index can be used to retrieve the individual
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004863 * pieces of the name. See also CXNameRange_WantSinglePiece.
4864 *
4865 * \returns The piece of the name pointed to by the given cursor. If there is no
4866 * name, or if the PieceIndex is out-of-range, a null-cursor will be returned.
4867 */
Francois Pichetece689f2011-07-25 22:00:44 +00004868CINDEX_LINKAGE CXSourceRange clang_getCursorReferenceNameRange(CXCursor C,
Fangrui Song6907ce22018-07-30 19:24:48 +00004869 unsigned NameFlags,
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004870 unsigned PieceIndex);
4871
4872enum CXNameRefFlags {
4873 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004874 * Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004875 * range.
4876 */
4877 CXNameRange_WantQualifier = 0x1,
Fangrui Song6907ce22018-07-30 19:24:48 +00004878
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004879 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004880 * Include the explicit template arguments, e.g. \<int> in x.f<int>,
James Dennett574cb4c2012-06-15 05:41:51 +00004881 * in the range.
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004882 */
4883 CXNameRange_WantTemplateArgs = 0x2,
4884
4885 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004886 * If the name is non-contiguous, return the full spanning range.
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004887 *
4888 * Non-contiguous names occur in Objective-C when a selector with two or more
4889 * parameters is used, or in C++ when using an operator:
4890 * \code
Nico Weber7deebef2014-04-24 03:17:47 +00004891 * [object doSomething:here withValue:there]; // Objective-C
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004892 * return some_vector[1]; // C++
4893 * \endcode
4894 */
4895 CXNameRange_WantSinglePiece = 0x4
4896};
Fangrui Song6907ce22018-07-30 19:24:48 +00004897
Douglas Gregord3f48bd2010-09-02 00:07:54 +00004898/**
Ted Kremenek9cfe9e62010-05-17 20:06:56 +00004899 * @}
4900 */
4901
4902/**
Douglas Gregor61656112010-01-26 18:31:56 +00004903 * \defgroup CINDEX_LEX Token extraction and manipulation
4904 *
4905 * The routines in this group provide access to the tokens within a
4906 * translation unit, along with a semantic mapping of those tokens to
4907 * their corresponding cursors.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004908 *
4909 * @{
4910 */
4911
4912/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004913 * Describes a kind of token.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004914 */
4915typedef enum CXTokenKind {
4916 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004917 * A token that contains some kind of punctuation.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004918 */
4919 CXToken_Punctuation,
Ted Kremenekd071c602010-03-13 02:50:34 +00004920
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004921 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004922 * A language keyword.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004923 */
4924 CXToken_Keyword,
Ted Kremenekd071c602010-03-13 02:50:34 +00004925
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004926 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004927 * An identifier (that is not a keyword).
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004928 */
4929 CXToken_Identifier,
Ted Kremenekd071c602010-03-13 02:50:34 +00004930
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004931 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004932 * A numeric, string, or character literal.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004933 */
4934 CXToken_Literal,
Ted Kremenekd071c602010-03-13 02:50:34 +00004935
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004936 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004937 * A comment.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004938 */
4939 CXToken_Comment
4940} CXTokenKind;
4941
4942/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004943 * Describes a single preprocessing token.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004944 */
4945typedef struct {
4946 unsigned int_data[4];
4947 void *ptr_data;
4948} CXToken;
4949
4950/**
Ivan Donchevskii3957e482018-06-13 12:37:08 +00004951 * Get the raw lexical token starting with the given location.
4952 *
4953 * \param TU the translation unit whose text is being tokenized.
4954 *
4955 * \param Location the source location with which the token starts.
4956 *
4957 * \returns The token starting with the given location or NULL if no such token
4958 * exist. The returned pointer must be freed with clang_disposeTokens before the
4959 * translation unit is destroyed.
4960 */
4961CINDEX_LINKAGE CXToken *clang_getToken(CXTranslationUnit TU,
4962 CXSourceLocation Location);
4963
4964/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004965 * Determine the kind of the given token.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004966 */
4967CINDEX_LINKAGE CXTokenKind clang_getTokenKind(CXToken);
Ted Kremenekd071c602010-03-13 02:50:34 +00004968
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004969/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004970 * Determine the spelling of the given token.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004971 *
4972 * The spelling of a token is the textual representation of that token, e.g.,
4973 * the text of an identifier or keyword.
4974 */
4975CINDEX_LINKAGE CXString clang_getTokenSpelling(CXTranslationUnit, CXToken);
Ted Kremenekd071c602010-03-13 02:50:34 +00004976
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004977/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004978 * Retrieve the source location of the given token.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004979 */
Ted Kremenekd071c602010-03-13 02:50:34 +00004980CINDEX_LINKAGE CXSourceLocation clang_getTokenLocation(CXTranslationUnit,
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004981 CXToken);
Ted Kremenekd071c602010-03-13 02:50:34 +00004982
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004983/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004984 * Retrieve a source range that covers the given token.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004985 */
4986CINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken);
4987
4988/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00004989 * Tokenize the source code described by the given range into raw
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004990 * lexical tokens.
4991 *
4992 * \param TU the translation unit whose text is being tokenized.
4993 *
4994 * \param Range the source range in which text should be tokenized. All of the
4995 * tokens produced by tokenization will fall within this source range,
4996 *
4997 * \param Tokens this pointer will be set to point to the array of tokens
4998 * that occur within the given source range. The returned pointer must be
4999 * freed with clang_disposeTokens() before the translation unit is destroyed.
5000 *
5001 * \param NumTokens will be set to the number of tokens in the \c *Tokens
5002 * array.
5003 *
5004 */
5005CINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
5006 CXToken **Tokens, unsigned *NumTokens);
Ted Kremenekd071c602010-03-13 02:50:34 +00005007
Douglas Gregor27b4fa92010-01-26 17:06:03 +00005008/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005009 * Annotate the given set of tokens by providing cursors for each token
Douglas Gregor27b4fa92010-01-26 17:06:03 +00005010 * that can be mapped to a specific entity within the abstract syntax tree.
5011 *
Douglas Gregor61656112010-01-26 18:31:56 +00005012 * This token-annotation routine is equivalent to invoking
5013 * clang_getCursor() for the source locations of each of the
5014 * tokens. The cursors provided are filtered, so that only those
5015 * cursors that have a direct correspondence to the token are
5016 * accepted. For example, given a function call \c f(x),
5017 * clang_getCursor() would provide the following cursors:
5018 *
5019 * * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'.
5020 * * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'.
5021 * * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'.
5022 *
5023 * Only the first and last of these cursors will occur within the
5024 * annotate, since the tokens "f" and "x' directly refer to a function
5025 * and a variable, respectively, but the parentheses are just a small
5026 * part of the full syntax of the function call expression, which is
5027 * not provided as an annotation.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00005028 *
5029 * \param TU the translation unit that owns the given tokens.
5030 *
5031 * \param Tokens the set of tokens to annotate.
5032 *
5033 * \param NumTokens the number of tokens in \p Tokens.
5034 *
5035 * \param Cursors an array of \p NumTokens cursors, whose contents will be
5036 * replaced with the cursors corresponding to each token.
5037 */
5038CINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU,
5039 CXToken *Tokens, unsigned NumTokens,
5040 CXCursor *Cursors);
Ted Kremenekd071c602010-03-13 02:50:34 +00005041
Douglas Gregor27b4fa92010-01-26 17:06:03 +00005042/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005043 * Free the given set of tokens.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00005044 */
Ted Kremenekd071c602010-03-13 02:50:34 +00005045CINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU,
Douglas Gregor27b4fa92010-01-26 17:06:03 +00005046 CXToken *Tokens, unsigned NumTokens);
Ted Kremenekd071c602010-03-13 02:50:34 +00005047
Douglas Gregor27b4fa92010-01-26 17:06:03 +00005048/**
5049 * @}
5050 */
Ted Kremenekd071c602010-03-13 02:50:34 +00005051
Douglas Gregor27b4fa92010-01-26 17:06:03 +00005052/**
Douglas Gregor6007cf22010-01-22 22:29:16 +00005053 * \defgroup CINDEX_DEBUG Debugging facilities
5054 *
5055 * These routines are used for testing and debugging, only, and should not
5056 * be relied upon.
5057 *
5058 * @{
5059 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005060
Steve Naroff76b8f132009-09-23 17:52:52 +00005061/* for debug/testing */
Ted Kremenek29004672010-02-17 00:41:32 +00005062CINDEX_LINKAGE CXString clang_getCursorKindSpelling(enum CXCursorKind Kind);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005063CINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(CXCursor,
5064 const char **startBuf,
Steve Naroff76b8f132009-09-23 17:52:52 +00005065 const char **endBuf,
5066 unsigned *startLine,
5067 unsigned *startColumn,
5068 unsigned *endLine,
5069 unsigned *endColumn);
Douglas Gregor1e21cc72010-02-18 23:07:20 +00005070CINDEX_LINKAGE void clang_enableStackTraces(void);
Daniel Dunbar23420652010-11-04 01:26:29 +00005071CINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void*), void *user_data,
5072 unsigned stack_size);
5073
Douglas Gregor9eb77012009-11-07 00:00:49 +00005074/**
Douglas Gregor6007cf22010-01-22 22:29:16 +00005075 * @}
5076 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005077
Douglas Gregor6007cf22010-01-22 22:29:16 +00005078/**
5079 * \defgroup CINDEX_CODE_COMPLET Code completion
5080 *
5081 * Code completion involves taking an (incomplete) source file, along with
5082 * knowledge of where the user is actively editing that file, and suggesting
5083 * syntactically- and semantically-valid constructs that the user might want to
5084 * use at that particular point in the source code. These data structures and
5085 * routines provide support for code completion.
5086 *
5087 * @{
5088 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005089
Douglas Gregor6007cf22010-01-22 22:29:16 +00005090/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005091 * A semantic string that describes a code-completion result.
Douglas Gregor9eb77012009-11-07 00:00:49 +00005092 *
5093 * A semantic string that describes the formatting of a code-completion
5094 * result as a single "template" of text that should be inserted into the
5095 * source buffer when a particular code-completion result is selected.
5096 * Each semantic string is made up of some number of "chunks", each of which
5097 * contains some text along with a description of what that text means, e.g.,
5098 * the name of the entity being referenced, whether the text chunk is part of
5099 * the template, or whether it is a "placeholder" that the user should replace
5100 * with actual code,of a specific kind. See \c CXCompletionChunkKind for a
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005101 * description of the different kinds of chunks.
Douglas Gregor9eb77012009-11-07 00:00:49 +00005102 */
5103typedef void *CXCompletionString;
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005104
Douglas Gregor9eb77012009-11-07 00:00:49 +00005105/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005106 * A single result of code completion.
Douglas Gregor9eb77012009-11-07 00:00:49 +00005107 */
5108typedef struct {
5109 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005110 * The kind of entity that this completion refers to.
Douglas Gregor9eb77012009-11-07 00:00:49 +00005111 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005112 * The cursor kind will be a macro, keyword, or a declaration (one of the
Douglas Gregor9eb77012009-11-07 00:00:49 +00005113 * *Decl cursor kinds), describing the entity that the completion is
5114 * referring to.
5115 *
5116 * \todo In the future, we would like to provide a full cursor, to allow
5117 * the client to extract additional information from declaration.
5118 */
5119 enum CXCursorKind CursorKind;
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005120
5121 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005122 * The code-completion string that describes how to insert this
Douglas Gregor9eb77012009-11-07 00:00:49 +00005123 * code-completion result into the editing buffer.
5124 */
5125 CXCompletionString CompletionString;
5126} CXCompletionResult;
5127
5128/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005129 * Describes a single piece of text within a code-completion string.
Douglas Gregor9eb77012009-11-07 00:00:49 +00005130 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005131 * Each "chunk" within a code-completion string (\c CXCompletionString) is
5132 * either a piece of text with a specific "kind" that describes how that text
Douglas Gregor9eb77012009-11-07 00:00:49 +00005133 * should be interpreted by the client or is another completion string.
5134 */
5135enum CXCompletionChunkKind {
5136 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005137 * A code-completion string that describes "optional" text that
Douglas Gregor9eb77012009-11-07 00:00:49 +00005138 * could be a part of the template (but is not required).
5139 *
5140 * The Optional chunk is the only kind of chunk that has a code-completion
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005141 * string for its representation, which is accessible via
Douglas Gregor9eb77012009-11-07 00:00:49 +00005142 * \c clang_getCompletionChunkCompletionString(). The code-completion string
5143 * describes an additional part of the template that is completely optional.
5144 * For example, optional chunks can be used to describe the placeholders for
5145 * arguments that match up with defaulted function parameters, e.g. given:
5146 *
5147 * \code
5148 * void f(int x, float y = 3.14, double z = 2.71828);
5149 * \endcode
5150 *
5151 * The code-completion string for this function would contain:
5152 * - a TypedText chunk for "f".
5153 * - a LeftParen chunk for "(".
5154 * - a Placeholder chunk for "int x"
5155 * - an Optional chunk containing the remaining defaulted arguments, e.g.,
5156 * - a Comma chunk for ","
Daniel Dunbar4053fae2010-02-17 08:07:44 +00005157 * - a Placeholder chunk for "float y"
Douglas Gregor9eb77012009-11-07 00:00:49 +00005158 * - an Optional chunk containing the last defaulted argument:
5159 * - a Comma chunk for ","
5160 * - a Placeholder chunk for "double z"
5161 * - a RightParen chunk for ")"
5162 *
Daniel Dunbar4053fae2010-02-17 08:07:44 +00005163 * There are many ways to handle Optional chunks. Two simple approaches are:
Douglas Gregor9eb77012009-11-07 00:00:49 +00005164 * - Completely ignore optional chunks, in which case the template for the
5165 * function "f" would only include the first parameter ("int x").
5166 * - Fully expand all optional chunks, in which case the template for the
5167 * function "f" would have all of the parameters.
5168 */
5169 CXCompletionChunk_Optional,
5170 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005171 * Text that a user would be expected to type to get this
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005172 * code-completion result.
Douglas Gregor9eb77012009-11-07 00:00:49 +00005173 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005174 * There will be exactly one "typed text" chunk in a semantic string, which
5175 * will typically provide the spelling of a keyword or the name of a
Douglas Gregor9eb77012009-11-07 00:00:49 +00005176 * declaration that could be used at the current code point. Clients are
5177 * expected to filter the code-completion results based on the text in this
5178 * chunk.
5179 */
5180 CXCompletionChunk_TypedText,
5181 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005182 * Text that should be inserted as part of a code-completion result.
Douglas Gregor9eb77012009-11-07 00:00:49 +00005183 *
5184 * A "text" chunk represents text that is part of the template to be
5185 * inserted into user code should this particular code-completion result
5186 * be selected.
5187 */
5188 CXCompletionChunk_Text,
5189 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005190 * Placeholder text that should be replaced by the user.
Douglas Gregor9eb77012009-11-07 00:00:49 +00005191 *
5192 * A "placeholder" chunk marks a place where the user should insert text
5193 * into the code-completion template. For example, placeholders might mark
5194 * the function parameters for a function declaration, to indicate that the
5195 * user should provide arguments for each of those parameters. The actual
5196 * text in a placeholder is a suggestion for the text to display before
5197 * the user replaces the placeholder with real code.
5198 */
5199 CXCompletionChunk_Placeholder,
5200 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005201 * Informative text that should be displayed but never inserted as
Douglas Gregor9eb77012009-11-07 00:00:49 +00005202 * part of the template.
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005203 *
Douglas Gregor9eb77012009-11-07 00:00:49 +00005204 * An "informative" chunk contains annotations that can be displayed to
5205 * help the user decide whether a particular code-completion result is the
5206 * right option, but which is not part of the actual template to be inserted
5207 * by code completion.
5208 */
5209 CXCompletionChunk_Informative,
5210 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005211 * Text that describes the current parameter when code-completion is
Douglas Gregor9eb77012009-11-07 00:00:49 +00005212 * referring to function call, message send, or template specialization.
5213 *
5214 * A "current parameter" chunk occurs when code-completion is providing
5215 * information about a parameter corresponding to the argument at the
5216 * code-completion point. For example, given a function
5217 *
5218 * \code
5219 * int add(int x, int y);
5220 * \endcode
5221 *
5222 * and the source code \c add(, where the code-completion point is after the
5223 * "(", the code-completion string will contain a "current parameter" chunk
5224 * for "int x", indicating that the current argument will initialize that
5225 * parameter. After typing further, to \c add(17, (where the code-completion
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005226 * point is after the ","), the code-completion string will contain a
Alexander Kornienko2a8c18d2018-04-06 15:14:32 +00005227 * "current parameter" chunk to "int y".
Douglas Gregor9eb77012009-11-07 00:00:49 +00005228 */
5229 CXCompletionChunk_CurrentParameter,
5230 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005231 * A left parenthesis ('('), used to initiate a function call or
Douglas Gregor9eb77012009-11-07 00:00:49 +00005232 * signal the beginning of a function parameter list.
5233 */
5234 CXCompletionChunk_LeftParen,
5235 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005236 * A right parenthesis (')'), used to finish a function call or
Douglas Gregor9eb77012009-11-07 00:00:49 +00005237 * signal the end of a function parameter list.
5238 */
5239 CXCompletionChunk_RightParen,
5240 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005241 * A left bracket ('[').
Douglas Gregor9eb77012009-11-07 00:00:49 +00005242 */
5243 CXCompletionChunk_LeftBracket,
5244 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005245 * A right bracket (']').
Douglas Gregor9eb77012009-11-07 00:00:49 +00005246 */
5247 CXCompletionChunk_RightBracket,
5248 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005249 * A left brace ('{').
Douglas Gregor9eb77012009-11-07 00:00:49 +00005250 */
5251 CXCompletionChunk_LeftBrace,
5252 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005253 * A right brace ('}').
Douglas Gregor9eb77012009-11-07 00:00:49 +00005254 */
5255 CXCompletionChunk_RightBrace,
5256 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005257 * A left angle bracket ('<').
Douglas Gregor9eb77012009-11-07 00:00:49 +00005258 */
5259 CXCompletionChunk_LeftAngle,
5260 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005261 * A right angle bracket ('>').
Douglas Gregor9eb77012009-11-07 00:00:49 +00005262 */
5263 CXCompletionChunk_RightAngle,
5264 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005265 * A comma separator (',').
Douglas Gregor9eb77012009-11-07 00:00:49 +00005266 */
Douglas Gregorb3fa9192009-12-18 18:53:37 +00005267 CXCompletionChunk_Comma,
5268 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005269 * Text that specifies the result type of a given result.
Douglas Gregorb3fa9192009-12-18 18:53:37 +00005270 *
5271 * This special kind of informative chunk is not meant to be inserted into
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005272 * the text buffer. Rather, it is meant to illustrate the type that an
Douglas Gregorb3fa9192009-12-18 18:53:37 +00005273 * expression using the given completion string would have.
5274 */
Douglas Gregor504a6ae2010-01-10 23:08:15 +00005275 CXCompletionChunk_ResultType,
5276 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005277 * A colon (':').
Douglas Gregor504a6ae2010-01-10 23:08:15 +00005278 */
5279 CXCompletionChunk_Colon,
5280 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005281 * A semicolon (';').
Douglas Gregor504a6ae2010-01-10 23:08:15 +00005282 */
5283 CXCompletionChunk_SemiColon,
5284 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005285 * An '=' sign.
Douglas Gregor504a6ae2010-01-10 23:08:15 +00005286 */
5287 CXCompletionChunk_Equal,
5288 /**
5289 * Horizontal space (' ').
5290 */
5291 CXCompletionChunk_HorizontalSpace,
5292 /**
Alex Lorenz6c2898a2017-04-06 14:03:25 +00005293 * Vertical space ('\\n'), after which it is generally a good idea to
Douglas Gregor504a6ae2010-01-10 23:08:15 +00005294 * perform indentation.
5295 */
5296 CXCompletionChunk_VerticalSpace
Douglas Gregor9eb77012009-11-07 00:00:49 +00005297};
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005298
Douglas Gregor9eb77012009-11-07 00:00:49 +00005299/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005300 * Determine the kind of a particular chunk within a completion string.
Douglas Gregor9eb77012009-11-07 00:00:49 +00005301 *
5302 * \param completion_string the completion string to query.
5303 *
5304 * \param chunk_number the 0-based index of the chunk in the completion string.
5305 *
5306 * \returns the kind of the chunk at the index \c chunk_number.
5307 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005308CINDEX_LINKAGE enum CXCompletionChunkKind
Douglas Gregor9eb77012009-11-07 00:00:49 +00005309clang_getCompletionChunkKind(CXCompletionString completion_string,
5310 unsigned chunk_number);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005311
Douglas Gregor9eb77012009-11-07 00:00:49 +00005312/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005313 * Retrieve the text associated with a particular chunk within a
Douglas Gregor9eb77012009-11-07 00:00:49 +00005314 * completion string.
5315 *
5316 * \param completion_string the completion string to query.
5317 *
5318 * \param chunk_number the 0-based index of the chunk in the completion string.
5319 *
5320 * \returns the text associated with the chunk at index \c chunk_number.
5321 */
Ted Kremenekf602f962010-02-17 01:42:24 +00005322CINDEX_LINKAGE CXString
Douglas Gregor9eb77012009-11-07 00:00:49 +00005323clang_getCompletionChunkText(CXCompletionString completion_string,
5324 unsigned chunk_number);
5325
5326/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005327 * Retrieve the completion string associated with a particular chunk
Douglas Gregor9eb77012009-11-07 00:00:49 +00005328 * within a completion string.
5329 *
5330 * \param completion_string the completion string to query.
5331 *
5332 * \param chunk_number the 0-based index of the chunk in the completion string.
5333 *
5334 * \returns the completion string associated with the chunk at index
Erik Verbruggen98ea7f62011-10-14 15:31:08 +00005335 * \c chunk_number.
Douglas Gregor9eb77012009-11-07 00:00:49 +00005336 */
5337CINDEX_LINKAGE CXCompletionString
5338clang_getCompletionChunkCompletionString(CXCompletionString completion_string,
5339 unsigned chunk_number);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005340
Douglas Gregor9eb77012009-11-07 00:00:49 +00005341/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005342 * Retrieve the number of chunks in the given code-completion string.
Douglas Gregor9eb77012009-11-07 00:00:49 +00005343 */
5344CINDEX_LINKAGE unsigned
5345clang_getNumCompletionChunks(CXCompletionString completion_string);
5346
5347/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005348 * Determine the priority of this code completion.
Douglas Gregora2db7932010-05-26 22:00:08 +00005349 *
Fangrui Song6907ce22018-07-30 19:24:48 +00005350 * The priority of a code completion indicates how likely it is that this
Douglas Gregora2db7932010-05-26 22:00:08 +00005351 * particular completion is the completion that the user will select. The
5352 * priority is selected by various internal heuristics.
5353 *
5354 * \param completion_string The completion string to query.
5355 *
5356 * \returns The priority of this completion string. Smaller values indicate
5357 * higher-priority (more likely) completions.
5358 */
5359CINDEX_LINKAGE unsigned
5360clang_getCompletionPriority(CXCompletionString completion_string);
Fangrui Song6907ce22018-07-30 19:24:48 +00005361
Douglas Gregora2db7932010-05-26 22:00:08 +00005362/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005363 * Determine the availability of the entity that this code-completion
Douglas Gregorf757a122010-08-23 23:00:57 +00005364 * string refers to.
5365 *
5366 * \param completion_string The completion string to query.
5367 *
5368 * \returns The availability of the completion string.
5369 */
Fangrui Song6907ce22018-07-30 19:24:48 +00005370CINDEX_LINKAGE enum CXAvailabilityKind
Douglas Gregorf757a122010-08-23 23:00:57 +00005371clang_getCompletionAvailability(CXCompletionString completion_string);
5372
5373/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005374 * Retrieve the number of annotations associated with the given
Erik Verbruggen98ea7f62011-10-14 15:31:08 +00005375 * completion string.
5376 *
5377 * \param completion_string the completion string to query.
5378 *
5379 * \returns the number of annotations associated with the given completion
5380 * string.
5381 */
5382CINDEX_LINKAGE unsigned
5383clang_getCompletionNumAnnotations(CXCompletionString completion_string);
5384
5385/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005386 * Retrieve the annotation associated with the given completion string.
Erik Verbruggen98ea7f62011-10-14 15:31:08 +00005387 *
5388 * \param completion_string the completion string to query.
5389 *
5390 * \param annotation_number the 0-based index of the annotation of the
5391 * completion string.
5392 *
5393 * \returns annotation string associated with the completion at index
5394 * \c annotation_number, or a NULL string if that annotation is not available.
5395 */
5396CINDEX_LINKAGE CXString
5397clang_getCompletionAnnotation(CXCompletionString completion_string,
5398 unsigned annotation_number);
5399
5400/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005401 * Retrieve the parent context of the given completion string.
Douglas Gregor78254c82012-03-27 23:34:16 +00005402 *
Fangrui Song6907ce22018-07-30 19:24:48 +00005403 * The parent context of a completion string is the semantic parent of
Douglas Gregor78254c82012-03-27 23:34:16 +00005404 * the declaration (if any) that the code completion represents. For example,
5405 * a code completion for an Objective-C method would have the method's class
5406 * or protocol as its context.
5407 *
5408 * \param completion_string The code completion string whose parent is
5409 * being queried.
5410 *
Argyrios Kyrtzidis9ae39562012-09-26 16:39:56 +00005411 * \param kind DEPRECATED: always set to CXCursor_NotImplemented if non-NULL.
Douglas Gregor78254c82012-03-27 23:34:16 +00005412 *
James Dennett574cb4c2012-06-15 05:41:51 +00005413 * \returns The name of the completion parent, e.g., "NSObject" if
Douglas Gregor78254c82012-03-27 23:34:16 +00005414 * the completion string represents a method in the NSObject class.
5415 */
5416CINDEX_LINKAGE CXString
5417clang_getCompletionParent(CXCompletionString completion_string,
5418 enum CXCursorKind *kind);
Dmitri Gribenko3292d062012-07-02 17:35:10 +00005419
5420/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005421 * Retrieve the brief documentation comment attached to the declaration
Dmitri Gribenko3292d062012-07-02 17:35:10 +00005422 * that corresponds to the given completion string.
5423 */
5424CINDEX_LINKAGE CXString
5425clang_getCompletionBriefComment(CXCompletionString completion_string);
5426
Douglas Gregor78254c82012-03-27 23:34:16 +00005427/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005428 * Retrieve a completion string for an arbitrary declaration or macro
Douglas Gregor3f35bb22011-08-04 20:04:59 +00005429 * definition cursor.
5430 *
5431 * \param cursor The cursor to query.
5432 *
5433 * \returns A non-context-sensitive completion string for declaration and macro
5434 * definition cursors, or NULL for other kinds of cursors.
5435 */
5436CINDEX_LINKAGE CXCompletionString
5437clang_getCursorCompletionString(CXCursor cursor);
Fangrui Song6907ce22018-07-30 19:24:48 +00005438
Douglas Gregor3f35bb22011-08-04 20:04:59 +00005439/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005440 * Contains the results of code-completion.
Douglas Gregorf72b6ac2009-12-18 16:20:58 +00005441 *
5442 * This data structure contains the results of code completion, as
Douglas Gregor6a9580282010-10-11 21:51:20 +00005443 * produced by \c clang_codeCompleteAt(). Its contents must be freed by
Douglas Gregorf72b6ac2009-12-18 16:20:58 +00005444 * \c clang_disposeCodeCompleteResults.
5445 */
5446typedef struct {
5447 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005448 * The code-completion results.
Douglas Gregorf72b6ac2009-12-18 16:20:58 +00005449 */
5450 CXCompletionResult *Results;
5451
5452 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005453 * The number of code-completion results stored in the
Douglas Gregorf72b6ac2009-12-18 16:20:58 +00005454 * \c Results array.
5455 */
5456 unsigned NumResults;
5457} CXCodeCompleteResults;
5458
5459/**
Ivan Donchevskii3957e482018-06-13 12:37:08 +00005460 * Retrieve the number of fix-its for the given completion index.
5461 *
5462 * Calling this makes sense only if CXCodeComplete_IncludeCompletionsWithFixIts
5463 * option was set.
5464 *
5465 * \param results The structure keeping all completion results
5466 *
5467 * \param completion_index The index of the completion
5468 *
5469 * \return The number of fix-its which must be applied before the completion at
5470 * completion_index can be applied
5471 */
5472CINDEX_LINKAGE unsigned
5473clang_getCompletionNumFixIts(CXCodeCompleteResults *results,
5474 unsigned completion_index);
5475
5476/**
5477 * Fix-its that *must* be applied before inserting the text for the
5478 * corresponding completion.
5479 *
5480 * By default, clang_codeCompleteAt() only returns completions with empty
5481 * fix-its. Extra completions with non-empty fix-its should be explicitly
5482 * requested by setting CXCodeComplete_IncludeCompletionsWithFixIts.
5483 *
5484 * For the clients to be able to compute position of the cursor after applying
5485 * fix-its, the following conditions are guaranteed to hold for
5486 * replacement_range of the stored fix-its:
5487 * - Ranges in the fix-its are guaranteed to never contain the completion
5488 * point (or identifier under completion point, if any) inside them, except
5489 * at the start or at the end of the range.
5490 * - If a fix-it range starts or ends with completion point (or starts or
5491 * ends after the identifier under completion point), it will contain at
5492 * least one character. It allows to unambiguously recompute completion
5493 * point after applying the fix-it.
5494 *
5495 * The intuition is that provided fix-its change code around the identifier we
5496 * complete, but are not allowed to touch the identifier itself or the
5497 * completion point. One example of completions with corrections are the ones
5498 * replacing '.' with '->' and vice versa:
5499 *
5500 * std::unique_ptr<std::vector<int>> vec_ptr;
5501 * In 'vec_ptr.^', one of the completions is 'push_back', it requires
5502 * replacing '.' with '->'.
5503 * In 'vec_ptr->^', one of the completions is 'release', it requires
5504 * replacing '->' with '.'.
5505 *
5506 * \param results The structure keeping all completion results
5507 *
5508 * \param completion_index The index of the completion
5509 *
5510 * \param fixit_index The index of the fix-it for the completion at
5511 * completion_index
5512 *
5513 * \param replacement_range The fix-it range that must be replaced before the
5514 * completion at completion_index can be applied
5515 *
5516 * \returns The fix-it string that must replace the code at replacement_range
5517 * before the completion at completion_index can be applied
5518 */
5519CINDEX_LINKAGE CXString clang_getCompletionFixIt(
5520 CXCodeCompleteResults *results, unsigned completion_index,
5521 unsigned fixit_index, CXSourceRange *replacement_range);
5522
5523/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005524 * Flags that can be passed to \c clang_codeCompleteAt() to
Douglas Gregorb68bc592010-08-05 09:09:23 +00005525 * modify its behavior.
5526 *
5527 * The enumerators in this enumeration can be bitwise-OR'd together to
5528 * provide multiple options to \c clang_codeCompleteAt().
5529 */
5530enum CXCodeComplete_Flags {
5531 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005532 * Whether to include macros within the set of code
Douglas Gregorb68bc592010-08-05 09:09:23 +00005533 * completions returned.
5534 */
5535 CXCodeComplete_IncludeMacros = 0x01,
5536
5537 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005538 * Whether to include code patterns for language constructs
Douglas Gregorb68bc592010-08-05 09:09:23 +00005539 * within the set of code completions, e.g., for loops.
5540 */
Dmitri Gribenko3292d062012-07-02 17:35:10 +00005541 CXCodeComplete_IncludeCodePatterns = 0x02,
5542
5543 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005544 * Whether to include brief documentation within the set of code
Dmitri Gribenko3292d062012-07-02 17:35:10 +00005545 * completions returned.
5546 */
Sam McCallbb2cf632018-01-12 14:51:47 +00005547 CXCodeComplete_IncludeBriefComments = 0x04,
5548
5549 /**
Sam McCallabdcc612018-01-24 17:50:20 +00005550 * Whether to speed up completion by omitting top- or namespace-level entities
5551 * defined in the preamble. There's no guarantee any particular entity is
5552 * omitted. This may be useful if the headers are indexed externally.
Sam McCallbb2cf632018-01-12 14:51:47 +00005553 */
Ivan Donchevskii3957e482018-06-13 12:37:08 +00005554 CXCodeComplete_SkipPreamble = 0x08,
5555
5556 /**
5557 * Whether to include completions with small
5558 * fix-its, e.g. change '.' to '->' on member access, etc.
5559 */
5560 CXCodeComplete_IncludeCompletionsWithFixIts = 0x10
Douglas Gregorb68bc592010-08-05 09:09:23 +00005561};
5562
5563/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005564 * Bits that represent the context under which completion is occurring.
Douglas Gregor21325842011-07-07 16:03:39 +00005565 *
5566 * The enumerators in this enumeration may be bitwise-OR'd together if multiple
5567 * contexts are occurring simultaneously.
5568 */
5569enum CXCompletionContext {
5570 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005571 * The context for completions is unexposed, as only Clang results
Douglas Gregor21325842011-07-07 16:03:39 +00005572 * should be included. (This is equivalent to having no context bits set.)
5573 */
5574 CXCompletionContext_Unexposed = 0,
Fangrui Song6907ce22018-07-30 19:24:48 +00005575
Douglas Gregor21325842011-07-07 16:03:39 +00005576 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005577 * Completions for any possible type should be included in the results.
Douglas Gregor21325842011-07-07 16:03:39 +00005578 */
5579 CXCompletionContext_AnyType = 1 << 0,
Fangrui Song6907ce22018-07-30 19:24:48 +00005580
Douglas Gregor21325842011-07-07 16:03:39 +00005581 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005582 * Completions for any possible value (variables, function calls, etc.)
Douglas Gregor21325842011-07-07 16:03:39 +00005583 * should be included in the results.
5584 */
5585 CXCompletionContext_AnyValue = 1 << 1,
5586 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005587 * Completions for values that resolve to an Objective-C object should
Douglas Gregor21325842011-07-07 16:03:39 +00005588 * be included in the results.
5589 */
5590 CXCompletionContext_ObjCObjectValue = 1 << 2,
5591 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005592 * Completions for values that resolve to an Objective-C selector
Douglas Gregor21325842011-07-07 16:03:39 +00005593 * should be included in the results.
5594 */
5595 CXCompletionContext_ObjCSelectorValue = 1 << 3,
5596 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005597 * Completions for values that resolve to a C++ class type should be
Douglas Gregor21325842011-07-07 16:03:39 +00005598 * included in the results.
5599 */
5600 CXCompletionContext_CXXClassTypeValue = 1 << 4,
Fangrui Song6907ce22018-07-30 19:24:48 +00005601
Douglas Gregor21325842011-07-07 16:03:39 +00005602 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005603 * Completions for fields of the member being accessed using the dot
Douglas Gregor21325842011-07-07 16:03:39 +00005604 * operator should be included in the results.
5605 */
5606 CXCompletionContext_DotMemberAccess = 1 << 5,
5607 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005608 * Completions for fields of the member being accessed using the arrow
Douglas Gregor21325842011-07-07 16:03:39 +00005609 * operator should be included in the results.
5610 */
5611 CXCompletionContext_ArrowMemberAccess = 1 << 6,
5612 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005613 * Completions for properties of the Objective-C object being accessed
Douglas Gregor21325842011-07-07 16:03:39 +00005614 * using the dot operator should be included in the results.
5615 */
5616 CXCompletionContext_ObjCPropertyAccess = 1 << 7,
Fangrui Song6907ce22018-07-30 19:24:48 +00005617
Douglas Gregor21325842011-07-07 16:03:39 +00005618 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005619 * Completions for enum tags should be included in the results.
Douglas Gregor21325842011-07-07 16:03:39 +00005620 */
5621 CXCompletionContext_EnumTag = 1 << 8,
5622 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005623 * Completions for union tags should be included in the results.
Douglas Gregor21325842011-07-07 16:03:39 +00005624 */
5625 CXCompletionContext_UnionTag = 1 << 9,
5626 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005627 * Completions for struct tags should be included in the results.
Douglas Gregor21325842011-07-07 16:03:39 +00005628 */
5629 CXCompletionContext_StructTag = 1 << 10,
Fangrui Song6907ce22018-07-30 19:24:48 +00005630
Douglas Gregor21325842011-07-07 16:03:39 +00005631 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005632 * Completions for C++ class names should be included in the results.
Douglas Gregor21325842011-07-07 16:03:39 +00005633 */
5634 CXCompletionContext_ClassTag = 1 << 11,
5635 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005636 * Completions for C++ namespaces and namespace aliases should be
Douglas Gregor21325842011-07-07 16:03:39 +00005637 * included in the results.
5638 */
5639 CXCompletionContext_Namespace = 1 << 12,
5640 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005641 * Completions for C++ nested name specifiers should be included in
Douglas Gregor21325842011-07-07 16:03:39 +00005642 * the results.
5643 */
5644 CXCompletionContext_NestedNameSpecifier = 1 << 13,
Fangrui Song6907ce22018-07-30 19:24:48 +00005645
Douglas Gregor21325842011-07-07 16:03:39 +00005646 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005647 * Completions for Objective-C interfaces (classes) should be included
Douglas Gregor21325842011-07-07 16:03:39 +00005648 * in the results.
5649 */
5650 CXCompletionContext_ObjCInterface = 1 << 14,
5651 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005652 * Completions for Objective-C protocols should be included in
Douglas Gregor21325842011-07-07 16:03:39 +00005653 * the results.
5654 */
5655 CXCompletionContext_ObjCProtocol = 1 << 15,
5656 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005657 * Completions for Objective-C categories should be included in
Douglas Gregor21325842011-07-07 16:03:39 +00005658 * the results.
5659 */
5660 CXCompletionContext_ObjCCategory = 1 << 16,
5661 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005662 * Completions for Objective-C instance messages should be included
Douglas Gregor21325842011-07-07 16:03:39 +00005663 * in the results.
5664 */
5665 CXCompletionContext_ObjCInstanceMessage = 1 << 17,
5666 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005667 * Completions for Objective-C class messages should be included in
Douglas Gregor21325842011-07-07 16:03:39 +00005668 * the results.
5669 */
5670 CXCompletionContext_ObjCClassMessage = 1 << 18,
5671 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005672 * Completions for Objective-C selector names should be included in
Douglas Gregor21325842011-07-07 16:03:39 +00005673 * the results.
5674 */
5675 CXCompletionContext_ObjCSelectorName = 1 << 19,
Fangrui Song6907ce22018-07-30 19:24:48 +00005676
Douglas Gregor21325842011-07-07 16:03:39 +00005677 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005678 * Completions for preprocessor macro names should be included in
Douglas Gregor21325842011-07-07 16:03:39 +00005679 * the results.
5680 */
5681 CXCompletionContext_MacroName = 1 << 20,
Fangrui Song6907ce22018-07-30 19:24:48 +00005682
Douglas Gregor21325842011-07-07 16:03:39 +00005683 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005684 * Natural language completions should be included in the results.
Douglas Gregor21325842011-07-07 16:03:39 +00005685 */
5686 CXCompletionContext_NaturalLanguage = 1 << 21,
Fangrui Song6907ce22018-07-30 19:24:48 +00005687
Douglas Gregor21325842011-07-07 16:03:39 +00005688 /**
Sam McCall3d8051a2018-09-18 08:40:41 +00005689 * #include file completions should be included in the results.
5690 */
5691 CXCompletionContext_IncludedFile = 1 << 22,
5692
5693 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005694 * The current context is unknown, so set all contexts.
Douglas Gregor21325842011-07-07 16:03:39 +00005695 */
Sam McCall3d8051a2018-09-18 08:40:41 +00005696 CXCompletionContext_Unknown = ((1 << 23) - 1)
Douglas Gregor21325842011-07-07 16:03:39 +00005697};
Fangrui Song6907ce22018-07-30 19:24:48 +00005698
Douglas Gregor21325842011-07-07 16:03:39 +00005699/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005700 * Returns a default set of code-completion options that can be
Fangrui Song6907ce22018-07-30 19:24:48 +00005701 * passed to\c clang_codeCompleteAt().
Douglas Gregorb68bc592010-08-05 09:09:23 +00005702 */
5703CINDEX_LINKAGE unsigned clang_defaultCodeCompleteOptions(void);
5704
5705/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005706 * Perform code completion at a given location in a translation unit.
Douglas Gregor8e984da2010-08-04 16:47:14 +00005707 *
5708 * This function performs code completion at a particular file, line, and
5709 * column within source code, providing results that suggest potential
5710 * code snippets based on the context of the completion. The basic model
5711 * for code completion is that Clang will parse a complete source file,
5712 * performing syntax checking up to the location where code-completion has
5713 * been requested. At that point, a special code-completion token is passed
5714 * to the parser, which recognizes this token and determines, based on the
5715 * current location in the C/Objective-C/C++ grammar and the state of
5716 * semantic analysis, what completions to provide. These completions are
5717 * returned via a new \c CXCodeCompleteResults structure.
5718 *
5719 * Code completion itself is meant to be triggered by the client when the
5720 * user types punctuation characters or whitespace, at which point the
5721 * code-completion location will coincide with the cursor. For example, if \c p
5722 * is a pointer, code-completion might be triggered after the "-" and then
Alexander Kornienko2a8c18d2018-04-06 15:14:32 +00005723 * after the ">" in \c p->. When the code-completion location is after the ">",
Douglas Gregor8e984da2010-08-04 16:47:14 +00005724 * the completion results will provide, e.g., the members of the struct that
5725 * "p" points to. The client is responsible for placing the cursor at the
5726 * beginning of the token currently being typed, then filtering the results
5727 * based on the contents of the token. For example, when code-completing for
5728 * the expression \c p->get, the client should provide the location just after
5729 * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the
5730 * client can filter the results based on the current token text ("get"), only
5731 * showing those results that start with "get". The intent of this interface
5732 * is to separate the relatively high-latency acquisition of code-completion
5733 * results from the filtering of results on a per-character basis, which must
5734 * have a lower latency.
5735 *
5736 * \param TU The translation unit in which code-completion should
5737 * occur. The source files for this translation unit need not be
5738 * completely up-to-date (and the contents of those source files may
5739 * be overridden via \p unsaved_files). Cursors referring into the
5740 * translation unit may be invalidated by this invocation.
5741 *
5742 * \param complete_filename The name of the source file where code
5743 * completion should be performed. This filename may be any file
5744 * included in the translation unit.
5745 *
5746 * \param complete_line The line at which code-completion should occur.
5747 *
5748 * \param complete_column The column at which code-completion should occur.
5749 * Note that the column should point just after the syntactic construct that
5750 * initiated code completion, and not in the middle of a lexical token.
5751 *
Vedant Kumarcbfe7bb2016-03-23 23:51:36 +00005752 * \param unsaved_files the Files that have not yet been saved to disk
Douglas Gregor8e984da2010-08-04 16:47:14 +00005753 * but may be required for parsing or code completion, including the
5754 * contents of those files. The contents and name of these files (as
5755 * specified by CXUnsavedFile) are copied when necessary, so the
5756 * client only needs to guarantee their validity until the call to
5757 * this function returns.
5758 *
5759 * \param num_unsaved_files The number of unsaved file entries in \p
5760 * unsaved_files.
5761 *
Douglas Gregorb68bc592010-08-05 09:09:23 +00005762 * \param options Extra options that control the behavior of code
5763 * completion, expressed as a bitwise OR of the enumerators of the
Fangrui Song6907ce22018-07-30 19:24:48 +00005764 * CXCodeComplete_Flags enumeration. The
Douglas Gregorb68bc592010-08-05 09:09:23 +00005765 * \c clang_defaultCodeCompleteOptions() function returns a default set
5766 * of code-completion options.
5767 *
Douglas Gregor8e984da2010-08-04 16:47:14 +00005768 * \returns If successful, a new \c CXCodeCompleteResults structure
5769 * containing code-completion results, which should eventually be
5770 * freed with \c clang_disposeCodeCompleteResults(). If code
5771 * completion fails, returns NULL.
5772 */
5773CINDEX_LINKAGE
5774CXCodeCompleteResults *clang_codeCompleteAt(CXTranslationUnit TU,
5775 const char *complete_filename,
5776 unsigned complete_line,
5777 unsigned complete_column,
5778 struct CXUnsavedFile *unsaved_files,
Douglas Gregorb68bc592010-08-05 09:09:23 +00005779 unsigned num_unsaved_files,
5780 unsigned options);
Douglas Gregor8e984da2010-08-04 16:47:14 +00005781
5782/**
Fangrui Song6907ce22018-07-30 19:24:48 +00005783 * Sort the code-completion results in case-insensitive alphabetical
Douglas Gregor49f67ce2010-08-26 13:48:20 +00005784 * order.
5785 *
5786 * \param Results The set of results to sort.
5787 * \param NumResults The number of results in \p Results.
5788 */
5789CINDEX_LINKAGE
5790void clang_sortCodeCompletionResults(CXCompletionResult *Results,
5791 unsigned NumResults);
Fangrui Song6907ce22018-07-30 19:24:48 +00005792
Douglas Gregor49f67ce2010-08-26 13:48:20 +00005793/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005794 * Free the given set of code-completion results.
Douglas Gregorf72b6ac2009-12-18 16:20:58 +00005795 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005796CINDEX_LINKAGE
Douglas Gregorf72b6ac2009-12-18 16:20:58 +00005797void clang_disposeCodeCompleteResults(CXCodeCompleteResults *Results);
Fangrui Song6907ce22018-07-30 19:24:48 +00005798
Douglas Gregor52606ff2010-01-20 01:10:47 +00005799/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005800 * Determine the number of diagnostics produced prior to the
Douglas Gregor33cdd812010-02-18 18:08:43 +00005801 * location where code completion was performed.
5802 */
Ted Kremenekd071c602010-03-13 02:50:34 +00005803CINDEX_LINKAGE
Douglas Gregor33cdd812010-02-18 18:08:43 +00005804unsigned clang_codeCompleteGetNumDiagnostics(CXCodeCompleteResults *Results);
5805
5806/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005807 * Retrieve a diagnostic associated with the given code completion.
Douglas Gregor33cdd812010-02-18 18:08:43 +00005808 *
James Dennett574cb4c2012-06-15 05:41:51 +00005809 * \param Results the code completion results to query.
Douglas Gregor33cdd812010-02-18 18:08:43 +00005810 * \param Index the zero-based diagnostic number to retrieve.
5811 *
5812 * \returns the requested diagnostic. This diagnostic must be freed
5813 * via a call to \c clang_disposeDiagnostic().
5814 */
Ted Kremenekd071c602010-03-13 02:50:34 +00005815CINDEX_LINKAGE
Douglas Gregor33cdd812010-02-18 18:08:43 +00005816CXDiagnostic clang_codeCompleteGetDiagnostic(CXCodeCompleteResults *Results,
5817 unsigned Index);
5818
5819/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005820 * Determines what completions are appropriate for the context
Douglas Gregor21325842011-07-07 16:03:39 +00005821 * the given code completion.
Fangrui Song6907ce22018-07-30 19:24:48 +00005822 *
Douglas Gregor21325842011-07-07 16:03:39 +00005823 * \param Results the code completion results to query
5824 *
5825 * \returns the kinds of completions that are appropriate for use
5826 * along with the given code completion results.
5827 */
5828CINDEX_LINKAGE
5829unsigned long long clang_codeCompleteGetContexts(
5830 CXCodeCompleteResults *Results);
Douglas Gregor63745d52011-07-21 01:05:26 +00005831
5832/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005833 * Returns the cursor kind for the container for the current code
Douglas Gregor63745d52011-07-21 01:05:26 +00005834 * completion context. The container is only guaranteed to be set for
5835 * contexts where a container exists (i.e. member accesses or Objective-C
5836 * message sends); if there is not a container, this function will return
5837 * CXCursor_InvalidCode.
5838 *
5839 * \param Results the code completion results to query
5840 *
5841 * \param IsIncomplete on return, this value will be false if Clang has complete
5842 * information about the container. If Clang does not have complete
5843 * information, this value will be true.
5844 *
5845 * \returns the container kind, or CXCursor_InvalidCode if there is not a
5846 * container
5847 */
5848CINDEX_LINKAGE
5849enum CXCursorKind clang_codeCompleteGetContainerKind(
5850 CXCodeCompleteResults *Results,
5851 unsigned *IsIncomplete);
5852
5853/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005854 * Returns the USR for the container for the current code completion
Douglas Gregor63745d52011-07-21 01:05:26 +00005855 * context. If there is not a container for the current context, this
5856 * function will return the empty string.
5857 *
5858 * \param Results the code completion results to query
5859 *
5860 * \returns the USR for the container
5861 */
5862CINDEX_LINKAGE
5863CXString clang_codeCompleteGetContainerUSR(CXCodeCompleteResults *Results);
NAKAMURA Takumiaa13f942015-12-09 07:52:46 +00005864
Douglas Gregorea777402011-07-26 15:24:30 +00005865/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005866 * Returns the currently-entered selector for an Objective-C message
Douglas Gregorea777402011-07-26 15:24:30 +00005867 * send, formatted like "initWithFoo:bar:". Only guaranteed to return a
5868 * non-empty string for CXCompletionContext_ObjCInstanceMessage and
5869 * CXCompletionContext_ObjCClassMessage.
5870 *
5871 * \param Results the code completion results to query
5872 *
5873 * \returns the selector (or partial selector) that has been entered thus far
5874 * for an Objective-C message send.
5875 */
5876CINDEX_LINKAGE
5877CXString clang_codeCompleteGetObjCSelector(CXCodeCompleteResults *Results);
Fangrui Song6907ce22018-07-30 19:24:48 +00005878
Douglas Gregor21325842011-07-07 16:03:39 +00005879/**
Douglas Gregor52606ff2010-01-20 01:10:47 +00005880 * @}
5881 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005882
Ted Kremenekc0f3f722010-01-22 22:44:15 +00005883/**
5884 * \defgroup CINDEX_MISC Miscellaneous utility functions
5885 *
5886 * @{
5887 */
Ted Kremenek3e315a22010-01-23 17:51:23 +00005888
5889/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005890 * Return a version string, suitable for showing to a user, but not
Ted Kremenek3e315a22010-01-23 17:51:23 +00005891 * intended to be parsed (the format is not guaranteed to be stable).
5892 */
NAKAMURA Takumieacd6672013-01-10 02:12:38 +00005893CINDEX_LINKAGE CXString clang_getClangVersion(void);
Ted Kremenekc0f3f722010-01-22 22:44:15 +00005894
Ted Kremenek1ec7b332011-03-18 23:05:39 +00005895/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005896 * Enable/disable crash recovery.
Ted Kremenek1ec7b332011-03-18 23:05:39 +00005897 *
James Dennett574cb4c2012-06-15 05:41:51 +00005898 * \param isEnabled Flag to indicate if crash recovery is enabled. A non-zero
5899 * value enables crash recovery, while 0 disables it.
Ted Kremenek1ec7b332011-03-18 23:05:39 +00005900 */
5901CINDEX_LINKAGE void clang_toggleCrashRecovery(unsigned isEnabled);
Fangrui Song6907ce22018-07-30 19:24:48 +00005902
Ted Kremenek0b86e3a2010-01-26 19:31:51 +00005903 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005904 * Visitor invoked for each file in a translation unit
Ted Kremenek0b86e3a2010-01-26 19:31:51 +00005905 * (used with clang_getInclusions()).
5906 *
5907 * This visitor function will be invoked by clang_getInclusions() for each
James Dennett574cb4c2012-06-15 05:41:51 +00005908 * file included (either at the top-level or by \#include directives) within
Ted Kremenek0b86e3a2010-01-26 19:31:51 +00005909 * a translation unit. The first argument is the file being included, and
5910 * the second and third arguments provide the inclusion stack. The
5911 * array is sorted in order of immediate inclusion. For example,
5912 * the first element refers to the location that included 'included_file'.
5913 */
5914typedef void (*CXInclusionVisitor)(CXFile included_file,
5915 CXSourceLocation* inclusion_stack,
5916 unsigned include_len,
5917 CXClientData client_data);
5918
5919/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005920 * Visit the set of preprocessor inclusions in a translation unit.
Ted Kremenek0b86e3a2010-01-26 19:31:51 +00005921 * The visitor function is called with the provided data for every included
5922 * file. This does not include headers included by the PCH file (unless one
5923 * is inspecting the inclusions in the PCH file itself).
5924 */
5925CINDEX_LINKAGE void clang_getInclusions(CXTranslationUnit tu,
5926 CXInclusionVisitor visitor,
5927 CXClientData client_data);
5928
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005929typedef enum {
5930 CXEval_Int = 1 ,
5931 CXEval_Float = 2,
5932 CXEval_ObjCStrLiteral = 3,
5933 CXEval_StrLiteral = 4,
5934 CXEval_CFStr = 5,
5935 CXEval_Other = 6,
5936
5937 CXEval_UnExposed = 0
5938
5939} CXEvalResultKind ;
5940
5941/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005942 * Evaluation result of a cursor
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005943 */
5944typedef void * CXEvalResult;
5945
5946/**
Fangrui Song6907ce22018-07-30 19:24:48 +00005947 * If cursor is a statement declaration tries to evaluate the
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005948 * statement and if its variable, tries to evaluate its initializer,
5949 * into its corresponding type.
5950 */
5951CINDEX_LINKAGE CXEvalResult clang_Cursor_Evaluate(CXCursor C);
5952
5953/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005954 * Returns the kind of the evaluated result.
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005955 */
Argyrios Kyrtzidisa851d7e2016-01-16 03:01:20 +00005956CINDEX_LINKAGE CXEvalResultKind clang_EvalResult_getKind(CXEvalResult E);
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005957
5958/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005959 * Returns the evaluation result as integer if the
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005960 * kind is Int.
5961 */
Argyrios Kyrtzidisa851d7e2016-01-16 03:01:20 +00005962CINDEX_LINKAGE int clang_EvalResult_getAsInt(CXEvalResult E);
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005963
5964/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005965 * Returns the evaluation result as a long long integer if the
Argyrios Kyrtzidis5dda1122016-12-01 23:41:27 +00005966 * kind is Int. This prevents overflows that may happen if the result is
5967 * returned with clang_EvalResult_getAsInt.
5968 */
5969CINDEX_LINKAGE long long clang_EvalResult_getAsLongLong(CXEvalResult E);
5970
5971/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005972 * Returns a non-zero value if the kind is Int and the evaluation
Argyrios Kyrtzidis5dda1122016-12-01 23:41:27 +00005973 * result resulted in an unsigned integer.
5974 */
5975CINDEX_LINKAGE unsigned clang_EvalResult_isUnsignedInt(CXEvalResult E);
5976
5977/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005978 * Returns the evaluation result as an unsigned integer if
Argyrios Kyrtzidis5dda1122016-12-01 23:41:27 +00005979 * the kind is Int and clang_EvalResult_isUnsignedInt is non-zero.
5980 */
5981CINDEX_LINKAGE unsigned long long clang_EvalResult_getAsUnsigned(CXEvalResult E);
5982
5983/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005984 * Returns the evaluation result as double if the
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005985 * kind is double.
5986 */
Argyrios Kyrtzidisa851d7e2016-01-16 03:01:20 +00005987CINDEX_LINKAGE double clang_EvalResult_getAsDouble(CXEvalResult E);
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005988
5989/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005990 * Returns the evaluation result as a constant string if the
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005991 * kind is other than Int or float. User must not free this pointer,
5992 * instead call clang_EvalResult_dispose on the CXEvalResult returned
5993 * by clang_Cursor_Evaluate.
5994 */
Argyrios Kyrtzidisa851d7e2016-01-16 03:01:20 +00005995CINDEX_LINKAGE const char* clang_EvalResult_getAsStr(CXEvalResult E);
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005996
5997/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00005998 * Disposes the created Eval memory.
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005999 */
Argyrios Kyrtzidisa851d7e2016-01-16 03:01:20 +00006000CINDEX_LINKAGE void clang_EvalResult_dispose(CXEvalResult E);
Ted Kremenek0b86e3a2010-01-26 19:31:51 +00006001/**
Ted Kremenekc0f3f722010-01-22 22:44:15 +00006002 * @}
6003 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00006004
Argyrios Kyrtzidisf89cc692011-07-11 20:15:00 +00006005/** \defgroup CINDEX_REMAPPING Remapping functions
6006 *
6007 * @{
6008 */
6009
6010/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006011 * A remapping of original source files and their translated files.
Argyrios Kyrtzidisf89cc692011-07-11 20:15:00 +00006012 */
6013typedef void *CXRemapping;
6014
6015/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006016 * Retrieve a remapping.
Argyrios Kyrtzidisf89cc692011-07-11 20:15:00 +00006017 *
6018 * \param path the path that contains metadata about remappings.
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 CXRemapping clang_getRemappings(const char *path);
6024
6025/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006026 * Retrieve a remapping.
Ted Kremenekf7639e12012-03-06 20:06:33 +00006027 *
6028 * \param filePaths pointer to an array of file paths containing remapping info.
6029 *
6030 * \param numFiles number of file paths.
6031 *
6032 * \returns the requested remapping. This remapping must be freed
6033 * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
6034 */
6035CINDEX_LINKAGE
6036CXRemapping clang_getRemappingsFromFileList(const char **filePaths,
6037 unsigned numFiles);
6038
6039/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006040 * Determine the number of remappings.
Argyrios Kyrtzidisf89cc692011-07-11 20:15:00 +00006041 */
6042CINDEX_LINKAGE unsigned clang_remap_getNumFiles(CXRemapping);
6043
6044/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006045 * Get the original and the associated filename from the remapping.
Fangrui Song6907ce22018-07-30 19:24:48 +00006046 *
Argyrios Kyrtzidisf89cc692011-07-11 20:15:00 +00006047 * \param original If non-NULL, will be set to the original filename.
6048 *
6049 * \param transformed If non-NULL, will be set to the filename that the original
6050 * is associated with.
6051 */
6052CINDEX_LINKAGE void clang_remap_getFilenames(CXRemapping, unsigned index,
6053 CXString *original, CXString *transformed);
6054
6055/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006056 * Dispose the remapping.
Argyrios Kyrtzidisf89cc692011-07-11 20:15:00 +00006057 */
6058CINDEX_LINKAGE void clang_remap_dispose(CXRemapping);
6059
6060/**
6061 * @}
6062 */
6063
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00006064/** \defgroup CINDEX_HIGH Higher level API functions
6065 *
6066 * @{
6067 */
6068
6069enum CXVisitorResult {
6070 CXVisit_Break,
6071 CXVisit_Continue
6072};
6073
Saleem Abdulrasoolec988b72016-05-24 01:23:24 +00006074typedef struct CXCursorAndRangeVisitor {
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00006075 void *context;
6076 enum CXVisitorResult (*visit)(void *context, CXCursor, CXSourceRange);
6077} CXCursorAndRangeVisitor;
6078
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00006079typedef enum {
6080 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006081 * Function returned successfully.
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00006082 */
6083 CXResult_Success = 0,
6084 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006085 * One of the parameters was invalid for the function.
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00006086 */
6087 CXResult_Invalid = 1,
6088 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006089 * The function was terminated by a callback (e.g. it returned
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00006090 * CXVisit_Break)
6091 */
6092 CXResult_VisitBreak = 2
6093
6094} CXResult;
6095
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00006096/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006097 * Find references of a declaration in a specific file.
Fangrui Song6907ce22018-07-30 19:24:48 +00006098 *
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00006099 * \param cursor pointing to a declaration or a reference of one.
6100 *
6101 * \param file to search for references.
6102 *
6103 * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
6104 * each reference found.
6105 * The CXSourceRange will point inside the file; if the reference is inside
6106 * a macro (and not a macro argument) the CXSourceRange will be invalid.
Argyrios Kyrtzidis951f61f2013-03-08 20:42:33 +00006107 *
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00006108 * \returns one of the CXResult enumerators.
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00006109 */
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00006110CINDEX_LINKAGE CXResult clang_findReferencesInFile(CXCursor cursor, CXFile file,
6111 CXCursorAndRangeVisitor visitor);
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00006112
Argyrios Kyrtzidis503c83a2013-03-08 02:32:34 +00006113/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006114 * Find #import/#include directives in a specific file.
Argyrios Kyrtzidis503c83a2013-03-08 02:32:34 +00006115 *
6116 * \param TU translation unit containing the file to query.
6117 *
6118 * \param file to search for #import/#include directives.
6119 *
6120 * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
6121 * each directive found.
Argyrios Kyrtzidis951f61f2013-03-08 20:42:33 +00006122 *
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00006123 * \returns one of the CXResult enumerators.
Argyrios Kyrtzidis503c83a2013-03-08 02:32:34 +00006124 */
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00006125CINDEX_LINKAGE CXResult clang_findIncludesInFile(CXTranslationUnit TU,
6126 CXFile file,
6127 CXCursorAndRangeVisitor visitor);
Argyrios Kyrtzidis503c83a2013-03-08 02:32:34 +00006128
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00006129#ifdef __has_feature
6130# if __has_feature(blocks)
6131
6132typedef enum CXVisitorResult
6133 (^CXCursorAndRangeVisitorBlock)(CXCursor, CXSourceRange);
6134
6135CINDEX_LINKAGE
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00006136CXResult clang_findReferencesInFileWithBlock(CXCursor, CXFile,
6137 CXCursorAndRangeVisitorBlock);
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00006138
Argyrios Kyrtzidis503c83a2013-03-08 02:32:34 +00006139CINDEX_LINKAGE
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00006140CXResult clang_findIncludesInFileWithBlock(CXTranslationUnit, CXFile,
6141 CXCursorAndRangeVisitorBlock);
Argyrios Kyrtzidis503c83a2013-03-08 02:32:34 +00006142
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00006143# endif
6144#endif
6145
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006146/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006147 * The client's data object that is associated with a CXFile.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006148 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006149typedef void *CXIdxClientFile;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006150
6151/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006152 * The client's data object that is associated with a semantic entity.
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006153 */
6154typedef void *CXIdxClientEntity;
6155
6156/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006157 * The client's data object that is associated with a semantic container
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006158 * of entities.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006159 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006160typedef void *CXIdxClientContainer;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006161
6162/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006163 * The client's data object that is associated with an AST file (PCH
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006164 * or module).
6165 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006166typedef void *CXIdxClientASTFile;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006167
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006168/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006169 * Source location passed to index callbacks.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006170 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006171typedef struct {
6172 void *ptr_data[2];
6173 unsigned int_data;
6174} CXIdxLoc;
6175
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006176/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006177 * Data for ppIncludedFile callback.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006178 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006179typedef struct {
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006180 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006181 * Location of '#' in the \#include/\#import directive.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006182 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006183 CXIdxLoc hashLoc;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006184 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006185 * Filename as written in the \#include/\#import directive.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006186 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006187 const char *filename;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006188 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006189 * The actual file that the \#include/\#import directive resolved to.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006190 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006191 CXFile file;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006192 int isImport;
6193 int isAngled;
Argyrios Kyrtzidis5e2ec482012-10-18 00:17:05 +00006194 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006195 * Non-zero if the directive was automatically turned into a module
Argyrios Kyrtzidis5e2ec482012-10-18 00:17:05 +00006196 * import.
6197 */
6198 int isModuleImport;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006199} CXIdxIncludedFileInfo;
6200
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006201/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006202 * Data for IndexerCallbacks#importedASTFile.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006203 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006204typedef struct {
Argyrios Kyrtzidis472eda02012-10-02 16:10:38 +00006205 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006206 * Top level AST file containing the imported PCH, module or submodule.
Argyrios Kyrtzidis472eda02012-10-02 16:10:38 +00006207 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006208 CXFile file;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006209 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006210 * The imported module or NULL if the AST file is a PCH.
Argyrios Kyrtzidisdc78f3e2012-10-05 00:22:40 +00006211 */
6212 CXModule module;
6213 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006214 * Location where the file is imported. Applicable only for modules.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006215 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006216 CXIdxLoc loc;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006217 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006218 * Non-zero if an inclusion directive was automatically turned into
Argyrios Kyrtzidisdc78f3e2012-10-05 00:22:40 +00006219 * a module import. Applicable only for modules.
Argyrios Kyrtzidis472eda02012-10-02 16:10:38 +00006220 */
Argyrios Kyrtzidis184b1442012-10-03 21:05:44 +00006221 int isImplicit;
Argyrios Kyrtzidis472eda02012-10-02 16:10:38 +00006222
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006223} CXIdxImportedASTFileInfo;
6224
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006225typedef enum {
6226 CXIdxEntity_Unexposed = 0,
6227 CXIdxEntity_Typedef = 1,
6228 CXIdxEntity_Function = 2,
6229 CXIdxEntity_Variable = 3,
6230 CXIdxEntity_Field = 4,
6231 CXIdxEntity_EnumConstant = 5,
6232
6233 CXIdxEntity_ObjCClass = 6,
6234 CXIdxEntity_ObjCProtocol = 7,
6235 CXIdxEntity_ObjCCategory = 8,
6236
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00006237 CXIdxEntity_ObjCInstanceMethod = 9,
6238 CXIdxEntity_ObjCClassMethod = 10,
6239 CXIdxEntity_ObjCProperty = 11,
6240 CXIdxEntity_ObjCIvar = 12,
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006241
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00006242 CXIdxEntity_Enum = 13,
6243 CXIdxEntity_Struct = 14,
6244 CXIdxEntity_Union = 15,
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006245
6246 CXIdxEntity_CXXClass = 16,
6247 CXIdxEntity_CXXNamespace = 17,
6248 CXIdxEntity_CXXNamespaceAlias = 18,
6249 CXIdxEntity_CXXStaticVariable = 19,
6250 CXIdxEntity_CXXStaticMethod = 20,
6251 CXIdxEntity_CXXInstanceMethod = 21,
Joao Matose9a3ed42012-08-31 22:18:20 +00006252 CXIdxEntity_CXXConstructor = 22,
6253 CXIdxEntity_CXXDestructor = 23,
6254 CXIdxEntity_CXXConversionFunction = 24,
6255 CXIdxEntity_CXXTypeAlias = 25,
6256 CXIdxEntity_CXXInterface = 26
6257
6258} CXIdxEntityKind;
6259
Argyrios Kyrtzidis52002882011-12-07 20:44:12 +00006260typedef enum {
6261 CXIdxEntityLang_None = 0,
6262 CXIdxEntityLang_C = 1,
6263 CXIdxEntityLang_ObjC = 2,
Argyrios Kyrtzidisb4b85f22017-04-24 14:52:00 +00006264 CXIdxEntityLang_CXX = 3,
6265 CXIdxEntityLang_Swift = 4
Argyrios Kyrtzidis52002882011-12-07 20:44:12 +00006266} CXIdxEntityLanguage;
6267
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006268/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006269 * Extra C++ template information for an entity. This can apply to:
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006270 * CXIdxEntity_Function
6271 * CXIdxEntity_CXXClass
6272 * CXIdxEntity_CXXStaticMethod
6273 * CXIdxEntity_CXXInstanceMethod
6274 * CXIdxEntity_CXXConstructor
6275 * CXIdxEntity_CXXConversionFunction
6276 * CXIdxEntity_CXXTypeAlias
6277 */
6278typedef enum {
6279 CXIdxEntity_NonTemplate = 0,
6280 CXIdxEntity_Template = 1,
6281 CXIdxEntity_TemplatePartialSpecialization = 2,
6282 CXIdxEntity_TemplateSpecialization = 3
6283} CXIdxEntityCXXTemplateKind;
6284
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00006285typedef enum {
6286 CXIdxAttr_Unexposed = 0,
6287 CXIdxAttr_IBAction = 1,
6288 CXIdxAttr_IBOutlet = 2,
6289 CXIdxAttr_IBOutletCollection = 3
6290} CXIdxAttrKind;
6291
6292typedef struct {
6293 CXIdxAttrKind kind;
6294 CXCursor cursor;
6295 CXIdxLoc loc;
6296} CXIdxAttrInfo;
6297
6298typedef struct {
Argyrios Kyrtzidis4d873b72011-12-15 00:05:00 +00006299 CXIdxEntityKind kind;
6300 CXIdxEntityCXXTemplateKind templateKind;
6301 CXIdxEntityLanguage lang;
6302 const char *name;
6303 const char *USR;
6304 CXCursor cursor;
6305 const CXIdxAttrInfo *const *attributes;
6306 unsigned numAttributes;
6307} CXIdxEntityInfo;
6308
6309typedef struct {
6310 CXCursor cursor;
6311} CXIdxContainerInfo;
6312
6313typedef struct {
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00006314 const CXIdxAttrInfo *attrInfo;
6315 const CXIdxEntityInfo *objcClass;
6316 CXCursor classCursor;
6317 CXIdxLoc classLoc;
6318} CXIdxIBOutletCollectionAttrInfo;
6319
Argyrios Kyrtzidis8b71bc72012-12-06 19:41:16 +00006320typedef enum {
6321 CXIdxDeclFlag_Skipped = 0x1
6322} CXIdxDeclInfoFlags;
6323
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006324typedef struct {
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006325 const CXIdxEntityInfo *entityInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006326 CXCursor cursor;
6327 CXIdxLoc loc;
Argyrios Kyrtzidis663c8ec2011-12-07 20:44:19 +00006328 const CXIdxContainerInfo *semanticContainer;
6329 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006330 * Generally same as #semanticContainer but can be different in
Argyrios Kyrtzidis663c8ec2011-12-07 20:44:19 +00006331 * cases like out-of-line C++ member functions.
6332 */
6333 const CXIdxContainerInfo *lexicalContainer;
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006334 int isRedeclaration;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006335 int isDefinition;
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00006336 int isContainer;
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006337 const CXIdxContainerInfo *declAsContainer;
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00006338 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006339 * Whether the declaration exists in code or was created implicitly
Nico Weber7deebef2014-04-24 03:17:47 +00006340 * by the compiler, e.g. implicit Objective-C methods for properties.
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00006341 */
6342 int isImplicit;
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00006343 const CXIdxAttrInfo *const *attributes;
6344 unsigned numAttributes;
Argyrios Kyrtzidis8b71bc72012-12-06 19:41:16 +00006345
6346 unsigned flags;
6347
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006348} CXIdxDeclInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006349
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006350typedef enum {
6351 CXIdxObjCContainer_ForwardRef = 0,
6352 CXIdxObjCContainer_Interface = 1,
6353 CXIdxObjCContainer_Implementation = 2
6354} CXIdxObjCContainerKind;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006355
6356typedef struct {
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006357 const CXIdxDeclInfo *declInfo;
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006358 CXIdxObjCContainerKind kind;
6359} CXIdxObjCContainerDeclInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006360
6361typedef struct {
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006362 const CXIdxEntityInfo *base;
6363 CXCursor cursor;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006364 CXIdxLoc loc;
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006365} CXIdxBaseClassInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006366
6367typedef struct {
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006368 const CXIdxEntityInfo *protocol;
6369 CXCursor cursor;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006370 CXIdxLoc loc;
6371} CXIdxObjCProtocolRefInfo;
6372
6373typedef struct {
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006374 const CXIdxObjCProtocolRefInfo *const *protocols;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006375 unsigned numProtocols;
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00006376} CXIdxObjCProtocolRefListInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006377
6378typedef struct {
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00006379 const CXIdxObjCContainerDeclInfo *containerInfo;
6380 const CXIdxBaseClassInfo *superInfo;
6381 const CXIdxObjCProtocolRefListInfo *protocols;
6382} CXIdxObjCInterfaceDeclInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006383
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006384typedef struct {
Argyrios Kyrtzidis9b9f7a92011-12-13 18:47:45 +00006385 const CXIdxObjCContainerDeclInfo *containerInfo;
6386 const CXIdxEntityInfo *objcClass;
6387 CXCursor classCursor;
6388 CXIdxLoc classLoc;
6389 const CXIdxObjCProtocolRefListInfo *protocols;
6390} CXIdxObjCCategoryDeclInfo;
6391
6392typedef struct {
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006393 const CXIdxDeclInfo *declInfo;
Argyrios Kyrtzidis93db2922012-02-28 17:50:33 +00006394 const CXIdxEntityInfo *getter;
6395 const CXIdxEntityInfo *setter;
6396} CXIdxObjCPropertyDeclInfo;
6397
6398typedef struct {
6399 const CXIdxDeclInfo *declInfo;
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006400 const CXIdxBaseClassInfo *const *bases;
6401 unsigned numBases;
6402} CXIdxCXXClassDeclInfo;
6403
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006404/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006405 * Data for IndexerCallbacks#indexEntityReference.
Fangrui Song31b97192018-02-12 17:42:09 +00006406 *
6407 * This may be deprecated in a future version as this duplicates
6408 * the \c CXSymbolRole_Implicit bit in \c CXSymbolRole.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006409 */
Argyrios Kyrtzidis0c7735e52011-10-18 15:50:50 +00006410typedef enum {
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006411 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006412 * The entity is referenced directly in user's code.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006413 */
Argyrios Kyrtzidis0c7735e52011-10-18 15:50:50 +00006414 CXIdxEntityRef_Direct = 1,
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006415 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006416 * An implicit reference, e.g. a reference of an Objective-C method
Nico Weber7deebef2014-04-24 03:17:47 +00006417 * via the dot syntax.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006418 */
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00006419 CXIdxEntityRef_Implicit = 2
Argyrios Kyrtzidis0c7735e52011-10-18 15:50:50 +00006420} CXIdxEntityRefKind;
6421
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006422/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006423 * Roles that are attributed to symbol occurrences.
Fangrui Song31b97192018-02-12 17:42:09 +00006424 *
6425 * Internal: this currently mirrors low 9 bits of clang::index::SymbolRole with
6426 * higher bits zeroed. These high bits may be exposed in the future.
6427 */
6428typedef enum {
6429 CXSymbolRole_None = 0,
6430 CXSymbolRole_Declaration = 1 << 0,
6431 CXSymbolRole_Definition = 1 << 1,
6432 CXSymbolRole_Reference = 1 << 2,
6433 CXSymbolRole_Read = 1 << 3,
6434 CXSymbolRole_Write = 1 << 4,
6435 CXSymbolRole_Call = 1 << 5,
6436 CXSymbolRole_Dynamic = 1 << 6,
6437 CXSymbolRole_AddressOf = 1 << 7,
6438 CXSymbolRole_Implicit = 1 << 8
6439} CXSymbolRole;
6440
6441/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006442 * Data for IndexerCallbacks#indexEntityReference.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006443 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006444typedef struct {
Argyrios Kyrtzidis663c8ec2011-12-07 20:44:19 +00006445 CXIdxEntityRefKind kind;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006446 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006447 * Reference cursor.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006448 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006449 CXCursor cursor;
6450 CXIdxLoc loc;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006451 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006452 * The entity that gets referenced.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006453 */
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006454 const CXIdxEntityInfo *referencedEntity;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006455 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006456 * Immediate "parent" of the reference. For example:
Fangrui Song6907ce22018-07-30 19:24:48 +00006457 *
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006458 * \code
6459 * Foo *var;
6460 * \endcode
Fangrui Song6907ce22018-07-30 19:24:48 +00006461 *
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006462 * The parent of reference of type 'Foo' is the variable 'var'.
Argyrios Kyrtzidis25cb0ff2011-12-13 18:47:41 +00006463 * For references inside statement bodies of functions/methods,
6464 * the parentEntity will be the function/method.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006465 */
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006466 const CXIdxEntityInfo *parentEntity;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006467 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006468 * Lexical container context of the reference.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006469 */
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006470 const CXIdxContainerInfo *container;
Fangrui Song31b97192018-02-12 17:42:09 +00006471 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006472 * Sets of symbol roles of the reference.
Fangrui Song31b97192018-02-12 17:42:09 +00006473 */
6474 CXSymbolRole role;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006475} CXIdxEntityRefInfo;
6476
James Dennett574cb4c2012-06-15 05:41:51 +00006477/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006478 * A group of callbacks used by #clang_indexSourceFile and
James Dennett574cb4c2012-06-15 05:41:51 +00006479 * #clang_indexTranslationUnit.
6480 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006481typedef struct {
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006482 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006483 * Called periodically to check whether indexing should be aborted.
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006484 * Should return 0 to continue, and non-zero to abort.
6485 */
6486 int (*abortQuery)(CXClientData client_data, void *reserved);
6487
6488 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006489 * Called at the end of indexing; passes the complete diagnostic set.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006490 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006491 void (*diagnostic)(CXClientData client_data,
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00006492 CXDiagnosticSet, void *reserved);
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006493
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006494 CXIdxClientFile (*enteredMainFile)(CXClientData client_data,
James Dennett574cb4c2012-06-15 05:41:51 +00006495 CXFile mainFile, void *reserved);
Fangrui Song6907ce22018-07-30 19:24:48 +00006496
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006497 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006498 * Called when a file gets \#included/\#imported.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006499 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006500 CXIdxClientFile (*ppIncludedFile)(CXClientData client_data,
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006501 const CXIdxIncludedFileInfo *);
Fangrui Song6907ce22018-07-30 19:24:48 +00006502
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006503 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006504 * Called when a AST file (PCH or module) gets imported.
Fangrui Song6907ce22018-07-30 19:24:48 +00006505 *
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006506 * AST files will not get indexed (there will not be callbacks to index all
6507 * the entities in an AST file). The recommended action is that, if the AST
Argyrios Kyrtzidis472eda02012-10-02 16:10:38 +00006508 * file is not already indexed, to initiate a new indexing job specific to
6509 * the AST file.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006510 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006511 CXIdxClientASTFile (*importedASTFile)(CXClientData client_data,
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006512 const CXIdxImportedASTFileInfo *);
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006513
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006514 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006515 * Called at the beginning of indexing a translation unit.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006516 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006517 CXIdxClientContainer (*startedTranslationUnit)(CXClientData client_data,
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006518 void *reserved);
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006519
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006520 void (*indexDeclaration)(CXClientData client_data,
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006521 const CXIdxDeclInfo *);
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006522
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006523 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006524 * Called to index a reference of an entity.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006525 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006526 void (*indexEntityReference)(CXClientData client_data,
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006527 const CXIdxEntityRefInfo *);
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006528
6529} IndexerCallbacks;
6530
NAKAMURA Takumiaacef7e2011-11-11 02:51:09 +00006531CINDEX_LINKAGE int clang_index_isEntityObjCContainerKind(CXIdxEntityKind);
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006532CINDEX_LINKAGE const CXIdxObjCContainerDeclInfo *
6533clang_index_getObjCContainerDeclInfo(const CXIdxDeclInfo *);
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006534
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006535CINDEX_LINKAGE const CXIdxObjCInterfaceDeclInfo *
6536clang_index_getObjCInterfaceDeclInfo(const CXIdxDeclInfo *);
6537
NAKAMURA Takumiaacef7e2011-11-11 02:51:09 +00006538CINDEX_LINKAGE
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006539const CXIdxObjCCategoryDeclInfo *
6540clang_index_getObjCCategoryDeclInfo(const CXIdxDeclInfo *);
6541
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00006542CINDEX_LINKAGE const CXIdxObjCProtocolRefListInfo *
6543clang_index_getObjCProtocolRefListInfo(const CXIdxDeclInfo *);
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006544
Argyrios Kyrtzidis93db2922012-02-28 17:50:33 +00006545CINDEX_LINKAGE const CXIdxObjCPropertyDeclInfo *
6546clang_index_getObjCPropertyDeclInfo(const CXIdxDeclInfo *);
6547
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00006548CINDEX_LINKAGE const CXIdxIBOutletCollectionAttrInfo *
6549clang_index_getIBOutletCollectionAttrInfo(const CXIdxAttrInfo *);
6550
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006551CINDEX_LINKAGE const CXIdxCXXClassDeclInfo *
6552clang_index_getCXXClassDeclInfo(const CXIdxDeclInfo *);
6553
6554/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006555 * For retrieving a custom CXIdxClientContainer attached to a
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006556 * container.
6557 */
6558CINDEX_LINKAGE CXIdxClientContainer
6559clang_index_getClientContainer(const CXIdxContainerInfo *);
6560
6561/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006562 * For setting a custom CXIdxClientContainer attached to a
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006563 * container.
6564 */
6565CINDEX_LINKAGE void
6566clang_index_setClientContainer(const CXIdxContainerInfo *,CXIdxClientContainer);
6567
6568/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006569 * For retrieving a custom CXIdxClientEntity attached to an entity.
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006570 */
6571CINDEX_LINKAGE CXIdxClientEntity
6572clang_index_getClientEntity(const CXIdxEntityInfo *);
6573
6574/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006575 * For setting a custom CXIdxClientEntity attached to an entity.
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006576 */
6577CINDEX_LINKAGE void
6578clang_index_setClientEntity(const CXIdxEntityInfo *, CXIdxClientEntity);
6579
6580/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006581 * An indexing action/session, to be applied to one or multiple
Argyrios Kyrtzidis8b71bc72012-12-06 19:41:16 +00006582 * translation units.
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006583 */
6584typedef void *CXIndexAction;
6585
6586/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006587 * An indexing action/session, to be applied to one or multiple
Argyrios Kyrtzidis8b71bc72012-12-06 19:41:16 +00006588 * translation units.
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006589 *
6590 * \param CIdx The index object with which the index action will be associated.
6591 */
6592CINDEX_LINKAGE CXIndexAction clang_IndexAction_create(CXIndex CIdx);
6593
6594/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006595 * Destroy the given index action.
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006596 *
6597 * The index action must not be destroyed until all of the translation units
6598 * created within that index action have been destroyed.
6599 */
6600CINDEX_LINKAGE void clang_IndexAction_dispose(CXIndexAction);
6601
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006602typedef enum {
6603 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006604 * Used to indicate that no special indexing options are needed.
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006605 */
6606 CXIndexOpt_None = 0x0,
Fangrui Song6907ce22018-07-30 19:24:48 +00006607
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006608 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006609 * Used to indicate that IndexerCallbacks#indexEntityReference should
James Dennett574cb4c2012-06-15 05:41:51 +00006610 * be invoked for only one reference of an entity per source file that does
6611 * not also include a declaration/definition of the entity.
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006612 */
Argyrios Kyrtzidisfb7d1452012-01-14 00:11:49 +00006613 CXIndexOpt_SuppressRedundantRefs = 0x1,
6614
6615 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006616 * Function-local symbols should be indexed. If this is not set
Argyrios Kyrtzidisfb7d1452012-01-14 00:11:49 +00006617 * function-local symbols will be ignored.
6618 */
Argyrios Kyrtzidis7e747952012-02-14 22:23:11 +00006619 CXIndexOpt_IndexFunctionLocalSymbols = 0x2,
6620
6621 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006622 * Implicit function/class template instantiations should be indexed.
Argyrios Kyrtzidis7e747952012-02-14 22:23:11 +00006623 * If this is not set, implicit instantiations will be ignored.
6624 */
Argyrios Kyrtzidis6c9ed7d2012-03-27 21:38:03 +00006625 CXIndexOpt_IndexImplicitTemplateInstantiations = 0x4,
6626
6627 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006628 * Suppress all compiler warnings when parsing for indexing.
Argyrios Kyrtzidis6c9ed7d2012-03-27 21:38:03 +00006629 */
Argyrios Kyrtzidis8b71bc72012-12-06 19:41:16 +00006630 CXIndexOpt_SuppressWarnings = 0x8,
6631
6632 /**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006633 * Skip a function/method body that was already parsed during an
Nico Weber7deebef2014-04-24 03:17:47 +00006634 * indexing session associated with a \c CXIndexAction object.
Argyrios Kyrtzidis8b71bc72012-12-06 19:41:16 +00006635 * Bodies in system headers are always skipped.
6636 */
6637 CXIndexOpt_SkipParsedBodiesInSession = 0x10
6638
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006639} CXIndexOptFlags;
6640
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006641/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006642 * Index the given source file and the translation unit corresponding
James Dennett574cb4c2012-06-15 05:41:51 +00006643 * to that file via callbacks implemented through #IndexerCallbacks.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006644 *
6645 * \param client_data pointer data supplied by the client, which will
6646 * be passed to the invoked callbacks.
6647 *
6648 * \param index_callbacks Pointer to indexing callbacks that the client
6649 * implements.
6650 *
James Dennett574cb4c2012-06-15 05:41:51 +00006651 * \param index_callbacks_size Size of #IndexerCallbacks structure that gets
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006652 * passed in index_callbacks.
6653 *
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006654 * \param index_options A bitmask of options that affects how indexing is
6655 * performed. This should be a bitwise OR of the CXIndexOpt_XXX flags.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006656 *
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00006657 * \param[out] out_TU pointer to store a \c CXTranslationUnit that can be
6658 * reused after indexing is finished. Set to \c NULL if you do not require it.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006659 *
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00006660 * \returns 0 on success or if there were errors from which the compiler could
Eric Christopher2c4555a2015-06-19 01:52:53 +00006661 * recover. If there is a failure from which there is no recovery, returns
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00006662 * a non-zero \c CXErrorCode.
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006663 *
James Dennett574cb4c2012-06-15 05:41:51 +00006664 * The rest of the parameters are the same as #clang_parseTranslationUnit.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006665 */
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006666CINDEX_LINKAGE int clang_indexSourceFile(CXIndexAction,
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006667 CXClientData client_data,
6668 IndexerCallbacks *index_callbacks,
6669 unsigned index_callbacks_size,
6670 unsigned index_options,
6671 const char *source_filename,
6672 const char * const *command_line_args,
6673 int num_command_line_args,
6674 struct CXUnsavedFile *unsaved_files,
6675 unsigned num_unsaved_files,
6676 CXTranslationUnit *out_TU,
6677 unsigned TU_options);
6678
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006679/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006680 * Same as clang_indexSourceFile but requires a full command line
Benjamin Kramerc02670e2015-11-18 16:14:27 +00006681 * for \c command_line_args including argv[0]. This is useful if the standard
6682 * library paths are relative to the binary.
6683 */
6684CINDEX_LINKAGE int clang_indexSourceFileFullArgv(
6685 CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks,
6686 unsigned index_callbacks_size, unsigned index_options,
6687 const char *source_filename, const char *const *command_line_args,
6688 int num_command_line_args, struct CXUnsavedFile *unsaved_files,
6689 unsigned num_unsaved_files, CXTranslationUnit *out_TU, unsigned TU_options);
6690
6691/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006692 * Index the given translation unit via callbacks implemented through
James Dennett574cb4c2012-06-15 05:41:51 +00006693 * #IndexerCallbacks.
Fangrui Song6907ce22018-07-30 19:24:48 +00006694 *
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006695 * The order of callback invocations is not guaranteed to be the same as
6696 * when indexing a source file. The high level order will be:
Fangrui Song6907ce22018-07-30 19:24:48 +00006697 *
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006698 * -Preprocessor callbacks invocations
6699 * -Declaration/reference callbacks invocations
6700 * -Diagnostic callback invocations
6701 *
James Dennett574cb4c2012-06-15 05:41:51 +00006702 * The parameters are the same as #clang_indexSourceFile.
Fangrui Song6907ce22018-07-30 19:24:48 +00006703 *
Eric Christopher2c4555a2015-06-19 01:52:53 +00006704 * \returns If there is a failure from which there is no recovery, returns
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006705 * non-zero, otherwise returns 0.
6706 */
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006707CINDEX_LINKAGE int clang_indexTranslationUnit(CXIndexAction,
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006708 CXClientData client_data,
6709 IndexerCallbacks *index_callbacks,
6710 unsigned index_callbacks_size,
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006711 unsigned index_options,
6712 CXTranslationUnit);
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006713
6714/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006715 * Retrieve the CXIdxFile, file, line, column, and offset represented by
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006716 * the given CXIdxLoc.
6717 *
6718 * If the location refers into a macro expansion, retrieves the
6719 * location of the macro expansion and if it refers into a macro argument
6720 * retrieves the location of the argument.
6721 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006722CINDEX_LINKAGE void clang_indexLoc_getFileLocation(CXIdxLoc loc,
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006723 CXIdxClientFile *indexFile,
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006724 CXFile *file,
6725 unsigned *line,
6726 unsigned *column,
6727 unsigned *offset);
6728
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006729/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006730 * Retrieve the CXSourceLocation represented by the given CXIdxLoc.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006731 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006732CINDEX_LINKAGE
6733CXSourceLocation clang_indexLoc_getCXSourceLocation(CXIdxLoc loc);
6734
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00006735/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006736 * Visitor invoked for each field found by a traversal.
Argyrios Kyrtzidis2bff5162015-04-13 16:55:04 +00006737 *
6738 * This visitor function will be invoked for each field found by
6739 * \c clang_Type_visitFields. Its first argument is the cursor being
6740 * visited, its second argument is the client data provided to
6741 * \c clang_Type_visitFields.
6742 *
6743 * The visitor should return one of the \c CXVisitorResult values
6744 * to direct \c clang_Type_visitFields.
6745 */
6746typedef enum CXVisitorResult (*CXFieldVisitor)(CXCursor C,
6747 CXClientData client_data);
6748
6749/**
Adrian Prantl9fc8faf2018-05-09 01:00:01 +00006750 * Visit the fields of a particular type.
Argyrios Kyrtzidis2bff5162015-04-13 16:55:04 +00006751 *
6752 * This function visits all the direct fields of the given cursor,
6753 * invoking the given \p visitor function with the cursors of each
6754 * visited field. The traversal may be ended prematurely, if
6755 * the visitor returns \c CXFieldVisit_Break.
6756 *
6757 * \param T the record type whose field may be visited.
6758 *
6759 * \param visitor the visitor function that will be invoked for each
6760 * field of \p T.
6761 *
6762 * \param client_data pointer data supplied by the client, which will
6763 * be passed to the visitor each time it is invoked.
6764 *
6765 * \returns a non-zero value if the traversal was terminated
6766 * prematurely by the visitor returning \c CXFieldVisit_Break.
6767 */
6768CINDEX_LINKAGE unsigned clang_Type_visitFields(CXType T,
6769 CXFieldVisitor visitor,
6770 CXClientData client_data);
6771
Argyrios Kyrtzidis2bff5162015-04-13 16:55:04 +00006772/**
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00006773 * @}
6774 */
6775
Douglas Gregor6007cf22010-01-22 22:29:16 +00006776/**
6777 * @}
6778 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00006779
Duncan P. N. Exon Smith8c484052019-11-14 13:57:57 -08006780LLVM_CLANG_C_EXTERN_C_END
6781
Ted Kremenekb60d87c2009-08-26 22:36:44 +00006782#endif