blob: e305283bbaf19759f366788bb636a4f76127ce04 [file] [log] [blame]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001/*===-- clang-c/Index.h - Indexing Public C Interface -------------*- C -*-===*\
2|* *|
Andrew Walbran16937d02019-10-22 13:54:20 +01003|* 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 *|
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01007|* *|
8|*===----------------------------------------------------------------------===*|
9|* *|
10|* This header provides a public interface to a Clang library for extracting *|
11|* high-level symbol information from source files without exposing the full *|
12|* Clang C++ API. *|
13|* *|
14\*===----------------------------------------------------------------------===*/
15
16#ifndef LLVM_CLANG_C_INDEX_H
17#define LLVM_CLANG_C_INDEX_H
18
19#include <time.h>
20
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020021#include "clang-c/BuildSystem.h"
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010022#include "clang-c/CXErrorCode.h"
23#include "clang-c/CXString.h"
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020024#include "clang-c/ExternC.h"
25#include "clang-c/Platform.h"
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010026
27/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +010028 * The version constants for the libclang API.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010029 * 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
33 * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
34 */
35#define CINDEX_VERSION_MAJOR 0
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020036#define CINDEX_VERSION_MINOR 61
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010037
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020038#define CINDEX_VERSION_ENCODE(major, minor) (((major)*10000) + ((minor)*1))
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010039
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020040#define CINDEX_VERSION \
41 CINDEX_VERSION_ENCODE(CINDEX_VERSION_MAJOR, CINDEX_VERSION_MINOR)
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010042
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020043#define CINDEX_VERSION_STRINGIZE_(major, minor) #major "." #minor
44#define CINDEX_VERSION_STRINGIZE(major, minor) \
45 CINDEX_VERSION_STRINGIZE_(major, minor)
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010046
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020047#define CINDEX_VERSION_STRING \
48 CINDEX_VERSION_STRINGIZE(CINDEX_VERSION_MAJOR, CINDEX_VERSION_MINOR)
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010049
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020050LLVM_CLANG_C_EXTERN_C_BEGIN
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010051
52/** \defgroup CINDEX libclang: C Interface to Clang
53 *
54 * The C Interface to Clang provides a relatively small API that exposes
55 * facilities for parsing source code into an abstract syntax tree (AST),
56 * loading already-parsed ASTs, traversing the AST, associating
57 * physical source locations with elements within the AST, and other
58 * facilities that support Clang-based development tools.
59 *
60 * This C interface to Clang will never provide all of the information
61 * representation stored in Clang's C++ AST, nor should it: the intent is to
62 * maintain an API that is relatively stable from one release to the next,
63 * providing only the basic functionality needed to support development tools.
64 *
65 * To avoid namespace pollution, data types are prefixed with "CX" and
66 * functions are prefixed with "clang_".
67 *
68 * @{
69 */
70
71/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +010072 * An "index" that consists of a set of translation units that would
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010073 * typically be linked together into an executable or library.
74 */
75typedef void *CXIndex;
76
77/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +010078 * An opaque type representing target information for a given translation
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010079 * unit.
80 */
81typedef struct CXTargetInfoImpl *CXTargetInfo;
82
83/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +010084 * A single translation unit, which resides in an index.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010085 */
86typedef struct CXTranslationUnitImpl *CXTranslationUnit;
87
88/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +010089 * Opaque pointer representing client data that will be passed through
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010090 * to various callbacks and visitors.
91 */
92typedef void *CXClientData;
93
94/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +010095 * Provides the contents of a file that has not yet been saved to disk.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010096 *
97 * Each CXUnsavedFile instance provides the name of a file on the
98 * system along with the current contents of that file that have not
99 * yet been saved to disk.
100 */
101struct CXUnsavedFile {
102 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100103 * The file whose contents have not yet been saved.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100104 *
105 * This file must already exist in the file system.
106 */
107 const char *Filename;
108
109 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100110 * A buffer containing the unsaved contents of this file.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100111 */
112 const char *Contents;
113
114 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100115 * The length of the unsaved contents of this buffer.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100116 */
117 unsigned long Length;
118};
119
120/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100121 * Describes the availability of a particular entity, which indicates
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100122 * whether the use of this entity will result in a warning or error due to
123 * it being deprecated or unavailable.
124 */
125enum CXAvailabilityKind {
126 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100127 * The entity is available.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100128 */
129 CXAvailability_Available,
130 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100131 * The entity is available, but has been deprecated (and its use is
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100132 * not recommended).
133 */
134 CXAvailability_Deprecated,
135 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100136 * The entity is not available; any use of it will be an error.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100137 */
138 CXAvailability_NotAvailable,
139 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100140 * The entity is available, but not accessible; any use of it will be
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100141 * an error.
142 */
143 CXAvailability_NotAccessible
144};
145
146/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100147 * Describes a version number of the form major.minor.subminor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100148 */
149typedef struct CXVersion {
150 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100151 * The major version number, e.g., the '10' in '10.7.3'. A negative
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100152 * value indicates that there is no version number at all.
153 */
154 int Major;
155 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100156 * The minor version number, e.g., the '7' in '10.7.3'. This value
157 * will be negative if no minor version number was provided, e.g., for
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100158 * version '10'.
159 */
160 int Minor;
161 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100162 * The subminor version number, e.g., the '3' in '10.7.3'. This value
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100163 * will be negative if no minor or subminor version number was provided,
164 * e.g., in version '10' or '10.7'.
165 */
166 int Subminor;
167} CXVersion;
168
169/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100170 * Describes the exception specification of a cursor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100171 *
172 * A negative value indicates that the cursor is not a function declaration.
173 */
174enum CXCursor_ExceptionSpecificationKind {
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100175 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100176 * The cursor has no exception specification.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100177 */
178 CXCursor_ExceptionSpecificationKind_None,
179
180 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100181 * The cursor has exception specification throw()
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100182 */
183 CXCursor_ExceptionSpecificationKind_DynamicNone,
184
185 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100186 * The cursor has exception specification throw(T1, T2)
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100187 */
188 CXCursor_ExceptionSpecificationKind_Dynamic,
189
190 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100191 * The cursor has exception specification throw(...).
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100192 */
193 CXCursor_ExceptionSpecificationKind_MSAny,
194
195 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100196 * The cursor has exception specification basic noexcept.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100197 */
198 CXCursor_ExceptionSpecificationKind_BasicNoexcept,
199
200 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100201 * The cursor has exception specification computed noexcept.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100202 */
203 CXCursor_ExceptionSpecificationKind_ComputedNoexcept,
204
205 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100206 * The exception specification has not yet been evaluated.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100207 */
208 CXCursor_ExceptionSpecificationKind_Unevaluated,
209
210 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100211 * The exception specification has not yet been instantiated.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100212 */
213 CXCursor_ExceptionSpecificationKind_Uninstantiated,
214
215 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100216 * The exception specification has not been parsed yet.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100217 */
Andrew Walbran3d2c1972020-04-07 12:24:26 +0100218 CXCursor_ExceptionSpecificationKind_Unparsed,
219
220 /**
221 * The cursor has a __declspec(nothrow) exception specification.
222 */
223 CXCursor_ExceptionSpecificationKind_NoThrow
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100224};
225
226/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100227 * Provides a shared context for creating translation units.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100228 *
229 * It provides two options:
230 *
231 * - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local"
232 * declarations (when loading any new translation units). A "local" declaration
233 * is one that belongs in the translation unit itself and not in a precompiled
234 * header that was used by the translation unit. If zero, all declarations
235 * will be enumerated.
236 *
237 * Here is an example:
238 *
239 * \code
240 * // excludeDeclsFromPCH = 1, displayDiagnostics=1
241 * Idx = clang_createIndex(1, 1);
242 *
243 * // IndexTest.pch was produced with the following command:
244 * // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch"
245 * TU = clang_createTranslationUnit(Idx, "IndexTest.pch");
246 *
247 * // This will load all the symbols from 'IndexTest.pch'
248 * clang_visitChildren(clang_getTranslationUnitCursor(TU),
249 * TranslationUnitVisitor, 0);
250 * clang_disposeTranslationUnit(TU);
251 *
252 * // This will load all the symbols from 'IndexTest.c', excluding symbols
253 * // from 'IndexTest.pch'.
254 * char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" };
255 * TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args,
256 * 0, 0);
257 * clang_visitChildren(clang_getTranslationUnitCursor(TU),
258 * TranslationUnitVisitor, 0);
259 * clang_disposeTranslationUnit(TU);
260 * \endcode
261 *
262 * This process of creating the 'pch', loading it separately, and using it (via
263 * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks
264 * (which gives the indexer the same performance benefit as the compiler).
265 */
266CINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH,
267 int displayDiagnostics);
268
269/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100270 * Destroy the given index.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100271 *
272 * The index must not be destroyed until all of the translation units created
273 * within that index have been destroyed.
274 */
275CINDEX_LINKAGE void clang_disposeIndex(CXIndex index);
276
277typedef enum {
278 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100279 * Used to indicate that no special CXIndex options are needed.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100280 */
281 CXGlobalOpt_None = 0x0,
282
283 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100284 * Used to indicate that threads that libclang creates for indexing
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100285 * purposes should use background priority.
286 *
287 * Affects #clang_indexSourceFile, #clang_indexTranslationUnit,
288 * #clang_parseTranslationUnit, #clang_saveTranslationUnit.
289 */
290 CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1,
291
292 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100293 * Used to indicate that threads that libclang creates for editing
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100294 * purposes should use background priority.
295 *
296 * Affects #clang_reparseTranslationUnit, #clang_codeCompleteAt,
297 * #clang_annotateTokens
298 */
299 CXGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2,
300
301 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100302 * Used to indicate that all threads that libclang creates should use
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100303 * background priority.
304 */
305 CXGlobalOpt_ThreadBackgroundPriorityForAll =
306 CXGlobalOpt_ThreadBackgroundPriorityForIndexing |
307 CXGlobalOpt_ThreadBackgroundPriorityForEditing
308
309} CXGlobalOptFlags;
310
311/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100312 * Sets general options associated with a CXIndex.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100313 *
314 * For example:
315 * \code
316 * CXIndex idx = ...;
317 * clang_CXIndex_setGlobalOptions(idx,
318 * clang_CXIndex_getGlobalOptions(idx) |
319 * CXGlobalOpt_ThreadBackgroundPriorityForIndexing);
320 * \endcode
321 *
322 * \param options A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags.
323 */
324CINDEX_LINKAGE void clang_CXIndex_setGlobalOptions(CXIndex, unsigned options);
325
326/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100327 * Gets the general options associated with a CXIndex.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100328 *
329 * \returns A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags that
330 * are associated with the given CXIndex object.
331 */
332CINDEX_LINKAGE unsigned clang_CXIndex_getGlobalOptions(CXIndex);
333
334/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100335 * Sets the invocation emission path option in a CXIndex.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100336 *
337 * The invocation emission path specifies a path which will contain log
338 * files for certain libclang invocations. A null value (default) implies that
339 * libclang invocations are not logged..
340 */
341CINDEX_LINKAGE void
342clang_CXIndex_setInvocationEmissionPathOption(CXIndex, const char *Path);
343
344/**
345 * \defgroup CINDEX_FILES File manipulation routines
346 *
347 * @{
348 */
349
350/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100351 * A particular source file that is part of a translation unit.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100352 */
353typedef void *CXFile;
354
355/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100356 * Retrieve the complete file and path name of the given file.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100357 */
358CINDEX_LINKAGE CXString clang_getFileName(CXFile SFile);
359
360/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100361 * Retrieve the last modification time of the given file.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100362 */
363CINDEX_LINKAGE time_t clang_getFileTime(CXFile SFile);
364
365/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100366 * Uniquely identifies a CXFile, that refers to the same underlying file,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100367 * across an indexing session.
368 */
369typedef struct {
370 unsigned long long data[3];
371} CXFileUniqueID;
372
373/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100374 * Retrieve the unique ID for the given \c file.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100375 *
376 * \param file the file to get the ID for.
377 * \param outID stores the returned CXFileUniqueID.
378 * \returns If there was a failure getting the unique ID, returns non-zero,
379 * otherwise returns 0.
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200380 */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100381CINDEX_LINKAGE int clang_getFileUniqueID(CXFile file, CXFileUniqueID *outID);
382
383/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100384 * Determine whether the given header is guarded against
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100385 * multiple inclusions, either with the conventional
386 * \#ifndef/\#define/\#endif macro guards or with \#pragma once.
387 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200388CINDEX_LINKAGE unsigned clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu,
389 CXFile file);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100390
391/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100392 * Retrieve a file handle within the given translation unit.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100393 *
394 * \param tu the translation unit
395 *
396 * \param file_name the name of the file.
397 *
398 * \returns the file handle for the named file in the translation unit \p tu,
399 * or a NULL file handle if the file was not a part of this translation unit.
400 */
401CINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu,
402 const char *file_name);
403
404/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100405 * Retrieve the buffer associated with the given file.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100406 *
407 * \param tu the translation unit
408 *
409 * \param file the file for which to retrieve the buffer.
410 *
411 * \param size [out] if non-NULL, will be set to the size of the buffer.
412 *
413 * \returns a pointer to the buffer in memory that holds the contents of
414 * \p file, or a NULL pointer when the file is not loaded.
415 */
416CINDEX_LINKAGE const char *clang_getFileContents(CXTranslationUnit tu,
417 CXFile file, size_t *size);
418
419/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100420 * Returns non-zero if the \c file1 and \c file2 point to the same file,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100421 * or they are both NULL.
422 */
423CINDEX_LINKAGE int clang_File_isEqual(CXFile file1, CXFile file2);
424
425/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100426 * Returns the real path name of \c file.
427 *
428 * An empty string may be returned. Use \c clang_getFileName() in that case.
429 */
430CINDEX_LINKAGE CXString clang_File_tryGetRealPathName(CXFile file);
431
432/**
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100433 * @}
434 */
435
436/**
437 * \defgroup CINDEX_LOCATIONS Physical source locations
438 *
439 * Clang represents physical source locations in its abstract syntax tree in
440 * great detail, with file, line, and column information for the majority of
441 * the tokens parsed in the source code. These data types and functions are
442 * used to represent source location information, either for a particular
443 * point in the program or for a range of points in the program, and extract
444 * specific location information from those data types.
445 *
446 * @{
447 */
448
449/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100450 * Identifies a specific source location within a translation
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100451 * unit.
452 *
453 * Use clang_getExpansionLocation() or clang_getSpellingLocation()
454 * to map a source location to a particular file, line, and column.
455 */
456typedef struct {
457 const void *ptr_data[2];
458 unsigned int_data;
459} CXSourceLocation;
460
461/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100462 * Identifies a half-open character range in the source code.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100463 *
464 * Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the
465 * starting and end locations from a source range, respectively.
466 */
467typedef struct {
468 const void *ptr_data[2];
469 unsigned begin_int_data;
470 unsigned end_int_data;
471} CXSourceRange;
472
473/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100474 * Retrieve a NULL (invalid) source location.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100475 */
476CINDEX_LINKAGE CXSourceLocation clang_getNullLocation(void);
477
478/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100479 * Determine whether two source locations, which must refer into
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100480 * the same translation unit, refer to exactly the same point in the source
481 * code.
482 *
483 * \returns non-zero if the source locations refer to the same location, zero
484 * if they refer to different locations.
485 */
486CINDEX_LINKAGE unsigned clang_equalLocations(CXSourceLocation loc1,
487 CXSourceLocation loc2);
488
489/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100490 * Retrieves the source location associated with a given file/line/column
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100491 * in a particular translation unit.
492 */
493CINDEX_LINKAGE CXSourceLocation clang_getLocation(CXTranslationUnit tu,
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200494 CXFile file, unsigned line,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100495 unsigned column);
496/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100497 * Retrieves the source location associated with a given character offset
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100498 * in a particular translation unit.
499 */
500CINDEX_LINKAGE CXSourceLocation clang_getLocationForOffset(CXTranslationUnit tu,
501 CXFile file,
502 unsigned offset);
503
504/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100505 * Returns non-zero if the given source location is in a system header.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100506 */
507CINDEX_LINKAGE int clang_Location_isInSystemHeader(CXSourceLocation location);
508
509/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100510 * Returns non-zero if the given source location is in the main file of
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100511 * the corresponding translation unit.
512 */
513CINDEX_LINKAGE int clang_Location_isFromMainFile(CXSourceLocation location);
514
515/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100516 * Retrieve a NULL (invalid) source range.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100517 */
518CINDEX_LINKAGE CXSourceRange clang_getNullRange(void);
519
520/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100521 * Retrieve a source range given the beginning and ending source
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100522 * locations.
523 */
524CINDEX_LINKAGE CXSourceRange clang_getRange(CXSourceLocation begin,
525 CXSourceLocation end);
526
527/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100528 * Determine whether two ranges are equivalent.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100529 *
530 * \returns non-zero if the ranges are the same, zero if they differ.
531 */
532CINDEX_LINKAGE unsigned clang_equalRanges(CXSourceRange range1,
533 CXSourceRange range2);
534
535/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100536 * Returns non-zero if \p range is null.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100537 */
538CINDEX_LINKAGE int clang_Range_isNull(CXSourceRange range);
539
540/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100541 * Retrieve the file, line, column, and offset represented by
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100542 * the given source location.
543 *
544 * If the location refers into a macro expansion, retrieves the
545 * location of the macro expansion.
546 *
547 * \param location the location within a source file that will be decomposed
548 * into its parts.
549 *
550 * \param file [out] if non-NULL, will be set to the file to which the given
551 * source location points.
552 *
553 * \param line [out] if non-NULL, will be set to the line to which the given
554 * source location points.
555 *
556 * \param column [out] if non-NULL, will be set to the column to which the given
557 * source location points.
558 *
559 * \param offset [out] if non-NULL, will be set to the offset into the
560 * buffer to which the given source location points.
561 */
562CINDEX_LINKAGE void clang_getExpansionLocation(CXSourceLocation location,
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200563 CXFile *file, unsigned *line,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100564 unsigned *column,
565 unsigned *offset);
566
567/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100568 * Retrieve the file, line and column represented by the given source
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100569 * location, as specified in a # line directive.
570 *
571 * Example: given the following source code in a file somefile.c
572 *
573 * \code
574 * #123 "dummy.c" 1
575 *
576 * static int func(void)
577 * {
578 * return 0;
579 * }
580 * \endcode
581 *
582 * the location information returned by this function would be
583 *
584 * File: dummy.c Line: 124 Column: 12
585 *
586 * whereas clang_getExpansionLocation would have returned
587 *
588 * File: somefile.c Line: 3 Column: 12
589 *
590 * \param location the location within a source file that will be decomposed
591 * into its parts.
592 *
593 * \param filename [out] if non-NULL, will be set to the filename of the
594 * source location. Note that filenames returned will be for "virtual" files,
595 * which don't necessarily exist on the machine running clang - e.g. when
596 * parsing preprocessed output obtained from a different environment. If
597 * a non-NULL value is passed in, remember to dispose of the returned value
598 * using \c clang_disposeString() once you've finished with it. For an invalid
599 * source location, an empty string is returned.
600 *
601 * \param line [out] if non-NULL, will be set to the line number of the
602 * source location. For an invalid source location, zero is returned.
603 *
604 * \param column [out] if non-NULL, will be set to the column number of the
605 * source location. For an invalid source location, zero is returned.
606 */
607CINDEX_LINKAGE void clang_getPresumedLocation(CXSourceLocation location,
608 CXString *filename,
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200609 unsigned *line, unsigned *column);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100610
611/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100612 * Legacy API to retrieve the file, line, column, and offset represented
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100613 * by the given source location.
614 *
615 * This interface has been replaced by the newer interface
616 * #clang_getExpansionLocation(). See that interface's documentation for
617 * details.
618 */
619CINDEX_LINKAGE void clang_getInstantiationLocation(CXSourceLocation location,
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200620 CXFile *file, unsigned *line,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100621 unsigned *column,
622 unsigned *offset);
623
624/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100625 * Retrieve the file, line, column, and offset represented by
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100626 * the given source location.
627 *
628 * If the location refers into a macro instantiation, return where the
629 * location was originally spelled in the source file.
630 *
631 * \param location the location within a source file that will be decomposed
632 * into its parts.
633 *
634 * \param file [out] if non-NULL, will be set to the file to which the given
635 * source location points.
636 *
637 * \param line [out] if non-NULL, will be set to the line to which the given
638 * source location points.
639 *
640 * \param column [out] if non-NULL, will be set to the column to which the given
641 * source location points.
642 *
643 * \param offset [out] if non-NULL, will be set to the offset into the
644 * buffer to which the given source location points.
645 */
646CINDEX_LINKAGE void clang_getSpellingLocation(CXSourceLocation location,
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200647 CXFile *file, unsigned *line,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100648 unsigned *column,
649 unsigned *offset);
650
651/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100652 * Retrieve the file, line, column, and offset represented by
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100653 * the given source location.
654 *
655 * If the location refers into a macro expansion, return where the macro was
656 * expanded or where the macro argument was written, if the location points at
657 * a macro argument.
658 *
659 * \param location the location within a source file that will be decomposed
660 * into its parts.
661 *
662 * \param file [out] if non-NULL, will be set to the file to which the given
663 * source location points.
664 *
665 * \param line [out] if non-NULL, will be set to the line to which the given
666 * source location points.
667 *
668 * \param column [out] if non-NULL, will be set to the column to which the given
669 * source location points.
670 *
671 * \param offset [out] if non-NULL, will be set to the offset into the
672 * buffer to which the given source location points.
673 */
674CINDEX_LINKAGE void clang_getFileLocation(CXSourceLocation location,
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200675 CXFile *file, unsigned *line,
676 unsigned *column, unsigned *offset);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100677
678/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100679 * Retrieve a source location representing the first character within a
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100680 * source range.
681 */
682CINDEX_LINKAGE CXSourceLocation clang_getRangeStart(CXSourceRange range);
683
684/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100685 * Retrieve a source location representing the last character within a
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100686 * source range.
687 */
688CINDEX_LINKAGE CXSourceLocation clang_getRangeEnd(CXSourceRange range);
689
690/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100691 * Identifies an array of ranges.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100692 */
693typedef struct {
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100694 /** The number of ranges in the \c ranges array. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100695 unsigned count;
696 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100697 * An array of \c CXSourceRanges.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100698 */
699 CXSourceRange *ranges;
700} CXSourceRangeList;
701
702/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100703 * Retrieve all ranges that were skipped by the preprocessor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100704 *
705 * The preprocessor will skip lines when they are surrounded by an
706 * if/ifdef/ifndef directive whose condition does not evaluate to true.
707 */
708CINDEX_LINKAGE CXSourceRangeList *clang_getSkippedRanges(CXTranslationUnit tu,
709 CXFile file);
710
711/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100712 * Retrieve all ranges from all files that were skipped by the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100713 * preprocessor.
714 *
715 * The preprocessor will skip lines when they are surrounded by an
716 * if/ifdef/ifndef directive whose condition does not evaluate to true.
717 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200718CINDEX_LINKAGE CXSourceRangeList *
719clang_getAllSkippedRanges(CXTranslationUnit tu);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100720
721/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100722 * Destroy the given \c CXSourceRangeList.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100723 */
724CINDEX_LINKAGE void clang_disposeSourceRangeList(CXSourceRangeList *ranges);
725
726/**
727 * @}
728 */
729
730/**
731 * \defgroup CINDEX_DIAG Diagnostic reporting
732 *
733 * @{
734 */
735
736/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100737 * Describes the severity of a particular diagnostic.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100738 */
739enum CXDiagnosticSeverity {
740 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100741 * A diagnostic that has been suppressed, e.g., by a command-line
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100742 * option.
743 */
744 CXDiagnostic_Ignored = 0,
745
746 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100747 * This diagnostic is a note that should be attached to the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100748 * previous (non-note) diagnostic.
749 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200750 CXDiagnostic_Note = 1,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100751
752 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100753 * This diagnostic indicates suspicious code that may not be
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100754 * wrong.
755 */
756 CXDiagnostic_Warning = 2,
757
758 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100759 * This diagnostic indicates that the code is ill-formed.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100760 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200761 CXDiagnostic_Error = 3,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100762
763 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100764 * This diagnostic indicates that the code is ill-formed such
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100765 * that future parser recovery is unlikely to produce useful
766 * results.
767 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200768 CXDiagnostic_Fatal = 4
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100769};
770
771/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100772 * A single diagnostic, containing the diagnostic's severity,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100773 * location, text, source ranges, and fix-it hints.
774 */
775typedef void *CXDiagnostic;
776
777/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100778 * A group of CXDiagnostics.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100779 */
780typedef void *CXDiagnosticSet;
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100781
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100782/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100783 * Determine the number of diagnostics in a CXDiagnosticSet.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100784 */
785CINDEX_LINKAGE unsigned clang_getNumDiagnosticsInSet(CXDiagnosticSet Diags);
786
787/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100788 * Retrieve a diagnostic associated with the given CXDiagnosticSet.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100789 *
790 * \param Diags the CXDiagnosticSet to query.
791 * \param Index the zero-based diagnostic number to retrieve.
792 *
793 * \returns the requested diagnostic. This diagnostic must be freed
794 * via a call to \c clang_disposeDiagnostic().
795 */
796CINDEX_LINKAGE CXDiagnostic clang_getDiagnosticInSet(CXDiagnosticSet Diags,
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100797 unsigned Index);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100798
799/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100800 * Describes the kind of error that occurred (if any) in a call to
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100801 * \c clang_loadDiagnostics.
802 */
803enum CXLoadDiag_Error {
804 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100805 * Indicates that no error occurred.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100806 */
807 CXLoadDiag_None = 0,
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100808
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100809 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100810 * Indicates that an unknown error occurred while attempting to
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100811 * deserialize diagnostics.
812 */
813 CXLoadDiag_Unknown = 1,
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100814
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100815 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100816 * Indicates that the file containing the serialized diagnostics
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100817 * could not be opened.
818 */
819 CXLoadDiag_CannotLoad = 2,
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100820
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100821 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100822 * Indicates that the serialized diagnostics file is invalid or
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100823 * corrupt.
824 */
825 CXLoadDiag_InvalidFile = 3
826};
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100827
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100828/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100829 * Deserialize a set of diagnostics from a Clang diagnostics bitcode
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100830 * file.
831 *
832 * \param file The name of the file to deserialize.
833 * \param error A pointer to a enum value recording if there was a problem
834 * deserializing the diagnostics.
835 * \param errorString A pointer to a CXString for recording the error string
836 * if the file was not successfully loaded.
837 *
838 * \returns A loaded CXDiagnosticSet if successful, and NULL otherwise. These
839 * diagnostics should be released using clang_disposeDiagnosticSet().
840 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200841CINDEX_LINKAGE CXDiagnosticSet clang_loadDiagnostics(
842 const char *file, enum CXLoadDiag_Error *error, CXString *errorString);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100843
844/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100845 * Release a CXDiagnosticSet and all of its contained diagnostics.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100846 */
847CINDEX_LINKAGE void clang_disposeDiagnosticSet(CXDiagnosticSet Diags);
848
849/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100850 * Retrieve the child diagnostics of a CXDiagnostic.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100851 *
852 * This CXDiagnosticSet does not need to be released by
853 * clang_disposeDiagnosticSet.
854 */
855CINDEX_LINKAGE CXDiagnosticSet clang_getChildDiagnostics(CXDiagnostic D);
856
857/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100858 * Determine the number of diagnostics produced for the given
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100859 * translation unit.
860 */
861CINDEX_LINKAGE unsigned clang_getNumDiagnostics(CXTranslationUnit Unit);
862
863/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100864 * Retrieve a diagnostic associated with the given translation unit.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100865 *
866 * \param Unit the translation unit to query.
867 * \param Index the zero-based diagnostic number to retrieve.
868 *
869 * \returns the requested diagnostic. This diagnostic must be freed
870 * via a call to \c clang_disposeDiagnostic().
871 */
872CINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit,
873 unsigned Index);
874
875/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100876 * Retrieve the complete set of diagnostics associated with a
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100877 * translation unit.
878 *
879 * \param Unit the translation unit to query.
880 */
881CINDEX_LINKAGE CXDiagnosticSet
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200882clang_getDiagnosticSetFromTU(CXTranslationUnit Unit);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100883
884/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100885 * Destroy a diagnostic.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100886 */
887CINDEX_LINKAGE void clang_disposeDiagnostic(CXDiagnostic Diagnostic);
888
889/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100890 * Options to control the display of diagnostics.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100891 *
892 * The values in this enum are meant to be combined to customize the
893 * behavior of \c clang_formatDiagnostic().
894 */
895enum CXDiagnosticDisplayOptions {
896 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100897 * Display the source-location information where the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100898 * diagnostic was located.
899 *
900 * When set, diagnostics will be prefixed by the file, line, and
901 * (optionally) column to which the diagnostic refers. For example,
902 *
903 * \code
904 * test.c:28: warning: extra tokens at end of #endif directive
905 * \endcode
906 *
907 * This option corresponds to the clang flag \c -fshow-source-location.
908 */
909 CXDiagnostic_DisplaySourceLocation = 0x01,
910
911 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100912 * If displaying the source-location information of the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100913 * diagnostic, also include the column number.
914 *
915 * This option corresponds to the clang flag \c -fshow-column.
916 */
917 CXDiagnostic_DisplayColumn = 0x02,
918
919 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100920 * If displaying the source-location information of the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100921 * diagnostic, also include information about source ranges in a
922 * machine-parsable format.
923 *
924 * This option corresponds to the clang flag
925 * \c -fdiagnostics-print-source-range-info.
926 */
927 CXDiagnostic_DisplaySourceRanges = 0x04,
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100928
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100929 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100930 * Display the option name associated with this diagnostic, if any.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100931 *
932 * The option name displayed (e.g., -Wconversion) will be placed in brackets
933 * after the diagnostic text. This option corresponds to the clang flag
934 * \c -fdiagnostics-show-option.
935 */
936 CXDiagnostic_DisplayOption = 0x08,
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100937
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100938 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100939 * Display the category number associated with this diagnostic, if any.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100940 *
941 * The category number is displayed within brackets after the diagnostic text.
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100942 * This option corresponds to the clang flag
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100943 * \c -fdiagnostics-show-category=id.
944 */
945 CXDiagnostic_DisplayCategoryId = 0x10,
946
947 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100948 * Display the category name associated with this diagnostic, if any.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100949 *
950 * The category name is displayed within brackets after the diagnostic text.
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100951 * This option corresponds to the clang flag
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100952 * \c -fdiagnostics-show-category=name.
953 */
954 CXDiagnostic_DisplayCategoryName = 0x20
955};
956
957/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100958 * Format the given diagnostic in a manner that is suitable for display.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100959 *
960 * This routine will format the given diagnostic to a string, rendering
961 * the diagnostic according to the various options given. The
962 * \c clang_defaultDiagnosticDisplayOptions() function returns the set of
963 * options that most closely mimics the behavior of the clang compiler.
964 *
965 * \param Diagnostic The diagnostic to print.
966 *
967 * \param Options A set of options that control the diagnostic display,
968 * created by combining \c CXDiagnosticDisplayOptions values.
969 *
970 * \returns A new string containing for formatted diagnostic.
971 */
972CINDEX_LINKAGE CXString clang_formatDiagnostic(CXDiagnostic Diagnostic,
973 unsigned Options);
974
975/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100976 * Retrieve the set of display options most similar to the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100977 * default behavior of the clang compiler.
978 *
979 * \returns A set of display options suitable for use with \c
980 * clang_formatDiagnostic().
981 */
982CINDEX_LINKAGE unsigned clang_defaultDiagnosticDisplayOptions(void);
983
984/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100985 * Determine the severity of the given diagnostic.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100986 */
987CINDEX_LINKAGE enum CXDiagnosticSeverity
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200988 clang_getDiagnosticSeverity(CXDiagnostic);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100989
990/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100991 * Retrieve the source location of the given diagnostic.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100992 *
993 * This location is where Clang would print the caret ('^') when
994 * displaying the diagnostic on the command line.
995 */
996CINDEX_LINKAGE CXSourceLocation clang_getDiagnosticLocation(CXDiagnostic);
997
998/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100999 * Retrieve the text of the given diagnostic.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001000 */
1001CINDEX_LINKAGE CXString clang_getDiagnosticSpelling(CXDiagnostic);
1002
1003/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001004 * Retrieve the name of the command-line option that enabled this
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001005 * diagnostic.
1006 *
1007 * \param Diag The diagnostic to be queried.
1008 *
1009 * \param Disable If non-NULL, will be set to the option that disables this
1010 * diagnostic (if any).
1011 *
1012 * \returns A string that contains the command-line option used to enable this
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001013 * warning, such as "-Wconversion" or "-pedantic".
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001014 */
1015CINDEX_LINKAGE CXString clang_getDiagnosticOption(CXDiagnostic Diag,
1016 CXString *Disable);
1017
1018/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001019 * Retrieve the category number for this diagnostic.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001020 *
1021 * Diagnostics can be categorized into groups along with other, related
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001022 * diagnostics (e.g., diagnostics under the same warning flag). This routine
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001023 * retrieves the category number for the given diagnostic.
1024 *
1025 * \returns The number of the category that contains this diagnostic, or zero
1026 * if this diagnostic is uncategorized.
1027 */
1028CINDEX_LINKAGE unsigned clang_getDiagnosticCategory(CXDiagnostic);
1029
1030/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001031 * Retrieve the name of a particular diagnostic category. This
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001032 * is now deprecated. Use clang_getDiagnosticCategoryText()
1033 * instead.
1034 *
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001035 * \param Category A diagnostic category number, as returned by
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001036 * \c clang_getDiagnosticCategory().
1037 *
1038 * \returns The name of the given diagnostic category.
1039 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001040CINDEX_DEPRECATED CINDEX_LINKAGE CXString
1041clang_getDiagnosticCategoryName(unsigned Category);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001042
1043/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001044 * Retrieve the diagnostic category text for a given diagnostic.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001045 *
1046 * \returns The text of the given diagnostic category.
1047 */
1048CINDEX_LINKAGE CXString clang_getDiagnosticCategoryText(CXDiagnostic);
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001049
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001050/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001051 * Determine the number of source ranges associated with the given
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001052 * diagnostic.
1053 */
1054CINDEX_LINKAGE unsigned clang_getDiagnosticNumRanges(CXDiagnostic);
1055
1056/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001057 * Retrieve a source range associated with the diagnostic.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001058 *
1059 * A diagnostic's source ranges highlight important elements in the source
1060 * code. On the command line, Clang displays source ranges by
1061 * underlining them with '~' characters.
1062 *
1063 * \param Diagnostic the diagnostic whose range is being extracted.
1064 *
1065 * \param Range the zero-based index specifying which range to
1066 *
1067 * \returns the requested source range.
1068 */
1069CINDEX_LINKAGE CXSourceRange clang_getDiagnosticRange(CXDiagnostic Diagnostic,
1070 unsigned Range);
1071
1072/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001073 * Determine the number of fix-it hints associated with the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001074 * given diagnostic.
1075 */
1076CINDEX_LINKAGE unsigned clang_getDiagnosticNumFixIts(CXDiagnostic Diagnostic);
1077
1078/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001079 * Retrieve the replacement information for a given fix-it.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001080 *
1081 * Fix-its are described in terms of a source range whose contents
1082 * should be replaced by a string. This approach generalizes over
1083 * three kinds of operations: removal of source code (the range covers
1084 * the code to be removed and the replacement string is empty),
1085 * replacement of source code (the range covers the code to be
1086 * replaced and the replacement string provides the new code), and
1087 * insertion (both the start and end of the range point at the
1088 * insertion location, and the replacement string provides the text to
1089 * insert).
1090 *
1091 * \param Diagnostic The diagnostic whose fix-its are being queried.
1092 *
1093 * \param FixIt The zero-based index of the fix-it.
1094 *
1095 * \param ReplacementRange The source range whose contents will be
1096 * replaced with the returned replacement string. Note that source
1097 * ranges are half-open ranges [a, b), so the source code should be
1098 * replaced from a and up to (but not including) b.
1099 *
1100 * \returns A string containing text that should be replace the source
1101 * code indicated by the \c ReplacementRange.
1102 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001103CINDEX_LINKAGE CXString clang_getDiagnosticFixIt(
1104 CXDiagnostic Diagnostic, unsigned FixIt, CXSourceRange *ReplacementRange);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001105
1106/**
1107 * @}
1108 */
1109
1110/**
1111 * \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation
1112 *
1113 * The routines in this group provide the ability to create and destroy
1114 * translation units from files, either by parsing the contents of the files or
1115 * by reading in a serialized representation of a translation unit.
1116 *
1117 * @{
1118 */
1119
1120/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001121 * Get the original translation unit source file name.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001122 */
1123CINDEX_LINKAGE CXString
1124clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit);
1125
1126/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001127 * Return the CXTranslationUnit for a given source file and the provided
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001128 * command line arguments one would pass to the compiler.
1129 *
1130 * Note: The 'source_filename' argument is optional. If the caller provides a
1131 * NULL pointer, the name of the source file is expected to reside in the
1132 * specified command line arguments.
1133 *
1134 * Note: When encountered in 'clang_command_line_args', the following options
1135 * are ignored:
1136 *
1137 * '-c'
1138 * '-emit-ast'
1139 * '-fsyntax-only'
1140 * '-o \<output file>' (both '-o' and '\<output file>' are ignored)
1141 *
1142 * \param CIdx The index object with which the translation unit will be
1143 * associated.
1144 *
1145 * \param source_filename The name of the source file to load, or NULL if the
1146 * source file is included in \p clang_command_line_args.
1147 *
1148 * \param num_clang_command_line_args The number of command-line arguments in
1149 * \p clang_command_line_args.
1150 *
1151 * \param clang_command_line_args The command-line arguments that would be
1152 * passed to the \c clang executable if it were being invoked out-of-process.
1153 * These command-line options will be parsed and will affect how the translation
1154 * unit is parsed. Note that the following options are ignored: '-c',
1155 * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
1156 *
1157 * \param num_unsaved_files the number of unsaved file entries in \p
1158 * unsaved_files.
1159 *
1160 * \param unsaved_files the files that have not yet been saved to disk
1161 * but may be required for code completion, including the contents of
1162 * those files. The contents and name of these files (as specified by
1163 * CXUnsavedFile) are copied when necessary, so the client only needs to
1164 * guarantee their validity until the call to this function returns.
1165 */
1166CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnitFromSourceFile(
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001167 CXIndex CIdx, const char *source_filename, int num_clang_command_line_args,
1168 const char *const *clang_command_line_args, unsigned num_unsaved_files,
1169 struct CXUnsavedFile *unsaved_files);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001170
1171/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001172 * Same as \c clang_createTranslationUnit2, but returns
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001173 * the \c CXTranslationUnit instead of an error code. In case of an error this
1174 * routine returns a \c NULL \c CXTranslationUnit, without further detailed
1175 * error codes.
1176 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001177CINDEX_LINKAGE CXTranslationUnit
1178clang_createTranslationUnit(CXIndex CIdx, const char *ast_filename);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001179
1180/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001181 * Create a translation unit from an AST file (\c -emit-ast).
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001182 *
1183 * \param[out] out_TU A non-NULL pointer to store the created
1184 * \c CXTranslationUnit.
1185 *
1186 * \returns Zero on success, otherwise returns an error code.
1187 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001188CINDEX_LINKAGE enum CXErrorCode
1189clang_createTranslationUnit2(CXIndex CIdx, const char *ast_filename,
1190 CXTranslationUnit *out_TU);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001191
1192/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001193 * Flags that control the creation of translation units.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001194 *
1195 * The enumerators in this enumeration type are meant to be bitwise
1196 * ORed together to specify which options should be used when
1197 * constructing the translation unit.
1198 */
1199enum CXTranslationUnit_Flags {
1200 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001201 * Used to indicate that no special translation-unit options are
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001202 * needed.
1203 */
1204 CXTranslationUnit_None = 0x0,
1205
1206 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001207 * Used to indicate that the parser should construct a "detailed"
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001208 * preprocessing record, including all macro definitions and instantiations.
1209 *
1210 * Constructing a detailed preprocessing record requires more memory
1211 * and time to parse, since the information contained in the record
1212 * is usually not retained. However, it can be useful for
1213 * applications that require more detailed information about the
1214 * behavior of the preprocessor.
1215 */
1216 CXTranslationUnit_DetailedPreprocessingRecord = 0x01,
1217
1218 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001219 * Used to indicate that the translation unit is incomplete.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001220 *
1221 * When a translation unit is considered "incomplete", semantic
1222 * analysis that is typically performed at the end of the
1223 * translation unit will be suppressed. For example, this suppresses
1224 * the completion of tentative declarations in C and of
1225 * instantiation of implicitly-instantiation function templates in
1226 * C++. This option is typically used when parsing a header with the
1227 * intent of producing a precompiled header.
1228 */
1229 CXTranslationUnit_Incomplete = 0x02,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001230
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001231 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001232 * Used to indicate that the translation unit should be built with an
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001233 * implicit precompiled header for the preamble.
1234 *
1235 * An implicit precompiled header is used as an optimization when a
1236 * particular translation unit is likely to be reparsed many times
1237 * when the sources aren't changing that often. In this case, an
1238 * implicit precompiled header will be built containing all of the
1239 * initial includes at the top of the main file (what we refer to as
1240 * the "preamble" of the file). In subsequent parses, if the
1241 * preamble or the files in it have not changed, \c
1242 * clang_reparseTranslationUnit() will re-use the implicit
1243 * precompiled header to improve parsing performance.
1244 */
1245 CXTranslationUnit_PrecompiledPreamble = 0x04,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001246
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001247 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001248 * Used to indicate that the translation unit should cache some
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001249 * code-completion results with each reparse of the source file.
1250 *
1251 * Caching of code-completion results is a performance optimization that
1252 * introduces some overhead to reparsing but improves the performance of
1253 * code-completion operations.
1254 */
1255 CXTranslationUnit_CacheCompletionResults = 0x08,
1256
1257 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001258 * Used to indicate that the translation unit will be serialized with
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001259 * \c clang_saveTranslationUnit.
1260 *
1261 * This option is typically used when parsing a header with the intent of
1262 * producing a precompiled header.
1263 */
1264 CXTranslationUnit_ForSerialization = 0x10,
1265
1266 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001267 * DEPRECATED: Enabled chained precompiled preambles in C++.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001268 *
1269 * Note: this is a *temporary* option that is available only while
1270 * we are testing C++ precompiled preamble support. It is deprecated.
1271 */
1272 CXTranslationUnit_CXXChainedPCH = 0x20,
1273
1274 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001275 * Used to indicate that function/method bodies should be skipped while
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001276 * parsing.
1277 *
1278 * This option can be used to search for declarations/definitions while
1279 * ignoring the usages.
1280 */
1281 CXTranslationUnit_SkipFunctionBodies = 0x40,
1282
1283 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001284 * Used to indicate that brief documentation comments should be
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001285 * included into the set of code completions returned from this translation
1286 * unit.
1287 */
1288 CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 0x80,
1289
1290 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001291 * Used to indicate that the precompiled preamble should be created on
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001292 * the first parse. Otherwise it will be created on the first reparse. This
1293 * trades runtime on the first parse (serializing the preamble takes time) for
1294 * reduced runtime on the second parse (can now reuse the preamble).
1295 */
1296 CXTranslationUnit_CreatePreambleOnFirstParse = 0x100,
1297
1298 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001299 * Do not stop processing when fatal errors are encountered.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001300 *
1301 * When fatal errors are encountered while parsing a translation unit,
1302 * semantic analysis is typically stopped early when compiling code. A common
1303 * source for fatal errors are unresolvable include files. For the
1304 * purposes of an IDE, this is undesirable behavior and as much information
1305 * as possible should be reported. Use this flag to enable this behavior.
1306 */
1307 CXTranslationUnit_KeepGoing = 0x200,
1308
1309 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001310 * Sets the preprocessor in a mode for parsing a single file only.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001311 */
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001312 CXTranslationUnit_SingleFileParse = 0x400,
1313
1314 /**
1315 * Used in combination with CXTranslationUnit_SkipFunctionBodies to
1316 * constrain the skipping of function bodies to the preamble.
1317 *
1318 * The function bodies of the main file are not skipped.
1319 */
1320 CXTranslationUnit_LimitSkipFunctionBodiesToPreamble = 0x800,
1321
1322 /**
1323 * Used to indicate that attributed types should be included in CXType.
1324 */
1325 CXTranslationUnit_IncludeAttributedTypes = 0x1000,
1326
1327 /**
1328 * Used to indicate that implicit attributes should be visited.
1329 */
Andrew Walbran3d2c1972020-04-07 12:24:26 +01001330 CXTranslationUnit_VisitImplicitAttributes = 0x2000,
1331
1332 /**
1333 * Used to indicate that non-errors from included files should be ignored.
1334 *
1335 * If set, clang_getDiagnosticSetFromTU() will not report e.g. warnings from
1336 * included files anymore. This speeds up clang_getDiagnosticSetFromTU() for
1337 * the case where these warnings are not of interest, as for an IDE for
1338 * example, which typically shows only the diagnostics in the main file.
1339 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001340 CXTranslationUnit_IgnoreNonErrorsFromIncludedFiles = 0x4000,
1341
1342 /**
1343 * Tells the preprocessor not to skip excluded conditional blocks.
1344 */
1345 CXTranslationUnit_RetainExcludedConditionalBlocks = 0x8000
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001346};
1347
1348/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001349 * Returns the set of flags that is suitable for parsing a translation
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001350 * unit that is being edited.
1351 *
1352 * The set of flags returned provide options for \c clang_parseTranslationUnit()
1353 * to indicate that the translation unit is likely to be reparsed many times,
1354 * either explicitly (via \c clang_reparseTranslationUnit()) or implicitly
1355 * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001356 * set contains an unspecified set of optimizations (e.g., the precompiled
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001357 * preamble) geared toward improving the performance of these routines. The
1358 * set of optimizations enabled may change from one version to the next.
1359 */
1360CINDEX_LINKAGE unsigned clang_defaultEditingTranslationUnitOptions(void);
1361
1362/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001363 * Same as \c clang_parseTranslationUnit2, but returns
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001364 * the \c CXTranslationUnit instead of an error code. In case of an error this
1365 * routine returns a \c NULL \c CXTranslationUnit, without further detailed
1366 * error codes.
1367 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001368CINDEX_LINKAGE CXTranslationUnit clang_parseTranslationUnit(
1369 CXIndex CIdx, const char *source_filename,
1370 const char *const *command_line_args, int num_command_line_args,
1371 struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files,
1372 unsigned options);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001373
1374/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001375 * Parse the given source file and the translation unit corresponding
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001376 * to that file.
1377 *
1378 * This routine is the main entry point for the Clang C API, providing the
1379 * ability to parse a source file into a translation unit that can then be
1380 * queried by other functions in the API. This routine accepts a set of
1381 * command-line arguments so that the compilation can be configured in the same
1382 * way that the compiler is configured on the command line.
1383 *
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001384 * \param CIdx The index object with which the translation unit will be
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001385 * associated.
1386 *
1387 * \param source_filename The name of the source file to load, or NULL if the
1388 * source file is included in \c command_line_args.
1389 *
1390 * \param command_line_args The command-line arguments that would be
1391 * passed to the \c clang executable if it were being invoked out-of-process.
1392 * These command-line options will be parsed and will affect how the translation
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001393 * unit is parsed. Note that the following options are ignored: '-c',
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001394 * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
1395 *
1396 * \param num_command_line_args The number of command-line arguments in
1397 * \c command_line_args.
1398 *
1399 * \param unsaved_files the files that have not yet been saved to disk
1400 * but may be required for parsing, including the contents of
1401 * those files. The contents and name of these files (as specified by
1402 * CXUnsavedFile) are copied when necessary, so the client only needs to
1403 * guarantee their validity until the call to this function returns.
1404 *
1405 * \param num_unsaved_files the number of unsaved file entries in \p
1406 * unsaved_files.
1407 *
1408 * \param options A bitmask of options that affects how the translation unit
1409 * is managed but not its compilation. This should be a bitwise OR of the
1410 * CXTranslationUnit_XXX flags.
1411 *
1412 * \param[out] out_TU A non-NULL pointer to store the created
1413 * \c CXTranslationUnit, describing the parsed code and containing any
1414 * diagnostics produced by the compiler.
1415 *
1416 * \returns Zero on success, otherwise returns an error code.
1417 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001418CINDEX_LINKAGE enum CXErrorCode clang_parseTranslationUnit2(
1419 CXIndex CIdx, const char *source_filename,
1420 const char *const *command_line_args, int num_command_line_args,
1421 struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files,
1422 unsigned options, CXTranslationUnit *out_TU);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001423
1424/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001425 * Same as clang_parseTranslationUnit2 but requires a full command line
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001426 * for \c command_line_args including argv[0]. This is useful if the standard
1427 * library paths are relative to the binary.
1428 */
1429CINDEX_LINKAGE enum CXErrorCode clang_parseTranslationUnit2FullArgv(
1430 CXIndex CIdx, const char *source_filename,
1431 const char *const *command_line_args, int num_command_line_args,
1432 struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files,
1433 unsigned options, CXTranslationUnit *out_TU);
1434
1435/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001436 * Flags that control how translation units are saved.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001437 *
1438 * The enumerators in this enumeration type are meant to be bitwise
1439 * ORed together to specify which options should be used when
1440 * saving the translation unit.
1441 */
1442enum CXSaveTranslationUnit_Flags {
1443 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001444 * Used to indicate that no special saving options are needed.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001445 */
1446 CXSaveTranslationUnit_None = 0x0
1447};
1448
1449/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001450 * Returns the set of flags that is suitable for saving a translation
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001451 * unit.
1452 *
1453 * The set of flags returned provide options for
1454 * \c clang_saveTranslationUnit() by default. The returned flag
1455 * set contains an unspecified set of options that save translation units with
1456 * the most commonly-requested data.
1457 */
1458CINDEX_LINKAGE unsigned clang_defaultSaveOptions(CXTranslationUnit TU);
1459
1460/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001461 * Describes the kind of error that occurred (if any) in a call to
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001462 * \c clang_saveTranslationUnit().
1463 */
1464enum CXSaveError {
1465 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001466 * Indicates that no error occurred while saving a translation unit.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001467 */
1468 CXSaveError_None = 0,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001469
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001470 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001471 * Indicates that an unknown error occurred while attempting to save
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001472 * the file.
1473 *
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001474 * This error typically indicates that file I/O failed when attempting to
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001475 * write the file.
1476 */
1477 CXSaveError_Unknown = 1,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001478
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001479 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001480 * Indicates that errors during translation prevented this attempt
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001481 * to save the translation unit.
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001482 *
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001483 * Errors that prevent the translation unit from being saved can be
1484 * extracted using \c clang_getNumDiagnostics() and \c clang_getDiagnostic().
1485 */
1486 CXSaveError_TranslationErrors = 2,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001487
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001488 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001489 * Indicates that the translation unit to be saved was somehow
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001490 * invalid (e.g., NULL).
1491 */
1492 CXSaveError_InvalidTU = 3
1493};
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001494
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001495/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001496 * Saves a translation unit into a serialized representation of
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001497 * that translation unit on disk.
1498 *
1499 * Any translation unit that was parsed without error can be saved
1500 * into a file. The translation unit can then be deserialized into a
1501 * new \c CXTranslationUnit with \c clang_createTranslationUnit() or,
1502 * if it is an incomplete translation unit that corresponds to a
1503 * header, used as a precompiled header when parsing other translation
1504 * units.
1505 *
1506 * \param TU The translation unit to save.
1507 *
1508 * \param FileName The file to which the translation unit will be saved.
1509 *
1510 * \param options A bitmask of options that affects how the translation unit
1511 * is saved. This should be a bitwise OR of the
1512 * CXSaveTranslationUnit_XXX flags.
1513 *
1514 * \returns A value that will match one of the enumerators of the CXSaveError
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001515 * enumeration. Zero (CXSaveError_None) indicates that the translation unit was
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001516 * saved successfully, while a non-zero value indicates that a problem occurred.
1517 */
1518CINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU,
1519 const char *FileName,
1520 unsigned options);
1521
1522/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001523 * Suspend a translation unit in order to free memory associated with it.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001524 *
1525 * A suspended translation unit uses significantly less memory but on the other
1526 * side does not support any other calls than \c clang_reparseTranslationUnit
1527 * to resume it or \c clang_disposeTranslationUnit to dispose it completely.
1528 */
1529CINDEX_LINKAGE unsigned clang_suspendTranslationUnit(CXTranslationUnit);
1530
1531/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001532 * Destroy the specified CXTranslationUnit object.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001533 */
1534CINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit);
1535
1536/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001537 * Flags that control the reparsing of translation units.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001538 *
1539 * The enumerators in this enumeration type are meant to be bitwise
1540 * ORed together to specify which options should be used when
1541 * reparsing the translation unit.
1542 */
1543enum CXReparse_Flags {
1544 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001545 * Used to indicate that no special reparsing options are needed.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001546 */
1547 CXReparse_None = 0x0
1548};
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001549
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001550/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001551 * Returns the set of flags that is suitable for reparsing a translation
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001552 * unit.
1553 *
1554 * The set of flags returned provide options for
1555 * \c clang_reparseTranslationUnit() by default. The returned flag
1556 * set contains an unspecified set of optimizations geared toward common uses
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001557 * of reparsing. The set of optimizations enabled may change from one version
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001558 * to the next.
1559 */
1560CINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU);
1561
1562/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001563 * Reparse the source files that produced this translation unit.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001564 *
1565 * This routine can be used to re-parse the source files that originally
1566 * created the given translation unit, for example because those source files
1567 * have changed (either on disk or as passed via \p unsaved_files). The
1568 * source code will be reparsed with the same command-line options as it
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001569 * was originally parsed.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001570 *
1571 * Reparsing a translation unit invalidates all cursors and source locations
1572 * that refer into that translation unit. This makes reparsing a translation
1573 * unit semantically equivalent to destroying the translation unit and then
1574 * creating a new translation unit with the same command-line arguments.
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001575 * However, it may be more efficient to reparse a translation
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001576 * unit using this routine.
1577 *
1578 * \param TU The translation unit whose contents will be re-parsed. The
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001579 * translation unit must originally have been built with
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001580 * \c clang_createTranslationUnitFromSourceFile().
1581 *
1582 * \param num_unsaved_files The number of unsaved file entries in \p
1583 * unsaved_files.
1584 *
1585 * \param unsaved_files The files that have not yet been saved to disk
1586 * but may be required for parsing, including the contents of
1587 * those files. The contents and name of these files (as specified by
1588 * CXUnsavedFile) are copied when necessary, so the client only needs to
1589 * guarantee their validity until the call to this function returns.
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001590 *
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001591 * \param options A bitset of options composed of the flags in CXReparse_Flags.
1592 * The function \c clang_defaultReparseOptions() produces a default set of
1593 * options recommended for most uses, based on the translation unit.
1594 *
1595 * \returns 0 if the sources could be reparsed. A non-zero error code will be
1596 * returned if reparsing was impossible, such that the translation unit is
1597 * invalid. In such cases, the only valid call for \c TU is
1598 * \c clang_disposeTranslationUnit(TU). The error codes returned by this
1599 * routine are described by the \c CXErrorCode enum.
1600 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001601CINDEX_LINKAGE int
1602clang_reparseTranslationUnit(CXTranslationUnit TU, unsigned num_unsaved_files,
1603 struct CXUnsavedFile *unsaved_files,
1604 unsigned options);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001605
1606/**
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001607 * Categorizes how memory is being used by a translation unit.
1608 */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001609enum CXTUResourceUsageKind {
1610 CXTUResourceUsage_AST = 1,
1611 CXTUResourceUsage_Identifiers = 2,
1612 CXTUResourceUsage_Selectors = 3,
1613 CXTUResourceUsage_GlobalCompletionResults = 4,
1614 CXTUResourceUsage_SourceManagerContentCache = 5,
1615 CXTUResourceUsage_AST_SideTables = 6,
1616 CXTUResourceUsage_SourceManager_Membuffer_Malloc = 7,
1617 CXTUResourceUsage_SourceManager_Membuffer_MMap = 8,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001618 CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc = 9,
1619 CXTUResourceUsage_ExternalASTSource_Membuffer_MMap = 10,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001620 CXTUResourceUsage_Preprocessor = 11,
1621 CXTUResourceUsage_PreprocessingRecord = 12,
1622 CXTUResourceUsage_SourceManager_DataStructures = 13,
1623 CXTUResourceUsage_Preprocessor_HeaderSearch = 14,
1624 CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST,
1625 CXTUResourceUsage_MEMORY_IN_BYTES_END =
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001626 CXTUResourceUsage_Preprocessor_HeaderSearch,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001627
1628 CXTUResourceUsage_First = CXTUResourceUsage_AST,
1629 CXTUResourceUsage_Last = CXTUResourceUsage_Preprocessor_HeaderSearch
1630};
1631
1632/**
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001633 * Returns the human-readable null-terminated C string that represents
1634 * the name of the memory category. This string should never be freed.
1635 */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001636CINDEX_LINKAGE
1637const char *clang_getTUResourceUsageName(enum CXTUResourceUsageKind kind);
1638
1639typedef struct CXTUResourceUsageEntry {
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001640 /* The memory usage category. */
1641 enum CXTUResourceUsageKind kind;
1642 /* Amount of resources used.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001643 The units will depend on the resource kind. */
1644 unsigned long amount;
1645} CXTUResourceUsageEntry;
1646
1647/**
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001648 * The memory usage of a CXTranslationUnit, broken into categories.
1649 */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001650typedef struct CXTUResourceUsage {
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001651 /* Private data member, used for queries. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001652 void *data;
1653
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001654 /* The number of entries in the 'entries' array. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001655 unsigned numEntries;
1656
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001657 /* An array of key-value pairs, representing the breakdown of memory
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001658 usage. */
1659 CXTUResourceUsageEntry *entries;
1660
1661} CXTUResourceUsage;
1662
1663/**
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001664 * Return the memory usage of a translation unit. This object
1665 * should be released with clang_disposeCXTUResourceUsage().
1666 */
1667CINDEX_LINKAGE CXTUResourceUsage
1668clang_getCXTUResourceUsage(CXTranslationUnit TU);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001669
1670CINDEX_LINKAGE void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage);
1671
1672/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001673 * Get target information for this translation unit.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001674 *
1675 * The CXTargetInfo object cannot outlive the CXTranslationUnit object.
1676 */
1677CINDEX_LINKAGE CXTargetInfo
1678clang_getTranslationUnitTargetInfo(CXTranslationUnit CTUnit);
1679
1680/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001681 * Destroy the CXTargetInfo object.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001682 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001683CINDEX_LINKAGE void clang_TargetInfo_dispose(CXTargetInfo Info);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001684
1685/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001686 * Get the normalized target triple as a string.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001687 *
1688 * Returns the empty string in case of any error.
1689 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001690CINDEX_LINKAGE CXString clang_TargetInfo_getTriple(CXTargetInfo Info);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001691
1692/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001693 * Get the pointer width of the target in bits.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001694 *
1695 * Returns -1 in case of error.
1696 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001697CINDEX_LINKAGE int clang_TargetInfo_getPointerWidth(CXTargetInfo Info);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001698
1699/**
1700 * @}
1701 */
1702
1703/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001704 * Describes the kind of entity that a cursor refers to.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001705 */
1706enum CXCursorKind {
1707 /* Declarations */
1708 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001709 * A declaration whose specific kind is not exposed via this
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001710 * interface.
1711 *
1712 * Unexposed declarations have the same operations as any other kind
1713 * of declaration; one can extract their location information,
1714 * spelling, find their definitions, etc. However, the specific kind
1715 * of the declaration is not reported.
1716 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001717 CXCursor_UnexposedDecl = 1,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001718 /** A C or C++ struct. */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001719 CXCursor_StructDecl = 2,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001720 /** A C or C++ union. */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001721 CXCursor_UnionDecl = 3,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001722 /** A C++ class. */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001723 CXCursor_ClassDecl = 4,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001724 /** An enumeration. */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001725 CXCursor_EnumDecl = 5,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001726 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001727 * A field (in C) or non-static data member (in C++) in a
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001728 * struct, union, or C++ class.
1729 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001730 CXCursor_FieldDecl = 6,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001731 /** An enumerator constant. */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001732 CXCursor_EnumConstantDecl = 7,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001733 /** A function. */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001734 CXCursor_FunctionDecl = 8,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001735 /** A variable. */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001736 CXCursor_VarDecl = 9,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001737 /** A function or method parameter. */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001738 CXCursor_ParmDecl = 10,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001739 /** An Objective-C \@interface. */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001740 CXCursor_ObjCInterfaceDecl = 11,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001741 /** An Objective-C \@interface for a category. */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001742 CXCursor_ObjCCategoryDecl = 12,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001743 /** An Objective-C \@protocol declaration. */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001744 CXCursor_ObjCProtocolDecl = 13,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001745 /** An Objective-C \@property declaration. */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001746 CXCursor_ObjCPropertyDecl = 14,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001747 /** An Objective-C instance variable. */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001748 CXCursor_ObjCIvarDecl = 15,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001749 /** An Objective-C instance method. */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001750 CXCursor_ObjCInstanceMethodDecl = 16,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001751 /** An Objective-C class method. */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001752 CXCursor_ObjCClassMethodDecl = 17,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001753 /** An Objective-C \@implementation. */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001754 CXCursor_ObjCImplementationDecl = 18,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001755 /** An Objective-C \@implementation for a category. */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001756 CXCursor_ObjCCategoryImplDecl = 19,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001757 /** A typedef. */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001758 CXCursor_TypedefDecl = 20,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001759 /** A C++ class method. */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001760 CXCursor_CXXMethod = 21,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001761 /** A C++ namespace. */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001762 CXCursor_Namespace = 22,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001763 /** A linkage specification, e.g. 'extern "C"'. */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001764 CXCursor_LinkageSpec = 23,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001765 /** A C++ constructor. */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001766 CXCursor_Constructor = 24,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001767 /** A C++ destructor. */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001768 CXCursor_Destructor = 25,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001769 /** A C++ conversion function. */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001770 CXCursor_ConversionFunction = 26,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001771 /** A C++ template type parameter. */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001772 CXCursor_TemplateTypeParameter = 27,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001773 /** A C++ non-type template parameter. */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001774 CXCursor_NonTypeTemplateParameter = 28,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001775 /** A C++ template template parameter. */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001776 CXCursor_TemplateTemplateParameter = 29,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001777 /** A C++ function template. */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001778 CXCursor_FunctionTemplate = 30,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001779 /** A C++ class template. */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001780 CXCursor_ClassTemplate = 31,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001781 /** A C++ class template partial specialization. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001782 CXCursor_ClassTemplatePartialSpecialization = 32,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001783 /** A C++ namespace alias declaration. */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001784 CXCursor_NamespaceAlias = 33,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001785 /** A C++ using directive. */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001786 CXCursor_UsingDirective = 34,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001787 /** A C++ using declaration. */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001788 CXCursor_UsingDeclaration = 35,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001789 /** A C++ alias declaration */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001790 CXCursor_TypeAliasDecl = 36,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001791 /** An Objective-C \@synthesize definition. */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001792 CXCursor_ObjCSynthesizeDecl = 37,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001793 /** An Objective-C \@dynamic definition. */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001794 CXCursor_ObjCDynamicDecl = 38,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001795 /** An access specifier. */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001796 CXCursor_CXXAccessSpecifier = 39,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001797
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001798 CXCursor_FirstDecl = CXCursor_UnexposedDecl,
1799 CXCursor_LastDecl = CXCursor_CXXAccessSpecifier,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001800
1801 /* References */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001802 CXCursor_FirstRef = 40, /* Decl references */
1803 CXCursor_ObjCSuperClassRef = 40,
1804 CXCursor_ObjCProtocolRef = 41,
1805 CXCursor_ObjCClassRef = 42,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001806 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001807 * A reference to a type declaration.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001808 *
1809 * A type reference occurs anywhere where a type is named but not
1810 * declared. For example, given:
1811 *
1812 * \code
1813 * typedef unsigned size_type;
1814 * size_type size;
1815 * \endcode
1816 *
1817 * The typedef is a declaration of size_type (CXCursor_TypedefDecl),
1818 * while the type of the variable "size" is referenced. The cursor
1819 * referenced by the type of size is the typedef for size_type.
1820 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001821 CXCursor_TypeRef = 43,
1822 CXCursor_CXXBaseSpecifier = 44,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001823 /**
1824 * A reference to a class template, function template, template
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001825 * template parameter, or class template partial specialization.
1826 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001827 CXCursor_TemplateRef = 45,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001828 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001829 * A reference to a namespace or namespace alias.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001830 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001831 CXCursor_NamespaceRef = 46,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001832 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001833 * A reference to a member of a struct, union, or class that occurs in
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001834 * some non-expression context, e.g., a designated initializer.
1835 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001836 CXCursor_MemberRef = 47,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001837 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001838 * A reference to a labeled statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001839 *
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001840 * This cursor kind is used to describe the jump to "start_over" in the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001841 * goto statement in the following example:
1842 *
1843 * \code
1844 * start_over:
1845 * ++counter;
1846 *
1847 * goto start_over;
1848 * \endcode
1849 *
1850 * A label reference cursor refers to a label statement.
1851 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001852 CXCursor_LabelRef = 48,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001853
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001854 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001855 * A reference to a set of overloaded functions or function templates
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001856 * that has not yet been resolved to a specific function or function template.
1857 *
1858 * An overloaded declaration reference cursor occurs in C++ templates where
1859 * a dependent name refers to a function. For example:
1860 *
1861 * \code
1862 * template<typename T> void swap(T&, T&);
1863 *
1864 * struct X { ... };
1865 * void swap(X&, X&);
1866 *
1867 * template<typename T>
1868 * void reverse(T* first, T* last) {
1869 * while (first < last - 1) {
1870 * swap(*first, *--last);
1871 * ++first;
1872 * }
1873 * }
1874 *
1875 * struct Y { };
1876 * void swap(Y&, Y&);
1877 * \endcode
1878 *
1879 * Here, the identifier "swap" is associated with an overloaded declaration
1880 * reference. In the template definition, "swap" refers to either of the two
1881 * "swap" functions declared above, so both results will be available. At
1882 * instantiation time, "swap" may also refer to other functions found via
1883 * argument-dependent lookup (e.g., the "swap" function at the end of the
1884 * example).
1885 *
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001886 * The functions \c clang_getNumOverloadedDecls() and
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001887 * \c clang_getOverloadedDecl() can be used to retrieve the definitions
1888 * referenced by this cursor.
1889 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001890 CXCursor_OverloadedDeclRef = 49,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001891
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001892 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001893 * A reference to a variable that occurs in some non-expression
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001894 * context, e.g., a C++ lambda capture list.
1895 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001896 CXCursor_VariableRef = 50,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001897
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001898 CXCursor_LastRef = CXCursor_VariableRef,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001899
1900 /* Error conditions */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001901 CXCursor_FirstInvalid = 70,
1902 CXCursor_InvalidFile = 70,
1903 CXCursor_NoDeclFound = 71,
1904 CXCursor_NotImplemented = 72,
1905 CXCursor_InvalidCode = 73,
1906 CXCursor_LastInvalid = CXCursor_InvalidCode,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001907
1908 /* Expressions */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001909 CXCursor_FirstExpr = 100,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001910
1911 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001912 * An expression whose specific kind is not exposed via this
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001913 * interface.
1914 *
1915 * Unexposed expressions have the same operations as any other kind
1916 * of expression; one can extract their location information,
1917 * spelling, children, etc. However, the specific kind of the
1918 * expression is not reported.
1919 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001920 CXCursor_UnexposedExpr = 100,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001921
1922 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001923 * An expression that refers to some value declaration, such
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001924 * as a function, variable, or enumerator.
1925 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001926 CXCursor_DeclRefExpr = 101,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001927
1928 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001929 * An expression that refers to a member of a struct, union,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001930 * class, Objective-C class, etc.
1931 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001932 CXCursor_MemberRefExpr = 102,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001933
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001934 /** An expression that calls a function. */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001935 CXCursor_CallExpr = 103,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001936
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001937 /** An expression that sends a message to an Objective-C
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001938 object or class. */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001939 CXCursor_ObjCMessageExpr = 104,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001940
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001941 /** An expression that represents a block literal. */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001942 CXCursor_BlockExpr = 105,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001943
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001944 /** An integer literal.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001945 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001946 CXCursor_IntegerLiteral = 106,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001947
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001948 /** A floating point number literal.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001949 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001950 CXCursor_FloatingLiteral = 107,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001951
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001952 /** An imaginary number literal.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001953 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001954 CXCursor_ImaginaryLiteral = 108,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001955
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001956 /** A string literal.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001957 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001958 CXCursor_StringLiteral = 109,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001959
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001960 /** A character literal.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001961 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001962 CXCursor_CharacterLiteral = 110,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001963
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001964 /** A parenthesized expression, e.g. "(1)".
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001965 *
1966 * This AST node is only formed if full location information is requested.
1967 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001968 CXCursor_ParenExpr = 111,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001969
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001970 /** This represents the unary-expression's (except sizeof and
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001971 * alignof).
1972 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001973 CXCursor_UnaryOperator = 112,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001974
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001975 /** [C99 6.5.2.1] Array Subscripting.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001976 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001977 CXCursor_ArraySubscriptExpr = 113,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001978
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001979 /** A builtin binary operation expression such as "x + y" or
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001980 * "x <= y".
1981 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001982 CXCursor_BinaryOperator = 114,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001983
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001984 /** Compound assignment such as "+=".
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001985 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001986 CXCursor_CompoundAssignOperator = 115,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001987
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001988 /** The ?: ternary operator.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001989 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001990 CXCursor_ConditionalOperator = 116,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001991
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001992 /** An explicit cast in C (C99 6.5.4) or a C-style cast in C++
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001993 * (C++ [expr.cast]), which uses the syntax (Type)expr.
1994 *
1995 * For example: (int)f.
1996 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001997 CXCursor_CStyleCastExpr = 117,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001998
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001999 /** [C99 6.5.2.5]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002000 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002001 CXCursor_CompoundLiteralExpr = 118,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002002
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002003 /** Describes an C or C++ initializer list.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002004 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002005 CXCursor_InitListExpr = 119,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002006
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002007 /** The GNU address of label extension, representing &&label.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002008 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002009 CXCursor_AddrLabelExpr = 120,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002010
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002011 /** This is the GNU Statement Expression extension: ({int X=4; X;})
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002012 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002013 CXCursor_StmtExpr = 121,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002014
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002015 /** Represents a C11 generic selection.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002016 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002017 CXCursor_GenericSelectionExpr = 122,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002018
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002019 /** Implements the GNU __null extension, which is a name for a null
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002020 * pointer constant that has integral type (e.g., int or long) and is the same
2021 * size and alignment as a pointer.
2022 *
2023 * The __null extension is typically only used by system headers, which define
2024 * NULL as __null in C++ rather than using 0 (which is an integer that may not
2025 * match the size of a pointer).
2026 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002027 CXCursor_GNUNullExpr = 123,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002028
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002029 /** C++'s static_cast<> expression.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002030 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002031 CXCursor_CXXStaticCastExpr = 124,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002032
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002033 /** C++'s dynamic_cast<> expression.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002034 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002035 CXCursor_CXXDynamicCastExpr = 125,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002036
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002037 /** C++'s reinterpret_cast<> expression.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002038 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002039 CXCursor_CXXReinterpretCastExpr = 126,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002040
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002041 /** C++'s const_cast<> expression.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002042 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002043 CXCursor_CXXConstCastExpr = 127,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002044
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002045 /** Represents an explicit C++ type conversion that uses "functional"
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002046 * notion (C++ [expr.type.conv]).
2047 *
2048 * Example:
2049 * \code
2050 * x = int(0.5);
2051 * \endcode
2052 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002053 CXCursor_CXXFunctionalCastExpr = 128,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002054
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002055 /** A C++ typeid expression (C++ [expr.typeid]).
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002056 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002057 CXCursor_CXXTypeidExpr = 129,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002058
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002059 /** [C++ 2.13.5] C++ Boolean Literal.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002060 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002061 CXCursor_CXXBoolLiteralExpr = 130,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002062
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002063 /** [C++0x 2.14.7] C++ Pointer Literal.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002064 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002065 CXCursor_CXXNullPtrLiteralExpr = 131,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002066
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002067 /** Represents the "this" expression in C++
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002068 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002069 CXCursor_CXXThisExpr = 132,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002070
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002071 /** [C++ 15] C++ Throw Expression.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002072 *
2073 * This handles 'throw' and 'throw' assignment-expression. When
2074 * assignment-expression isn't present, Op will be null.
2075 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002076 CXCursor_CXXThrowExpr = 133,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002077
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002078 /** A new expression for memory allocation and constructor calls, e.g:
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002079 * "new CXXNewExpr(foo)".
2080 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002081 CXCursor_CXXNewExpr = 134,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002082
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002083 /** A delete expression for memory deallocation and destructor calls,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002084 * e.g. "delete[] pArray".
2085 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002086 CXCursor_CXXDeleteExpr = 135,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002087
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002088 /** A unary expression. (noexcept, sizeof, or other traits)
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002089 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002090 CXCursor_UnaryExpr = 136,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002091
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002092 /** An Objective-C string literal i.e. @"foo".
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002093 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002094 CXCursor_ObjCStringLiteral = 137,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002095
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002096 /** An Objective-C \@encode expression.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002097 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002098 CXCursor_ObjCEncodeExpr = 138,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002099
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002100 /** An Objective-C \@selector expression.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002101 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002102 CXCursor_ObjCSelectorExpr = 139,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002103
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002104 /** An Objective-C \@protocol expression.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002105 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002106 CXCursor_ObjCProtocolExpr = 140,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002107
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002108 /** An Objective-C "bridged" cast expression, which casts between
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002109 * Objective-C pointers and C pointers, transferring ownership in the process.
2110 *
2111 * \code
2112 * NSString *str = (__bridge_transfer NSString *)CFCreateString();
2113 * \endcode
2114 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002115 CXCursor_ObjCBridgedCastExpr = 141,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002116
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002117 /** Represents a C++0x pack expansion that produces a sequence of
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002118 * expressions.
2119 *
2120 * A pack expansion expression contains a pattern (which itself is an
2121 * expression) followed by an ellipsis. For example:
2122 *
2123 * \code
2124 * template<typename F, typename ...Types>
2125 * void forward(F f, Types &&...args) {
2126 * f(static_cast<Types&&>(args)...);
2127 * }
2128 * \endcode
2129 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002130 CXCursor_PackExpansionExpr = 142,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002131
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002132 /** Represents an expression that computes the length of a parameter
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002133 * pack.
2134 *
2135 * \code
2136 * template<typename ...Types>
2137 * struct count {
2138 * static const unsigned value = sizeof...(Types);
2139 * };
2140 * \endcode
2141 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002142 CXCursor_SizeOfPackExpr = 143,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002143
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002144 /* Represents a C++ lambda expression that produces a local function
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002145 * object.
2146 *
2147 * \code
2148 * void abssort(float *x, unsigned N) {
2149 * std::sort(x, x + N,
2150 * [](float a, float b) {
2151 * return std::abs(a) < std::abs(b);
2152 * });
2153 * }
2154 * \endcode
2155 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002156 CXCursor_LambdaExpr = 144,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002157
2158 /** Objective-c Boolean Literal.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002159 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002160 CXCursor_ObjCBoolLiteralExpr = 145,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002161
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002162 /** Represents the "self" expression in an Objective-C method.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002163 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002164 CXCursor_ObjCSelfExpr = 146,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002165
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002166 /** OpenMP 5.0 [2.1.5, Array Section].
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002167 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002168 CXCursor_OMPArraySectionExpr = 147,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002169
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002170 /** Represents an @available(...) check.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002171 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002172 CXCursor_ObjCAvailabilityCheckExpr = 148,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002173
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002174 /**
2175 * Fixed point literal
2176 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002177 CXCursor_FixedPointLiteral = 149,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002178
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002179 /** OpenMP 5.0 [2.1.4, Array Shaping].
2180 */
2181 CXCursor_OMPArrayShapingExpr = 150,
2182
2183 /**
2184 * OpenMP 5.0 [2.1.6 Iterators]
2185 */
2186 CXCursor_OMPIteratorExpr = 151,
2187
2188 /** OpenCL's addrspace_cast<> expression.
2189 */
2190 CXCursor_CXXAddrspaceCastExpr = 152,
2191
2192 CXCursor_LastExpr = CXCursor_CXXAddrspaceCastExpr,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002193
2194 /* Statements */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002195 CXCursor_FirstStmt = 200,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002196 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002197 * A statement whose specific kind is not exposed via this
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002198 * interface.
2199 *
2200 * Unexposed statements have the same operations as any other kind of
2201 * statement; one can extract their location information, spelling,
2202 * children, etc. However, the specific kind of the statement is not
2203 * reported.
2204 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002205 CXCursor_UnexposedStmt = 200,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002206
2207 /** A labelled statement in a function.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002208 *
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002209 * This cursor kind is used to describe the "start_over:" label statement in
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002210 * the following example:
2211 *
2212 * \code
2213 * start_over:
2214 * ++counter;
2215 * \endcode
2216 *
2217 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002218 CXCursor_LabelStmt = 201,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002219
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002220 /** A group of statements like { stmt stmt }.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002221 *
2222 * This cursor kind is used to describe compound statements, e.g. function
2223 * bodies.
2224 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002225 CXCursor_CompoundStmt = 202,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002226
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002227 /** A case statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002228 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002229 CXCursor_CaseStmt = 203,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002230
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002231 /** A default statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002232 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002233 CXCursor_DefaultStmt = 204,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002234
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002235 /** An if statement
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002236 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002237 CXCursor_IfStmt = 205,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002238
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002239 /** A switch statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002240 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002241 CXCursor_SwitchStmt = 206,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002242
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002243 /** A while statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002244 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002245 CXCursor_WhileStmt = 207,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002246
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002247 /** A do statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002248 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002249 CXCursor_DoStmt = 208,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002250
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002251 /** A for statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002252 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002253 CXCursor_ForStmt = 209,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002254
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002255 /** A goto statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002256 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002257 CXCursor_GotoStmt = 210,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002258
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002259 /** An indirect goto statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002260 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002261 CXCursor_IndirectGotoStmt = 211,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002262
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002263 /** A continue statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002264 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002265 CXCursor_ContinueStmt = 212,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002266
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002267 /** A break statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002268 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002269 CXCursor_BreakStmt = 213,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002270
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002271 /** A return statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002272 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002273 CXCursor_ReturnStmt = 214,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002274
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002275 /** A GCC inline assembly statement extension.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002276 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002277 CXCursor_GCCAsmStmt = 215,
2278 CXCursor_AsmStmt = CXCursor_GCCAsmStmt,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002279
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002280 /** Objective-C's overall \@try-\@catch-\@finally statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002281 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002282 CXCursor_ObjCAtTryStmt = 216,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002283
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002284 /** Objective-C's \@catch statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002285 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002286 CXCursor_ObjCAtCatchStmt = 217,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002287
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002288 /** Objective-C's \@finally statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002289 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002290 CXCursor_ObjCAtFinallyStmt = 218,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002291
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002292 /** Objective-C's \@throw statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002293 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002294 CXCursor_ObjCAtThrowStmt = 219,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002295
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002296 /** Objective-C's \@synchronized statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002297 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002298 CXCursor_ObjCAtSynchronizedStmt = 220,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002299
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002300 /** Objective-C's autorelease pool statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002301 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002302 CXCursor_ObjCAutoreleasePoolStmt = 221,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002303
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002304 /** Objective-C's collection statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002305 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002306 CXCursor_ObjCForCollectionStmt = 222,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002307
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002308 /** C++'s catch statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002309 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002310 CXCursor_CXXCatchStmt = 223,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002311
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002312 /** C++'s try statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002313 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002314 CXCursor_CXXTryStmt = 224,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002315
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002316 /** C++'s for (* : *) statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002317 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002318 CXCursor_CXXForRangeStmt = 225,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002319
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002320 /** Windows Structured Exception Handling's try statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002321 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002322 CXCursor_SEHTryStmt = 226,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002323
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002324 /** Windows Structured Exception Handling's except statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002325 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002326 CXCursor_SEHExceptStmt = 227,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002327
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002328 /** Windows Structured Exception Handling's finally statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002329 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002330 CXCursor_SEHFinallyStmt = 228,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002331
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002332 /** A MS inline assembly statement extension.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002333 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002334 CXCursor_MSAsmStmt = 229,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002335
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002336 /** The null statement ";": C99 6.8.3p3.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002337 *
2338 * This cursor kind is used to describe the null statement.
2339 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002340 CXCursor_NullStmt = 230,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002341
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002342 /** Adaptor class for mixing declarations with statements and
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002343 * expressions.
2344 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002345 CXCursor_DeclStmt = 231,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002346
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002347 /** OpenMP parallel directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002348 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002349 CXCursor_OMPParallelDirective = 232,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002350
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002351 /** OpenMP SIMD directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002352 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002353 CXCursor_OMPSimdDirective = 233,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002354
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002355 /** OpenMP for directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002356 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002357 CXCursor_OMPForDirective = 234,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002358
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002359 /** OpenMP sections directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002360 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002361 CXCursor_OMPSectionsDirective = 235,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002362
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002363 /** OpenMP section directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002364 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002365 CXCursor_OMPSectionDirective = 236,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002366
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002367 /** OpenMP single directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002368 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002369 CXCursor_OMPSingleDirective = 237,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002370
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002371 /** OpenMP parallel for directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002372 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002373 CXCursor_OMPParallelForDirective = 238,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002374
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002375 /** OpenMP parallel sections directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002376 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002377 CXCursor_OMPParallelSectionsDirective = 239,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002378
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002379 /** OpenMP task directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002380 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002381 CXCursor_OMPTaskDirective = 240,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002382
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002383 /** OpenMP master directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002384 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002385 CXCursor_OMPMasterDirective = 241,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002386
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002387 /** OpenMP critical directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002388 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002389 CXCursor_OMPCriticalDirective = 242,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002390
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002391 /** OpenMP taskyield directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002392 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002393 CXCursor_OMPTaskyieldDirective = 243,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002394
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002395 /** OpenMP barrier directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002396 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002397 CXCursor_OMPBarrierDirective = 244,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002398
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002399 /** OpenMP taskwait directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002400 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002401 CXCursor_OMPTaskwaitDirective = 245,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002402
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002403 /** OpenMP flush directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002404 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002405 CXCursor_OMPFlushDirective = 246,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002406
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002407 /** Windows Structured Exception Handling's leave statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002408 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002409 CXCursor_SEHLeaveStmt = 247,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002410
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002411 /** OpenMP ordered directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002412 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002413 CXCursor_OMPOrderedDirective = 248,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002414
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002415 /** OpenMP atomic directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002416 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002417 CXCursor_OMPAtomicDirective = 249,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002418
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002419 /** OpenMP for SIMD directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002420 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002421 CXCursor_OMPForSimdDirective = 250,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002422
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002423 /** OpenMP parallel for SIMD directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002424 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002425 CXCursor_OMPParallelForSimdDirective = 251,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002426
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002427 /** OpenMP target directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002428 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002429 CXCursor_OMPTargetDirective = 252,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002430
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002431 /** OpenMP teams directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002432 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002433 CXCursor_OMPTeamsDirective = 253,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002434
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002435 /** OpenMP taskgroup directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002436 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002437 CXCursor_OMPTaskgroupDirective = 254,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002438
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002439 /** OpenMP cancellation point directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002440 */
2441 CXCursor_OMPCancellationPointDirective = 255,
2442
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002443 /** OpenMP cancel directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002444 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002445 CXCursor_OMPCancelDirective = 256,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002446
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002447 /** OpenMP target data directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002448 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002449 CXCursor_OMPTargetDataDirective = 257,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002450
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002451 /** OpenMP taskloop directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002452 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002453 CXCursor_OMPTaskLoopDirective = 258,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002454
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002455 /** OpenMP taskloop simd directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002456 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002457 CXCursor_OMPTaskLoopSimdDirective = 259,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002458
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002459 /** OpenMP distribute directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002460 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002461 CXCursor_OMPDistributeDirective = 260,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002462
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002463 /** OpenMP target enter data directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002464 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002465 CXCursor_OMPTargetEnterDataDirective = 261,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002466
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002467 /** OpenMP target exit data directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002468 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002469 CXCursor_OMPTargetExitDataDirective = 262,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002470
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002471 /** OpenMP target parallel directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002472 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002473 CXCursor_OMPTargetParallelDirective = 263,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002474
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002475 /** OpenMP target parallel for directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002476 */
2477 CXCursor_OMPTargetParallelForDirective = 264,
2478
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002479 /** OpenMP target update directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002480 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002481 CXCursor_OMPTargetUpdateDirective = 265,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002482
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002483 /** OpenMP distribute parallel for directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002484 */
2485 CXCursor_OMPDistributeParallelForDirective = 266,
2486
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002487 /** OpenMP distribute parallel for simd directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002488 */
2489 CXCursor_OMPDistributeParallelForSimdDirective = 267,
2490
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002491 /** OpenMP distribute simd directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002492 */
2493 CXCursor_OMPDistributeSimdDirective = 268,
2494
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002495 /** OpenMP target parallel for simd directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002496 */
2497 CXCursor_OMPTargetParallelForSimdDirective = 269,
2498
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002499 /** OpenMP target simd directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002500 */
2501 CXCursor_OMPTargetSimdDirective = 270,
2502
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002503 /** OpenMP teams distribute directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002504 */
2505 CXCursor_OMPTeamsDistributeDirective = 271,
2506
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002507 /** OpenMP teams distribute simd directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002508 */
2509 CXCursor_OMPTeamsDistributeSimdDirective = 272,
2510
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002511 /** OpenMP teams distribute parallel for simd directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002512 */
2513 CXCursor_OMPTeamsDistributeParallelForSimdDirective = 273,
2514
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002515 /** OpenMP teams distribute parallel for directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002516 */
2517 CXCursor_OMPTeamsDistributeParallelForDirective = 274,
2518
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002519 /** OpenMP target teams directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002520 */
2521 CXCursor_OMPTargetTeamsDirective = 275,
2522
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002523 /** OpenMP target teams distribute directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002524 */
2525 CXCursor_OMPTargetTeamsDistributeDirective = 276,
2526
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002527 /** OpenMP target teams distribute parallel for directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002528 */
2529 CXCursor_OMPTargetTeamsDistributeParallelForDirective = 277,
2530
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002531 /** OpenMP target teams distribute parallel for simd directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002532 */
2533 CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective = 278,
2534
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002535 /** OpenMP target teams distribute simd directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002536 */
2537 CXCursor_OMPTargetTeamsDistributeSimdDirective = 279,
2538
Andrew Walbran3d2c1972020-04-07 12:24:26 +01002539 /** C++2a std::bit_cast expression.
2540 */
2541 CXCursor_BuiltinBitCastExpr = 280,
2542
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002543 /** OpenMP master taskloop directive.
2544 */
2545 CXCursor_OMPMasterTaskLoopDirective = 281,
2546
2547 /** OpenMP parallel master taskloop directive.
2548 */
2549 CXCursor_OMPParallelMasterTaskLoopDirective = 282,
2550
2551 /** OpenMP master taskloop simd directive.
2552 */
2553 CXCursor_OMPMasterTaskLoopSimdDirective = 283,
2554
2555 /** OpenMP parallel master taskloop simd directive.
2556 */
2557 CXCursor_OMPParallelMasterTaskLoopSimdDirective = 284,
2558
2559 /** OpenMP parallel master directive.
2560 */
2561 CXCursor_OMPParallelMasterDirective = 285,
2562
2563 /** OpenMP depobj directive.
2564 */
2565 CXCursor_OMPDepobjDirective = 286,
2566
2567 /** OpenMP scan directive.
2568 */
2569 CXCursor_OMPScanDirective = 287,
2570
2571 CXCursor_LastStmt = CXCursor_OMPScanDirective,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002572
2573 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002574 * Cursor that represents the translation unit itself.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002575 *
2576 * The translation unit cursor exists primarily to act as the root
2577 * cursor for traversing the contents of a translation unit.
2578 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002579 CXCursor_TranslationUnit = 300,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002580
2581 /* Attributes */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002582 CXCursor_FirstAttr = 400,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002583 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002584 * An attribute whose specific kind is not exposed via this
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002585 * interface.
2586 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002587 CXCursor_UnexposedAttr = 400,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002588
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002589 CXCursor_IBActionAttr = 401,
2590 CXCursor_IBOutletAttr = 402,
2591 CXCursor_IBOutletCollectionAttr = 403,
2592 CXCursor_CXXFinalAttr = 404,
2593 CXCursor_CXXOverrideAttr = 405,
2594 CXCursor_AnnotateAttr = 406,
2595 CXCursor_AsmLabelAttr = 407,
2596 CXCursor_PackedAttr = 408,
2597 CXCursor_PureAttr = 409,
2598 CXCursor_ConstAttr = 410,
2599 CXCursor_NoDuplicateAttr = 411,
2600 CXCursor_CUDAConstantAttr = 412,
2601 CXCursor_CUDADeviceAttr = 413,
2602 CXCursor_CUDAGlobalAttr = 414,
2603 CXCursor_CUDAHostAttr = 415,
2604 CXCursor_CUDASharedAttr = 416,
2605 CXCursor_VisibilityAttr = 417,
2606 CXCursor_DLLExport = 418,
2607 CXCursor_DLLImport = 419,
2608 CXCursor_NSReturnsRetained = 420,
2609 CXCursor_NSReturnsNotRetained = 421,
2610 CXCursor_NSReturnsAutoreleased = 422,
2611 CXCursor_NSConsumesSelf = 423,
2612 CXCursor_NSConsumed = 424,
2613 CXCursor_ObjCException = 425,
2614 CXCursor_ObjCNSObject = 426,
2615 CXCursor_ObjCIndependentClass = 427,
2616 CXCursor_ObjCPreciseLifetime = 428,
2617 CXCursor_ObjCReturnsInnerPointer = 429,
2618 CXCursor_ObjCRequiresSuper = 430,
2619 CXCursor_ObjCRootClass = 431,
2620 CXCursor_ObjCSubclassingRestricted = 432,
2621 CXCursor_ObjCExplicitProtocolImpl = 433,
2622 CXCursor_ObjCDesignatedInitializer = 434,
2623 CXCursor_ObjCRuntimeVisible = 435,
2624 CXCursor_ObjCBoxable = 436,
2625 CXCursor_FlagEnum = 437,
2626 CXCursor_ConvergentAttr = 438,
2627 CXCursor_WarnUnusedAttr = 439,
2628 CXCursor_WarnUnusedResultAttr = 440,
2629 CXCursor_AlignedAttr = 441,
2630 CXCursor_LastAttr = CXCursor_AlignedAttr,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002631
2632 /* Preprocessing */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002633 CXCursor_PreprocessingDirective = 500,
2634 CXCursor_MacroDefinition = 501,
2635 CXCursor_MacroExpansion = 502,
2636 CXCursor_MacroInstantiation = CXCursor_MacroExpansion,
2637 CXCursor_InclusionDirective = 503,
2638 CXCursor_FirstPreprocessing = CXCursor_PreprocessingDirective,
2639 CXCursor_LastPreprocessing = CXCursor_InclusionDirective,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002640
2641 /* Extra Declarations */
2642 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002643 * A module import declaration.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002644 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002645 CXCursor_ModuleImportDecl = 600,
2646 CXCursor_TypeAliasTemplateDecl = 601,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002647 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002648 * A static_assert or _Static_assert node
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002649 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002650 CXCursor_StaticAssert = 602,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002651 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002652 * a friend declaration.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002653 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002654 CXCursor_FriendDecl = 603,
2655 CXCursor_FirstExtraDecl = CXCursor_ModuleImportDecl,
2656 CXCursor_LastExtraDecl = CXCursor_FriendDecl,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002657
2658 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002659 * A code completion overload candidate.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002660 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002661 CXCursor_OverloadCandidate = 700
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002662};
2663
2664/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002665 * A cursor representing some element in the abstract syntax tree for
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002666 * a translation unit.
2667 *
2668 * The cursor abstraction unifies the different kinds of entities in a
2669 * program--declaration, statements, expressions, references to declarations,
2670 * etc.--under a single "cursor" abstraction with a common set of operations.
2671 * Common operation for a cursor include: getting the physical location in
2672 * a source file where the cursor points, getting the name associated with a
2673 * cursor, and retrieving cursors for any child nodes of a particular cursor.
2674 *
2675 * Cursors can be produced in two specific ways.
2676 * clang_getTranslationUnitCursor() produces a cursor for a translation unit,
2677 * from which one can use clang_visitChildren() to explore the rest of the
2678 * translation unit. clang_getCursor() maps from a physical source location
2679 * to the entity that resides at that location, allowing one to map from the
2680 * source code into the AST.
2681 */
2682typedef struct {
2683 enum CXCursorKind kind;
2684 int xdata;
2685 const void *data[3];
2686} CXCursor;
2687
2688/**
2689 * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations
2690 *
2691 * @{
2692 */
2693
2694/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002695 * Retrieve the NULL cursor, which represents no entity.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002696 */
2697CINDEX_LINKAGE CXCursor clang_getNullCursor(void);
2698
2699/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002700 * Retrieve the cursor that represents the given translation unit.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002701 *
2702 * The translation unit cursor can be used to start traversing the
2703 * various declarations within the given translation unit.
2704 */
2705CINDEX_LINKAGE CXCursor clang_getTranslationUnitCursor(CXTranslationUnit);
2706
2707/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002708 * Determine whether two cursors are equivalent.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002709 */
2710CINDEX_LINKAGE unsigned clang_equalCursors(CXCursor, CXCursor);
2711
2712/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002713 * Returns non-zero if \p cursor is null.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002714 */
2715CINDEX_LINKAGE int clang_Cursor_isNull(CXCursor cursor);
2716
2717/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002718 * Compute a hash value for the given cursor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002719 */
2720CINDEX_LINKAGE unsigned clang_hashCursor(CXCursor);
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002721
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002722/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002723 * Retrieve the kind of the given cursor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002724 */
2725CINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor);
2726
2727/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002728 * Determine whether the given cursor kind represents a declaration.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002729 */
2730CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind);
2731
2732/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002733 * Determine whether the given declaration is invalid.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002734 *
2735 * A declaration is invalid if it could not be parsed successfully.
2736 *
2737 * \returns non-zero if the cursor represents a declaration and it is
2738 * invalid, otherwise NULL.
2739 */
2740CINDEX_LINKAGE unsigned clang_isInvalidDeclaration(CXCursor);
2741
2742/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002743 * Determine whether the given cursor kind represents a simple
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002744 * reference.
2745 *
2746 * Note that other kinds of cursors (such as expressions) can also refer to
2747 * other cursors. Use clang_getCursorReferenced() to determine whether a
2748 * particular cursor refers to another entity.
2749 */
2750CINDEX_LINKAGE unsigned clang_isReference(enum CXCursorKind);
2751
2752/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002753 * Determine whether the given cursor kind represents an expression.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002754 */
2755CINDEX_LINKAGE unsigned clang_isExpression(enum CXCursorKind);
2756
2757/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002758 * Determine whether the given cursor kind represents a statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002759 */
2760CINDEX_LINKAGE unsigned clang_isStatement(enum CXCursorKind);
2761
2762/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002763 * Determine whether the given cursor kind represents an attribute.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002764 */
2765CINDEX_LINKAGE unsigned clang_isAttribute(enum CXCursorKind);
2766
2767/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002768 * Determine whether the given cursor has any attributes.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002769 */
2770CINDEX_LINKAGE unsigned clang_Cursor_hasAttrs(CXCursor C);
2771
2772/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002773 * Determine whether the given cursor kind represents an invalid
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002774 * cursor.
2775 */
2776CINDEX_LINKAGE unsigned clang_isInvalid(enum CXCursorKind);
2777
2778/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002779 * Determine whether the given cursor kind represents a translation
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002780 * unit.
2781 */
2782CINDEX_LINKAGE unsigned clang_isTranslationUnit(enum CXCursorKind);
2783
2784/***
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002785 * Determine whether the given cursor represents a preprocessing
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002786 * element, such as a preprocessor directive or macro instantiation.
2787 */
2788CINDEX_LINKAGE unsigned clang_isPreprocessing(enum CXCursorKind);
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002789
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002790/***
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002791 * Determine whether the given cursor represents a currently
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002792 * unexposed piece of the AST (e.g., CXCursor_UnexposedStmt).
2793 */
2794CINDEX_LINKAGE unsigned clang_isUnexposed(enum CXCursorKind);
2795
2796/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002797 * Describe the linkage of the entity referred to by a cursor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002798 */
2799enum CXLinkageKind {
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002800 /** This value indicates that no linkage information is available
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002801 * for a provided CXCursor. */
2802 CXLinkage_Invalid,
2803 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002804 * This is the linkage for variables, parameters, and so on that
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002805 * have automatic storage. This covers normal (non-extern) local variables.
2806 */
2807 CXLinkage_NoLinkage,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002808 /** This is the linkage for static variables and static functions. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002809 CXLinkage_Internal,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002810 /** This is the linkage for entities with external linkage that live
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002811 * in C++ anonymous namespaces.*/
2812 CXLinkage_UniqueExternal,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002813 /** This is the linkage for entities with true, external linkage. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002814 CXLinkage_External
2815};
2816
2817/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002818 * Determine the linkage of the entity referred to by a given cursor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002819 */
2820CINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor);
2821
2822enum CXVisibilityKind {
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002823 /** This value indicates that no visibility information is available
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002824 * for a provided CXCursor. */
2825 CXVisibility_Invalid,
2826
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002827 /** Symbol not seen by the linker. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002828 CXVisibility_Hidden,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002829 /** Symbol seen by the linker but resolves to a symbol inside this object. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002830 CXVisibility_Protected,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002831 /** Symbol seen by the linker and acts like a normal symbol. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002832 CXVisibility_Default
2833};
2834
2835/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002836 * Describe the visibility of the entity referred to by a cursor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002837 *
2838 * This returns the default visibility if not explicitly specified by
2839 * a visibility attribute. The default visibility may be changed by
2840 * commandline arguments.
2841 *
2842 * \param cursor The cursor to query.
2843 *
2844 * \returns The visibility of the cursor.
2845 */
2846CINDEX_LINKAGE enum CXVisibilityKind clang_getCursorVisibility(CXCursor cursor);
2847
2848/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002849 * Determine the availability of the entity that this cursor refers to,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002850 * taking the current target platform into account.
2851 *
2852 * \param cursor The cursor to query.
2853 *
2854 * \returns The availability of the cursor.
2855 */
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002856CINDEX_LINKAGE enum CXAvailabilityKind
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002857clang_getCursorAvailability(CXCursor cursor);
2858
2859/**
2860 * Describes the availability of a given entity on a particular platform, e.g.,
2861 * a particular class might only be available on Mac OS 10.7 or newer.
2862 */
2863typedef struct CXPlatformAvailability {
2864 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002865 * A string that describes the platform for which this structure
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002866 * provides availability information.
2867 *
2868 * Possible values are "ios" or "macos".
2869 */
2870 CXString Platform;
2871 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002872 * The version number in which this entity was introduced.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002873 */
2874 CXVersion Introduced;
2875 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002876 * The version number in which this entity was deprecated (but is
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002877 * still available).
2878 */
2879 CXVersion Deprecated;
2880 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002881 * The version number in which this entity was obsoleted, and therefore
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002882 * is no longer available.
2883 */
2884 CXVersion Obsoleted;
2885 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002886 * Whether the entity is unconditionally unavailable on this platform.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002887 */
2888 int Unavailable;
2889 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002890 * An optional message to provide to a user of this API, e.g., to
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002891 * suggest replacement APIs.
2892 */
2893 CXString Message;
2894} CXPlatformAvailability;
2895
2896/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002897 * Determine the availability of the entity that this cursor refers to
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002898 * on any platforms for which availability information is known.
2899 *
2900 * \param cursor The cursor to query.
2901 *
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002902 * \param always_deprecated If non-NULL, will be set to indicate whether the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002903 * entity is deprecated on all platforms.
2904 *
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002905 * \param deprecated_message If non-NULL, will be set to the message text
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002906 * provided along with the unconditional deprecation of this entity. The client
2907 * is responsible for deallocating this string.
2908 *
2909 * \param always_unavailable If non-NULL, will be set to indicate whether the
2910 * entity is unavailable on all platforms.
2911 *
2912 * \param unavailable_message If non-NULL, will be set to the message text
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002913 * provided along with the unconditional unavailability of this entity. The
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002914 * client is responsible for deallocating this string.
2915 *
2916 * \param availability If non-NULL, an array of CXPlatformAvailability instances
2917 * that will be populated with platform availability information, up to either
2918 * the number of platforms for which availability information is available (as
2919 * returned by this function) or \c availability_size, whichever is smaller.
2920 *
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002921 * \param availability_size The number of elements available in the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002922 * \c availability array.
2923 *
2924 * \returns The number of platforms (N) for which availability information is
2925 * available (which is unrelated to \c availability_size).
2926 *
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002927 * Note that the client is responsible for calling
2928 * \c clang_disposeCXPlatformAvailability to free each of the
2929 * platform-availability structures returned. There are
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002930 * \c min(N, availability_size) such structures.
2931 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002932CINDEX_LINKAGE int clang_getCursorPlatformAvailability(
2933 CXCursor cursor, int *always_deprecated, CXString *deprecated_message,
2934 int *always_unavailable, CXString *unavailable_message,
2935 CXPlatformAvailability *availability, int availability_size);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002936
2937/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002938 * Free the memory associated with a \c CXPlatformAvailability structure.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002939 */
2940CINDEX_LINKAGE void
2941clang_disposeCXPlatformAvailability(CXPlatformAvailability *availability);
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002942
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002943/**
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002944 * If cursor refers to a variable declaration and it has initializer returns
2945 * cursor referring to the initializer otherwise return null cursor.
2946 */
2947CINDEX_LINKAGE CXCursor clang_Cursor_getVarDeclInitializer(CXCursor cursor);
2948
2949/**
2950 * If cursor refers to a variable declaration that has global storage returns 1.
2951 * If cursor refers to a variable declaration that doesn't have global storage
2952 * returns 0. Otherwise returns -1.
2953 */
2954CINDEX_LINKAGE int clang_Cursor_hasVarDeclGlobalStorage(CXCursor cursor);
2955
2956/**
2957 * If cursor refers to a variable declaration that has external storage
2958 * returns 1. If cursor refers to a variable declaration that doesn't have
2959 * external storage returns 0. Otherwise returns -1.
2960 */
2961CINDEX_LINKAGE int clang_Cursor_hasVarDeclExternalStorage(CXCursor cursor);
2962
2963/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002964 * Describe the "language" of the entity referred to by a cursor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002965 */
2966enum CXLanguageKind {
2967 CXLanguage_Invalid = 0,
2968 CXLanguage_C,
2969 CXLanguage_ObjC,
2970 CXLanguage_CPlusPlus
2971};
2972
2973/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002974 * Determine the "language" of the entity referred to by a given cursor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002975 */
2976CINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor);
2977
2978/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002979 * Describe the "thread-local storage (TLS) kind" of the declaration
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002980 * referred to by a cursor.
2981 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02002982enum CXTLSKind { CXTLS_None = 0, CXTLS_Dynamic, CXTLS_Static };
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002983
2984/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002985 * Determine the "thread-local storage (TLS) kind" of the declaration
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002986 * referred to by a cursor.
2987 */
2988CINDEX_LINKAGE enum CXTLSKind clang_getCursorTLSKind(CXCursor cursor);
2989
2990/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002991 * Returns the translation unit that a cursor originated from.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002992 */
2993CINDEX_LINKAGE CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor);
2994
2995/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002996 * A fast container representing a set of CXCursors.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002997 */
2998typedef struct CXCursorSetImpl *CXCursorSet;
2999
3000/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003001 * Creates an empty CXCursorSet.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003002 */
3003CINDEX_LINKAGE CXCursorSet clang_createCXCursorSet(void);
3004
3005/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003006 * Disposes a CXCursorSet and releases its associated memory.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003007 */
3008CINDEX_LINKAGE void clang_disposeCXCursorSet(CXCursorSet cset);
3009
3010/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003011 * Queries a CXCursorSet to see if it contains a specific CXCursor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003012 *
3013 * \returns non-zero if the set contains the specified cursor.
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02003014 */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003015CINDEX_LINKAGE unsigned clang_CXCursorSet_contains(CXCursorSet cset,
3016 CXCursor cursor);
3017
3018/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003019 * Inserts a CXCursor into a CXCursorSet.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003020 *
3021 * \returns zero if the CXCursor was already in the set, and non-zero otherwise.
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02003022 */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003023CINDEX_LINKAGE unsigned clang_CXCursorSet_insert(CXCursorSet cset,
3024 CXCursor cursor);
3025
3026/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003027 * Determine the semantic parent of the given cursor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003028 *
3029 * The semantic parent of a cursor is the cursor that semantically contains
3030 * the given \p cursor. For many declarations, the lexical and semantic parents
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003031 * are equivalent (the lexical parent is returned by
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003032 * \c clang_getCursorLexicalParent()). They diverge when declarations or
3033 * definitions are provided out-of-line. For example:
3034 *
3035 * \code
3036 * class C {
3037 * void f();
3038 * };
3039 *
3040 * void C::f() { }
3041 * \endcode
3042 *
3043 * In the out-of-line definition of \c C::f, the semantic parent is
3044 * the class \c C, of which this function is a member. The lexical parent is
3045 * the place where the declaration actually occurs in the source code; in this
3046 * case, the definition occurs in the translation unit. In general, the
3047 * lexical parent for a given entity can change without affecting the semantics
3048 * of the program, and the lexical parent of different declarations of the
3049 * same entity may be different. Changing the semantic parent of a declaration,
3050 * on the other hand, can have a major impact on semantics, and redeclarations
3051 * of a particular entity should all have the same semantic context.
3052 *
3053 * In the example above, both declarations of \c C::f have \c C as their
3054 * semantic context, while the lexical context of the first \c C::f is \c C
3055 * and the lexical context of the second \c C::f is the translation unit.
3056 *
3057 * For global declarations, the semantic parent is the translation unit.
3058 */
3059CINDEX_LINKAGE CXCursor clang_getCursorSemanticParent(CXCursor cursor);
3060
3061/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003062 * Determine the lexical parent of the given cursor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003063 *
3064 * The lexical parent of a cursor is the cursor in which the given \p cursor
3065 * was actually written. For many declarations, the lexical and semantic parents
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003066 * are equivalent (the semantic parent is returned by
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003067 * \c clang_getCursorSemanticParent()). They diverge when declarations or
3068 * definitions are provided out-of-line. For example:
3069 *
3070 * \code
3071 * class C {
3072 * void f();
3073 * };
3074 *
3075 * void C::f() { }
3076 * \endcode
3077 *
3078 * In the out-of-line definition of \c C::f, the semantic parent is
3079 * the class \c C, of which this function is a member. The lexical parent is
3080 * the place where the declaration actually occurs in the source code; in this
3081 * case, the definition occurs in the translation unit. In general, the
3082 * lexical parent for a given entity can change without affecting the semantics
3083 * of the program, and the lexical parent of different declarations of the
3084 * same entity may be different. Changing the semantic parent of a declaration,
3085 * on the other hand, can have a major impact on semantics, and redeclarations
3086 * of a particular entity should all have the same semantic context.
3087 *
3088 * In the example above, both declarations of \c C::f have \c C as their
3089 * semantic context, while the lexical context of the first \c C::f is \c C
3090 * and the lexical context of the second \c C::f is the translation unit.
3091 *
3092 * For declarations written in the global scope, the lexical parent is
3093 * the translation unit.
3094 */
3095CINDEX_LINKAGE CXCursor clang_getCursorLexicalParent(CXCursor cursor);
3096
3097/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003098 * Determine the set of methods that are overridden by the given
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003099 * method.
3100 *
3101 * In both Objective-C and C++, a method (aka virtual member function,
3102 * in C++) can override a virtual method in a base class. For
3103 * Objective-C, a method is said to override any method in the class's
3104 * base class, its protocols, or its categories' protocols, that has the same
3105 * selector and is of the same kind (class or instance).
3106 * If no such method exists, the search continues to the class's superclass,
3107 * its protocols, and its categories, and so on. A method from an Objective-C
3108 * implementation is considered to override the same methods as its
3109 * corresponding method in the interface.
3110 *
3111 * For C++, a virtual member function overrides any virtual member
3112 * function with the same signature that occurs in its base
3113 * classes. With multiple inheritance, a virtual member function can
3114 * override several virtual member functions coming from different
3115 * base classes.
3116 *
3117 * In all cases, this function determines the immediate overridden
3118 * method, rather than all of the overridden methods. For example, if
3119 * a method is originally declared in a class A, then overridden in B
3120 * (which in inherits from A) and also in C (which inherited from B),
3121 * then the only overridden method returned from this function when
3122 * invoked on C's method will be B's method. The client may then
3123 * invoke this function again, given the previously-found overridden
3124 * methods, to map out the complete method-override set.
3125 *
3126 * \param cursor A cursor representing an Objective-C or C++
3127 * method. This routine will compute the set of methods that this
3128 * method overrides.
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003129 *
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003130 * \param overridden A pointer whose pointee will be replaced with a
3131 * pointer to an array of cursors, representing the set of overridden
3132 * methods. If there are no overridden methods, the pointee will be
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003133 * set to NULL. The pointee must be freed via a call to
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003134 * \c clang_disposeOverriddenCursors().
3135 *
3136 * \param num_overridden A pointer to the number of overridden
3137 * functions, will be set to the number of overridden functions in the
3138 * array pointed to by \p overridden.
3139 */
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003140CINDEX_LINKAGE void clang_getOverriddenCursors(CXCursor cursor,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003141 CXCursor **overridden,
3142 unsigned *num_overridden);
3143
3144/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003145 * Free the set of overridden cursors returned by \c
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003146 * clang_getOverriddenCursors().
3147 */
3148CINDEX_LINKAGE void clang_disposeOverriddenCursors(CXCursor *overridden);
3149
3150/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003151 * Retrieve the file that is included by the given inclusion directive
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003152 * cursor.
3153 */
3154CINDEX_LINKAGE CXFile clang_getIncludedFile(CXCursor cursor);
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003155
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003156/**
3157 * @}
3158 */
3159
3160/**
3161 * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code
3162 *
3163 * Cursors represent a location within the Abstract Syntax Tree (AST). These
3164 * routines help map between cursors and the physical locations where the
3165 * described entities occur in the source code. The mapping is provided in
3166 * both directions, so one can map from source code to the AST and back.
3167 *
3168 * @{
3169 */
3170
3171/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003172 * Map a source location to the cursor that describes the entity at that
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003173 * location in the source code.
3174 *
3175 * clang_getCursor() maps an arbitrary source location within a translation
3176 * unit down to the most specific cursor that describes the entity at that
3177 * location. For example, given an expression \c x + y, invoking
3178 * clang_getCursor() with a source location pointing to "x" will return the
3179 * cursor for "x"; similarly for "y". If the cursor points anywhere between
3180 * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor()
3181 * will return a cursor referring to the "+" expression.
3182 *
3183 * \returns a cursor representing the entity at the given source location, or
3184 * a NULL cursor if no such entity can be found.
3185 */
3186CINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, CXSourceLocation);
3187
3188/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003189 * Retrieve the physical location of the source constructor referenced
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003190 * by the given cursor.
3191 *
3192 * The location of a declaration is typically the location of the name of that
3193 * declaration, where the name of that declaration would occur if it is
3194 * unnamed, or some keyword that introduces that particular declaration.
3195 * The location of a reference is where that reference occurs within the
3196 * source code.
3197 */
3198CINDEX_LINKAGE CXSourceLocation clang_getCursorLocation(CXCursor);
3199
3200/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003201 * Retrieve the physical extent of the source construct referenced by
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003202 * the given cursor.
3203 *
3204 * The extent of a cursor starts with the file/line/column pointing at the
3205 * first character within the source construct that the cursor refers to and
3206 * ends with the last character within that source construct. For a
3207 * declaration, the extent covers the declaration itself. For a reference,
3208 * the extent covers the location of the reference (e.g., where the referenced
3209 * entity was actually used).
3210 */
3211CINDEX_LINKAGE CXSourceRange clang_getCursorExtent(CXCursor);
3212
3213/**
3214 * @}
3215 */
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003216
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003217/**
3218 * \defgroup CINDEX_TYPES Type information for CXCursors
3219 *
3220 * @{
3221 */
3222
3223/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003224 * Describes the kind of type
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003225 */
3226enum CXTypeKind {
3227 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003228 * Represents an invalid type (e.g., where no type is available).
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003229 */
3230 CXType_Invalid = 0,
3231
3232 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003233 * A type whose specific kind is not exposed via this
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003234 * interface.
3235 */
3236 CXType_Unexposed = 1,
3237
3238 /* Builtin types */
3239 CXType_Void = 2,
3240 CXType_Bool = 3,
3241 CXType_Char_U = 4,
3242 CXType_UChar = 5,
3243 CXType_Char16 = 6,
3244 CXType_Char32 = 7,
3245 CXType_UShort = 8,
3246 CXType_UInt = 9,
3247 CXType_ULong = 10,
3248 CXType_ULongLong = 11,
3249 CXType_UInt128 = 12,
3250 CXType_Char_S = 13,
3251 CXType_SChar = 14,
3252 CXType_WChar = 15,
3253 CXType_Short = 16,
3254 CXType_Int = 17,
3255 CXType_Long = 18,
3256 CXType_LongLong = 19,
3257 CXType_Int128 = 20,
3258 CXType_Float = 21,
3259 CXType_Double = 22,
3260 CXType_LongDouble = 23,
3261 CXType_NullPtr = 24,
3262 CXType_Overload = 25,
3263 CXType_Dependent = 26,
3264 CXType_ObjCId = 27,
3265 CXType_ObjCClass = 28,
3266 CXType_ObjCSel = 29,
3267 CXType_Float128 = 30,
3268 CXType_Half = 31,
3269 CXType_Float16 = 32,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003270 CXType_ShortAccum = 33,
3271 CXType_Accum = 34,
3272 CXType_LongAccum = 35,
3273 CXType_UShortAccum = 36,
3274 CXType_UAccum = 37,
3275 CXType_ULongAccum = 38,
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02003276 CXType_BFloat16 = 39,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003277 CXType_FirstBuiltin = CXType_Void,
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02003278 CXType_LastBuiltin = CXType_BFloat16,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003279
3280 CXType_Complex = 100,
3281 CXType_Pointer = 101,
3282 CXType_BlockPointer = 102,
3283 CXType_LValueReference = 103,
3284 CXType_RValueReference = 104,
3285 CXType_Record = 105,
3286 CXType_Enum = 106,
3287 CXType_Typedef = 107,
3288 CXType_ObjCInterface = 108,
3289 CXType_ObjCObjectPointer = 109,
3290 CXType_FunctionNoProto = 110,
3291 CXType_FunctionProto = 111,
3292 CXType_ConstantArray = 112,
3293 CXType_Vector = 113,
3294 CXType_IncompleteArray = 114,
3295 CXType_VariableArray = 115,
3296 CXType_DependentSizedArray = 116,
3297 CXType_MemberPointer = 117,
3298 CXType_Auto = 118,
3299
3300 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003301 * Represents a type that was referred to using an elaborated type keyword.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003302 *
3303 * E.g., struct S, or via a qualified name, e.g., N::M::type, or both.
3304 */
3305 CXType_Elaborated = 119,
3306
3307 /* OpenCL PipeType. */
3308 CXType_Pipe = 120,
3309
3310 /* OpenCL builtin types. */
3311 CXType_OCLImage1dRO = 121,
3312 CXType_OCLImage1dArrayRO = 122,
3313 CXType_OCLImage1dBufferRO = 123,
3314 CXType_OCLImage2dRO = 124,
3315 CXType_OCLImage2dArrayRO = 125,
3316 CXType_OCLImage2dDepthRO = 126,
3317 CXType_OCLImage2dArrayDepthRO = 127,
3318 CXType_OCLImage2dMSAARO = 128,
3319 CXType_OCLImage2dArrayMSAARO = 129,
3320 CXType_OCLImage2dMSAADepthRO = 130,
3321 CXType_OCLImage2dArrayMSAADepthRO = 131,
3322 CXType_OCLImage3dRO = 132,
3323 CXType_OCLImage1dWO = 133,
3324 CXType_OCLImage1dArrayWO = 134,
3325 CXType_OCLImage1dBufferWO = 135,
3326 CXType_OCLImage2dWO = 136,
3327 CXType_OCLImage2dArrayWO = 137,
3328 CXType_OCLImage2dDepthWO = 138,
3329 CXType_OCLImage2dArrayDepthWO = 139,
3330 CXType_OCLImage2dMSAAWO = 140,
3331 CXType_OCLImage2dArrayMSAAWO = 141,
3332 CXType_OCLImage2dMSAADepthWO = 142,
3333 CXType_OCLImage2dArrayMSAADepthWO = 143,
3334 CXType_OCLImage3dWO = 144,
3335 CXType_OCLImage1dRW = 145,
3336 CXType_OCLImage1dArrayRW = 146,
3337 CXType_OCLImage1dBufferRW = 147,
3338 CXType_OCLImage2dRW = 148,
3339 CXType_OCLImage2dArrayRW = 149,
3340 CXType_OCLImage2dDepthRW = 150,
3341 CXType_OCLImage2dArrayDepthRW = 151,
3342 CXType_OCLImage2dMSAARW = 152,
3343 CXType_OCLImage2dArrayMSAARW = 153,
3344 CXType_OCLImage2dMSAADepthRW = 154,
3345 CXType_OCLImage2dArrayMSAADepthRW = 155,
3346 CXType_OCLImage3dRW = 156,
3347 CXType_OCLSampler = 157,
3348 CXType_OCLEvent = 158,
3349 CXType_OCLQueue = 159,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003350 CXType_OCLReserveID = 160,
3351
3352 CXType_ObjCObject = 161,
3353 CXType_ObjCTypeParam = 162,
Andrew Walbran16937d02019-10-22 13:54:20 +01003354 CXType_Attributed = 163,
3355
3356 CXType_OCLIntelSubgroupAVCMcePayload = 164,
3357 CXType_OCLIntelSubgroupAVCImePayload = 165,
3358 CXType_OCLIntelSubgroupAVCRefPayload = 166,
3359 CXType_OCLIntelSubgroupAVCSicPayload = 167,
3360 CXType_OCLIntelSubgroupAVCMceResult = 168,
3361 CXType_OCLIntelSubgroupAVCImeResult = 169,
3362 CXType_OCLIntelSubgroupAVCRefResult = 170,
3363 CXType_OCLIntelSubgroupAVCSicResult = 171,
3364 CXType_OCLIntelSubgroupAVCImeResultSingleRefStreamout = 172,
3365 CXType_OCLIntelSubgroupAVCImeResultDualRefStreamout = 173,
3366 CXType_OCLIntelSubgroupAVCImeSingleRefStreamin = 174,
3367
Andrew Walbran3d2c1972020-04-07 12:24:26 +01003368 CXType_OCLIntelSubgroupAVCImeDualRefStreamin = 175,
3369
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02003370 CXType_ExtVector = 176,
3371 CXType_Atomic = 177
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003372};
3373
3374/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003375 * Describes the calling convention of a function type
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003376 */
3377enum CXCallingConv {
3378 CXCallingConv_Default = 0,
3379 CXCallingConv_C = 1,
3380 CXCallingConv_X86StdCall = 2,
3381 CXCallingConv_X86FastCall = 3,
3382 CXCallingConv_X86ThisCall = 4,
3383 CXCallingConv_X86Pascal = 5,
3384 CXCallingConv_AAPCS = 6,
3385 CXCallingConv_AAPCS_VFP = 7,
3386 CXCallingConv_X86RegCall = 8,
3387 CXCallingConv_IntelOclBicc = 9,
3388 CXCallingConv_Win64 = 10,
3389 /* Alias for compatibility with older versions of API. */
3390 CXCallingConv_X86_64Win64 = CXCallingConv_Win64,
3391 CXCallingConv_X86_64SysV = 11,
3392 CXCallingConv_X86VectorCall = 12,
3393 CXCallingConv_Swift = 13,
3394 CXCallingConv_PreserveMost = 14,
3395 CXCallingConv_PreserveAll = 15,
Andrew Walbran16937d02019-10-22 13:54:20 +01003396 CXCallingConv_AArch64VectorCall = 16,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003397
3398 CXCallingConv_Invalid = 100,
3399 CXCallingConv_Unexposed = 200
3400};
3401
3402/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003403 * The type of an element in the abstract syntax tree.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003404 *
3405 */
3406typedef struct {
3407 enum CXTypeKind kind;
3408 void *data[2];
3409} CXType;
3410
3411/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003412 * Retrieve the type of a CXCursor (if any).
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003413 */
3414CINDEX_LINKAGE CXType clang_getCursorType(CXCursor C);
3415
3416/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003417 * Pretty-print the underlying type using the rules of the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003418 * language of the translation unit from which it came.
3419 *
3420 * If the type is invalid, an empty string is returned.
3421 */
3422CINDEX_LINKAGE CXString clang_getTypeSpelling(CXType CT);
3423
3424/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003425 * Retrieve the underlying type of a typedef declaration.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003426 *
3427 * If the cursor does not reference a typedef declaration, an invalid type is
3428 * returned.
3429 */
3430CINDEX_LINKAGE CXType clang_getTypedefDeclUnderlyingType(CXCursor C);
3431
3432/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003433 * Retrieve the integer type of an enum declaration.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003434 *
3435 * If the cursor does not reference an enum declaration, an invalid type is
3436 * returned.
3437 */
3438CINDEX_LINKAGE CXType clang_getEnumDeclIntegerType(CXCursor C);
3439
3440/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003441 * Retrieve the integer value of an enum constant declaration as a signed
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003442 * long long.
3443 *
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02003444 * If the cursor does not reference an enum constant declaration, LLONG_MIN is
3445 * returned. Since this is also potentially a valid constant value, the kind of
3446 * the cursor must be verified before calling this function.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003447 */
3448CINDEX_LINKAGE long long clang_getEnumConstantDeclValue(CXCursor C);
3449
3450/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003451 * Retrieve the integer value of an enum constant declaration as an unsigned
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003452 * long long.
3453 *
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02003454 * If the cursor does not reference an enum constant declaration, ULLONG_MAX is
3455 * returned. Since this is also potentially a valid constant value, the kind of
3456 * the cursor must be verified before calling this function.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003457 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02003458CINDEX_LINKAGE unsigned long long
3459clang_getEnumConstantDeclUnsignedValue(CXCursor C);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003460
3461/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003462 * Retrieve the bit width of a bit field declaration as an integer.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003463 *
3464 * If a cursor that is not a bit field declaration is passed in, -1 is returned.
3465 */
3466CINDEX_LINKAGE int clang_getFieldDeclBitWidth(CXCursor C);
3467
3468/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003469 * Retrieve the number of non-variadic arguments associated with a given
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003470 * cursor.
3471 *
3472 * The number of arguments can be determined for calls as well as for
3473 * declarations of functions or methods. For other cursors -1 is returned.
3474 */
3475CINDEX_LINKAGE int clang_Cursor_getNumArguments(CXCursor C);
3476
3477/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003478 * Retrieve the argument cursor of a function or method.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003479 *
3480 * The argument cursor can be determined for calls as well as for declarations
3481 * of functions or methods. For other cursors and for invalid indices, an
3482 * invalid cursor is returned.
3483 */
3484CINDEX_LINKAGE CXCursor clang_Cursor_getArgument(CXCursor C, unsigned i);
3485
3486/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003487 * Describes the kind of a template argument.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003488 *
3489 * See the definition of llvm::clang::TemplateArgument::ArgKind for full
3490 * element descriptions.
3491 */
3492enum CXTemplateArgumentKind {
3493 CXTemplateArgumentKind_Null,
3494 CXTemplateArgumentKind_Type,
3495 CXTemplateArgumentKind_Declaration,
3496 CXTemplateArgumentKind_NullPtr,
3497 CXTemplateArgumentKind_Integral,
3498 CXTemplateArgumentKind_Template,
3499 CXTemplateArgumentKind_TemplateExpansion,
3500 CXTemplateArgumentKind_Expression,
3501 CXTemplateArgumentKind_Pack,
3502 /* Indicates an error case, preventing the kind from being deduced. */
3503 CXTemplateArgumentKind_Invalid
3504};
3505
3506/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003507 *Returns the number of template args of a function decl representing a
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003508 * template specialization.
3509 *
3510 * If the argument cursor cannot be converted into a template function
3511 * declaration, -1 is returned.
3512 *
3513 * For example, for the following declaration and specialization:
3514 * template <typename T, int kInt, bool kBool>
3515 * void foo() { ... }
3516 *
3517 * template <>
3518 * void foo<float, -7, true>();
3519 *
3520 * The value 3 would be returned from this call.
3521 */
3522CINDEX_LINKAGE int clang_Cursor_getNumTemplateArguments(CXCursor C);
3523
3524/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003525 * Retrieve the kind of the I'th template argument of the CXCursor C.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003526 *
3527 * If the argument CXCursor does not represent a FunctionDecl, an invalid
3528 * template argument kind is returned.
3529 *
3530 * For example, for the following declaration and specialization:
3531 * template <typename T, int kInt, bool kBool>
3532 * void foo() { ... }
3533 *
3534 * template <>
3535 * void foo<float, -7, true>();
3536 *
3537 * For I = 0, 1, and 2, Type, Integral, and Integral will be returned,
3538 * respectively.
3539 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02003540CINDEX_LINKAGE enum CXTemplateArgumentKind
3541clang_Cursor_getTemplateArgumentKind(CXCursor C, unsigned I);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003542
3543/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003544 * Retrieve a CXType representing the type of a TemplateArgument of a
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003545 * function decl representing a template specialization.
3546 *
3547 * If the argument CXCursor does not represent a FunctionDecl whose I'th
3548 * template argument has a kind of CXTemplateArgKind_Integral, an invalid type
3549 * is returned.
3550 *
3551 * For example, for the following declaration and specialization:
3552 * template <typename T, int kInt, bool kBool>
3553 * void foo() { ... }
3554 *
3555 * template <>
3556 * void foo<float, -7, true>();
3557 *
3558 * If called with I = 0, "float", will be returned.
3559 * Invalid types will be returned for I == 1 or 2.
3560 */
3561CINDEX_LINKAGE CXType clang_Cursor_getTemplateArgumentType(CXCursor C,
3562 unsigned I);
3563
3564/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003565 * Retrieve the value of an Integral TemplateArgument (of a function
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003566 * decl representing a template specialization) as a signed long long.
3567 *
3568 * It is undefined to call this function on a CXCursor that does not represent a
3569 * FunctionDecl or whose I'th template argument is not an integral value.
3570 *
3571 * For example, for the following declaration and specialization:
3572 * template <typename T, int kInt, bool kBool>
3573 * void foo() { ... }
3574 *
3575 * template <>
3576 * void foo<float, -7, true>();
3577 *
3578 * If called with I = 1 or 2, -7 or true will be returned, respectively.
3579 * For I == 0, this function's behavior is undefined.
3580 */
3581CINDEX_LINKAGE long long clang_Cursor_getTemplateArgumentValue(CXCursor C,
3582 unsigned I);
3583
3584/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003585 * Retrieve the value of an Integral TemplateArgument (of a function
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003586 * decl representing a template specialization) as an unsigned long long.
3587 *
3588 * It is undefined to call this function on a CXCursor that does not represent a
3589 * FunctionDecl or whose I'th template argument is not an integral value.
3590 *
3591 * For example, for the following declaration and specialization:
3592 * template <typename T, int kInt, bool kBool>
3593 * void foo() { ... }
3594 *
3595 * template <>
3596 * void foo<float, 2147483649, true>();
3597 *
3598 * If called with I = 1 or 2, 2147483649 or true will be returned, respectively.
3599 * For I == 0, this function's behavior is undefined.
3600 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02003601CINDEX_LINKAGE unsigned long long
3602clang_Cursor_getTemplateArgumentUnsignedValue(CXCursor C, unsigned I);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003603
3604/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003605 * Determine whether two CXTypes represent the same type.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003606 *
3607 * \returns non-zero if the CXTypes represent the same type and
3608 * zero otherwise.
3609 */
3610CINDEX_LINKAGE unsigned clang_equalTypes(CXType A, CXType B);
3611
3612/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003613 * Return the canonical type for a CXType.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003614 *
3615 * Clang's type system explicitly models typedefs and all the ways
3616 * a specific type can be represented. The canonical type is the underlying
3617 * type with all the "sugar" removed. For example, if 'T' is a typedef
3618 * for 'int', the canonical type for 'T' would be 'int'.
3619 */
3620CINDEX_LINKAGE CXType clang_getCanonicalType(CXType T);
3621
3622/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003623 * Determine whether a CXType has the "const" qualifier set,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003624 * without looking through typedefs that may have added "const" at a
3625 * different level.
3626 */
3627CINDEX_LINKAGE unsigned clang_isConstQualifiedType(CXType T);
3628
3629/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003630 * Determine whether a CXCursor that is a macro, is
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003631 * function like.
3632 */
3633CINDEX_LINKAGE unsigned clang_Cursor_isMacroFunctionLike(CXCursor C);
3634
3635/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003636 * Determine whether a CXCursor that is a macro, is a
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003637 * builtin one.
3638 */
3639CINDEX_LINKAGE unsigned clang_Cursor_isMacroBuiltin(CXCursor C);
3640
3641/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003642 * Determine whether a CXCursor that is a function declaration, is an
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003643 * inline declaration.
3644 */
3645CINDEX_LINKAGE unsigned clang_Cursor_isFunctionInlined(CXCursor C);
3646
3647/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003648 * Determine whether a CXType has the "volatile" qualifier set,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003649 * without looking through typedefs that may have added "volatile" at
3650 * a different level.
3651 */
3652CINDEX_LINKAGE unsigned clang_isVolatileQualifiedType(CXType T);
3653
3654/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003655 * Determine whether a CXType has the "restrict" qualifier set,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003656 * without looking through typedefs that may have added "restrict" at a
3657 * different level.
3658 */
3659CINDEX_LINKAGE unsigned clang_isRestrictQualifiedType(CXType T);
3660
3661/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003662 * Returns the address space of the given type.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003663 */
3664CINDEX_LINKAGE unsigned clang_getAddressSpace(CXType T);
3665
3666/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003667 * Returns the typedef name of the given type.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003668 */
3669CINDEX_LINKAGE CXString clang_getTypedefName(CXType CT);
3670
3671/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003672 * For pointer types, returns the type of the pointee.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003673 */
3674CINDEX_LINKAGE CXType clang_getPointeeType(CXType T);
3675
3676/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003677 * Return the cursor for the declaration of the given type.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003678 */
3679CINDEX_LINKAGE CXCursor clang_getTypeDeclaration(CXType T);
3680
3681/**
3682 * Returns the Objective-C type encoding for the specified declaration.
3683 */
3684CINDEX_LINKAGE CXString clang_getDeclObjCTypeEncoding(CXCursor C);
3685
3686/**
3687 * Returns the Objective-C type encoding for the specified CXType.
3688 */
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003689CINDEX_LINKAGE CXString clang_Type_getObjCEncoding(CXType type);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003690
3691/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003692 * Retrieve the spelling of a given CXTypeKind.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003693 */
3694CINDEX_LINKAGE CXString clang_getTypeKindSpelling(enum CXTypeKind K);
3695
3696/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003697 * Retrieve the calling convention associated with a function type.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003698 *
3699 * If a non-function type is passed in, CXCallingConv_Invalid is returned.
3700 */
3701CINDEX_LINKAGE enum CXCallingConv clang_getFunctionTypeCallingConv(CXType T);
3702
3703/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003704 * Retrieve the return type associated with a function type.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003705 *
3706 * If a non-function type is passed in, an invalid type is returned.
3707 */
3708CINDEX_LINKAGE CXType clang_getResultType(CXType T);
3709
3710/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003711 * Retrieve the exception specification type associated with a function type.
3712 * This is a value of type CXCursor_ExceptionSpecificationKind.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003713 *
3714 * If a non-function type is passed in, an error code of -1 is returned.
3715 */
3716CINDEX_LINKAGE int clang_getExceptionSpecificationType(CXType T);
3717
3718/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003719 * Retrieve the number of non-variadic parameters associated with a
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003720 * function type.
3721 *
3722 * If a non-function type is passed in, -1 is returned.
3723 */
3724CINDEX_LINKAGE int clang_getNumArgTypes(CXType T);
3725
3726/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003727 * Retrieve the type of a parameter of a function type.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003728 *
3729 * If a non-function type is passed in or the function does not have enough
3730 * parameters, an invalid type is returned.
3731 */
3732CINDEX_LINKAGE CXType clang_getArgType(CXType T, unsigned i);
3733
3734/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003735 * Retrieves the base type of the ObjCObjectType.
3736 *
3737 * If the type is not an ObjC object, an invalid type is returned.
3738 */
3739CINDEX_LINKAGE CXType clang_Type_getObjCObjectBaseType(CXType T);
3740
3741/**
3742 * Retrieve the number of protocol references associated with an ObjC object/id.
3743 *
3744 * If the type is not an ObjC object, 0 is returned.
3745 */
3746CINDEX_LINKAGE unsigned clang_Type_getNumObjCProtocolRefs(CXType T);
3747
3748/**
3749 * Retrieve the decl for a protocol reference for an ObjC object/id.
3750 *
3751 * If the type is not an ObjC object or there are not enough protocol
3752 * references, an invalid cursor is returned.
3753 */
3754CINDEX_LINKAGE CXCursor clang_Type_getObjCProtocolDecl(CXType T, unsigned i);
3755
3756/**
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02003757 * Retrieve the number of type arguments associated with an ObjC object.
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003758 *
3759 * If the type is not an ObjC object, 0 is returned.
3760 */
3761CINDEX_LINKAGE unsigned clang_Type_getNumObjCTypeArgs(CXType T);
3762
3763/**
3764 * Retrieve a type argument associated with an ObjC object.
3765 *
3766 * If the type is not an ObjC or the index is not valid,
3767 * an invalid type is returned.
3768 */
3769CINDEX_LINKAGE CXType clang_Type_getObjCTypeArg(CXType T, unsigned i);
3770
3771/**
3772 * Return 1 if the CXType is a variadic function type, and 0 otherwise.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003773 */
3774CINDEX_LINKAGE unsigned clang_isFunctionTypeVariadic(CXType T);
3775
3776/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003777 * Retrieve the return type associated with a given cursor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003778 *
3779 * This only returns a valid type if the cursor refers to a function or method.
3780 */
3781CINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C);
3782
3783/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003784 * Retrieve the exception specification type associated with a given cursor.
3785 * This is a value of type CXCursor_ExceptionSpecificationKind.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003786 *
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02003787 * This only returns a valid result if the cursor refers to a function or
3788 * method.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003789 */
3790CINDEX_LINKAGE int clang_getCursorExceptionSpecificationType(CXCursor C);
3791
3792/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003793 * Return 1 if the CXType is a POD (plain old data) type, and 0
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003794 * otherwise.
3795 */
3796CINDEX_LINKAGE unsigned clang_isPODType(CXType T);
3797
3798/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003799 * Return the element type of an array, complex, or vector type.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003800 *
3801 * If a type is passed in that is not an array, complex, or vector type,
3802 * an invalid type is returned.
3803 */
3804CINDEX_LINKAGE CXType clang_getElementType(CXType T);
3805
3806/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003807 * Return the number of elements of an array or vector type.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003808 *
3809 * If a type is passed in that is not an array or vector type,
3810 * -1 is returned.
3811 */
3812CINDEX_LINKAGE long long clang_getNumElements(CXType T);
3813
3814/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003815 * Return the element type of an array type.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003816 *
3817 * If a non-array type is passed in, an invalid type is returned.
3818 */
3819CINDEX_LINKAGE CXType clang_getArrayElementType(CXType T);
3820
3821/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003822 * Return the array size of a constant array.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003823 *
3824 * If a non-array type is passed in, -1 is returned.
3825 */
3826CINDEX_LINKAGE long long clang_getArraySize(CXType T);
3827
3828/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003829 * Retrieve the type named by the qualified-id.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003830 *
3831 * If a non-elaborated type is passed in, an invalid type is returned.
3832 */
3833CINDEX_LINKAGE CXType clang_Type_getNamedType(CXType T);
3834
3835/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003836 * Determine if a typedef is 'transparent' tag.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003837 *
3838 * A typedef is considered 'transparent' if it shares a name and spelling
3839 * location with its underlying tag type, as is the case with the NS_ENUM macro.
3840 *
3841 * \returns non-zero if transparent and zero otherwise.
3842 */
3843CINDEX_LINKAGE unsigned clang_Type_isTransparentTagTypedef(CXType T);
3844
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003845enum CXTypeNullabilityKind {
3846 /**
3847 * Values of this type can never be null.
3848 */
3849 CXTypeNullability_NonNull = 0,
3850 /**
3851 * Values of this type can be null.
3852 */
3853 CXTypeNullability_Nullable = 1,
3854 /**
3855 * Whether values of this type can be null is (explicitly)
3856 * unspecified. This captures a (fairly rare) case where we
3857 * can't conclude anything about the nullability of the type even
3858 * though it has been considered.
3859 */
3860 CXTypeNullability_Unspecified = 2,
3861 /**
3862 * Nullability is not applicable to this type.
3863 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02003864 CXTypeNullability_Invalid = 3,
3865
3866 /**
3867 * Generally behaves like Nullable, except when used in a block parameter that
3868 * was imported into a swift async method. There, swift will assume that the
3869 * parameter can get null even if no error occured. _Nullable parameters are
3870 * assumed to only get null on error.
3871 */
3872 CXTypeNullability_NullableResult = 4
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003873};
3874
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003875/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003876 * Retrieve the nullability kind of a pointer type.
3877 */
3878CINDEX_LINKAGE enum CXTypeNullabilityKind clang_Type_getNullability(CXType T);
3879
3880/**
3881 * List the possible error codes for \c clang_Type_getSizeOf,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003882 * \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf and
3883 * \c clang_Cursor_getOffsetOf.
3884 *
3885 * A value of this enumeration type can be returned if the target type is not
3886 * a valid argument to sizeof, alignof or offsetof.
3887 */
3888enum CXTypeLayoutError {
3889 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003890 * Type is of kind CXType_Invalid.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003891 */
3892 CXTypeLayoutError_Invalid = -1,
3893 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003894 * The type is an incomplete Type.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003895 */
3896 CXTypeLayoutError_Incomplete = -2,
3897 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003898 * The type is a dependent Type.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003899 */
3900 CXTypeLayoutError_Dependent = -3,
3901 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003902 * The type is not a constant size type.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003903 */
3904 CXTypeLayoutError_NotConstantSize = -4,
3905 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003906 * The Field name is not valid for this record.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003907 */
Andrew Walbran3d2c1972020-04-07 12:24:26 +01003908 CXTypeLayoutError_InvalidFieldName = -5,
3909 /**
3910 * The type is undeduced.
3911 */
3912 CXTypeLayoutError_Undeduced = -6
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003913};
3914
3915/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003916 * Return the alignment of a type in bytes as per C++[expr.alignof]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003917 * standard.
3918 *
3919 * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
3920 * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
3921 * is returned.
3922 * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
3923 * returned.
3924 * If the type declaration is not a constant size type,
3925 * CXTypeLayoutError_NotConstantSize is returned.
3926 */
3927CINDEX_LINKAGE long long clang_Type_getAlignOf(CXType T);
3928
3929/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003930 * Return the class type of an member pointer type.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003931 *
3932 * If a non-member-pointer type is passed in, an invalid type is returned.
3933 */
3934CINDEX_LINKAGE CXType clang_Type_getClassType(CXType T);
3935
3936/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003937 * Return the size of a type in bytes as per C++[expr.sizeof] standard.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003938 *
3939 * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
3940 * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
3941 * is returned.
3942 * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
3943 * returned.
3944 */
3945CINDEX_LINKAGE long long clang_Type_getSizeOf(CXType T);
3946
3947/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003948 * Return the offset of a field named S in a record of type T in bits
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003949 * as it would be returned by __offsetof__ as per C++11[18.2p4]
3950 *
3951 * If the cursor is not a record field declaration, CXTypeLayoutError_Invalid
3952 * is returned.
3953 * If the field's type declaration is an incomplete type,
3954 * CXTypeLayoutError_Incomplete is returned.
3955 * If the field's type declaration is a dependent type,
3956 * CXTypeLayoutError_Dependent is returned.
3957 * If the field's name S is not found,
3958 * CXTypeLayoutError_InvalidFieldName is returned.
3959 */
3960CINDEX_LINKAGE long long clang_Type_getOffsetOf(CXType T, const char *S);
3961
3962/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003963 * Return the type that was modified by this attributed type.
3964 *
3965 * If the type is not an attributed type, an invalid type is returned.
3966 */
3967CINDEX_LINKAGE CXType clang_Type_getModifiedType(CXType T);
3968
3969/**
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02003970 * Gets the type contained by this atomic type.
3971 *
3972 * If a non-atomic type is passed in, an invalid type is returned.
3973 */
3974CINDEX_LINKAGE CXType clang_Type_getValueType(CXType CT);
3975
3976/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003977 * Return the offset of the field represented by the Cursor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003978 *
3979 * If the cursor is not a field declaration, -1 is returned.
3980 * If the cursor semantic parent is not a record field declaration,
3981 * CXTypeLayoutError_Invalid is returned.
3982 * If the field's type declaration is an incomplete type,
3983 * CXTypeLayoutError_Incomplete is returned.
3984 * If the field's type declaration is a dependent type,
3985 * CXTypeLayoutError_Dependent is returned.
3986 * If the field's name S is not found,
3987 * CXTypeLayoutError_InvalidFieldName is returned.
3988 */
3989CINDEX_LINKAGE long long clang_Cursor_getOffsetOfField(CXCursor C);
3990
3991/**
Andrew Walbran3d2c1972020-04-07 12:24:26 +01003992 * Determine whether the given cursor represents an anonymous
3993 * tag or namespace
3994 */
3995CINDEX_LINKAGE unsigned clang_Cursor_isAnonymous(CXCursor C);
3996
3997/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003998 * Determine whether the given cursor represents an anonymous record
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003999 * declaration.
4000 */
Andrew Walbran3d2c1972020-04-07 12:24:26 +01004001CINDEX_LINKAGE unsigned clang_Cursor_isAnonymousRecordDecl(CXCursor C);
4002
4003/**
4004 * Determine whether the given cursor represents an inline namespace
4005 * declaration.
4006 */
4007CINDEX_LINKAGE unsigned clang_Cursor_isInlineNamespace(CXCursor C);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004008
4009enum CXRefQualifierKind {
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004010 /** No ref-qualifier was provided. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004011 CXRefQualifier_None = 0,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004012 /** An lvalue ref-qualifier was provided (\c &). */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004013 CXRefQualifier_LValue,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004014 /** An rvalue ref-qualifier was provided (\c &&). */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004015 CXRefQualifier_RValue
4016};
4017
4018/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004019 * Returns the number of template arguments for given template
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004020 * specialization, or -1 if type \c T is not a template specialization.
4021 */
4022CINDEX_LINKAGE int clang_Type_getNumTemplateArguments(CXType T);
4023
4024/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004025 * Returns the type template argument of a template class specialization
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004026 * at given index.
4027 *
4028 * This function only returns template type arguments and does not handle
4029 * template template arguments or variadic packs.
4030 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02004031CINDEX_LINKAGE CXType clang_Type_getTemplateArgumentAsType(CXType T,
4032 unsigned i);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004033
4034/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004035 * Retrieve the ref-qualifier kind of a function or method.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004036 *
4037 * The ref-qualifier is returned for C++ functions or methods. For other types
4038 * or non-C++ declarations, CXRefQualifier_None is returned.
4039 */
4040CINDEX_LINKAGE enum CXRefQualifierKind clang_Type_getCXXRefQualifier(CXType T);
4041
4042/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004043 * Returns non-zero if the cursor specifies a Record member that is a
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004044 * bitfield.
4045 */
4046CINDEX_LINKAGE unsigned clang_Cursor_isBitField(CXCursor C);
4047
4048/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004049 * Returns 1 if the base class specified by the cursor with kind
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004050 * CX_CXXBaseSpecifier is virtual.
4051 */
4052CINDEX_LINKAGE unsigned clang_isVirtualBase(CXCursor);
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004053
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004054/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004055 * Represents the C++ access control level to a base class for a
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004056 * cursor with kind CX_CXXBaseSpecifier.
4057 */
4058enum CX_CXXAccessSpecifier {
4059 CX_CXXInvalidAccessSpecifier,
4060 CX_CXXPublic,
4061 CX_CXXProtected,
4062 CX_CXXPrivate
4063};
4064
4065/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004066 * Returns the access control level for the referenced object.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004067 *
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02004068 * If the cursor refers to a C++ declaration, its access control level within
4069 * its parent scope is returned. Otherwise, if the cursor refers to a base
4070 * specifier or access specifier, the specifier itself is returned.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004071 */
4072CINDEX_LINKAGE enum CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor);
4073
4074/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004075 * Represents the storage classes as declared in the source. CX_SC_Invalid
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004076 * was added for the case that the passed cursor in not a declaration.
4077 */
4078enum CX_StorageClass {
4079 CX_SC_Invalid,
4080 CX_SC_None,
4081 CX_SC_Extern,
4082 CX_SC_Static,
4083 CX_SC_PrivateExtern,
4084 CX_SC_OpenCLWorkGroupLocal,
4085 CX_SC_Auto,
4086 CX_SC_Register
4087};
4088
4089/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004090 * Returns the storage class for a function or variable declaration.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004091 *
4092 * If the passed in Cursor is not a function or variable declaration,
4093 * CX_SC_Invalid is returned else the storage class.
4094 */
4095CINDEX_LINKAGE enum CX_StorageClass clang_Cursor_getStorageClass(CXCursor);
4096
4097/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004098 * Determine the number of overloaded declarations referenced by a
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004099 * \c CXCursor_OverloadedDeclRef cursor.
4100 *
4101 * \param cursor The cursor whose overloaded declarations are being queried.
4102 *
4103 * \returns The number of overloaded declarations referenced by \c cursor. If it
4104 * is not a \c CXCursor_OverloadedDeclRef cursor, returns 0.
4105 */
4106CINDEX_LINKAGE unsigned clang_getNumOverloadedDecls(CXCursor cursor);
4107
4108/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004109 * Retrieve a cursor for one of the overloaded declarations referenced
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004110 * by a \c CXCursor_OverloadedDeclRef cursor.
4111 *
4112 * \param cursor The cursor whose overloaded declarations are being queried.
4113 *
4114 * \param index The zero-based index into the set of overloaded declarations in
4115 * the cursor.
4116 *
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004117 * \returns A cursor representing the declaration referenced by the given
4118 * \c cursor at the specified \c index. If the cursor does not have an
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004119 * associated set of overloaded declarations, or if the index is out of bounds,
4120 * returns \c clang_getNullCursor();
4121 */
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004122CINDEX_LINKAGE CXCursor clang_getOverloadedDecl(CXCursor cursor,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004123 unsigned index);
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004124
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004125/**
4126 * @}
4127 */
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004128
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004129/**
4130 * \defgroup CINDEX_ATTRIBUTES Information for attributes
4131 *
4132 * @{
4133 */
4134
4135/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004136 * For cursors representing an iboutletcollection attribute,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004137 * this function returns the collection element type.
4138 *
4139 */
4140CINDEX_LINKAGE CXType clang_getIBOutletCollectionType(CXCursor);
4141
4142/**
4143 * @}
4144 */
4145
4146/**
4147 * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors
4148 *
4149 * These routines provide the ability to traverse the abstract syntax tree
4150 * using cursors.
4151 *
4152 * @{
4153 */
4154
4155/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004156 * Describes how the traversal of the children of a particular
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004157 * cursor should proceed after visiting a particular child cursor.
4158 *
4159 * A value of this enumeration type should be returned by each
4160 * \c CXCursorVisitor to indicate how clang_visitChildren() proceed.
4161 */
4162enum CXChildVisitResult {
4163 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004164 * Terminates the cursor traversal.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004165 */
4166 CXChildVisit_Break,
4167 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004168 * Continues the cursor traversal with the next sibling of
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004169 * the cursor just visited, without visiting its children.
4170 */
4171 CXChildVisit_Continue,
4172 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004173 * Recursively traverse the children of this cursor, using
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004174 * the same visitor and client data.
4175 */
4176 CXChildVisit_Recurse
4177};
4178
4179/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004180 * Visitor invoked for each cursor found by a traversal.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004181 *
4182 * This visitor function will be invoked for each cursor found by
4183 * clang_visitCursorChildren(). Its first argument is the cursor being
4184 * visited, its second argument is the parent visitor for that cursor,
4185 * and its third argument is the client data provided to
4186 * clang_visitCursorChildren().
4187 *
4188 * The visitor should return one of the \c CXChildVisitResult values
4189 * to direct clang_visitCursorChildren().
4190 */
4191typedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor,
4192 CXCursor parent,
4193 CXClientData client_data);
4194
4195/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004196 * Visit the children of a particular cursor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004197 *
4198 * This function visits all the direct children of the given cursor,
4199 * invoking the given \p visitor function with the cursors of each
4200 * visited child. The traversal may be recursive, if the visitor returns
4201 * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if
4202 * the visitor returns \c CXChildVisit_Break.
4203 *
4204 * \param parent the cursor whose child may be visited. All kinds of
4205 * cursors can be visited, including invalid cursors (which, by
4206 * definition, have no children).
4207 *
4208 * \param visitor the visitor function that will be invoked for each
4209 * child of \p parent.
4210 *
4211 * \param client_data pointer data supplied by the client, which will
4212 * be passed to the visitor each time it is invoked.
4213 *
4214 * \returns a non-zero value if the traversal was terminated
4215 * prematurely by the visitor returning \c CXChildVisit_Break.
4216 */
4217CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent,
4218 CXCursorVisitor visitor,
4219 CXClientData client_data);
4220#ifdef __has_feature
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02004221#if __has_feature(blocks)
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004222/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004223 * Visitor invoked for each cursor found by a traversal.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004224 *
4225 * This visitor block will be invoked for each cursor found by
4226 * clang_visitChildrenWithBlock(). Its first argument is the cursor being
4227 * visited, its second argument is the parent visitor for that cursor.
4228 *
4229 * The visitor should return one of the \c CXChildVisitResult values
4230 * to direct clang_visitChildrenWithBlock().
4231 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02004232typedef enum CXChildVisitResult (^CXCursorVisitorBlock)(CXCursor cursor,
4233 CXCursor parent);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004234
4235/**
4236 * Visits the children of a cursor using the specified block. Behaves
4237 * identically to clang_visitChildren() in all other respects.
4238 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02004239CINDEX_LINKAGE unsigned
4240clang_visitChildrenWithBlock(CXCursor parent, CXCursorVisitorBlock block);
4241#endif
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004242#endif
4243
4244/**
4245 * @}
4246 */
4247
4248/**
4249 * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST
4250 *
4251 * These routines provide the ability to determine references within and
4252 * across translation units, by providing the names of the entities referenced
4253 * by cursors, follow reference cursors to the declarations they reference,
4254 * and associate declarations with their definitions.
4255 *
4256 * @{
4257 */
4258
4259/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004260 * Retrieve a Unified Symbol Resolution (USR) for the entity referenced
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004261 * by the given cursor.
4262 *
4263 * A Unified Symbol Resolution (USR) is a string that identifies a particular
4264 * entity (function, class, variable, etc.) within a program. USRs can be
4265 * compared across translation units to determine, e.g., when references in
4266 * one translation refer to an entity defined in another translation unit.
4267 */
4268CINDEX_LINKAGE CXString clang_getCursorUSR(CXCursor);
4269
4270/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004271 * Construct a USR for a specified Objective-C class.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004272 */
4273CINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name);
4274
4275/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004276 * Construct a USR for a specified Objective-C category.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004277 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02004278CINDEX_LINKAGE CXString clang_constructUSR_ObjCCategory(
4279 const char *class_name, const char *category_name);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004280
4281/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004282 * Construct a USR for a specified Objective-C protocol.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004283 */
4284CINDEX_LINKAGE CXString
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02004285clang_constructUSR_ObjCProtocol(const char *protocol_name);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004286
4287/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004288 * Construct a USR for a specified Objective-C instance variable and
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004289 * the USR for its containing class.
4290 */
4291CINDEX_LINKAGE CXString clang_constructUSR_ObjCIvar(const char *name,
4292 CXString classUSR);
4293
4294/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004295 * Construct a USR for a specified Objective-C method and
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004296 * the USR for its containing class.
4297 */
4298CINDEX_LINKAGE CXString clang_constructUSR_ObjCMethod(const char *name,
4299 unsigned isInstanceMethod,
4300 CXString classUSR);
4301
4302/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004303 * Construct a USR for a specified Objective-C property and the USR
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004304 * for its containing class.
4305 */
4306CINDEX_LINKAGE CXString clang_constructUSR_ObjCProperty(const char *property,
4307 CXString classUSR);
4308
4309/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004310 * Retrieve a name for the entity referenced by this cursor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004311 */
4312CINDEX_LINKAGE CXString clang_getCursorSpelling(CXCursor);
4313
4314/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004315 * Retrieve a range for a piece that forms the cursors spelling name.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004316 * Most of the times there is only one range for the complete spelling but for
4317 * Objective-C methods and Objective-C message expressions, there are multiple
4318 * pieces for each selector identifier.
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004319 *
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004320 * \param pieceIndex the index of the spelling name piece. If this is greater
4321 * than the actual number of pieces, it will return a NULL (invalid) range.
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004322 *
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004323 * \param options Reserved.
4324 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02004325CINDEX_LINKAGE CXSourceRange clang_Cursor_getSpellingNameRange(
4326 CXCursor, unsigned pieceIndex, unsigned options);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004327
4328/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004329 * Opaque pointer representing a policy that controls pretty printing
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004330 * for \c clang_getCursorPrettyPrinted.
4331 */
4332typedef void *CXPrintingPolicy;
4333
4334/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004335 * Properties for the printing policy.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004336 *
4337 * See \c clang::PrintingPolicy for more information.
4338 */
4339enum CXPrintingPolicyProperty {
4340 CXPrintingPolicy_Indentation,
4341 CXPrintingPolicy_SuppressSpecifiers,
4342 CXPrintingPolicy_SuppressTagKeyword,
4343 CXPrintingPolicy_IncludeTagDefinition,
4344 CXPrintingPolicy_SuppressScope,
4345 CXPrintingPolicy_SuppressUnwrittenScope,
4346 CXPrintingPolicy_SuppressInitializers,
4347 CXPrintingPolicy_ConstantArraySizeAsWritten,
4348 CXPrintingPolicy_AnonymousTagLocations,
4349 CXPrintingPolicy_SuppressStrongLifetime,
4350 CXPrintingPolicy_SuppressLifetimeQualifiers,
4351 CXPrintingPolicy_SuppressTemplateArgsInCXXConstructors,
4352 CXPrintingPolicy_Bool,
4353 CXPrintingPolicy_Restrict,
4354 CXPrintingPolicy_Alignof,
4355 CXPrintingPolicy_UnderscoreAlignof,
4356 CXPrintingPolicy_UseVoidForZeroParams,
4357 CXPrintingPolicy_TerseOutput,
4358 CXPrintingPolicy_PolishForDeclaration,
4359 CXPrintingPolicy_Half,
4360 CXPrintingPolicy_MSWChar,
4361 CXPrintingPolicy_IncludeNewlines,
4362 CXPrintingPolicy_MSVCFormatting,
4363 CXPrintingPolicy_ConstantsAsWritten,
4364 CXPrintingPolicy_SuppressImplicitBase,
4365 CXPrintingPolicy_FullyQualifiedName,
4366
4367 CXPrintingPolicy_LastProperty = CXPrintingPolicy_FullyQualifiedName
4368};
4369
4370/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004371 * Get a property value for the given printing policy.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004372 */
4373CINDEX_LINKAGE unsigned
4374clang_PrintingPolicy_getProperty(CXPrintingPolicy Policy,
4375 enum CXPrintingPolicyProperty Property);
4376
4377/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004378 * Set a property value for the given printing policy.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004379 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02004380CINDEX_LINKAGE void
4381clang_PrintingPolicy_setProperty(CXPrintingPolicy Policy,
4382 enum CXPrintingPolicyProperty Property,
4383 unsigned Value);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004384
4385/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004386 * Retrieve the default policy for the cursor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004387 *
4388 * The policy should be released after use with \c
4389 * clang_PrintingPolicy_dispose.
4390 */
4391CINDEX_LINKAGE CXPrintingPolicy clang_getCursorPrintingPolicy(CXCursor);
4392
4393/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004394 * Release a printing policy.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004395 */
4396CINDEX_LINKAGE void clang_PrintingPolicy_dispose(CXPrintingPolicy Policy);
4397
4398/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004399 * Pretty print declarations.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004400 *
4401 * \param Cursor The cursor representing a declaration.
4402 *
4403 * \param Policy The policy to control the entities being printed. If
4404 * NULL, a default policy is used.
4405 *
4406 * \returns The pretty printed declaration or the empty string for
4407 * other cursors.
4408 */
4409CINDEX_LINKAGE CXString clang_getCursorPrettyPrinted(CXCursor Cursor,
4410 CXPrintingPolicy Policy);
4411
4412/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004413 * Retrieve the display name for the entity referenced by this cursor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004414 *
4415 * The display name contains extra information that helps identify the cursor,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004416 * such as the parameters of a function or template or the arguments of a
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004417 * class template specialization.
4418 */
4419CINDEX_LINKAGE CXString clang_getCursorDisplayName(CXCursor);
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004420
4421/** For a cursor that is a reference, retrieve a cursor representing the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004422 * entity that it references.
4423 *
4424 * Reference cursors refer to other entities in the AST. For example, an
4425 * Objective-C superclass reference cursor refers to an Objective-C class.
4426 * This function produces the cursor for the Objective-C class from the
4427 * cursor for the superclass reference. If the input cursor is a declaration or
4428 * definition, it returns that declaration or definition unchanged.
4429 * Otherwise, returns the NULL cursor.
4430 */
4431CINDEX_LINKAGE CXCursor clang_getCursorReferenced(CXCursor);
4432
4433/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004434 * For a cursor that is either a reference to or a declaration
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004435 * of some entity, retrieve a cursor that describes the definition of
4436 * that entity.
4437 *
4438 * Some entities can be declared multiple times within a translation
4439 * unit, but only one of those declarations can also be a
4440 * definition. For example, given:
4441 *
4442 * \code
4443 * int f(int, int);
4444 * int g(int x, int y) { return f(x, y); }
4445 * int f(int a, int b) { return a + b; }
4446 * int f(int, int);
4447 * \endcode
4448 *
4449 * there are three declarations of the function "f", but only the
4450 * second one is a definition. The clang_getCursorDefinition()
4451 * function will take any cursor pointing to a declaration of "f"
4452 * (the first or fourth lines of the example) or a cursor referenced
4453 * that uses "f" (the call to "f' inside "g") and will return a
4454 * declaration cursor pointing to the definition (the second "f"
4455 * declaration).
4456 *
4457 * If given a cursor for which there is no corresponding definition,
4458 * e.g., because there is no definition of that entity within this
4459 * translation unit, returns a NULL cursor.
4460 */
4461CINDEX_LINKAGE CXCursor clang_getCursorDefinition(CXCursor);
4462
4463/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004464 * Determine whether the declaration pointed to by this cursor
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004465 * is also a definition of that entity.
4466 */
4467CINDEX_LINKAGE unsigned clang_isCursorDefinition(CXCursor);
4468
4469/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004470 * Retrieve the canonical cursor corresponding to the given cursor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004471 *
4472 * In the C family of languages, many kinds of entities can be declared several
4473 * times within a single translation unit. For example, a structure type can
4474 * be forward-declared (possibly multiple times) and later defined:
4475 *
4476 * \code
4477 * struct X;
4478 * struct X;
4479 * struct X {
4480 * int member;
4481 * };
4482 * \endcode
4483 *
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004484 * The declarations and the definition of \c X are represented by three
4485 * different cursors, all of which are declarations of the same underlying
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004486 * entity. One of these cursor is considered the "canonical" cursor, which
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004487 * is effectively the representative for the underlying entity. One can
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004488 * determine if two cursors are declarations of the same underlying entity by
4489 * comparing their canonical cursors.
4490 *
4491 * \returns The canonical cursor for the entity referred to by the given cursor.
4492 */
4493CINDEX_LINKAGE CXCursor clang_getCanonicalCursor(CXCursor);
4494
4495/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004496 * If the cursor points to a selector identifier in an Objective-C
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004497 * method or message expression, this returns the selector index.
4498 *
4499 * After getting a cursor with #clang_getCursor, this can be called to
4500 * determine if the location points to a selector identifier.
4501 *
4502 * \returns The selector index if the cursor is an Objective-C method or message
4503 * expression and the cursor is pointing to a selector identifier, or -1
4504 * otherwise.
4505 */
4506CINDEX_LINKAGE int clang_Cursor_getObjCSelectorIndex(CXCursor);
4507
4508/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004509 * Given a cursor pointing to a C++ method call or an Objective-C
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004510 * message, returns non-zero if the method/message is "dynamic", meaning:
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004511 *
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004512 * For a C++ method: the call is virtual.
4513 * For an Objective-C message: the receiver is an object instance, not 'super'
4514 * or a specific class.
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004515 *
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004516 * If the method/message is "static" or the cursor does not point to a
4517 * method/message, it will return zero.
4518 */
4519CINDEX_LINKAGE int clang_Cursor_isDynamicCall(CXCursor C);
4520
4521/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004522 * Given a cursor pointing to an Objective-C message or property
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004523 * reference, or C++ method call, returns the CXType of the receiver.
4524 */
4525CINDEX_LINKAGE CXType clang_Cursor_getReceiverType(CXCursor C);
4526
4527/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004528 * Property attributes for a \c CXCursor_ObjCPropertyDecl.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004529 */
4530typedef enum {
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02004531 CXObjCPropertyAttr_noattr = 0x00,
4532 CXObjCPropertyAttr_readonly = 0x01,
4533 CXObjCPropertyAttr_getter = 0x02,
4534 CXObjCPropertyAttr_assign = 0x04,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004535 CXObjCPropertyAttr_readwrite = 0x08,
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02004536 CXObjCPropertyAttr_retain = 0x10,
4537 CXObjCPropertyAttr_copy = 0x20,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004538 CXObjCPropertyAttr_nonatomic = 0x40,
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02004539 CXObjCPropertyAttr_setter = 0x80,
4540 CXObjCPropertyAttr_atomic = 0x100,
4541 CXObjCPropertyAttr_weak = 0x200,
4542 CXObjCPropertyAttr_strong = 0x400,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004543 CXObjCPropertyAttr_unsafe_unretained = 0x800,
4544 CXObjCPropertyAttr_class = 0x1000
4545} CXObjCPropertyAttrKind;
4546
4547/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004548 * Given a cursor that represents a property declaration, return the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004549 * associated property attributes. The bits are formed from
4550 * \c CXObjCPropertyAttrKind.
4551 *
4552 * \param reserved Reserved for future use, pass 0.
4553 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02004554CINDEX_LINKAGE unsigned
4555clang_Cursor_getObjCPropertyAttributes(CXCursor C, unsigned reserved);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004556
4557/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004558 * Given a cursor that represents a property declaration, return the
4559 * name of the method that implements the getter.
4560 */
4561CINDEX_LINKAGE CXString clang_Cursor_getObjCPropertyGetterName(CXCursor C);
4562
4563/**
4564 * Given a cursor that represents a property declaration, return the
4565 * name of the method that implements the setter, if any.
4566 */
4567CINDEX_LINKAGE CXString clang_Cursor_getObjCPropertySetterName(CXCursor C);
4568
4569/**
4570 * 'Qualifiers' written next to the return and parameter types in
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004571 * Objective-C method declarations.
4572 */
4573typedef enum {
4574 CXObjCDeclQualifier_None = 0x0,
4575 CXObjCDeclQualifier_In = 0x1,
4576 CXObjCDeclQualifier_Inout = 0x2,
4577 CXObjCDeclQualifier_Out = 0x4,
4578 CXObjCDeclQualifier_Bycopy = 0x8,
4579 CXObjCDeclQualifier_Byref = 0x10,
4580 CXObjCDeclQualifier_Oneway = 0x20
4581} CXObjCDeclQualifierKind;
4582
4583/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004584 * Given a cursor that represents an Objective-C method or parameter
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004585 * declaration, return the associated Objective-C qualifiers for the return
4586 * type or the parameter respectively. The bits are formed from
4587 * CXObjCDeclQualifierKind.
4588 */
4589CINDEX_LINKAGE unsigned clang_Cursor_getObjCDeclQualifiers(CXCursor C);
4590
4591/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004592 * Given a cursor that represents an Objective-C method or property
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004593 * declaration, return non-zero if the declaration was affected by "\@optional".
4594 * Returns zero if the cursor is not such a declaration or it is "\@required".
4595 */
4596CINDEX_LINKAGE unsigned clang_Cursor_isObjCOptional(CXCursor C);
4597
4598/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004599 * Returns non-zero if the given cursor is a variadic function or method.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004600 */
4601CINDEX_LINKAGE unsigned clang_Cursor_isVariadic(CXCursor C);
4602
4603/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004604 * Returns non-zero if the given cursor points to a symbol marked with
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004605 * external_source_symbol attribute.
4606 *
4607 * \param language If non-NULL, and the attribute is present, will be set to
4608 * the 'language' string from the attribute.
4609 *
4610 * \param definedIn If non-NULL, and the attribute is present, will be set to
4611 * the 'definedIn' string from the attribute.
4612 *
4613 * \param isGenerated If non-NULL, and the attribute is present, will be set to
4614 * non-zero if the 'generated_declaration' is set in the attribute.
4615 */
4616CINDEX_LINKAGE unsigned clang_Cursor_isExternalSymbol(CXCursor C,
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02004617 CXString *language,
4618 CXString *definedIn,
4619 unsigned *isGenerated);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004620
4621/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004622 * Given a cursor that represents a declaration, return the associated
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004623 * comment's source range. The range may include multiple consecutive comments
4624 * with whitespace in between.
4625 */
4626CINDEX_LINKAGE CXSourceRange clang_Cursor_getCommentRange(CXCursor C);
4627
4628/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004629 * Given a cursor that represents a declaration, return the associated
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004630 * comment text, including comment markers.
4631 */
4632CINDEX_LINKAGE CXString clang_Cursor_getRawCommentText(CXCursor C);
4633
4634/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004635 * Given a cursor that represents a documentable entity (e.g.,
4636 * declaration), return the associated \paragraph; otherwise return the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004637 * first paragraph.
4638 */
4639CINDEX_LINKAGE CXString clang_Cursor_getBriefCommentText(CXCursor C);
4640
4641/**
4642 * @}
4643 */
4644
4645/** \defgroup CINDEX_MANGLE Name Mangling API Functions
4646 *
4647 * @{
4648 */
4649
4650/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004651 * Retrieve the CXString representing the mangled name of the cursor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004652 */
4653CINDEX_LINKAGE CXString clang_Cursor_getMangling(CXCursor);
4654
4655/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004656 * Retrieve the CXStrings representing the mangled symbols of the C++
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004657 * constructor or destructor at the cursor.
4658 */
4659CINDEX_LINKAGE CXStringSet *clang_Cursor_getCXXManglings(CXCursor);
4660
4661/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004662 * Retrieve the CXStrings representing the mangled symbols of the ObjC
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004663 * class interface or implementation at the cursor.
4664 */
4665CINDEX_LINKAGE CXStringSet *clang_Cursor_getObjCManglings(CXCursor);
4666
4667/**
4668 * @}
4669 */
4670
4671/**
4672 * \defgroup CINDEX_MODULE Module introspection
4673 *
4674 * The functions in this group provide access to information about modules.
4675 *
4676 * @{
4677 */
4678
4679typedef void *CXModule;
4680
4681/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004682 * Given a CXCursor_ModuleImportDecl cursor, return the associated module.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004683 */
4684CINDEX_LINKAGE CXModule clang_Cursor_getModule(CXCursor C);
4685
4686/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004687 * Given a CXFile header file, return the module that contains it, if one
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004688 * exists.
4689 */
4690CINDEX_LINKAGE CXModule clang_getModuleForFile(CXTranslationUnit, CXFile);
4691
4692/**
4693 * \param Module a module object.
4694 *
4695 * \returns the module file where the provided module object came from.
4696 */
4697CINDEX_LINKAGE CXFile clang_Module_getASTFile(CXModule Module);
4698
4699/**
4700 * \param Module a module object.
4701 *
4702 * \returns the parent of a sub-module or NULL if the given module is top-level,
4703 * e.g. for 'std.vector' it will return the 'std' module.
4704 */
4705CINDEX_LINKAGE CXModule clang_Module_getParent(CXModule Module);
4706
4707/**
4708 * \param Module a module object.
4709 *
4710 * \returns the name of the module, e.g. for the 'std.vector' sub-module it
4711 * will return "vector".
4712 */
4713CINDEX_LINKAGE CXString clang_Module_getName(CXModule Module);
4714
4715/**
4716 * \param Module a module object.
4717 *
4718 * \returns the full name of the module, e.g. "std.vector".
4719 */
4720CINDEX_LINKAGE CXString clang_Module_getFullName(CXModule Module);
4721
4722/**
4723 * \param Module a module object.
4724 *
4725 * \returns non-zero if the module is a system one.
4726 */
4727CINDEX_LINKAGE int clang_Module_isSystem(CXModule Module);
4728
4729/**
4730 * \param Module a module object.
4731 *
4732 * \returns the number of top level headers associated with this module.
4733 */
4734CINDEX_LINKAGE unsigned clang_Module_getNumTopLevelHeaders(CXTranslationUnit,
4735 CXModule Module);
4736
4737/**
4738 * \param Module a module object.
4739 *
4740 * \param Index top level header index (zero-based).
4741 *
4742 * \returns the specified top level header associated with the module.
4743 */
4744CINDEX_LINKAGE
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02004745CXFile clang_Module_getTopLevelHeader(CXTranslationUnit, CXModule Module,
4746 unsigned Index);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004747
4748/**
4749 * @}
4750 */
4751
4752/**
4753 * \defgroup CINDEX_CPP C++ AST introspection
4754 *
4755 * The routines in this group provide access information in the ASTs specific
4756 * to C++ language features.
4757 *
4758 * @{
4759 */
4760
4761/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004762 * Determine if a C++ constructor is a converting constructor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004763 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02004764CINDEX_LINKAGE unsigned
4765clang_CXXConstructor_isConvertingConstructor(CXCursor C);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004766
4767/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004768 * Determine if a C++ constructor is a copy constructor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004769 */
4770CINDEX_LINKAGE unsigned clang_CXXConstructor_isCopyConstructor(CXCursor C);
4771
4772/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004773 * Determine if a C++ constructor is the default constructor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004774 */
4775CINDEX_LINKAGE unsigned clang_CXXConstructor_isDefaultConstructor(CXCursor C);
4776
4777/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004778 * Determine if a C++ constructor is a move constructor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004779 */
4780CINDEX_LINKAGE unsigned clang_CXXConstructor_isMoveConstructor(CXCursor C);
4781
4782/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004783 * Determine if a C++ field is declared 'mutable'.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004784 */
4785CINDEX_LINKAGE unsigned clang_CXXField_isMutable(CXCursor C);
4786
4787/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004788 * Determine if a C++ method is declared '= default'.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004789 */
4790CINDEX_LINKAGE unsigned clang_CXXMethod_isDefaulted(CXCursor C);
4791
4792/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004793 * Determine if a C++ member function or member function template is
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004794 * pure virtual.
4795 */
4796CINDEX_LINKAGE unsigned clang_CXXMethod_isPureVirtual(CXCursor C);
4797
4798/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004799 * Determine if a C++ member function or member function template is
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004800 * declared 'static'.
4801 */
4802CINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C);
4803
4804/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004805 * Determine if a C++ member function or member function template is
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004806 * explicitly declared 'virtual' or if it overrides a virtual method from
4807 * one of the base classes.
4808 */
4809CINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual(CXCursor C);
4810
4811/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004812 * Determine if a C++ record is abstract, i.e. whether a class or struct
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004813 * has a pure virtual member function.
4814 */
4815CINDEX_LINKAGE unsigned clang_CXXRecord_isAbstract(CXCursor C);
4816
4817/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004818 * Determine if an enum declaration refers to a scoped enum.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004819 */
4820CINDEX_LINKAGE unsigned clang_EnumDecl_isScoped(CXCursor C);
4821
4822/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004823 * Determine if a C++ member function or member function template is
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004824 * declared 'const'.
4825 */
4826CINDEX_LINKAGE unsigned clang_CXXMethod_isConst(CXCursor C);
4827
4828/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004829 * Given a cursor that represents a template, determine
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004830 * the cursor kind of the specializations would be generated by instantiating
4831 * the template.
4832 *
4833 * This routine can be used to determine what flavor of function template,
4834 * class template, or class template partial specialization is stored in the
4835 * cursor. For example, it can describe whether a class template cursor is
4836 * declared with "struct", "class" or "union".
4837 *
4838 * \param C The cursor to query. This cursor should represent a template
4839 * declaration.
4840 *
4841 * \returns The cursor kind of the specializations that would be generated
4842 * by instantiating the template \p C. If \p C is not a template, returns
4843 * \c CXCursor_NoDeclFound.
4844 */
4845CINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind(CXCursor C);
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004846
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004847/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004848 * Given a cursor that may represent a specialization or instantiation
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004849 * of a template, retrieve the cursor that represents the template that it
4850 * specializes or from which it was instantiated.
4851 *
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004852 * This routine determines the template involved both for explicit
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004853 * specializations of templates and for implicit instantiations of the template,
4854 * both of which are referred to as "specializations". For a class template
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004855 * specialization (e.g., \c std::vector<bool>), this routine will return
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004856 * either the primary template (\c std::vector) or, if the specialization was
4857 * instantiated from a class template partial specialization, the class template
4858 * partial specialization. For a class template partial specialization and a
4859 * function template specialization (including instantiations), this
4860 * this routine will return the specialized template.
4861 *
4862 * For members of a class template (e.g., member functions, member classes, or
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004863 * static data members), returns the specialized or instantiated member.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004864 * Although not strictly "templates" in the C++ language, members of class
4865 * templates have the same notions of specializations and instantiations that
4866 * templates do, so this routine treats them similarly.
4867 *
4868 * \param C A cursor that may be a specialization of a template or a member
4869 * of a template.
4870 *
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004871 * \returns If the given cursor is a specialization or instantiation of a
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004872 * template or a member thereof, the template or member that it specializes or
4873 * from which it was instantiated. Otherwise, returns a NULL cursor.
4874 */
4875CINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate(CXCursor C);
4876
4877/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004878 * Given a cursor that references something else, return the source range
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004879 * covering that reference.
4880 *
4881 * \param C A cursor pointing to a member reference, a declaration reference, or
4882 * an operator call.
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004883 * \param NameFlags A bitset with three independent flags:
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004884 * CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and
4885 * CXNameRange_WantSinglePiece.
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004886 * \param PieceIndex For contiguous names or when passing the flag
4887 * CXNameRange_WantSinglePiece, only one piece with index 0 is
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004888 * available. When the CXNameRange_WantSinglePiece flag is not passed for a
4889 * non-contiguous names, this index can be used to retrieve the individual
4890 * pieces of the name. See also CXNameRange_WantSinglePiece.
4891 *
4892 * \returns The piece of the name pointed to by the given cursor. If there is no
4893 * name, or if the PieceIndex is out-of-range, a null-cursor will be returned.
4894 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02004895CINDEX_LINKAGE CXSourceRange clang_getCursorReferenceNameRange(
4896 CXCursor C, unsigned NameFlags, unsigned PieceIndex);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004897
4898enum CXNameRefFlags {
4899 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004900 * Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004901 * range.
4902 */
4903 CXNameRange_WantQualifier = 0x1,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004904
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004905 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004906 * Include the explicit template arguments, e.g. \<int> in x.f<int>,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004907 * in the range.
4908 */
4909 CXNameRange_WantTemplateArgs = 0x2,
4910
4911 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004912 * If the name is non-contiguous, return the full spanning range.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004913 *
4914 * Non-contiguous names occur in Objective-C when a selector with two or more
4915 * parameters is used, or in C++ when using an operator:
4916 * \code
4917 * [object doSomething:here withValue:there]; // Objective-C
4918 * return some_vector[1]; // C++
4919 * \endcode
4920 */
4921 CXNameRange_WantSinglePiece = 0x4
4922};
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004923
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004924/**
4925 * @}
4926 */
4927
4928/**
4929 * \defgroup CINDEX_LEX Token extraction and manipulation
4930 *
4931 * The routines in this group provide access to the tokens within a
4932 * translation unit, along with a semantic mapping of those tokens to
4933 * their corresponding cursors.
4934 *
4935 * @{
4936 */
4937
4938/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004939 * Describes a kind of token.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004940 */
4941typedef enum CXTokenKind {
4942 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004943 * A token that contains some kind of punctuation.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004944 */
4945 CXToken_Punctuation,
4946
4947 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004948 * A language keyword.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004949 */
4950 CXToken_Keyword,
4951
4952 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004953 * An identifier (that is not a keyword).
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004954 */
4955 CXToken_Identifier,
4956
4957 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004958 * A numeric, string, or character literal.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004959 */
4960 CXToken_Literal,
4961
4962 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004963 * A comment.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004964 */
4965 CXToken_Comment
4966} CXTokenKind;
4967
4968/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004969 * Describes a single preprocessing token.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004970 */
4971typedef struct {
4972 unsigned int_data[4];
4973 void *ptr_data;
4974} CXToken;
4975
4976/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004977 * Get the raw lexical token starting with the given location.
4978 *
4979 * \param TU the translation unit whose text is being tokenized.
4980 *
4981 * \param Location the source location with which the token starts.
4982 *
4983 * \returns The token starting with the given location or NULL if no such token
4984 * exist. The returned pointer must be freed with clang_disposeTokens before the
4985 * translation unit is destroyed.
4986 */
4987CINDEX_LINKAGE CXToken *clang_getToken(CXTranslationUnit TU,
4988 CXSourceLocation Location);
4989
4990/**
4991 * Determine the kind of the given token.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004992 */
4993CINDEX_LINKAGE CXTokenKind clang_getTokenKind(CXToken);
4994
4995/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004996 * Determine the spelling of the given token.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004997 *
4998 * The spelling of a token is the textual representation of that token, e.g.,
4999 * the text of an identifier or keyword.
5000 */
5001CINDEX_LINKAGE CXString clang_getTokenSpelling(CXTranslationUnit, CXToken);
5002
5003/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005004 * Retrieve the source location of the given token.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005005 */
5006CINDEX_LINKAGE CXSourceLocation clang_getTokenLocation(CXTranslationUnit,
5007 CXToken);
5008
5009/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005010 * Retrieve a source range that covers the given token.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005011 */
5012CINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken);
5013
5014/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005015 * Tokenize the source code described by the given range into raw
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005016 * lexical tokens.
5017 *
5018 * \param TU the translation unit whose text is being tokenized.
5019 *
5020 * \param Range the source range in which text should be tokenized. All of the
5021 * tokens produced by tokenization will fall within this source range,
5022 *
5023 * \param Tokens this pointer will be set to point to the array of tokens
5024 * that occur within the given source range. The returned pointer must be
5025 * freed with clang_disposeTokens() before the translation unit is destroyed.
5026 *
5027 * \param NumTokens will be set to the number of tokens in the \c *Tokens
5028 * array.
5029 *
5030 */
5031CINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
5032 CXToken **Tokens, unsigned *NumTokens);
5033
5034/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005035 * Annotate the given set of tokens by providing cursors for each token
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005036 * that can be mapped to a specific entity within the abstract syntax tree.
5037 *
5038 * This token-annotation routine is equivalent to invoking
5039 * clang_getCursor() for the source locations of each of the
5040 * tokens. The cursors provided are filtered, so that only those
5041 * cursors that have a direct correspondence to the token are
5042 * accepted. For example, given a function call \c f(x),
5043 * clang_getCursor() would provide the following cursors:
5044 *
5045 * * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'.
5046 * * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'.
5047 * * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'.
5048 *
5049 * Only the first and last of these cursors will occur within the
5050 * annotate, since the tokens "f" and "x' directly refer to a function
5051 * and a variable, respectively, but the parentheses are just a small
5052 * part of the full syntax of the function call expression, which is
5053 * not provided as an annotation.
5054 *
5055 * \param TU the translation unit that owns the given tokens.
5056 *
5057 * \param Tokens the set of tokens to annotate.
5058 *
5059 * \param NumTokens the number of tokens in \p Tokens.
5060 *
5061 * \param Cursors an array of \p NumTokens cursors, whose contents will be
5062 * replaced with the cursors corresponding to each token.
5063 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02005064CINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU, CXToken *Tokens,
5065 unsigned NumTokens, CXCursor *Cursors);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005066
5067/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005068 * Free the given set of tokens.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005069 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02005070CINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU, CXToken *Tokens,
5071 unsigned NumTokens);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005072
5073/**
5074 * @}
5075 */
5076
5077/**
5078 * \defgroup CINDEX_DEBUG Debugging facilities
5079 *
5080 * These routines are used for testing and debugging, only, and should not
5081 * be relied upon.
5082 *
5083 * @{
5084 */
5085
5086/* for debug/testing */
5087CINDEX_LINKAGE CXString clang_getCursorKindSpelling(enum CXCursorKind Kind);
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02005088CINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(
5089 CXCursor, const char **startBuf, const char **endBuf, unsigned *startLine,
5090 unsigned *startColumn, unsigned *endLine, unsigned *endColumn);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005091CINDEX_LINKAGE void clang_enableStackTraces(void);
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02005092CINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void *), void *user_data,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005093 unsigned stack_size);
5094
5095/**
5096 * @}
5097 */
5098
5099/**
5100 * \defgroup CINDEX_CODE_COMPLET Code completion
5101 *
5102 * Code completion involves taking an (incomplete) source file, along with
5103 * knowledge of where the user is actively editing that file, and suggesting
5104 * syntactically- and semantically-valid constructs that the user might want to
5105 * use at that particular point in the source code. These data structures and
5106 * routines provide support for code completion.
5107 *
5108 * @{
5109 */
5110
5111/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005112 * A semantic string that describes a code-completion result.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005113 *
5114 * A semantic string that describes the formatting of a code-completion
5115 * result as a single "template" of text that should be inserted into the
5116 * source buffer when a particular code-completion result is selected.
5117 * Each semantic string is made up of some number of "chunks", each of which
5118 * contains some text along with a description of what that text means, e.g.,
5119 * the name of the entity being referenced, whether the text chunk is part of
5120 * the template, or whether it is a "placeholder" that the user should replace
5121 * with actual code,of a specific kind. See \c CXCompletionChunkKind for a
5122 * description of the different kinds of chunks.
5123 */
5124typedef void *CXCompletionString;
5125
5126/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005127 * A single result of code completion.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005128 */
5129typedef struct {
5130 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005131 * The kind of entity that this completion refers to.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005132 *
5133 * The cursor kind will be a macro, keyword, or a declaration (one of the
5134 * *Decl cursor kinds), describing the entity that the completion is
5135 * referring to.
5136 *
5137 * \todo In the future, we would like to provide a full cursor, to allow
5138 * the client to extract additional information from declaration.
5139 */
5140 enum CXCursorKind CursorKind;
5141
5142 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005143 * The code-completion string that describes how to insert this
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005144 * code-completion result into the editing buffer.
5145 */
5146 CXCompletionString CompletionString;
5147} CXCompletionResult;
5148
5149/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005150 * Describes a single piece of text within a code-completion string.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005151 *
5152 * Each "chunk" within a code-completion string (\c CXCompletionString) is
5153 * either a piece of text with a specific "kind" that describes how that text
5154 * should be interpreted by the client or is another completion string.
5155 */
5156enum CXCompletionChunkKind {
5157 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005158 * A code-completion string that describes "optional" text that
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005159 * could be a part of the template (but is not required).
5160 *
5161 * The Optional chunk is the only kind of chunk that has a code-completion
5162 * string for its representation, which is accessible via
5163 * \c clang_getCompletionChunkCompletionString(). The code-completion string
5164 * describes an additional part of the template that is completely optional.
5165 * For example, optional chunks can be used to describe the placeholders for
5166 * arguments that match up with defaulted function parameters, e.g. given:
5167 *
5168 * \code
5169 * void f(int x, float y = 3.14, double z = 2.71828);
5170 * \endcode
5171 *
5172 * The code-completion string for this function would contain:
5173 * - a TypedText chunk for "f".
5174 * - a LeftParen chunk for "(".
5175 * - a Placeholder chunk for "int x"
5176 * - an Optional chunk containing the remaining defaulted arguments, e.g.,
5177 * - a Comma chunk for ","
5178 * - a Placeholder chunk for "float y"
5179 * - an Optional chunk containing the last defaulted argument:
5180 * - a Comma chunk for ","
5181 * - a Placeholder chunk for "double z"
5182 * - a RightParen chunk for ")"
5183 *
5184 * There are many ways to handle Optional chunks. Two simple approaches are:
5185 * - Completely ignore optional chunks, in which case the template for the
5186 * function "f" would only include the first parameter ("int x").
5187 * - Fully expand all optional chunks, in which case the template for the
5188 * function "f" would have all of the parameters.
5189 */
5190 CXCompletionChunk_Optional,
5191 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005192 * Text that a user would be expected to type to get this
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005193 * code-completion result.
5194 *
5195 * There will be exactly one "typed text" chunk in a semantic string, which
5196 * will typically provide the spelling of a keyword or the name of a
5197 * declaration that could be used at the current code point. Clients are
5198 * expected to filter the code-completion results based on the text in this
5199 * chunk.
5200 */
5201 CXCompletionChunk_TypedText,
5202 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005203 * Text that should be inserted as part of a code-completion result.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005204 *
5205 * A "text" chunk represents text that is part of the template to be
5206 * inserted into user code should this particular code-completion result
5207 * be selected.
5208 */
5209 CXCompletionChunk_Text,
5210 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005211 * Placeholder text that should be replaced by the user.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005212 *
5213 * A "placeholder" chunk marks a place where the user should insert text
5214 * into the code-completion template. For example, placeholders might mark
5215 * the function parameters for a function declaration, to indicate that the
5216 * user should provide arguments for each of those parameters. The actual
5217 * text in a placeholder is a suggestion for the text to display before
5218 * the user replaces the placeholder with real code.
5219 */
5220 CXCompletionChunk_Placeholder,
5221 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005222 * Informative text that should be displayed but never inserted as
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005223 * part of the template.
5224 *
5225 * An "informative" chunk contains annotations that can be displayed to
5226 * help the user decide whether a particular code-completion result is the
5227 * right option, but which is not part of the actual template to be inserted
5228 * by code completion.
5229 */
5230 CXCompletionChunk_Informative,
5231 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005232 * Text that describes the current parameter when code-completion is
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005233 * referring to function call, message send, or template specialization.
5234 *
5235 * A "current parameter" chunk occurs when code-completion is providing
5236 * information about a parameter corresponding to the argument at the
5237 * code-completion point. For example, given a function
5238 *
5239 * \code
5240 * int add(int x, int y);
5241 * \endcode
5242 *
5243 * and the source code \c add(, where the code-completion point is after the
5244 * "(", the code-completion string will contain a "current parameter" chunk
5245 * for "int x", indicating that the current argument will initialize that
5246 * parameter. After typing further, to \c add(17, (where the code-completion
5247 * point is after the ","), the code-completion string will contain a
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005248 * "current parameter" chunk to "int y".
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005249 */
5250 CXCompletionChunk_CurrentParameter,
5251 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005252 * A left parenthesis ('('), used to initiate a function call or
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005253 * signal the beginning of a function parameter list.
5254 */
5255 CXCompletionChunk_LeftParen,
5256 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005257 * A right parenthesis (')'), used to finish a function call or
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005258 * signal the end of a function parameter list.
5259 */
5260 CXCompletionChunk_RightParen,
5261 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005262 * A left bracket ('[').
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005263 */
5264 CXCompletionChunk_LeftBracket,
5265 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005266 * A right bracket (']').
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005267 */
5268 CXCompletionChunk_RightBracket,
5269 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005270 * A left brace ('{').
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005271 */
5272 CXCompletionChunk_LeftBrace,
5273 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005274 * A right brace ('}').
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005275 */
5276 CXCompletionChunk_RightBrace,
5277 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005278 * A left angle bracket ('<').
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005279 */
5280 CXCompletionChunk_LeftAngle,
5281 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005282 * A right angle bracket ('>').
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005283 */
5284 CXCompletionChunk_RightAngle,
5285 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005286 * A comma separator (',').
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005287 */
5288 CXCompletionChunk_Comma,
5289 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005290 * Text that specifies the result type of a given result.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005291 *
5292 * This special kind of informative chunk is not meant to be inserted into
5293 * the text buffer. Rather, it is meant to illustrate the type that an
5294 * expression using the given completion string would have.
5295 */
5296 CXCompletionChunk_ResultType,
5297 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005298 * A colon (':').
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005299 */
5300 CXCompletionChunk_Colon,
5301 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005302 * A semicolon (';').
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005303 */
5304 CXCompletionChunk_SemiColon,
5305 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005306 * An '=' sign.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005307 */
5308 CXCompletionChunk_Equal,
5309 /**
5310 * Horizontal space (' ').
5311 */
5312 CXCompletionChunk_HorizontalSpace,
5313 /**
5314 * Vertical space ('\\n'), after which it is generally a good idea to
5315 * perform indentation.
5316 */
5317 CXCompletionChunk_VerticalSpace
5318};
5319
5320/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005321 * Determine the kind of a particular chunk within a completion string.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005322 *
5323 * \param completion_string the completion string to query.
5324 *
5325 * \param chunk_number the 0-based index of the chunk in the completion string.
5326 *
5327 * \returns the kind of the chunk at the index \c chunk_number.
5328 */
5329CINDEX_LINKAGE enum CXCompletionChunkKind
5330clang_getCompletionChunkKind(CXCompletionString completion_string,
5331 unsigned chunk_number);
5332
5333/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005334 * Retrieve the text associated with a particular chunk within a
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005335 * completion string.
5336 *
5337 * \param completion_string the completion string to query.
5338 *
5339 * \param chunk_number the 0-based index of the chunk in the completion string.
5340 *
5341 * \returns the text associated with the chunk at index \c chunk_number.
5342 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02005343CINDEX_LINKAGE CXString clang_getCompletionChunkText(
5344 CXCompletionString completion_string, unsigned chunk_number);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005345
5346/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005347 * Retrieve the completion string associated with a particular chunk
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005348 * within a completion string.
5349 *
5350 * \param completion_string the completion string to query.
5351 *
5352 * \param chunk_number the 0-based index of the chunk in the completion string.
5353 *
5354 * \returns the completion string associated with the chunk at index
5355 * \c chunk_number.
5356 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02005357CINDEX_LINKAGE CXCompletionString clang_getCompletionChunkCompletionString(
5358 CXCompletionString completion_string, unsigned chunk_number);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005359
5360/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005361 * Retrieve the number of chunks in the given code-completion string.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005362 */
5363CINDEX_LINKAGE unsigned
5364clang_getNumCompletionChunks(CXCompletionString completion_string);
5365
5366/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005367 * Determine the priority of this code completion.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005368 *
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005369 * The priority of a code completion indicates how likely it is that this
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005370 * particular completion is the completion that the user will select. The
5371 * priority is selected by various internal heuristics.
5372 *
5373 * \param completion_string The completion string to query.
5374 *
5375 * \returns The priority of this completion string. Smaller values indicate
5376 * higher-priority (more likely) completions.
5377 */
5378CINDEX_LINKAGE unsigned
5379clang_getCompletionPriority(CXCompletionString completion_string);
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005380
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005381/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005382 * Determine the availability of the entity that this code-completion
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005383 * string refers to.
5384 *
5385 * \param completion_string The completion string to query.
5386 *
5387 * \returns The availability of the completion string.
5388 */
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005389CINDEX_LINKAGE enum CXAvailabilityKind
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005390clang_getCompletionAvailability(CXCompletionString completion_string);
5391
5392/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005393 * Retrieve the number of annotations associated with the given
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005394 * completion string.
5395 *
5396 * \param completion_string the completion string to query.
5397 *
5398 * \returns the number of annotations associated with the given completion
5399 * string.
5400 */
5401CINDEX_LINKAGE unsigned
5402clang_getCompletionNumAnnotations(CXCompletionString completion_string);
5403
5404/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005405 * Retrieve the annotation associated with the given completion string.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005406 *
5407 * \param completion_string the completion string to query.
5408 *
5409 * \param annotation_number the 0-based index of the annotation of the
5410 * completion string.
5411 *
5412 * \returns annotation string associated with the completion at index
5413 * \c annotation_number, or a NULL string if that annotation is not available.
5414 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02005415CINDEX_LINKAGE CXString clang_getCompletionAnnotation(
5416 CXCompletionString completion_string, unsigned annotation_number);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005417
5418/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005419 * Retrieve the parent context of the given completion string.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005420 *
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005421 * The parent context of a completion string is the semantic parent of
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005422 * the declaration (if any) that the code completion represents. For example,
5423 * a code completion for an Objective-C method would have the method's class
5424 * or protocol as its context.
5425 *
5426 * \param completion_string The code completion string whose parent is
5427 * being queried.
5428 *
5429 * \param kind DEPRECATED: always set to CXCursor_NotImplemented if non-NULL.
5430 *
5431 * \returns The name of the completion parent, e.g., "NSObject" if
5432 * the completion string represents a method in the NSObject class.
5433 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02005434CINDEX_LINKAGE CXString clang_getCompletionParent(
5435 CXCompletionString completion_string, enum CXCursorKind *kind);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005436
5437/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005438 * Retrieve the brief documentation comment attached to the declaration
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005439 * that corresponds to the given completion string.
5440 */
5441CINDEX_LINKAGE CXString
5442clang_getCompletionBriefComment(CXCompletionString completion_string);
5443
5444/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005445 * Retrieve a completion string for an arbitrary declaration or macro
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005446 * definition cursor.
5447 *
5448 * \param cursor The cursor to query.
5449 *
5450 * \returns A non-context-sensitive completion string for declaration and macro
5451 * definition cursors, or NULL for other kinds of cursors.
5452 */
5453CINDEX_LINKAGE CXCompletionString
5454clang_getCursorCompletionString(CXCursor cursor);
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005455
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005456/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005457 * Contains the results of code-completion.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005458 *
5459 * This data structure contains the results of code completion, as
5460 * produced by \c clang_codeCompleteAt(). Its contents must be freed by
5461 * \c clang_disposeCodeCompleteResults.
5462 */
5463typedef struct {
5464 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005465 * The code-completion results.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005466 */
5467 CXCompletionResult *Results;
5468
5469 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005470 * The number of code-completion results stored in the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005471 * \c Results array.
5472 */
5473 unsigned NumResults;
5474} CXCodeCompleteResults;
5475
5476/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005477 * Retrieve the number of fix-its for the given completion index.
5478 *
5479 * Calling this makes sense only if CXCodeComplete_IncludeCompletionsWithFixIts
5480 * option was set.
5481 *
5482 * \param results The structure keeping all completion results
5483 *
5484 * \param completion_index The index of the completion
5485 *
5486 * \return The number of fix-its which must be applied before the completion at
5487 * completion_index can be applied
5488 */
5489CINDEX_LINKAGE unsigned
5490clang_getCompletionNumFixIts(CXCodeCompleteResults *results,
5491 unsigned completion_index);
5492
5493/**
5494 * Fix-its that *must* be applied before inserting the text for the
5495 * corresponding completion.
5496 *
5497 * By default, clang_codeCompleteAt() only returns completions with empty
5498 * fix-its. Extra completions with non-empty fix-its should be explicitly
5499 * requested by setting CXCodeComplete_IncludeCompletionsWithFixIts.
5500 *
5501 * For the clients to be able to compute position of the cursor after applying
5502 * fix-its, the following conditions are guaranteed to hold for
5503 * replacement_range of the stored fix-its:
5504 * - Ranges in the fix-its are guaranteed to never contain the completion
5505 * point (or identifier under completion point, if any) inside them, except
5506 * at the start or at the end of the range.
5507 * - If a fix-it range starts or ends with completion point (or starts or
5508 * ends after the identifier under completion point), it will contain at
5509 * least one character. It allows to unambiguously recompute completion
5510 * point after applying the fix-it.
5511 *
5512 * The intuition is that provided fix-its change code around the identifier we
5513 * complete, but are not allowed to touch the identifier itself or the
5514 * completion point. One example of completions with corrections are the ones
5515 * replacing '.' with '->' and vice versa:
5516 *
5517 * std::unique_ptr<std::vector<int>> vec_ptr;
5518 * In 'vec_ptr.^', one of the completions is 'push_back', it requires
5519 * replacing '.' with '->'.
5520 * In 'vec_ptr->^', one of the completions is 'release', it requires
5521 * replacing '->' with '.'.
5522 *
5523 * \param results The structure keeping all completion results
5524 *
5525 * \param completion_index The index of the completion
5526 *
5527 * \param fixit_index The index of the fix-it for the completion at
5528 * completion_index
5529 *
5530 * \param replacement_range The fix-it range that must be replaced before the
5531 * completion at completion_index can be applied
5532 *
5533 * \returns The fix-it string that must replace the code at replacement_range
5534 * before the completion at completion_index can be applied
5535 */
5536CINDEX_LINKAGE CXString clang_getCompletionFixIt(
5537 CXCodeCompleteResults *results, unsigned completion_index,
5538 unsigned fixit_index, CXSourceRange *replacement_range);
5539
5540/**
5541 * Flags that can be passed to \c clang_codeCompleteAt() to
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005542 * modify its behavior.
5543 *
5544 * The enumerators in this enumeration can be bitwise-OR'd together to
5545 * provide multiple options to \c clang_codeCompleteAt().
5546 */
5547enum CXCodeComplete_Flags {
5548 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005549 * Whether to include macros within the set of code
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005550 * completions returned.
5551 */
5552 CXCodeComplete_IncludeMacros = 0x01,
5553
5554 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005555 * Whether to include code patterns for language constructs
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005556 * within the set of code completions, e.g., for loops.
5557 */
5558 CXCodeComplete_IncludeCodePatterns = 0x02,
5559
5560 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005561 * Whether to include brief documentation within the set of code
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005562 * completions returned.
5563 */
5564 CXCodeComplete_IncludeBriefComments = 0x04,
5565
5566 /**
5567 * Whether to speed up completion by omitting top- or namespace-level entities
5568 * defined in the preamble. There's no guarantee any particular entity is
5569 * omitted. This may be useful if the headers are indexed externally.
5570 */
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005571 CXCodeComplete_SkipPreamble = 0x08,
5572
5573 /**
5574 * Whether to include completions with small
5575 * fix-its, e.g. change '.' to '->' on member access, etc.
5576 */
5577 CXCodeComplete_IncludeCompletionsWithFixIts = 0x10
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005578};
5579
5580/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005581 * Bits that represent the context under which completion is occurring.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005582 *
5583 * The enumerators in this enumeration may be bitwise-OR'd together if multiple
5584 * contexts are occurring simultaneously.
5585 */
5586enum CXCompletionContext {
5587 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005588 * The context for completions is unexposed, as only Clang results
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005589 * should be included. (This is equivalent to having no context bits set.)
5590 */
5591 CXCompletionContext_Unexposed = 0,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005592
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005593 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005594 * Completions for any possible type should be included in the results.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005595 */
5596 CXCompletionContext_AnyType = 1 << 0,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005597
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005598 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005599 * Completions for any possible value (variables, function calls, etc.)
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005600 * should be included in the results.
5601 */
5602 CXCompletionContext_AnyValue = 1 << 1,
5603 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005604 * Completions for values that resolve to an Objective-C object should
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005605 * be included in the results.
5606 */
5607 CXCompletionContext_ObjCObjectValue = 1 << 2,
5608 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005609 * Completions for values that resolve to an Objective-C selector
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005610 * should be included in the results.
5611 */
5612 CXCompletionContext_ObjCSelectorValue = 1 << 3,
5613 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005614 * Completions for values that resolve to a C++ class type should be
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005615 * included in the results.
5616 */
5617 CXCompletionContext_CXXClassTypeValue = 1 << 4,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005618
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005619 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005620 * Completions for fields of the member being accessed using the dot
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005621 * operator should be included in the results.
5622 */
5623 CXCompletionContext_DotMemberAccess = 1 << 5,
5624 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005625 * Completions for fields of the member being accessed using the arrow
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005626 * operator should be included in the results.
5627 */
5628 CXCompletionContext_ArrowMemberAccess = 1 << 6,
5629 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005630 * Completions for properties of the Objective-C object being accessed
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005631 * using the dot operator should be included in the results.
5632 */
5633 CXCompletionContext_ObjCPropertyAccess = 1 << 7,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005634
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005635 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005636 * Completions for enum tags should be included in the results.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005637 */
5638 CXCompletionContext_EnumTag = 1 << 8,
5639 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005640 * Completions for union tags should be included in the results.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005641 */
5642 CXCompletionContext_UnionTag = 1 << 9,
5643 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005644 * Completions for struct tags should be included in the results.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005645 */
5646 CXCompletionContext_StructTag = 1 << 10,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005647
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005648 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005649 * Completions for C++ class names should be included in the results.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005650 */
5651 CXCompletionContext_ClassTag = 1 << 11,
5652 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005653 * Completions for C++ namespaces and namespace aliases should be
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005654 * included in the results.
5655 */
5656 CXCompletionContext_Namespace = 1 << 12,
5657 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005658 * Completions for C++ nested name specifiers should be included in
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005659 * the results.
5660 */
5661 CXCompletionContext_NestedNameSpecifier = 1 << 13,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005662
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005663 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005664 * Completions for Objective-C interfaces (classes) should be included
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005665 * in the results.
5666 */
5667 CXCompletionContext_ObjCInterface = 1 << 14,
5668 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005669 * Completions for Objective-C protocols should be included in
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005670 * the results.
5671 */
5672 CXCompletionContext_ObjCProtocol = 1 << 15,
5673 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005674 * Completions for Objective-C categories should be included in
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005675 * the results.
5676 */
5677 CXCompletionContext_ObjCCategory = 1 << 16,
5678 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005679 * Completions for Objective-C instance messages should be included
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005680 * in the results.
5681 */
5682 CXCompletionContext_ObjCInstanceMessage = 1 << 17,
5683 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005684 * Completions for Objective-C class messages should be included in
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005685 * the results.
5686 */
5687 CXCompletionContext_ObjCClassMessage = 1 << 18,
5688 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005689 * Completions for Objective-C selector names should be included in
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005690 * the results.
5691 */
5692 CXCompletionContext_ObjCSelectorName = 1 << 19,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005693
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005694 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005695 * Completions for preprocessor macro names should be included in
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005696 * the results.
5697 */
5698 CXCompletionContext_MacroName = 1 << 20,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005699
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005700 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005701 * Natural language completions should be included in the results.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005702 */
5703 CXCompletionContext_NaturalLanguage = 1 << 21,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005704
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005705 /**
Andrew Scull0372a572018-11-16 15:47:06 +00005706 * #include file completions should be included in the results.
5707 */
5708 CXCompletionContext_IncludedFile = 1 << 22,
5709
5710 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005711 * The current context is unknown, so set all contexts.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005712 */
Andrew Scull0372a572018-11-16 15:47:06 +00005713 CXCompletionContext_Unknown = ((1 << 23) - 1)
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005714};
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005715
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005716/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005717 * Returns a default set of code-completion options that can be
5718 * passed to\c clang_codeCompleteAt().
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005719 */
5720CINDEX_LINKAGE unsigned clang_defaultCodeCompleteOptions(void);
5721
5722/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005723 * Perform code completion at a given location in a translation unit.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005724 *
5725 * This function performs code completion at a particular file, line, and
5726 * column within source code, providing results that suggest potential
5727 * code snippets based on the context of the completion. The basic model
5728 * for code completion is that Clang will parse a complete source file,
5729 * performing syntax checking up to the location where code-completion has
5730 * been requested. At that point, a special code-completion token is passed
5731 * to the parser, which recognizes this token and determines, based on the
5732 * current location in the C/Objective-C/C++ grammar and the state of
5733 * semantic analysis, what completions to provide. These completions are
5734 * returned via a new \c CXCodeCompleteResults structure.
5735 *
5736 * Code completion itself is meant to be triggered by the client when the
5737 * user types punctuation characters or whitespace, at which point the
5738 * code-completion location will coincide with the cursor. For example, if \c p
5739 * is a pointer, code-completion might be triggered after the "-" and then
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005740 * after the ">" in \c p->. When the code-completion location is after the ">",
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005741 * the completion results will provide, e.g., the members of the struct that
5742 * "p" points to. The client is responsible for placing the cursor at the
5743 * beginning of the token currently being typed, then filtering the results
5744 * based on the contents of the token. For example, when code-completing for
5745 * the expression \c p->get, the client should provide the location just after
5746 * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the
5747 * client can filter the results based on the current token text ("get"), only
5748 * showing those results that start with "get". The intent of this interface
5749 * is to separate the relatively high-latency acquisition of code-completion
5750 * results from the filtering of results on a per-character basis, which must
5751 * have a lower latency.
5752 *
5753 * \param TU The translation unit in which code-completion should
5754 * occur. The source files for this translation unit need not be
5755 * completely up-to-date (and the contents of those source files may
5756 * be overridden via \p unsaved_files). Cursors referring into the
5757 * translation unit may be invalidated by this invocation.
5758 *
5759 * \param complete_filename The name of the source file where code
5760 * completion should be performed. This filename may be any file
5761 * included in the translation unit.
5762 *
5763 * \param complete_line The line at which code-completion should occur.
5764 *
5765 * \param complete_column The column at which code-completion should occur.
5766 * Note that the column should point just after the syntactic construct that
5767 * initiated code completion, and not in the middle of a lexical token.
5768 *
5769 * \param unsaved_files the Files that have not yet been saved to disk
5770 * but may be required for parsing or code completion, including the
5771 * contents of those files. The contents and name of these files (as
5772 * specified by CXUnsavedFile) are copied when necessary, so the
5773 * client only needs to guarantee their validity until the call to
5774 * this function returns.
5775 *
5776 * \param num_unsaved_files The number of unsaved file entries in \p
5777 * unsaved_files.
5778 *
5779 * \param options Extra options that control the behavior of code
5780 * completion, expressed as a bitwise OR of the enumerators of the
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005781 * CXCodeComplete_Flags enumeration. The
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005782 * \c clang_defaultCodeCompleteOptions() function returns a default set
5783 * of code-completion options.
5784 *
5785 * \returns If successful, a new \c CXCodeCompleteResults structure
5786 * containing code-completion results, which should eventually be
5787 * freed with \c clang_disposeCodeCompleteResults(). If code
5788 * completion fails, returns NULL.
5789 */
5790CINDEX_LINKAGE
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02005791CXCodeCompleteResults *
5792clang_codeCompleteAt(CXTranslationUnit TU, const char *complete_filename,
5793 unsigned complete_line, unsigned complete_column,
5794 struct CXUnsavedFile *unsaved_files,
5795 unsigned num_unsaved_files, unsigned options);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005796
5797/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005798 * Sort the code-completion results in case-insensitive alphabetical
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005799 * order.
5800 *
5801 * \param Results The set of results to sort.
5802 * \param NumResults The number of results in \p Results.
5803 */
5804CINDEX_LINKAGE
5805void clang_sortCodeCompletionResults(CXCompletionResult *Results,
5806 unsigned NumResults);
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005807
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005808/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005809 * Free the given set of code-completion results.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005810 */
5811CINDEX_LINKAGE
5812void clang_disposeCodeCompleteResults(CXCodeCompleteResults *Results);
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005813
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005814/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005815 * Determine the number of diagnostics produced prior to the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005816 * location where code completion was performed.
5817 */
5818CINDEX_LINKAGE
5819unsigned clang_codeCompleteGetNumDiagnostics(CXCodeCompleteResults *Results);
5820
5821/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005822 * Retrieve a diagnostic associated with the given code completion.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005823 *
5824 * \param Results the code completion results to query.
5825 * \param Index the zero-based diagnostic number to retrieve.
5826 *
5827 * \returns the requested diagnostic. This diagnostic must be freed
5828 * via a call to \c clang_disposeDiagnostic().
5829 */
5830CINDEX_LINKAGE
5831CXDiagnostic clang_codeCompleteGetDiagnostic(CXCodeCompleteResults *Results,
5832 unsigned Index);
5833
5834/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005835 * Determines what completions are appropriate for the context
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005836 * the given code completion.
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005837 *
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005838 * \param Results the code completion results to query
5839 *
5840 * \returns the kinds of completions that are appropriate for use
5841 * along with the given code completion results.
5842 */
5843CINDEX_LINKAGE
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02005844unsigned long long
5845clang_codeCompleteGetContexts(CXCodeCompleteResults *Results);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005846
5847/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005848 * Returns the cursor kind for the container for the current code
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005849 * completion context. The container is only guaranteed to be set for
5850 * contexts where a container exists (i.e. member accesses or Objective-C
5851 * message sends); if there is not a container, this function will return
5852 * CXCursor_InvalidCode.
5853 *
5854 * \param Results the code completion results to query
5855 *
5856 * \param IsIncomplete on return, this value will be false if Clang has complete
5857 * information about the container. If Clang does not have complete
5858 * information, this value will be true.
5859 *
5860 * \returns the container kind, or CXCursor_InvalidCode if there is not a
5861 * container
5862 */
5863CINDEX_LINKAGE
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02005864enum CXCursorKind
5865clang_codeCompleteGetContainerKind(CXCodeCompleteResults *Results,
5866 unsigned *IsIncomplete);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005867
5868/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005869 * Returns the USR for the container for the current code completion
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005870 * context. If there is not a container for the current context, this
5871 * function will return the empty string.
5872 *
5873 * \param Results the code completion results to query
5874 *
5875 * \returns the USR for the container
5876 */
5877CINDEX_LINKAGE
5878CXString clang_codeCompleteGetContainerUSR(CXCodeCompleteResults *Results);
5879
5880/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005881 * Returns the currently-entered selector for an Objective-C message
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005882 * send, formatted like "initWithFoo:bar:". Only guaranteed to return a
5883 * non-empty string for CXCompletionContext_ObjCInstanceMessage and
5884 * CXCompletionContext_ObjCClassMessage.
5885 *
5886 * \param Results the code completion results to query
5887 *
5888 * \returns the selector (or partial selector) that has been entered thus far
5889 * for an Objective-C message send.
5890 */
5891CINDEX_LINKAGE
5892CXString clang_codeCompleteGetObjCSelector(CXCodeCompleteResults *Results);
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005893
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005894/**
5895 * @}
5896 */
5897
5898/**
5899 * \defgroup CINDEX_MISC Miscellaneous utility functions
5900 *
5901 * @{
5902 */
5903
5904/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005905 * Return a version string, suitable for showing to a user, but not
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005906 * intended to be parsed (the format is not guaranteed to be stable).
5907 */
5908CINDEX_LINKAGE CXString clang_getClangVersion(void);
5909
5910/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005911 * Enable/disable crash recovery.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005912 *
5913 * \param isEnabled Flag to indicate if crash recovery is enabled. A non-zero
5914 * value enables crash recovery, while 0 disables it.
5915 */
5916CINDEX_LINKAGE void clang_toggleCrashRecovery(unsigned isEnabled);
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005917
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02005918/**
5919 * Visitor invoked for each file in a translation unit
5920 * (used with clang_getInclusions()).
5921 *
5922 * This visitor function will be invoked by clang_getInclusions() for each
5923 * file included (either at the top-level or by \#include directives) within
5924 * a translation unit. The first argument is the file being included, and
5925 * the second and third arguments provide the inclusion stack. The
5926 * array is sorted in order of immediate inclusion. For example,
5927 * the first element refers to the location that included 'included_file'.
5928 */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005929typedef void (*CXInclusionVisitor)(CXFile included_file,
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02005930 CXSourceLocation *inclusion_stack,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005931 unsigned include_len,
5932 CXClientData client_data);
5933
5934/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005935 * Visit the set of preprocessor inclusions in a translation unit.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005936 * The visitor function is called with the provided data for every included
5937 * file. This does not include headers included by the PCH file (unless one
5938 * is inspecting the inclusions in the PCH file itself).
5939 */
5940CINDEX_LINKAGE void clang_getInclusions(CXTranslationUnit tu,
5941 CXInclusionVisitor visitor,
5942 CXClientData client_data);
5943
5944typedef enum {
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02005945 CXEval_Int = 1,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005946 CXEval_Float = 2,
5947 CXEval_ObjCStrLiteral = 3,
5948 CXEval_StrLiteral = 4,
5949 CXEval_CFStr = 5,
5950 CXEval_Other = 6,
5951
5952 CXEval_UnExposed = 0
5953
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02005954} CXEvalResultKind;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005955
5956/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005957 * Evaluation result of a cursor
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005958 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02005959typedef void *CXEvalResult;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005960
5961/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005962 * If cursor is a statement declaration tries to evaluate the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005963 * statement and if its variable, tries to evaluate its initializer,
5964 * into its corresponding type.
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02005965 * If it's an expression, tries to evaluate the expression.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005966 */
5967CINDEX_LINKAGE CXEvalResult clang_Cursor_Evaluate(CXCursor C);
5968
5969/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005970 * Returns the kind of the evaluated result.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005971 */
5972CINDEX_LINKAGE CXEvalResultKind clang_EvalResult_getKind(CXEvalResult E);
5973
5974/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005975 * Returns the evaluation result as integer if the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005976 * kind is Int.
5977 */
5978CINDEX_LINKAGE int clang_EvalResult_getAsInt(CXEvalResult E);
5979
5980/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005981 * Returns the evaluation result as a long long integer if the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005982 * kind is Int. This prevents overflows that may happen if the result is
5983 * returned with clang_EvalResult_getAsInt.
5984 */
5985CINDEX_LINKAGE long long clang_EvalResult_getAsLongLong(CXEvalResult E);
5986
5987/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005988 * Returns a non-zero value if the kind is Int and the evaluation
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005989 * result resulted in an unsigned integer.
5990 */
5991CINDEX_LINKAGE unsigned clang_EvalResult_isUnsignedInt(CXEvalResult E);
5992
5993/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005994 * Returns the evaluation result as an unsigned integer if
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005995 * the kind is Int and clang_EvalResult_isUnsignedInt is non-zero.
5996 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02005997CINDEX_LINKAGE unsigned long long
5998clang_EvalResult_getAsUnsigned(CXEvalResult E);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005999
6000/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006001 * Returns the evaluation result as double if the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006002 * kind is double.
6003 */
6004CINDEX_LINKAGE double clang_EvalResult_getAsDouble(CXEvalResult E);
6005
6006/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006007 * Returns the evaluation result as a constant string if the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006008 * kind is other than Int or float. User must not free this pointer,
6009 * instead call clang_EvalResult_dispose on the CXEvalResult returned
6010 * by clang_Cursor_Evaluate.
6011 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02006012CINDEX_LINKAGE const char *clang_EvalResult_getAsStr(CXEvalResult E);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006013
6014/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006015 * Disposes the created Eval memory.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006016 */
6017CINDEX_LINKAGE void clang_EvalResult_dispose(CXEvalResult E);
6018/**
6019 * @}
6020 */
6021
6022/** \defgroup CINDEX_REMAPPING Remapping functions
6023 *
6024 * @{
6025 */
6026
6027/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006028 * A remapping of original source files and their translated files.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006029 */
6030typedef void *CXRemapping;
6031
6032/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006033 * Retrieve a remapping.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006034 *
6035 * \param path the path that contains metadata about remappings.
6036 *
6037 * \returns the requested remapping. This remapping must be freed
6038 * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
6039 */
6040CINDEX_LINKAGE CXRemapping clang_getRemappings(const char *path);
6041
6042/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006043 * Retrieve a remapping.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006044 *
6045 * \param filePaths pointer to an array of file paths containing remapping info.
6046 *
6047 * \param numFiles number of file paths.
6048 *
6049 * \returns the requested remapping. This remapping must be freed
6050 * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
6051 */
6052CINDEX_LINKAGE
6053CXRemapping clang_getRemappingsFromFileList(const char **filePaths,
6054 unsigned numFiles);
6055
6056/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006057 * Determine the number of remappings.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006058 */
6059CINDEX_LINKAGE unsigned clang_remap_getNumFiles(CXRemapping);
6060
6061/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006062 * Get the original and the associated filename from the remapping.
6063 *
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006064 * \param original If non-NULL, will be set to the original filename.
6065 *
6066 * \param transformed If non-NULL, will be set to the filename that the original
6067 * is associated with.
6068 */
6069CINDEX_LINKAGE void clang_remap_getFilenames(CXRemapping, unsigned index,
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02006070 CXString *original,
6071 CXString *transformed);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006072
6073/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006074 * Dispose the remapping.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006075 */
6076CINDEX_LINKAGE void clang_remap_dispose(CXRemapping);
6077
6078/**
6079 * @}
6080 */
6081
6082/** \defgroup CINDEX_HIGH Higher level API functions
6083 *
6084 * @{
6085 */
6086
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02006087enum CXVisitorResult { CXVisit_Break, CXVisit_Continue };
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006088
6089typedef struct CXCursorAndRangeVisitor {
6090 void *context;
6091 enum CXVisitorResult (*visit)(void *context, CXCursor, CXSourceRange);
6092} CXCursorAndRangeVisitor;
6093
6094typedef enum {
6095 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006096 * Function returned successfully.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006097 */
6098 CXResult_Success = 0,
6099 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006100 * One of the parameters was invalid for the function.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006101 */
6102 CXResult_Invalid = 1,
6103 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006104 * The function was terminated by a callback (e.g. it returned
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006105 * CXVisit_Break)
6106 */
6107 CXResult_VisitBreak = 2
6108
6109} CXResult;
6110
6111/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006112 * Find references of a declaration in a specific file.
6113 *
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006114 * \param cursor pointing to a declaration or a reference of one.
6115 *
6116 * \param file to search for references.
6117 *
6118 * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
6119 * each reference found.
6120 * The CXSourceRange will point inside the file; if the reference is inside
6121 * a macro (and not a macro argument) the CXSourceRange will be invalid.
6122 *
6123 * \returns one of the CXResult enumerators.
6124 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02006125CINDEX_LINKAGE CXResult clang_findReferencesInFile(
6126 CXCursor cursor, CXFile file, CXCursorAndRangeVisitor visitor);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006127
6128/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006129 * Find #import/#include directives in a specific file.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006130 *
6131 * \param TU translation unit containing the file to query.
6132 *
6133 * \param file to search for #import/#include directives.
6134 *
6135 * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
6136 * each directive found.
6137 *
6138 * \returns one of the CXResult enumerators.
6139 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02006140CINDEX_LINKAGE CXResult clang_findIncludesInFile(
6141 CXTranslationUnit TU, CXFile file, CXCursorAndRangeVisitor visitor);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006142
6143#ifdef __has_feature
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02006144#if __has_feature(blocks)
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006145
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02006146typedef enum CXVisitorResult (^CXCursorAndRangeVisitorBlock)(CXCursor,
6147 CXSourceRange);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006148
6149CINDEX_LINKAGE
6150CXResult clang_findReferencesInFileWithBlock(CXCursor, CXFile,
6151 CXCursorAndRangeVisitorBlock);
6152
6153CINDEX_LINKAGE
6154CXResult clang_findIncludesInFileWithBlock(CXTranslationUnit, CXFile,
6155 CXCursorAndRangeVisitorBlock);
6156
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02006157#endif
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006158#endif
6159
6160/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006161 * The client's data object that is associated with a CXFile.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006162 */
6163typedef void *CXIdxClientFile;
6164
6165/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006166 * The client's data object that is associated with a semantic entity.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006167 */
6168typedef void *CXIdxClientEntity;
6169
6170/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006171 * The client's data object that is associated with a semantic container
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006172 * of entities.
6173 */
6174typedef void *CXIdxClientContainer;
6175
6176/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006177 * The client's data object that is associated with an AST file (PCH
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006178 * or module).
6179 */
6180typedef void *CXIdxClientASTFile;
6181
6182/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006183 * Source location passed to index callbacks.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006184 */
6185typedef struct {
6186 void *ptr_data[2];
6187 unsigned int_data;
6188} CXIdxLoc;
6189
6190/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006191 * Data for ppIncludedFile callback.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006192 */
6193typedef struct {
6194 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006195 * Location of '#' in the \#include/\#import directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006196 */
6197 CXIdxLoc hashLoc;
6198 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006199 * Filename as written in the \#include/\#import directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006200 */
6201 const char *filename;
6202 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006203 * The actual file that the \#include/\#import directive resolved to.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006204 */
6205 CXFile file;
6206 int isImport;
6207 int isAngled;
6208 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006209 * Non-zero if the directive was automatically turned into a module
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006210 * import.
6211 */
6212 int isModuleImport;
6213} CXIdxIncludedFileInfo;
6214
6215/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006216 * Data for IndexerCallbacks#importedASTFile.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006217 */
6218typedef struct {
6219 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006220 * Top level AST file containing the imported PCH, module or submodule.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006221 */
6222 CXFile file;
6223 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006224 * The imported module or NULL if the AST file is a PCH.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006225 */
6226 CXModule module;
6227 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006228 * Location where the file is imported. Applicable only for modules.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006229 */
6230 CXIdxLoc loc;
6231 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006232 * Non-zero if an inclusion directive was automatically turned into
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006233 * a module import. Applicable only for modules.
6234 */
6235 int isImplicit;
6236
6237} CXIdxImportedASTFileInfo;
6238
6239typedef enum {
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02006240 CXIdxEntity_Unexposed = 0,
6241 CXIdxEntity_Typedef = 1,
6242 CXIdxEntity_Function = 2,
6243 CXIdxEntity_Variable = 3,
6244 CXIdxEntity_Field = 4,
6245 CXIdxEntity_EnumConstant = 5,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006246
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02006247 CXIdxEntity_ObjCClass = 6,
6248 CXIdxEntity_ObjCProtocol = 7,
6249 CXIdxEntity_ObjCCategory = 8,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006250
6251 CXIdxEntity_ObjCInstanceMethod = 9,
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02006252 CXIdxEntity_ObjCClassMethod = 10,
6253 CXIdxEntity_ObjCProperty = 11,
6254 CXIdxEntity_ObjCIvar = 12,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006255
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02006256 CXIdxEntity_Enum = 13,
6257 CXIdxEntity_Struct = 14,
6258 CXIdxEntity_Union = 15,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006259
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02006260 CXIdxEntity_CXXClass = 16,
6261 CXIdxEntity_CXXNamespace = 17,
6262 CXIdxEntity_CXXNamespaceAlias = 18,
6263 CXIdxEntity_CXXStaticVariable = 19,
6264 CXIdxEntity_CXXStaticMethod = 20,
6265 CXIdxEntity_CXXInstanceMethod = 21,
6266 CXIdxEntity_CXXConstructor = 22,
6267 CXIdxEntity_CXXDestructor = 23,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006268 CXIdxEntity_CXXConversionFunction = 24,
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02006269 CXIdxEntity_CXXTypeAlias = 25,
6270 CXIdxEntity_CXXInterface = 26
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006271
6272} CXIdxEntityKind;
6273
6274typedef enum {
6275 CXIdxEntityLang_None = 0,
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02006276 CXIdxEntityLang_C = 1,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006277 CXIdxEntityLang_ObjC = 2,
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02006278 CXIdxEntityLang_CXX = 3,
6279 CXIdxEntityLang_Swift = 4
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006280} CXIdxEntityLanguage;
6281
6282/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006283 * Extra C++ template information for an entity. This can apply to:
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006284 * CXIdxEntity_Function
6285 * CXIdxEntity_CXXClass
6286 * CXIdxEntity_CXXStaticMethod
6287 * CXIdxEntity_CXXInstanceMethod
6288 * CXIdxEntity_CXXConstructor
6289 * CXIdxEntity_CXXConversionFunction
6290 * CXIdxEntity_CXXTypeAlias
6291 */
6292typedef enum {
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02006293 CXIdxEntity_NonTemplate = 0,
6294 CXIdxEntity_Template = 1,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006295 CXIdxEntity_TemplatePartialSpecialization = 2,
6296 CXIdxEntity_TemplateSpecialization = 3
6297} CXIdxEntityCXXTemplateKind;
6298
6299typedef enum {
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02006300 CXIdxAttr_Unexposed = 0,
6301 CXIdxAttr_IBAction = 1,
6302 CXIdxAttr_IBOutlet = 2,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006303 CXIdxAttr_IBOutletCollection = 3
6304} CXIdxAttrKind;
6305
6306typedef struct {
6307 CXIdxAttrKind kind;
6308 CXCursor cursor;
6309 CXIdxLoc loc;
6310} CXIdxAttrInfo;
6311
6312typedef struct {
6313 CXIdxEntityKind kind;
6314 CXIdxEntityCXXTemplateKind templateKind;
6315 CXIdxEntityLanguage lang;
6316 const char *name;
6317 const char *USR;
6318 CXCursor cursor;
6319 const CXIdxAttrInfo *const *attributes;
6320 unsigned numAttributes;
6321} CXIdxEntityInfo;
6322
6323typedef struct {
6324 CXCursor cursor;
6325} CXIdxContainerInfo;
6326
6327typedef struct {
6328 const CXIdxAttrInfo *attrInfo;
6329 const CXIdxEntityInfo *objcClass;
6330 CXCursor classCursor;
6331 CXIdxLoc classLoc;
6332} CXIdxIBOutletCollectionAttrInfo;
6333
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02006334typedef enum { CXIdxDeclFlag_Skipped = 0x1 } CXIdxDeclInfoFlags;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006335
6336typedef struct {
6337 const CXIdxEntityInfo *entityInfo;
6338 CXCursor cursor;
6339 CXIdxLoc loc;
6340 const CXIdxContainerInfo *semanticContainer;
6341 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006342 * Generally same as #semanticContainer but can be different in
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006343 * cases like out-of-line C++ member functions.
6344 */
6345 const CXIdxContainerInfo *lexicalContainer;
6346 int isRedeclaration;
6347 int isDefinition;
6348 int isContainer;
6349 const CXIdxContainerInfo *declAsContainer;
6350 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006351 * Whether the declaration exists in code or was created implicitly
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006352 * by the compiler, e.g. implicit Objective-C methods for properties.
6353 */
6354 int isImplicit;
6355 const CXIdxAttrInfo *const *attributes;
6356 unsigned numAttributes;
6357
6358 unsigned flags;
6359
6360} CXIdxDeclInfo;
6361
6362typedef enum {
6363 CXIdxObjCContainer_ForwardRef = 0,
6364 CXIdxObjCContainer_Interface = 1,
6365 CXIdxObjCContainer_Implementation = 2
6366} CXIdxObjCContainerKind;
6367
6368typedef struct {
6369 const CXIdxDeclInfo *declInfo;
6370 CXIdxObjCContainerKind kind;
6371} CXIdxObjCContainerDeclInfo;
6372
6373typedef struct {
6374 const CXIdxEntityInfo *base;
6375 CXCursor cursor;
6376 CXIdxLoc loc;
6377} CXIdxBaseClassInfo;
6378
6379typedef struct {
6380 const CXIdxEntityInfo *protocol;
6381 CXCursor cursor;
6382 CXIdxLoc loc;
6383} CXIdxObjCProtocolRefInfo;
6384
6385typedef struct {
6386 const CXIdxObjCProtocolRefInfo *const *protocols;
6387 unsigned numProtocols;
6388} CXIdxObjCProtocolRefListInfo;
6389
6390typedef struct {
6391 const CXIdxObjCContainerDeclInfo *containerInfo;
6392 const CXIdxBaseClassInfo *superInfo;
6393 const CXIdxObjCProtocolRefListInfo *protocols;
6394} CXIdxObjCInterfaceDeclInfo;
6395
6396typedef struct {
6397 const CXIdxObjCContainerDeclInfo *containerInfo;
6398 const CXIdxEntityInfo *objcClass;
6399 CXCursor classCursor;
6400 CXIdxLoc classLoc;
6401 const CXIdxObjCProtocolRefListInfo *protocols;
6402} CXIdxObjCCategoryDeclInfo;
6403
6404typedef struct {
6405 const CXIdxDeclInfo *declInfo;
6406 const CXIdxEntityInfo *getter;
6407 const CXIdxEntityInfo *setter;
6408} CXIdxObjCPropertyDeclInfo;
6409
6410typedef struct {
6411 const CXIdxDeclInfo *declInfo;
6412 const CXIdxBaseClassInfo *const *bases;
6413 unsigned numBases;
6414} CXIdxCXXClassDeclInfo;
6415
6416/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006417 * Data for IndexerCallbacks#indexEntityReference.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006418 *
6419 * This may be deprecated in a future version as this duplicates
6420 * the \c CXSymbolRole_Implicit bit in \c CXSymbolRole.
6421 */
6422typedef enum {
6423 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006424 * The entity is referenced directly in user's code.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006425 */
6426 CXIdxEntityRef_Direct = 1,
6427 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006428 * An implicit reference, e.g. a reference of an Objective-C method
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006429 * via the dot syntax.
6430 */
6431 CXIdxEntityRef_Implicit = 2
6432} CXIdxEntityRefKind;
6433
6434/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006435 * Roles that are attributed to symbol occurrences.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006436 *
6437 * Internal: this currently mirrors low 9 bits of clang::index::SymbolRole with
6438 * higher bits zeroed. These high bits may be exposed in the future.
6439 */
6440typedef enum {
6441 CXSymbolRole_None = 0,
6442 CXSymbolRole_Declaration = 1 << 0,
6443 CXSymbolRole_Definition = 1 << 1,
6444 CXSymbolRole_Reference = 1 << 2,
6445 CXSymbolRole_Read = 1 << 3,
6446 CXSymbolRole_Write = 1 << 4,
6447 CXSymbolRole_Call = 1 << 5,
6448 CXSymbolRole_Dynamic = 1 << 6,
6449 CXSymbolRole_AddressOf = 1 << 7,
6450 CXSymbolRole_Implicit = 1 << 8
6451} CXSymbolRole;
6452
6453/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006454 * Data for IndexerCallbacks#indexEntityReference.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006455 */
6456typedef struct {
6457 CXIdxEntityRefKind kind;
6458 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006459 * Reference cursor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006460 */
6461 CXCursor cursor;
6462 CXIdxLoc loc;
6463 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006464 * The entity that gets referenced.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006465 */
6466 const CXIdxEntityInfo *referencedEntity;
6467 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006468 * Immediate "parent" of the reference. For example:
6469 *
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006470 * \code
6471 * Foo *var;
6472 * \endcode
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006473 *
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006474 * The parent of reference of type 'Foo' is the variable 'var'.
6475 * For references inside statement bodies of functions/methods,
6476 * the parentEntity will be the function/method.
6477 */
6478 const CXIdxEntityInfo *parentEntity;
6479 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006480 * Lexical container context of the reference.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006481 */
6482 const CXIdxContainerInfo *container;
6483 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006484 * Sets of symbol roles of the reference.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006485 */
6486 CXSymbolRole role;
6487} CXIdxEntityRefInfo;
6488
6489/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006490 * A group of callbacks used by #clang_indexSourceFile and
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006491 * #clang_indexTranslationUnit.
6492 */
6493typedef struct {
6494 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006495 * Called periodically to check whether indexing should be aborted.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006496 * Should return 0 to continue, and non-zero to abort.
6497 */
6498 int (*abortQuery)(CXClientData client_data, void *reserved);
6499
6500 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006501 * Called at the end of indexing; passes the complete diagnostic set.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006502 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02006503 void (*diagnostic)(CXClientData client_data, CXDiagnosticSet, void *reserved);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006504
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02006505 CXIdxClientFile (*enteredMainFile)(CXClientData client_data, CXFile mainFile,
6506 void *reserved);
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006507
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006508 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006509 * Called when a file gets \#included/\#imported.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006510 */
6511 CXIdxClientFile (*ppIncludedFile)(CXClientData client_data,
6512 const CXIdxIncludedFileInfo *);
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006513
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006514 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006515 * Called when a AST file (PCH or module) gets imported.
6516 *
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006517 * AST files will not get indexed (there will not be callbacks to index all
6518 * the entities in an AST file). The recommended action is that, if the AST
6519 * file is not already indexed, to initiate a new indexing job specific to
6520 * the AST file.
6521 */
6522 CXIdxClientASTFile (*importedASTFile)(CXClientData client_data,
6523 const CXIdxImportedASTFileInfo *);
6524
6525 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006526 * Called at the beginning of indexing a translation unit.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006527 */
6528 CXIdxClientContainer (*startedTranslationUnit)(CXClientData client_data,
6529 void *reserved);
6530
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02006531 void (*indexDeclaration)(CXClientData client_data, const CXIdxDeclInfo *);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006532
6533 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006534 * Called to index a reference of an entity.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006535 */
6536 void (*indexEntityReference)(CXClientData client_data,
6537 const CXIdxEntityRefInfo *);
6538
6539} IndexerCallbacks;
6540
6541CINDEX_LINKAGE int clang_index_isEntityObjCContainerKind(CXIdxEntityKind);
6542CINDEX_LINKAGE const CXIdxObjCContainerDeclInfo *
6543clang_index_getObjCContainerDeclInfo(const CXIdxDeclInfo *);
6544
6545CINDEX_LINKAGE const CXIdxObjCInterfaceDeclInfo *
6546clang_index_getObjCInterfaceDeclInfo(const CXIdxDeclInfo *);
6547
6548CINDEX_LINKAGE
6549const CXIdxObjCCategoryDeclInfo *
6550clang_index_getObjCCategoryDeclInfo(const CXIdxDeclInfo *);
6551
6552CINDEX_LINKAGE const CXIdxObjCProtocolRefListInfo *
6553clang_index_getObjCProtocolRefListInfo(const CXIdxDeclInfo *);
6554
6555CINDEX_LINKAGE const CXIdxObjCPropertyDeclInfo *
6556clang_index_getObjCPropertyDeclInfo(const CXIdxDeclInfo *);
6557
6558CINDEX_LINKAGE const CXIdxIBOutletCollectionAttrInfo *
6559clang_index_getIBOutletCollectionAttrInfo(const CXIdxAttrInfo *);
6560
6561CINDEX_LINKAGE const CXIdxCXXClassDeclInfo *
6562clang_index_getCXXClassDeclInfo(const CXIdxDeclInfo *);
6563
6564/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006565 * For retrieving a custom CXIdxClientContainer attached to a
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006566 * container.
6567 */
6568CINDEX_LINKAGE CXIdxClientContainer
6569clang_index_getClientContainer(const CXIdxContainerInfo *);
6570
6571/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006572 * For setting a custom CXIdxClientContainer attached to a
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006573 * container.
6574 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02006575CINDEX_LINKAGE void clang_index_setClientContainer(const CXIdxContainerInfo *,
6576 CXIdxClientContainer);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006577
6578/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006579 * For retrieving a custom CXIdxClientEntity attached to an entity.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006580 */
6581CINDEX_LINKAGE CXIdxClientEntity
6582clang_index_getClientEntity(const CXIdxEntityInfo *);
6583
6584/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006585 * For setting a custom CXIdxClientEntity attached to an entity.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006586 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02006587CINDEX_LINKAGE void clang_index_setClientEntity(const CXIdxEntityInfo *,
6588 CXIdxClientEntity);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006589
6590/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006591 * An indexing action/session, to be applied to one or multiple
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006592 * translation units.
6593 */
6594typedef void *CXIndexAction;
6595
6596/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006597 * An indexing action/session, to be applied to one or multiple
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006598 * translation units.
6599 *
6600 * \param CIdx The index object with which the index action will be associated.
6601 */
6602CINDEX_LINKAGE CXIndexAction clang_IndexAction_create(CXIndex CIdx);
6603
6604/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006605 * Destroy the given index action.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006606 *
6607 * The index action must not be destroyed until all of the translation units
6608 * created within that index action have been destroyed.
6609 */
6610CINDEX_LINKAGE void clang_IndexAction_dispose(CXIndexAction);
6611
6612typedef enum {
6613 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006614 * Used to indicate that no special indexing options are needed.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006615 */
6616 CXIndexOpt_None = 0x0,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006617
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006618 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006619 * Used to indicate that IndexerCallbacks#indexEntityReference should
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006620 * be invoked for only one reference of an entity per source file that does
6621 * not also include a declaration/definition of the entity.
6622 */
6623 CXIndexOpt_SuppressRedundantRefs = 0x1,
6624
6625 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006626 * Function-local symbols should be indexed. If this is not set
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006627 * function-local symbols will be ignored.
6628 */
6629 CXIndexOpt_IndexFunctionLocalSymbols = 0x2,
6630
6631 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006632 * Implicit function/class template instantiations should be indexed.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006633 * If this is not set, implicit instantiations will be ignored.
6634 */
6635 CXIndexOpt_IndexImplicitTemplateInstantiations = 0x4,
6636
6637 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006638 * Suppress all compiler warnings when parsing for indexing.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006639 */
6640 CXIndexOpt_SuppressWarnings = 0x8,
6641
6642 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006643 * Skip a function/method body that was already parsed during an
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006644 * indexing session associated with a \c CXIndexAction object.
6645 * Bodies in system headers are always skipped.
6646 */
6647 CXIndexOpt_SkipParsedBodiesInSession = 0x10
6648
6649} CXIndexOptFlags;
6650
6651/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006652 * Index the given source file and the translation unit corresponding
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006653 * to that file via callbacks implemented through #IndexerCallbacks.
6654 *
6655 * \param client_data pointer data supplied by the client, which will
6656 * be passed to the invoked callbacks.
6657 *
6658 * \param index_callbacks Pointer to indexing callbacks that the client
6659 * implements.
6660 *
6661 * \param index_callbacks_size Size of #IndexerCallbacks structure that gets
6662 * passed in index_callbacks.
6663 *
6664 * \param index_options A bitmask of options that affects how indexing is
6665 * performed. This should be a bitwise OR of the CXIndexOpt_XXX flags.
6666 *
6667 * \param[out] out_TU pointer to store a \c CXTranslationUnit that can be
6668 * reused after indexing is finished. Set to \c NULL if you do not require it.
6669 *
6670 * \returns 0 on success or if there were errors from which the compiler could
6671 * recover. If there is a failure from which there is no recovery, returns
6672 * a non-zero \c CXErrorCode.
6673 *
6674 * The rest of the parameters are the same as #clang_parseTranslationUnit.
6675 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02006676CINDEX_LINKAGE int clang_indexSourceFile(
6677 CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks,
6678 unsigned index_callbacks_size, unsigned index_options,
6679 const char *source_filename, const char *const *command_line_args,
6680 int num_command_line_args, struct CXUnsavedFile *unsaved_files,
6681 unsigned num_unsaved_files, CXTranslationUnit *out_TU, unsigned TU_options);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006682
6683/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006684 * Same as clang_indexSourceFile but requires a full command line
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006685 * for \c command_line_args including argv[0]. This is useful if the standard
6686 * library paths are relative to the binary.
6687 */
6688CINDEX_LINKAGE int clang_indexSourceFileFullArgv(
6689 CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks,
6690 unsigned index_callbacks_size, unsigned index_options,
6691 const char *source_filename, const char *const *command_line_args,
6692 int num_command_line_args, struct CXUnsavedFile *unsaved_files,
6693 unsigned num_unsaved_files, CXTranslationUnit *out_TU, unsigned TU_options);
6694
6695/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006696 * Index the given translation unit via callbacks implemented through
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006697 * #IndexerCallbacks.
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006698 *
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006699 * The order of callback invocations is not guaranteed to be the same as
6700 * when indexing a source file. The high level order will be:
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006701 *
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006702 * -Preprocessor callbacks invocations
6703 * -Declaration/reference callbacks invocations
6704 * -Diagnostic callback invocations
6705 *
6706 * The parameters are the same as #clang_indexSourceFile.
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006707 *
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006708 * \returns If there is a failure from which there is no recovery, returns
6709 * non-zero, otherwise returns 0.
6710 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02006711CINDEX_LINKAGE int clang_indexTranslationUnit(
6712 CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks,
6713 unsigned index_callbacks_size, unsigned index_options, CXTranslationUnit);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006714
6715/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006716 * Retrieve the CXIdxFile, file, line, column, and offset represented by
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006717 * the given CXIdxLoc.
6718 *
6719 * If the location refers into a macro expansion, retrieves the
6720 * location of the macro expansion and if it refers into a macro argument
6721 * retrieves the location of the argument.
6722 */
6723CINDEX_LINKAGE void clang_indexLoc_getFileLocation(CXIdxLoc loc,
6724 CXIdxClientFile *indexFile,
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02006725 CXFile *file, unsigned *line,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006726 unsigned *column,
6727 unsigned *offset);
6728
6729/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006730 * Retrieve the CXSourceLocation represented by the given CXIdxLoc.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006731 */
6732CINDEX_LINKAGE
6733CXSourceLocation clang_indexLoc_getCXSourceLocation(CXIdxLoc loc);
6734
6735/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006736 * Visitor invoked for each field found by a traversal.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006737 *
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/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006750 * Visit the fields of a particular type.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006751 *
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 */
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02006768CINDEX_LINKAGE unsigned clang_Type_visitFields(CXType T, CXFieldVisitor visitor,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006769 CXClientData client_data);
6770
6771/**
6772 * @}
6773 */
6774
6775/**
6776 * @}
6777 */
6778
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02006779LLVM_CLANG_C_EXTERN_C_END
6780
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006781#endif