blob: 38af8aa6d8b6c3783df76a6446d52452bff789f0 [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
21#include "clang-c/Platform.h"
22#include "clang-c/CXErrorCode.h"
23#include "clang-c/CXString.h"
24#include "clang-c/BuildSystem.h"
25
26/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +010027 * The version constants for the libclang API.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010028 * CINDEX_VERSION_MINOR should increase when there are API additions.
29 * CINDEX_VERSION_MAJOR is intended for "major" source/ABI breaking changes.
30 *
31 * The policy about the libclang API was always to keep it source and ABI
32 * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
33 */
34#define CINDEX_VERSION_MAJOR 0
Andrew Walbran16937d02019-10-22 13:54:20 +010035#define CINDEX_VERSION_MINOR 51
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010036
37#define CINDEX_VERSION_ENCODE(major, minor) ( \
38 ((major) * 10000) \
39 + ((minor) * 1))
40
41#define CINDEX_VERSION CINDEX_VERSION_ENCODE( \
42 CINDEX_VERSION_MAJOR, \
43 CINDEX_VERSION_MINOR )
44
45#define CINDEX_VERSION_STRINGIZE_(major, minor) \
46 #major"."#minor
47#define CINDEX_VERSION_STRINGIZE(major, minor) \
48 CINDEX_VERSION_STRINGIZE_(major, minor)
49
50#define CINDEX_VERSION_STRING CINDEX_VERSION_STRINGIZE( \
51 CINDEX_VERSION_MAJOR, \
52 CINDEX_VERSION_MINOR)
53
54#ifdef __cplusplus
55extern "C" {
56#endif
57
58/** \defgroup CINDEX libclang: C Interface to Clang
59 *
60 * The C Interface to Clang provides a relatively small API that exposes
61 * facilities for parsing source code into an abstract syntax tree (AST),
62 * loading already-parsed ASTs, traversing the AST, associating
63 * physical source locations with elements within the AST, and other
64 * facilities that support Clang-based development tools.
65 *
66 * This C interface to Clang will never provide all of the information
67 * representation stored in Clang's C++ AST, nor should it: the intent is to
68 * maintain an API that is relatively stable from one release to the next,
69 * providing only the basic functionality needed to support development tools.
70 *
71 * To avoid namespace pollution, data types are prefixed with "CX" and
72 * functions are prefixed with "clang_".
73 *
74 * @{
75 */
76
77/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +010078 * An "index" that consists of a set of translation units that would
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010079 * typically be linked together into an executable or library.
80 */
81typedef void *CXIndex;
82
83/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +010084 * An opaque type representing target information for a given translation
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010085 * unit.
86 */
87typedef struct CXTargetInfoImpl *CXTargetInfo;
88
89/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +010090 * A single translation unit, which resides in an index.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010091 */
92typedef struct CXTranslationUnitImpl *CXTranslationUnit;
93
94/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +010095 * Opaque pointer representing client data that will be passed through
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010096 * to various callbacks and visitors.
97 */
98typedef void *CXClientData;
99
100/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100101 * Provides the contents of a file that has not yet been saved to disk.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100102 *
103 * Each CXUnsavedFile instance provides the name of a file on the
104 * system along with the current contents of that file that have not
105 * yet been saved to disk.
106 */
107struct CXUnsavedFile {
108 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100109 * The file whose contents have not yet been saved.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100110 *
111 * This file must already exist in the file system.
112 */
113 const char *Filename;
114
115 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100116 * A buffer containing the unsaved contents of this file.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100117 */
118 const char *Contents;
119
120 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100121 * The length of the unsaved contents of this buffer.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100122 */
123 unsigned long Length;
124};
125
126/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100127 * Describes the availability of a particular entity, which indicates
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100128 * whether the use of this entity will result in a warning or error due to
129 * it being deprecated or unavailable.
130 */
131enum CXAvailabilityKind {
132 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100133 * The entity is available.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100134 */
135 CXAvailability_Available,
136 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100137 * The entity is available, but has been deprecated (and its use is
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100138 * not recommended).
139 */
140 CXAvailability_Deprecated,
141 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100142 * The entity is not available; any use of it will be an error.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100143 */
144 CXAvailability_NotAvailable,
145 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100146 * The entity is available, but not accessible; any use of it will be
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100147 * an error.
148 */
149 CXAvailability_NotAccessible
150};
151
152/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100153 * Describes a version number of the form major.minor.subminor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100154 */
155typedef struct CXVersion {
156 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100157 * The major version number, e.g., the '10' in '10.7.3'. A negative
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100158 * value indicates that there is no version number at all.
159 */
160 int Major;
161 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100162 * The minor version number, e.g., the '7' in '10.7.3'. This value
163 * will be negative if no minor version number was provided, e.g., for
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100164 * version '10'.
165 */
166 int Minor;
167 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100168 * The subminor version number, e.g., the '3' in '10.7.3'. This value
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100169 * will be negative if no minor or subminor version number was provided,
170 * e.g., in version '10' or '10.7'.
171 */
172 int Subminor;
173} CXVersion;
174
175/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100176 * Describes the exception specification of a cursor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100177 *
178 * A negative value indicates that the cursor is not a function declaration.
179 */
180enum CXCursor_ExceptionSpecificationKind {
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100181 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100182 * The cursor has no exception specification.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100183 */
184 CXCursor_ExceptionSpecificationKind_None,
185
186 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100187 * The cursor has exception specification throw()
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100188 */
189 CXCursor_ExceptionSpecificationKind_DynamicNone,
190
191 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100192 * The cursor has exception specification throw(T1, T2)
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100193 */
194 CXCursor_ExceptionSpecificationKind_Dynamic,
195
196 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100197 * The cursor has exception specification throw(...).
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100198 */
199 CXCursor_ExceptionSpecificationKind_MSAny,
200
201 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100202 * The cursor has exception specification basic noexcept.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100203 */
204 CXCursor_ExceptionSpecificationKind_BasicNoexcept,
205
206 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100207 * The cursor has exception specification computed noexcept.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100208 */
209 CXCursor_ExceptionSpecificationKind_ComputedNoexcept,
210
211 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100212 * The exception specification has not yet been evaluated.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100213 */
214 CXCursor_ExceptionSpecificationKind_Unevaluated,
215
216 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100217 * The exception specification has not yet been instantiated.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100218 */
219 CXCursor_ExceptionSpecificationKind_Uninstantiated,
220
221 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100222 * The exception specification has not been parsed yet.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100223 */
224 CXCursor_ExceptionSpecificationKind_Unparsed
225};
226
227/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100228 * Provides a shared context for creating translation units.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100229 *
230 * It provides two options:
231 *
232 * - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local"
233 * declarations (when loading any new translation units). A "local" declaration
234 * is one that belongs in the translation unit itself and not in a precompiled
235 * header that was used by the translation unit. If zero, all declarations
236 * will be enumerated.
237 *
238 * Here is an example:
239 *
240 * \code
241 * // excludeDeclsFromPCH = 1, displayDiagnostics=1
242 * Idx = clang_createIndex(1, 1);
243 *
244 * // IndexTest.pch was produced with the following command:
245 * // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch"
246 * TU = clang_createTranslationUnit(Idx, "IndexTest.pch");
247 *
248 * // This will load all the symbols from 'IndexTest.pch'
249 * clang_visitChildren(clang_getTranslationUnitCursor(TU),
250 * TranslationUnitVisitor, 0);
251 * clang_disposeTranslationUnit(TU);
252 *
253 * // This will load all the symbols from 'IndexTest.c', excluding symbols
254 * // from 'IndexTest.pch'.
255 * char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" };
256 * TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args,
257 * 0, 0);
258 * clang_visitChildren(clang_getTranslationUnitCursor(TU),
259 * TranslationUnitVisitor, 0);
260 * clang_disposeTranslationUnit(TU);
261 * \endcode
262 *
263 * This process of creating the 'pch', loading it separately, and using it (via
264 * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks
265 * (which gives the indexer the same performance benefit as the compiler).
266 */
267CINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH,
268 int displayDiagnostics);
269
270/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100271 * Destroy the given index.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100272 *
273 * The index must not be destroyed until all of the translation units created
274 * within that index have been destroyed.
275 */
276CINDEX_LINKAGE void clang_disposeIndex(CXIndex index);
277
278typedef enum {
279 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100280 * Used to indicate that no special CXIndex options are needed.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100281 */
282 CXGlobalOpt_None = 0x0,
283
284 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100285 * Used to indicate that threads that libclang creates for indexing
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100286 * purposes should use background priority.
287 *
288 * Affects #clang_indexSourceFile, #clang_indexTranslationUnit,
289 * #clang_parseTranslationUnit, #clang_saveTranslationUnit.
290 */
291 CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1,
292
293 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100294 * Used to indicate that threads that libclang creates for editing
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100295 * purposes should use background priority.
296 *
297 * Affects #clang_reparseTranslationUnit, #clang_codeCompleteAt,
298 * #clang_annotateTokens
299 */
300 CXGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2,
301
302 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100303 * Used to indicate that all threads that libclang creates should use
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100304 * background priority.
305 */
306 CXGlobalOpt_ThreadBackgroundPriorityForAll =
307 CXGlobalOpt_ThreadBackgroundPriorityForIndexing |
308 CXGlobalOpt_ThreadBackgroundPriorityForEditing
309
310} CXGlobalOptFlags;
311
312/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100313 * Sets general options associated with a CXIndex.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100314 *
315 * For example:
316 * \code
317 * CXIndex idx = ...;
318 * clang_CXIndex_setGlobalOptions(idx,
319 * clang_CXIndex_getGlobalOptions(idx) |
320 * CXGlobalOpt_ThreadBackgroundPriorityForIndexing);
321 * \endcode
322 *
323 * \param options A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags.
324 */
325CINDEX_LINKAGE void clang_CXIndex_setGlobalOptions(CXIndex, unsigned options);
326
327/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100328 * Gets the general options associated with a CXIndex.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100329 *
330 * \returns A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags that
331 * are associated with the given CXIndex object.
332 */
333CINDEX_LINKAGE unsigned clang_CXIndex_getGlobalOptions(CXIndex);
334
335/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100336 * Sets the invocation emission path option in a CXIndex.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100337 *
338 * The invocation emission path specifies a path which will contain log
339 * files for certain libclang invocations. A null value (default) implies that
340 * libclang invocations are not logged..
341 */
342CINDEX_LINKAGE void
343clang_CXIndex_setInvocationEmissionPathOption(CXIndex, const char *Path);
344
345/**
346 * \defgroup CINDEX_FILES File manipulation routines
347 *
348 * @{
349 */
350
351/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100352 * A particular source file that is part of a translation unit.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100353 */
354typedef void *CXFile;
355
356/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100357 * Retrieve the complete file and path name of the given file.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100358 */
359CINDEX_LINKAGE CXString clang_getFileName(CXFile SFile);
360
361/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100362 * Retrieve the last modification time of the given file.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100363 */
364CINDEX_LINKAGE time_t clang_getFileTime(CXFile SFile);
365
366/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100367 * Uniquely identifies a CXFile, that refers to the same underlying file,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100368 * across an indexing session.
369 */
370typedef struct {
371 unsigned long long data[3];
372} CXFileUniqueID;
373
374/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100375 * Retrieve the unique ID for the given \c file.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100376 *
377 * \param file the file to get the ID for.
378 * \param outID stores the returned CXFileUniqueID.
379 * \returns If there was a failure getting the unique ID, returns non-zero,
380 * otherwise returns 0.
381*/
382CINDEX_LINKAGE int clang_getFileUniqueID(CXFile file, CXFileUniqueID *outID);
383
384/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100385 * Determine whether the given header is guarded against
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100386 * multiple inclusions, either with the conventional
387 * \#ifndef/\#define/\#endif macro guards or with \#pragma once.
388 */
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100389CINDEX_LINKAGE unsigned
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100390clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu, CXFile file);
391
392/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100393 * Retrieve a file handle within the given translation unit.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100394 *
395 * \param tu the translation unit
396 *
397 * \param file_name the name of the file.
398 *
399 * \returns the file handle for the named file in the translation unit \p tu,
400 * or a NULL file handle if the file was not a part of this translation unit.
401 */
402CINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu,
403 const char *file_name);
404
405/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100406 * Retrieve the buffer associated with the given file.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100407 *
408 * \param tu the translation unit
409 *
410 * \param file the file for which to retrieve the buffer.
411 *
412 * \param size [out] if non-NULL, will be set to the size of the buffer.
413 *
414 * \returns a pointer to the buffer in memory that holds the contents of
415 * \p file, or a NULL pointer when the file is not loaded.
416 */
417CINDEX_LINKAGE const char *clang_getFileContents(CXTranslationUnit tu,
418 CXFile file, size_t *size);
419
420/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100421 * Returns non-zero if the \c file1 and \c file2 point to the same file,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100422 * or they are both NULL.
423 */
424CINDEX_LINKAGE int clang_File_isEqual(CXFile file1, CXFile file2);
425
426/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100427 * Returns the real path name of \c file.
428 *
429 * An empty string may be returned. Use \c clang_getFileName() in that case.
430 */
431CINDEX_LINKAGE CXString clang_File_tryGetRealPathName(CXFile file);
432
433/**
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100434 * @}
435 */
436
437/**
438 * \defgroup CINDEX_LOCATIONS Physical source locations
439 *
440 * Clang represents physical source locations in its abstract syntax tree in
441 * great detail, with file, line, and column information for the majority of
442 * the tokens parsed in the source code. These data types and functions are
443 * used to represent source location information, either for a particular
444 * point in the program or for a range of points in the program, and extract
445 * specific location information from those data types.
446 *
447 * @{
448 */
449
450/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100451 * Identifies a specific source location within a translation
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100452 * unit.
453 *
454 * Use clang_getExpansionLocation() or clang_getSpellingLocation()
455 * to map a source location to a particular file, line, and column.
456 */
457typedef struct {
458 const void *ptr_data[2];
459 unsigned int_data;
460} CXSourceLocation;
461
462/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100463 * Identifies a half-open character range in the source code.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100464 *
465 * Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the
466 * starting and end locations from a source range, respectively.
467 */
468typedef struct {
469 const void *ptr_data[2];
470 unsigned begin_int_data;
471 unsigned end_int_data;
472} CXSourceRange;
473
474/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100475 * Retrieve a NULL (invalid) source location.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100476 */
477CINDEX_LINKAGE CXSourceLocation clang_getNullLocation(void);
478
479/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100480 * Determine whether two source locations, which must refer into
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100481 * the same translation unit, refer to exactly the same point in the source
482 * code.
483 *
484 * \returns non-zero if the source locations refer to the same location, zero
485 * if they refer to different locations.
486 */
487CINDEX_LINKAGE unsigned clang_equalLocations(CXSourceLocation loc1,
488 CXSourceLocation loc2);
489
490/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100491 * Retrieves the source location associated with a given file/line/column
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100492 * in a particular translation unit.
493 */
494CINDEX_LINKAGE CXSourceLocation clang_getLocation(CXTranslationUnit tu,
495 CXFile file,
496 unsigned line,
497 unsigned column);
498/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100499 * Retrieves the source location associated with a given character offset
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100500 * in a particular translation unit.
501 */
502CINDEX_LINKAGE CXSourceLocation clang_getLocationForOffset(CXTranslationUnit tu,
503 CXFile file,
504 unsigned offset);
505
506/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100507 * Returns non-zero if the given source location is in a system header.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100508 */
509CINDEX_LINKAGE int clang_Location_isInSystemHeader(CXSourceLocation location);
510
511/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100512 * Returns non-zero if the given source location is in the main file of
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100513 * the corresponding translation unit.
514 */
515CINDEX_LINKAGE int clang_Location_isFromMainFile(CXSourceLocation location);
516
517/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100518 * Retrieve a NULL (invalid) source range.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100519 */
520CINDEX_LINKAGE CXSourceRange clang_getNullRange(void);
521
522/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100523 * Retrieve a source range given the beginning and ending source
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100524 * locations.
525 */
526CINDEX_LINKAGE CXSourceRange clang_getRange(CXSourceLocation begin,
527 CXSourceLocation end);
528
529/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100530 * Determine whether two ranges are equivalent.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100531 *
532 * \returns non-zero if the ranges are the same, zero if they differ.
533 */
534CINDEX_LINKAGE unsigned clang_equalRanges(CXSourceRange range1,
535 CXSourceRange range2);
536
537/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100538 * Returns non-zero if \p range is null.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100539 */
540CINDEX_LINKAGE int clang_Range_isNull(CXSourceRange range);
541
542/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100543 * Retrieve the file, line, column, and offset represented by
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100544 * the given source location.
545 *
546 * If the location refers into a macro expansion, retrieves the
547 * location of the macro expansion.
548 *
549 * \param location the location within a source file that will be decomposed
550 * into its parts.
551 *
552 * \param file [out] if non-NULL, will be set to the file to which the given
553 * source location points.
554 *
555 * \param line [out] if non-NULL, will be set to the line to which the given
556 * source location points.
557 *
558 * \param column [out] if non-NULL, will be set to the column to which the given
559 * source location points.
560 *
561 * \param offset [out] if non-NULL, will be set to the offset into the
562 * buffer to which the given source location points.
563 */
564CINDEX_LINKAGE void clang_getExpansionLocation(CXSourceLocation location,
565 CXFile *file,
566 unsigned *line,
567 unsigned *column,
568 unsigned *offset);
569
570/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100571 * Retrieve the file, line and column represented by the given source
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100572 * location, as specified in a # line directive.
573 *
574 * Example: given the following source code in a file somefile.c
575 *
576 * \code
577 * #123 "dummy.c" 1
578 *
579 * static int func(void)
580 * {
581 * return 0;
582 * }
583 * \endcode
584 *
585 * the location information returned by this function would be
586 *
587 * File: dummy.c Line: 124 Column: 12
588 *
589 * whereas clang_getExpansionLocation would have returned
590 *
591 * File: somefile.c Line: 3 Column: 12
592 *
593 * \param location the location within a source file that will be decomposed
594 * into its parts.
595 *
596 * \param filename [out] if non-NULL, will be set to the filename of the
597 * source location. Note that filenames returned will be for "virtual" files,
598 * which don't necessarily exist on the machine running clang - e.g. when
599 * parsing preprocessed output obtained from a different environment. If
600 * a non-NULL value is passed in, remember to dispose of the returned value
601 * using \c clang_disposeString() once you've finished with it. For an invalid
602 * source location, an empty string is returned.
603 *
604 * \param line [out] if non-NULL, will be set to the line number of the
605 * source location. For an invalid source location, zero is returned.
606 *
607 * \param column [out] if non-NULL, will be set to the column number of the
608 * source location. For an invalid source location, zero is returned.
609 */
610CINDEX_LINKAGE void clang_getPresumedLocation(CXSourceLocation location,
611 CXString *filename,
612 unsigned *line,
613 unsigned *column);
614
615/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100616 * Legacy API to retrieve the file, line, column, and offset represented
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100617 * by the given source location.
618 *
619 * This interface has been replaced by the newer interface
620 * #clang_getExpansionLocation(). See that interface's documentation for
621 * details.
622 */
623CINDEX_LINKAGE void clang_getInstantiationLocation(CXSourceLocation location,
624 CXFile *file,
625 unsigned *line,
626 unsigned *column,
627 unsigned *offset);
628
629/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100630 * Retrieve the file, line, column, and offset represented by
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100631 * the given source location.
632 *
633 * If the location refers into a macro instantiation, return where the
634 * location was originally spelled in the source file.
635 *
636 * \param location the location within a source file that will be decomposed
637 * into its parts.
638 *
639 * \param file [out] if non-NULL, will be set to the file to which the given
640 * source location points.
641 *
642 * \param line [out] if non-NULL, will be set to the line to which the given
643 * source location points.
644 *
645 * \param column [out] if non-NULL, will be set to the column to which the given
646 * source location points.
647 *
648 * \param offset [out] if non-NULL, will be set to the offset into the
649 * buffer to which the given source location points.
650 */
651CINDEX_LINKAGE void clang_getSpellingLocation(CXSourceLocation location,
652 CXFile *file,
653 unsigned *line,
654 unsigned *column,
655 unsigned *offset);
656
657/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100658 * Retrieve the file, line, column, and offset represented by
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100659 * the given source location.
660 *
661 * If the location refers into a macro expansion, return where the macro was
662 * expanded or where the macro argument was written, if the location points at
663 * a macro argument.
664 *
665 * \param location the location within a source file that will be decomposed
666 * into its parts.
667 *
668 * \param file [out] if non-NULL, will be set to the file to which the given
669 * source location points.
670 *
671 * \param line [out] if non-NULL, will be set to the line to which the given
672 * source location points.
673 *
674 * \param column [out] if non-NULL, will be set to the column to which the given
675 * source location points.
676 *
677 * \param offset [out] if non-NULL, will be set to the offset into the
678 * buffer to which the given source location points.
679 */
680CINDEX_LINKAGE void clang_getFileLocation(CXSourceLocation location,
681 CXFile *file,
682 unsigned *line,
683 unsigned *column,
684 unsigned *offset);
685
686/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100687 * Retrieve a source location representing the first character within a
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100688 * source range.
689 */
690CINDEX_LINKAGE CXSourceLocation clang_getRangeStart(CXSourceRange range);
691
692/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100693 * Retrieve a source location representing the last character within a
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100694 * source range.
695 */
696CINDEX_LINKAGE CXSourceLocation clang_getRangeEnd(CXSourceRange range);
697
698/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100699 * Identifies an array of ranges.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100700 */
701typedef struct {
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100702 /** The number of ranges in the \c ranges array. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100703 unsigned count;
704 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100705 * An array of \c CXSourceRanges.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100706 */
707 CXSourceRange *ranges;
708} CXSourceRangeList;
709
710/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100711 * Retrieve all ranges that were skipped by the preprocessor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100712 *
713 * The preprocessor will skip lines when they are surrounded by an
714 * if/ifdef/ifndef directive whose condition does not evaluate to true.
715 */
716CINDEX_LINKAGE CXSourceRangeList *clang_getSkippedRanges(CXTranslationUnit tu,
717 CXFile file);
718
719/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100720 * Retrieve all ranges from all files that were skipped by the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100721 * preprocessor.
722 *
723 * The preprocessor will skip lines when they are surrounded by an
724 * if/ifdef/ifndef directive whose condition does not evaluate to true.
725 */
726CINDEX_LINKAGE CXSourceRangeList *clang_getAllSkippedRanges(CXTranslationUnit tu);
727
728/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100729 * Destroy the given \c CXSourceRangeList.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100730 */
731CINDEX_LINKAGE void clang_disposeSourceRangeList(CXSourceRangeList *ranges);
732
733/**
734 * @}
735 */
736
737/**
738 * \defgroup CINDEX_DIAG Diagnostic reporting
739 *
740 * @{
741 */
742
743/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100744 * Describes the severity of a particular diagnostic.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100745 */
746enum CXDiagnosticSeverity {
747 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100748 * A diagnostic that has been suppressed, e.g., by a command-line
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100749 * option.
750 */
751 CXDiagnostic_Ignored = 0,
752
753 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100754 * This diagnostic is a note that should be attached to the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100755 * previous (non-note) diagnostic.
756 */
757 CXDiagnostic_Note = 1,
758
759 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100760 * This diagnostic indicates suspicious code that may not be
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100761 * wrong.
762 */
763 CXDiagnostic_Warning = 2,
764
765 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100766 * This diagnostic indicates that the code is ill-formed.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100767 */
768 CXDiagnostic_Error = 3,
769
770 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100771 * This diagnostic indicates that the code is ill-formed such
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100772 * that future parser recovery is unlikely to produce useful
773 * results.
774 */
775 CXDiagnostic_Fatal = 4
776};
777
778/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100779 * A single diagnostic, containing the diagnostic's severity,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100780 * location, text, source ranges, and fix-it hints.
781 */
782typedef void *CXDiagnostic;
783
784/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100785 * A group of CXDiagnostics.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100786 */
787typedef void *CXDiagnosticSet;
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100788
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100789/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100790 * Determine the number of diagnostics in a CXDiagnosticSet.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100791 */
792CINDEX_LINKAGE unsigned clang_getNumDiagnosticsInSet(CXDiagnosticSet Diags);
793
794/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100795 * Retrieve a diagnostic associated with the given CXDiagnosticSet.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100796 *
797 * \param Diags the CXDiagnosticSet to query.
798 * \param Index the zero-based diagnostic number to retrieve.
799 *
800 * \returns the requested diagnostic. This diagnostic must be freed
801 * via a call to \c clang_disposeDiagnostic().
802 */
803CINDEX_LINKAGE CXDiagnostic clang_getDiagnosticInSet(CXDiagnosticSet Diags,
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100804 unsigned Index);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100805
806/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100807 * Describes the kind of error that occurred (if any) in a call to
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100808 * \c clang_loadDiagnostics.
809 */
810enum CXLoadDiag_Error {
811 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100812 * Indicates that no error occurred.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100813 */
814 CXLoadDiag_None = 0,
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100815
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100816 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100817 * Indicates that an unknown error occurred while attempting to
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100818 * deserialize diagnostics.
819 */
820 CXLoadDiag_Unknown = 1,
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100821
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100822 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100823 * Indicates that the file containing the serialized diagnostics
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100824 * could not be opened.
825 */
826 CXLoadDiag_CannotLoad = 2,
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100827
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100828 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100829 * Indicates that the serialized diagnostics file is invalid or
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100830 * corrupt.
831 */
832 CXLoadDiag_InvalidFile = 3
833};
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100834
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100835/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100836 * Deserialize a set of diagnostics from a Clang diagnostics bitcode
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100837 * file.
838 *
839 * \param file The name of the file to deserialize.
840 * \param error A pointer to a enum value recording if there was a problem
841 * deserializing the diagnostics.
842 * \param errorString A pointer to a CXString for recording the error string
843 * if the file was not successfully loaded.
844 *
845 * \returns A loaded CXDiagnosticSet if successful, and NULL otherwise. These
846 * diagnostics should be released using clang_disposeDiagnosticSet().
847 */
848CINDEX_LINKAGE CXDiagnosticSet clang_loadDiagnostics(const char *file,
849 enum CXLoadDiag_Error *error,
850 CXString *errorString);
851
852/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100853 * Release a CXDiagnosticSet and all of its contained diagnostics.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100854 */
855CINDEX_LINKAGE void clang_disposeDiagnosticSet(CXDiagnosticSet Diags);
856
857/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100858 * Retrieve the child diagnostics of a CXDiagnostic.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100859 *
860 * This CXDiagnosticSet does not need to be released by
861 * clang_disposeDiagnosticSet.
862 */
863CINDEX_LINKAGE CXDiagnosticSet clang_getChildDiagnostics(CXDiagnostic D);
864
865/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100866 * Determine the number of diagnostics produced for the given
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100867 * translation unit.
868 */
869CINDEX_LINKAGE unsigned clang_getNumDiagnostics(CXTranslationUnit Unit);
870
871/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100872 * Retrieve a diagnostic associated with the given translation unit.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100873 *
874 * \param Unit the translation unit to query.
875 * \param Index the zero-based diagnostic number to retrieve.
876 *
877 * \returns the requested diagnostic. This diagnostic must be freed
878 * via a call to \c clang_disposeDiagnostic().
879 */
880CINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit,
881 unsigned Index);
882
883/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100884 * Retrieve the complete set of diagnostics associated with a
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100885 * translation unit.
886 *
887 * \param Unit the translation unit to query.
888 */
889CINDEX_LINKAGE CXDiagnosticSet
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100890 clang_getDiagnosticSetFromTU(CXTranslationUnit Unit);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100891
892/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100893 * Destroy a diagnostic.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100894 */
895CINDEX_LINKAGE void clang_disposeDiagnostic(CXDiagnostic Diagnostic);
896
897/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100898 * Options to control the display of diagnostics.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100899 *
900 * The values in this enum are meant to be combined to customize the
901 * behavior of \c clang_formatDiagnostic().
902 */
903enum CXDiagnosticDisplayOptions {
904 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100905 * Display the source-location information where the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100906 * diagnostic was located.
907 *
908 * When set, diagnostics will be prefixed by the file, line, and
909 * (optionally) column to which the diagnostic refers. For example,
910 *
911 * \code
912 * test.c:28: warning: extra tokens at end of #endif directive
913 * \endcode
914 *
915 * This option corresponds to the clang flag \c -fshow-source-location.
916 */
917 CXDiagnostic_DisplaySourceLocation = 0x01,
918
919 /**
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 the column number.
922 *
923 * This option corresponds to the clang flag \c -fshow-column.
924 */
925 CXDiagnostic_DisplayColumn = 0x02,
926
927 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100928 * If displaying the source-location information of the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100929 * diagnostic, also include information about source ranges in a
930 * machine-parsable format.
931 *
932 * This option corresponds to the clang flag
933 * \c -fdiagnostics-print-source-range-info.
934 */
935 CXDiagnostic_DisplaySourceRanges = 0x04,
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100936
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100937 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100938 * Display the option name associated with this diagnostic, if any.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100939 *
940 * The option name displayed (e.g., -Wconversion) will be placed in brackets
941 * after the diagnostic text. This option corresponds to the clang flag
942 * \c -fdiagnostics-show-option.
943 */
944 CXDiagnostic_DisplayOption = 0x08,
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100945
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100946 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100947 * Display the category number associated with this diagnostic, if any.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100948 *
949 * The category number is displayed within brackets after the diagnostic text.
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100950 * This option corresponds to the clang flag
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100951 * \c -fdiagnostics-show-category=id.
952 */
953 CXDiagnostic_DisplayCategoryId = 0x10,
954
955 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100956 * Display the category name associated with this diagnostic, if any.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100957 *
958 * The category name is displayed within brackets after the diagnostic text.
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100959 * This option corresponds to the clang flag
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100960 * \c -fdiagnostics-show-category=name.
961 */
962 CXDiagnostic_DisplayCategoryName = 0x20
963};
964
965/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100966 * Format the given diagnostic in a manner that is suitable for display.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100967 *
968 * This routine will format the given diagnostic to a string, rendering
969 * the diagnostic according to the various options given. The
970 * \c clang_defaultDiagnosticDisplayOptions() function returns the set of
971 * options that most closely mimics the behavior of the clang compiler.
972 *
973 * \param Diagnostic The diagnostic to print.
974 *
975 * \param Options A set of options that control the diagnostic display,
976 * created by combining \c CXDiagnosticDisplayOptions values.
977 *
978 * \returns A new string containing for formatted diagnostic.
979 */
980CINDEX_LINKAGE CXString clang_formatDiagnostic(CXDiagnostic Diagnostic,
981 unsigned Options);
982
983/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100984 * Retrieve the set of display options most similar to the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100985 * default behavior of the clang compiler.
986 *
987 * \returns A set of display options suitable for use with \c
988 * clang_formatDiagnostic().
989 */
990CINDEX_LINKAGE unsigned clang_defaultDiagnosticDisplayOptions(void);
991
992/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100993 * Determine the severity of the given diagnostic.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100994 */
995CINDEX_LINKAGE enum CXDiagnosticSeverity
996clang_getDiagnosticSeverity(CXDiagnostic);
997
998/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100999 * Retrieve the source location of the given diagnostic.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001000 *
1001 * This location is where Clang would print the caret ('^') when
1002 * displaying the diagnostic on the command line.
1003 */
1004CINDEX_LINKAGE CXSourceLocation clang_getDiagnosticLocation(CXDiagnostic);
1005
1006/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001007 * Retrieve the text of the given diagnostic.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001008 */
1009CINDEX_LINKAGE CXString clang_getDiagnosticSpelling(CXDiagnostic);
1010
1011/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001012 * Retrieve the name of the command-line option that enabled this
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001013 * diagnostic.
1014 *
1015 * \param Diag The diagnostic to be queried.
1016 *
1017 * \param Disable If non-NULL, will be set to the option that disables this
1018 * diagnostic (if any).
1019 *
1020 * \returns A string that contains the command-line option used to enable this
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001021 * warning, such as "-Wconversion" or "-pedantic".
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001022 */
1023CINDEX_LINKAGE CXString clang_getDiagnosticOption(CXDiagnostic Diag,
1024 CXString *Disable);
1025
1026/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001027 * Retrieve the category number for this diagnostic.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001028 *
1029 * Diagnostics can be categorized into groups along with other, related
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001030 * diagnostics (e.g., diagnostics under the same warning flag). This routine
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001031 * retrieves the category number for the given diagnostic.
1032 *
1033 * \returns The number of the category that contains this diagnostic, or zero
1034 * if this diagnostic is uncategorized.
1035 */
1036CINDEX_LINKAGE unsigned clang_getDiagnosticCategory(CXDiagnostic);
1037
1038/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001039 * Retrieve the name of a particular diagnostic category. This
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001040 * is now deprecated. Use clang_getDiagnosticCategoryText()
1041 * instead.
1042 *
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001043 * \param Category A diagnostic category number, as returned by
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001044 * \c clang_getDiagnosticCategory().
1045 *
1046 * \returns The name of the given diagnostic category.
1047 */
1048CINDEX_DEPRECATED CINDEX_LINKAGE
1049CXString clang_getDiagnosticCategoryName(unsigned Category);
1050
1051/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001052 * Retrieve the diagnostic category text for a given diagnostic.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001053 *
1054 * \returns The text of the given diagnostic category.
1055 */
1056CINDEX_LINKAGE CXString clang_getDiagnosticCategoryText(CXDiagnostic);
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001057
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001058/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001059 * Determine the number of source ranges associated with the given
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001060 * diagnostic.
1061 */
1062CINDEX_LINKAGE unsigned clang_getDiagnosticNumRanges(CXDiagnostic);
1063
1064/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001065 * Retrieve a source range associated with the diagnostic.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001066 *
1067 * A diagnostic's source ranges highlight important elements in the source
1068 * code. On the command line, Clang displays source ranges by
1069 * underlining them with '~' characters.
1070 *
1071 * \param Diagnostic the diagnostic whose range is being extracted.
1072 *
1073 * \param Range the zero-based index specifying which range to
1074 *
1075 * \returns the requested source range.
1076 */
1077CINDEX_LINKAGE CXSourceRange clang_getDiagnosticRange(CXDiagnostic Diagnostic,
1078 unsigned Range);
1079
1080/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001081 * Determine the number of fix-it hints associated with the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001082 * given diagnostic.
1083 */
1084CINDEX_LINKAGE unsigned clang_getDiagnosticNumFixIts(CXDiagnostic Diagnostic);
1085
1086/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001087 * Retrieve the replacement information for a given fix-it.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001088 *
1089 * Fix-its are described in terms of a source range whose contents
1090 * should be replaced by a string. This approach generalizes over
1091 * three kinds of operations: removal of source code (the range covers
1092 * the code to be removed and the replacement string is empty),
1093 * replacement of source code (the range covers the code to be
1094 * replaced and the replacement string provides the new code), and
1095 * insertion (both the start and end of the range point at the
1096 * insertion location, and the replacement string provides the text to
1097 * insert).
1098 *
1099 * \param Diagnostic The diagnostic whose fix-its are being queried.
1100 *
1101 * \param FixIt The zero-based index of the fix-it.
1102 *
1103 * \param ReplacementRange The source range whose contents will be
1104 * replaced with the returned replacement string. Note that source
1105 * ranges are half-open ranges [a, b), so the source code should be
1106 * replaced from a and up to (but not including) b.
1107 *
1108 * \returns A string containing text that should be replace the source
1109 * code indicated by the \c ReplacementRange.
1110 */
1111CINDEX_LINKAGE CXString clang_getDiagnosticFixIt(CXDiagnostic Diagnostic,
1112 unsigned FixIt,
1113 CXSourceRange *ReplacementRange);
1114
1115/**
1116 * @}
1117 */
1118
1119/**
1120 * \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation
1121 *
1122 * The routines in this group provide the ability to create and destroy
1123 * translation units from files, either by parsing the contents of the files or
1124 * by reading in a serialized representation of a translation unit.
1125 *
1126 * @{
1127 */
1128
1129/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001130 * Get the original translation unit source file name.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001131 */
1132CINDEX_LINKAGE CXString
1133clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit);
1134
1135/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001136 * Return the CXTranslationUnit for a given source file and the provided
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001137 * command line arguments one would pass to the compiler.
1138 *
1139 * Note: The 'source_filename' argument is optional. If the caller provides a
1140 * NULL pointer, the name of the source file is expected to reside in the
1141 * specified command line arguments.
1142 *
1143 * Note: When encountered in 'clang_command_line_args', the following options
1144 * are ignored:
1145 *
1146 * '-c'
1147 * '-emit-ast'
1148 * '-fsyntax-only'
1149 * '-o \<output file>' (both '-o' and '\<output file>' are ignored)
1150 *
1151 * \param CIdx The index object with which the translation unit will be
1152 * associated.
1153 *
1154 * \param source_filename The name of the source file to load, or NULL if the
1155 * source file is included in \p clang_command_line_args.
1156 *
1157 * \param num_clang_command_line_args The number of command-line arguments in
1158 * \p clang_command_line_args.
1159 *
1160 * \param clang_command_line_args The command-line arguments that would be
1161 * passed to the \c clang executable if it were being invoked out-of-process.
1162 * These command-line options will be parsed and will affect how the translation
1163 * unit is parsed. Note that the following options are ignored: '-c',
1164 * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
1165 *
1166 * \param num_unsaved_files the number of unsaved file entries in \p
1167 * unsaved_files.
1168 *
1169 * \param unsaved_files the files that have not yet been saved to disk
1170 * but may be required for code completion, including the contents of
1171 * those files. The contents and name of these files (as specified by
1172 * CXUnsavedFile) are copied when necessary, so the client only needs to
1173 * guarantee their validity until the call to this function returns.
1174 */
1175CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnitFromSourceFile(
1176 CXIndex CIdx,
1177 const char *source_filename,
1178 int num_clang_command_line_args,
1179 const char * const *clang_command_line_args,
1180 unsigned num_unsaved_files,
1181 struct CXUnsavedFile *unsaved_files);
1182
1183/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001184 * Same as \c clang_createTranslationUnit2, but returns
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001185 * the \c CXTranslationUnit instead of an error code. In case of an error this
1186 * routine returns a \c NULL \c CXTranslationUnit, without further detailed
1187 * error codes.
1188 */
1189CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnit(
1190 CXIndex CIdx,
1191 const char *ast_filename);
1192
1193/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001194 * Create a translation unit from an AST file (\c -emit-ast).
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001195 *
1196 * \param[out] out_TU A non-NULL pointer to store the created
1197 * \c CXTranslationUnit.
1198 *
1199 * \returns Zero on success, otherwise returns an error code.
1200 */
1201CINDEX_LINKAGE enum CXErrorCode clang_createTranslationUnit2(
1202 CXIndex CIdx,
1203 const char *ast_filename,
1204 CXTranslationUnit *out_TU);
1205
1206/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001207 * Flags that control the creation of translation units.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001208 *
1209 * The enumerators in this enumeration type are meant to be bitwise
1210 * ORed together to specify which options should be used when
1211 * constructing the translation unit.
1212 */
1213enum CXTranslationUnit_Flags {
1214 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001215 * Used to indicate that no special translation-unit options are
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001216 * needed.
1217 */
1218 CXTranslationUnit_None = 0x0,
1219
1220 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001221 * Used to indicate that the parser should construct a "detailed"
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001222 * preprocessing record, including all macro definitions and instantiations.
1223 *
1224 * Constructing a detailed preprocessing record requires more memory
1225 * and time to parse, since the information contained in the record
1226 * is usually not retained. However, it can be useful for
1227 * applications that require more detailed information about the
1228 * behavior of the preprocessor.
1229 */
1230 CXTranslationUnit_DetailedPreprocessingRecord = 0x01,
1231
1232 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001233 * Used to indicate that the translation unit is incomplete.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001234 *
1235 * When a translation unit is considered "incomplete", semantic
1236 * analysis that is typically performed at the end of the
1237 * translation unit will be suppressed. For example, this suppresses
1238 * the completion of tentative declarations in C and of
1239 * instantiation of implicitly-instantiation function templates in
1240 * C++. This option is typically used when parsing a header with the
1241 * intent of producing a precompiled header.
1242 */
1243 CXTranslationUnit_Incomplete = 0x02,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001244
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001245 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001246 * Used to indicate that the translation unit should be built with an
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001247 * implicit precompiled header for the preamble.
1248 *
1249 * An implicit precompiled header is used as an optimization when a
1250 * particular translation unit is likely to be reparsed many times
1251 * when the sources aren't changing that often. In this case, an
1252 * implicit precompiled header will be built containing all of the
1253 * initial includes at the top of the main file (what we refer to as
1254 * the "preamble" of the file). In subsequent parses, if the
1255 * preamble or the files in it have not changed, \c
1256 * clang_reparseTranslationUnit() will re-use the implicit
1257 * precompiled header to improve parsing performance.
1258 */
1259 CXTranslationUnit_PrecompiledPreamble = 0x04,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001260
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001261 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001262 * Used to indicate that the translation unit should cache some
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001263 * code-completion results with each reparse of the source file.
1264 *
1265 * Caching of code-completion results is a performance optimization that
1266 * introduces some overhead to reparsing but improves the performance of
1267 * code-completion operations.
1268 */
1269 CXTranslationUnit_CacheCompletionResults = 0x08,
1270
1271 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001272 * Used to indicate that the translation unit will be serialized with
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001273 * \c clang_saveTranslationUnit.
1274 *
1275 * This option is typically used when parsing a header with the intent of
1276 * producing a precompiled header.
1277 */
1278 CXTranslationUnit_ForSerialization = 0x10,
1279
1280 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001281 * DEPRECATED: Enabled chained precompiled preambles in C++.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001282 *
1283 * Note: this is a *temporary* option that is available only while
1284 * we are testing C++ precompiled preamble support. It is deprecated.
1285 */
1286 CXTranslationUnit_CXXChainedPCH = 0x20,
1287
1288 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001289 * Used to indicate that function/method bodies should be skipped while
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001290 * parsing.
1291 *
1292 * This option can be used to search for declarations/definitions while
1293 * ignoring the usages.
1294 */
1295 CXTranslationUnit_SkipFunctionBodies = 0x40,
1296
1297 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001298 * Used to indicate that brief documentation comments should be
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001299 * included into the set of code completions returned from this translation
1300 * unit.
1301 */
1302 CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 0x80,
1303
1304 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001305 * Used to indicate that the precompiled preamble should be created on
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001306 * the first parse. Otherwise it will be created on the first reparse. This
1307 * trades runtime on the first parse (serializing the preamble takes time) for
1308 * reduced runtime on the second parse (can now reuse the preamble).
1309 */
1310 CXTranslationUnit_CreatePreambleOnFirstParse = 0x100,
1311
1312 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001313 * Do not stop processing when fatal errors are encountered.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001314 *
1315 * When fatal errors are encountered while parsing a translation unit,
1316 * semantic analysis is typically stopped early when compiling code. A common
1317 * source for fatal errors are unresolvable include files. For the
1318 * purposes of an IDE, this is undesirable behavior and as much information
1319 * as possible should be reported. Use this flag to enable this behavior.
1320 */
1321 CXTranslationUnit_KeepGoing = 0x200,
1322
1323 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001324 * Sets the preprocessor in a mode for parsing a single file only.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001325 */
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001326 CXTranslationUnit_SingleFileParse = 0x400,
1327
1328 /**
1329 * Used in combination with CXTranslationUnit_SkipFunctionBodies to
1330 * constrain the skipping of function bodies to the preamble.
1331 *
1332 * The function bodies of the main file are not skipped.
1333 */
1334 CXTranslationUnit_LimitSkipFunctionBodiesToPreamble = 0x800,
1335
1336 /**
1337 * Used to indicate that attributed types should be included in CXType.
1338 */
1339 CXTranslationUnit_IncludeAttributedTypes = 0x1000,
1340
1341 /**
1342 * Used to indicate that implicit attributes should be visited.
1343 */
1344 CXTranslationUnit_VisitImplicitAttributes = 0x2000
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001345};
1346
1347/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001348 * Returns the set of flags that is suitable for parsing a translation
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001349 * unit that is being edited.
1350 *
1351 * The set of flags returned provide options for \c clang_parseTranslationUnit()
1352 * to indicate that the translation unit is likely to be reparsed many times,
1353 * either explicitly (via \c clang_reparseTranslationUnit()) or implicitly
1354 * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001355 * set contains an unspecified set of optimizations (e.g., the precompiled
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001356 * preamble) geared toward improving the performance of these routines. The
1357 * set of optimizations enabled may change from one version to the next.
1358 */
1359CINDEX_LINKAGE unsigned clang_defaultEditingTranslationUnitOptions(void);
1360
1361/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001362 * Same as \c clang_parseTranslationUnit2, but returns
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001363 * the \c CXTranslationUnit instead of an error code. In case of an error this
1364 * routine returns a \c NULL \c CXTranslationUnit, without further detailed
1365 * error codes.
1366 */
1367CINDEX_LINKAGE CXTranslationUnit
1368clang_parseTranslationUnit(CXIndex CIdx,
1369 const char *source_filename,
1370 const char *const *command_line_args,
1371 int num_command_line_args,
1372 struct CXUnsavedFile *unsaved_files,
1373 unsigned num_unsaved_files,
1374 unsigned options);
1375
1376/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001377 * Parse the given source file and the translation unit corresponding
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001378 * to that file.
1379 *
1380 * This routine is the main entry point for the Clang C API, providing the
1381 * ability to parse a source file into a translation unit that can then be
1382 * queried by other functions in the API. This routine accepts a set of
1383 * command-line arguments so that the compilation can be configured in the same
1384 * way that the compiler is configured on the command line.
1385 *
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001386 * \param CIdx The index object with which the translation unit will be
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001387 * associated.
1388 *
1389 * \param source_filename The name of the source file to load, or NULL if the
1390 * source file is included in \c command_line_args.
1391 *
1392 * \param command_line_args The command-line arguments that would be
1393 * passed to the \c clang executable if it were being invoked out-of-process.
1394 * These command-line options will be parsed and will affect how the translation
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001395 * unit is parsed. Note that the following options are ignored: '-c',
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001396 * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
1397 *
1398 * \param num_command_line_args The number of command-line arguments in
1399 * \c command_line_args.
1400 *
1401 * \param unsaved_files the files that have not yet been saved to disk
1402 * but may be required for parsing, including the contents of
1403 * those files. The contents and name of these files (as specified by
1404 * CXUnsavedFile) are copied when necessary, so the client only needs to
1405 * guarantee their validity until the call to this function returns.
1406 *
1407 * \param num_unsaved_files the number of unsaved file entries in \p
1408 * unsaved_files.
1409 *
1410 * \param options A bitmask of options that affects how the translation unit
1411 * is managed but not its compilation. This should be a bitwise OR of the
1412 * CXTranslationUnit_XXX flags.
1413 *
1414 * \param[out] out_TU A non-NULL pointer to store the created
1415 * \c CXTranslationUnit, describing the parsed code and containing any
1416 * diagnostics produced by the compiler.
1417 *
1418 * \returns Zero on success, otherwise returns an error code.
1419 */
1420CINDEX_LINKAGE enum CXErrorCode
1421clang_parseTranslationUnit2(CXIndex CIdx,
1422 const char *source_filename,
1423 const char *const *command_line_args,
1424 int num_command_line_args,
1425 struct CXUnsavedFile *unsaved_files,
1426 unsigned num_unsaved_files,
1427 unsigned options,
1428 CXTranslationUnit *out_TU);
1429
1430/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001431 * Same as clang_parseTranslationUnit2 but requires a full command line
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001432 * for \c command_line_args including argv[0]. This is useful if the standard
1433 * library paths are relative to the binary.
1434 */
1435CINDEX_LINKAGE enum CXErrorCode clang_parseTranslationUnit2FullArgv(
1436 CXIndex CIdx, const char *source_filename,
1437 const char *const *command_line_args, int num_command_line_args,
1438 struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files,
1439 unsigned options, CXTranslationUnit *out_TU);
1440
1441/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001442 * Flags that control how translation units are saved.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001443 *
1444 * The enumerators in this enumeration type are meant to be bitwise
1445 * ORed together to specify which options should be used when
1446 * saving the translation unit.
1447 */
1448enum CXSaveTranslationUnit_Flags {
1449 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001450 * Used to indicate that no special saving options are needed.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001451 */
1452 CXSaveTranslationUnit_None = 0x0
1453};
1454
1455/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001456 * Returns the set of flags that is suitable for saving a translation
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001457 * unit.
1458 *
1459 * The set of flags returned provide options for
1460 * \c clang_saveTranslationUnit() by default. The returned flag
1461 * set contains an unspecified set of options that save translation units with
1462 * the most commonly-requested data.
1463 */
1464CINDEX_LINKAGE unsigned clang_defaultSaveOptions(CXTranslationUnit TU);
1465
1466/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001467 * Describes the kind of error that occurred (if any) in a call to
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001468 * \c clang_saveTranslationUnit().
1469 */
1470enum CXSaveError {
1471 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001472 * Indicates that no error occurred while saving a translation unit.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001473 */
1474 CXSaveError_None = 0,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001475
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001476 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001477 * Indicates that an unknown error occurred while attempting to save
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001478 * the file.
1479 *
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001480 * This error typically indicates that file I/O failed when attempting to
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001481 * write the file.
1482 */
1483 CXSaveError_Unknown = 1,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001484
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001485 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001486 * Indicates that errors during translation prevented this attempt
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001487 * to save the translation unit.
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001488 *
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001489 * Errors that prevent the translation unit from being saved can be
1490 * extracted using \c clang_getNumDiagnostics() and \c clang_getDiagnostic().
1491 */
1492 CXSaveError_TranslationErrors = 2,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001493
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001494 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001495 * Indicates that the translation unit to be saved was somehow
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001496 * invalid (e.g., NULL).
1497 */
1498 CXSaveError_InvalidTU = 3
1499};
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001500
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001501/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001502 * Saves a translation unit into a serialized representation of
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001503 * that translation unit on disk.
1504 *
1505 * Any translation unit that was parsed without error can be saved
1506 * into a file. The translation unit can then be deserialized into a
1507 * new \c CXTranslationUnit with \c clang_createTranslationUnit() or,
1508 * if it is an incomplete translation unit that corresponds to a
1509 * header, used as a precompiled header when parsing other translation
1510 * units.
1511 *
1512 * \param TU The translation unit to save.
1513 *
1514 * \param FileName The file to which the translation unit will be saved.
1515 *
1516 * \param options A bitmask of options that affects how the translation unit
1517 * is saved. This should be a bitwise OR of the
1518 * CXSaveTranslationUnit_XXX flags.
1519 *
1520 * \returns A value that will match one of the enumerators of the CXSaveError
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001521 * enumeration. Zero (CXSaveError_None) indicates that the translation unit was
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001522 * saved successfully, while a non-zero value indicates that a problem occurred.
1523 */
1524CINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU,
1525 const char *FileName,
1526 unsigned options);
1527
1528/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001529 * Suspend a translation unit in order to free memory associated with it.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001530 *
1531 * A suspended translation unit uses significantly less memory but on the other
1532 * side does not support any other calls than \c clang_reparseTranslationUnit
1533 * to resume it or \c clang_disposeTranslationUnit to dispose it completely.
1534 */
1535CINDEX_LINKAGE unsigned clang_suspendTranslationUnit(CXTranslationUnit);
1536
1537/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001538 * Destroy the specified CXTranslationUnit object.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001539 */
1540CINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit);
1541
1542/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001543 * Flags that control the reparsing of translation units.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001544 *
1545 * The enumerators in this enumeration type are meant to be bitwise
1546 * ORed together to specify which options should be used when
1547 * reparsing the translation unit.
1548 */
1549enum CXReparse_Flags {
1550 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001551 * Used to indicate that no special reparsing options are needed.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001552 */
1553 CXReparse_None = 0x0
1554};
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001555
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001556/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001557 * Returns the set of flags that is suitable for reparsing a translation
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001558 * unit.
1559 *
1560 * The set of flags returned provide options for
1561 * \c clang_reparseTranslationUnit() by default. The returned flag
1562 * set contains an unspecified set of optimizations geared toward common uses
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001563 * of reparsing. The set of optimizations enabled may change from one version
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001564 * to the next.
1565 */
1566CINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU);
1567
1568/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001569 * Reparse the source files that produced this translation unit.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001570 *
1571 * This routine can be used to re-parse the source files that originally
1572 * created the given translation unit, for example because those source files
1573 * have changed (either on disk or as passed via \p unsaved_files). The
1574 * source code will be reparsed with the same command-line options as it
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001575 * was originally parsed.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001576 *
1577 * Reparsing a translation unit invalidates all cursors and source locations
1578 * that refer into that translation unit. This makes reparsing a translation
1579 * unit semantically equivalent to destroying the translation unit and then
1580 * creating a new translation unit with the same command-line arguments.
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001581 * However, it may be more efficient to reparse a translation
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001582 * unit using this routine.
1583 *
1584 * \param TU The translation unit whose contents will be re-parsed. The
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001585 * translation unit must originally have been built with
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001586 * \c clang_createTranslationUnitFromSourceFile().
1587 *
1588 * \param num_unsaved_files The number of unsaved file entries in \p
1589 * unsaved_files.
1590 *
1591 * \param unsaved_files The files that have not yet been saved to disk
1592 * but may be required for parsing, including the contents of
1593 * those files. The contents and name of these files (as specified by
1594 * CXUnsavedFile) are copied when necessary, so the client only needs to
1595 * guarantee their validity until the call to this function returns.
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001596 *
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001597 * \param options A bitset of options composed of the flags in CXReparse_Flags.
1598 * The function \c clang_defaultReparseOptions() produces a default set of
1599 * options recommended for most uses, based on the translation unit.
1600 *
1601 * \returns 0 if the sources could be reparsed. A non-zero error code will be
1602 * returned if reparsing was impossible, such that the translation unit is
1603 * invalid. In such cases, the only valid call for \c TU is
1604 * \c clang_disposeTranslationUnit(TU). The error codes returned by this
1605 * routine are described by the \c CXErrorCode enum.
1606 */
1607CINDEX_LINKAGE int clang_reparseTranslationUnit(CXTranslationUnit TU,
1608 unsigned num_unsaved_files,
1609 struct CXUnsavedFile *unsaved_files,
1610 unsigned options);
1611
1612/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001613 * Categorizes how memory is being used by a translation unit.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001614 */
1615enum CXTUResourceUsageKind {
1616 CXTUResourceUsage_AST = 1,
1617 CXTUResourceUsage_Identifiers = 2,
1618 CXTUResourceUsage_Selectors = 3,
1619 CXTUResourceUsage_GlobalCompletionResults = 4,
1620 CXTUResourceUsage_SourceManagerContentCache = 5,
1621 CXTUResourceUsage_AST_SideTables = 6,
1622 CXTUResourceUsage_SourceManager_Membuffer_Malloc = 7,
1623 CXTUResourceUsage_SourceManager_Membuffer_MMap = 8,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001624 CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc = 9,
1625 CXTUResourceUsage_ExternalASTSource_Membuffer_MMap = 10,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001626 CXTUResourceUsage_Preprocessor = 11,
1627 CXTUResourceUsage_PreprocessingRecord = 12,
1628 CXTUResourceUsage_SourceManager_DataStructures = 13,
1629 CXTUResourceUsage_Preprocessor_HeaderSearch = 14,
1630 CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST,
1631 CXTUResourceUsage_MEMORY_IN_BYTES_END =
1632 CXTUResourceUsage_Preprocessor_HeaderSearch,
1633
1634 CXTUResourceUsage_First = CXTUResourceUsage_AST,
1635 CXTUResourceUsage_Last = CXTUResourceUsage_Preprocessor_HeaderSearch
1636};
1637
1638/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001639 * Returns the human-readable null-terminated C string that represents
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001640 * the name of the memory category. This string should never be freed.
1641 */
1642CINDEX_LINKAGE
1643const char *clang_getTUResourceUsageName(enum CXTUResourceUsageKind kind);
1644
1645typedef struct CXTUResourceUsageEntry {
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001646 /* The memory usage category. */
1647 enum CXTUResourceUsageKind kind;
1648 /* Amount of resources used.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001649 The units will depend on the resource kind. */
1650 unsigned long amount;
1651} CXTUResourceUsageEntry;
1652
1653/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001654 * The memory usage of a CXTranslationUnit, broken into categories.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001655 */
1656typedef struct CXTUResourceUsage {
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001657 /* Private data member, used for queries. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001658 void *data;
1659
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001660 /* The number of entries in the 'entries' array. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001661 unsigned numEntries;
1662
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001663 /* An array of key-value pairs, representing the breakdown of memory
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001664 usage. */
1665 CXTUResourceUsageEntry *entries;
1666
1667} CXTUResourceUsage;
1668
1669/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001670 * Return the memory usage of a translation unit. This object
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001671 * should be released with clang_disposeCXTUResourceUsage().
1672 */
1673CINDEX_LINKAGE CXTUResourceUsage clang_getCXTUResourceUsage(CXTranslationUnit TU);
1674
1675CINDEX_LINKAGE void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage);
1676
1677/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001678 * Get target information for this translation unit.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001679 *
1680 * The CXTargetInfo object cannot outlive the CXTranslationUnit object.
1681 */
1682CINDEX_LINKAGE CXTargetInfo
1683clang_getTranslationUnitTargetInfo(CXTranslationUnit CTUnit);
1684
1685/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001686 * Destroy the CXTargetInfo object.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001687 */
1688CINDEX_LINKAGE void
1689clang_TargetInfo_dispose(CXTargetInfo Info);
1690
1691/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001692 * Get the normalized target triple as a string.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001693 *
1694 * Returns the empty string in case of any error.
1695 */
1696CINDEX_LINKAGE CXString
1697clang_TargetInfo_getTriple(CXTargetInfo Info);
1698
1699/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001700 * Get the pointer width of the target in bits.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001701 *
1702 * Returns -1 in case of error.
1703 */
1704CINDEX_LINKAGE int
1705clang_TargetInfo_getPointerWidth(CXTargetInfo Info);
1706
1707/**
1708 * @}
1709 */
1710
1711/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001712 * Describes the kind of entity that a cursor refers to.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001713 */
1714enum CXCursorKind {
1715 /* Declarations */
1716 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001717 * A declaration whose specific kind is not exposed via this
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001718 * interface.
1719 *
1720 * Unexposed declarations have the same operations as any other kind
1721 * of declaration; one can extract their location information,
1722 * spelling, find their definitions, etc. However, the specific kind
1723 * of the declaration is not reported.
1724 */
1725 CXCursor_UnexposedDecl = 1,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001726 /** A C or C++ struct. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001727 CXCursor_StructDecl = 2,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001728 /** A C or C++ union. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001729 CXCursor_UnionDecl = 3,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001730 /** A C++ class. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001731 CXCursor_ClassDecl = 4,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001732 /** An enumeration. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001733 CXCursor_EnumDecl = 5,
1734 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001735 * A field (in C) or non-static data member (in C++) in a
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001736 * struct, union, or C++ class.
1737 */
1738 CXCursor_FieldDecl = 6,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001739 /** An enumerator constant. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001740 CXCursor_EnumConstantDecl = 7,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001741 /** A function. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001742 CXCursor_FunctionDecl = 8,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001743 /** A variable. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001744 CXCursor_VarDecl = 9,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001745 /** A function or method parameter. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001746 CXCursor_ParmDecl = 10,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001747 /** An Objective-C \@interface. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001748 CXCursor_ObjCInterfaceDecl = 11,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001749 /** An Objective-C \@interface for a category. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001750 CXCursor_ObjCCategoryDecl = 12,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001751 /** An Objective-C \@protocol declaration. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001752 CXCursor_ObjCProtocolDecl = 13,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001753 /** An Objective-C \@property declaration. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001754 CXCursor_ObjCPropertyDecl = 14,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001755 /** An Objective-C instance variable. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001756 CXCursor_ObjCIvarDecl = 15,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001757 /** An Objective-C instance method. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001758 CXCursor_ObjCInstanceMethodDecl = 16,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001759 /** An Objective-C class method. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001760 CXCursor_ObjCClassMethodDecl = 17,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001761 /** An Objective-C \@implementation. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001762 CXCursor_ObjCImplementationDecl = 18,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001763 /** An Objective-C \@implementation for a category. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001764 CXCursor_ObjCCategoryImplDecl = 19,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001765 /** A typedef. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001766 CXCursor_TypedefDecl = 20,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001767 /** A C++ class method. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001768 CXCursor_CXXMethod = 21,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001769 /** A C++ namespace. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001770 CXCursor_Namespace = 22,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001771 /** A linkage specification, e.g. 'extern "C"'. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001772 CXCursor_LinkageSpec = 23,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001773 /** A C++ constructor. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001774 CXCursor_Constructor = 24,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001775 /** A C++ destructor. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001776 CXCursor_Destructor = 25,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001777 /** A C++ conversion function. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001778 CXCursor_ConversionFunction = 26,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001779 /** A C++ template type parameter. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001780 CXCursor_TemplateTypeParameter = 27,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001781 /** A C++ non-type template parameter. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001782 CXCursor_NonTypeTemplateParameter = 28,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001783 /** A C++ template template parameter. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001784 CXCursor_TemplateTemplateParameter = 29,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001785 /** A C++ function template. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001786 CXCursor_FunctionTemplate = 30,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001787 /** A C++ class template. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001788 CXCursor_ClassTemplate = 31,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001789 /** A C++ class template partial specialization. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001790 CXCursor_ClassTemplatePartialSpecialization = 32,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001791 /** A C++ namespace alias declaration. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001792 CXCursor_NamespaceAlias = 33,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001793 /** A C++ using directive. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001794 CXCursor_UsingDirective = 34,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001795 /** A C++ using declaration. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001796 CXCursor_UsingDeclaration = 35,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001797 /** A C++ alias declaration */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001798 CXCursor_TypeAliasDecl = 36,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001799 /** An Objective-C \@synthesize definition. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001800 CXCursor_ObjCSynthesizeDecl = 37,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001801 /** An Objective-C \@dynamic definition. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001802 CXCursor_ObjCDynamicDecl = 38,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001803 /** An access specifier. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001804 CXCursor_CXXAccessSpecifier = 39,
1805
1806 CXCursor_FirstDecl = CXCursor_UnexposedDecl,
1807 CXCursor_LastDecl = CXCursor_CXXAccessSpecifier,
1808
1809 /* References */
1810 CXCursor_FirstRef = 40, /* Decl references */
1811 CXCursor_ObjCSuperClassRef = 40,
1812 CXCursor_ObjCProtocolRef = 41,
1813 CXCursor_ObjCClassRef = 42,
1814 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001815 * A reference to a type declaration.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001816 *
1817 * A type reference occurs anywhere where a type is named but not
1818 * declared. For example, given:
1819 *
1820 * \code
1821 * typedef unsigned size_type;
1822 * size_type size;
1823 * \endcode
1824 *
1825 * The typedef is a declaration of size_type (CXCursor_TypedefDecl),
1826 * while the type of the variable "size" is referenced. The cursor
1827 * referenced by the type of size is the typedef for size_type.
1828 */
1829 CXCursor_TypeRef = 43,
1830 CXCursor_CXXBaseSpecifier = 44,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001831 /**
1832 * A reference to a class template, function template, template
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001833 * template parameter, or class template partial specialization.
1834 */
1835 CXCursor_TemplateRef = 45,
1836 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001837 * A reference to a namespace or namespace alias.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001838 */
1839 CXCursor_NamespaceRef = 46,
1840 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001841 * A reference to a member of a struct, union, or class that occurs in
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001842 * some non-expression context, e.g., a designated initializer.
1843 */
1844 CXCursor_MemberRef = 47,
1845 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001846 * A reference to a labeled statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001847 *
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001848 * This cursor kind is used to describe the jump to "start_over" in the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001849 * goto statement in the following example:
1850 *
1851 * \code
1852 * start_over:
1853 * ++counter;
1854 *
1855 * goto start_over;
1856 * \endcode
1857 *
1858 * A label reference cursor refers to a label statement.
1859 */
1860 CXCursor_LabelRef = 48,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001861
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001862 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001863 * A reference to a set of overloaded functions or function templates
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001864 * that has not yet been resolved to a specific function or function template.
1865 *
1866 * An overloaded declaration reference cursor occurs in C++ templates where
1867 * a dependent name refers to a function. For example:
1868 *
1869 * \code
1870 * template<typename T> void swap(T&, T&);
1871 *
1872 * struct X { ... };
1873 * void swap(X&, X&);
1874 *
1875 * template<typename T>
1876 * void reverse(T* first, T* last) {
1877 * while (first < last - 1) {
1878 * swap(*first, *--last);
1879 * ++first;
1880 * }
1881 * }
1882 *
1883 * struct Y { };
1884 * void swap(Y&, Y&);
1885 * \endcode
1886 *
1887 * Here, the identifier "swap" is associated with an overloaded declaration
1888 * reference. In the template definition, "swap" refers to either of the two
1889 * "swap" functions declared above, so both results will be available. At
1890 * instantiation time, "swap" may also refer to other functions found via
1891 * argument-dependent lookup (e.g., the "swap" function at the end of the
1892 * example).
1893 *
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001894 * The functions \c clang_getNumOverloadedDecls() and
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001895 * \c clang_getOverloadedDecl() can be used to retrieve the definitions
1896 * referenced by this cursor.
1897 */
1898 CXCursor_OverloadedDeclRef = 49,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001899
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001900 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001901 * A reference to a variable that occurs in some non-expression
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001902 * context, e.g., a C++ lambda capture list.
1903 */
1904 CXCursor_VariableRef = 50,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001905
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001906 CXCursor_LastRef = CXCursor_VariableRef,
1907
1908 /* Error conditions */
1909 CXCursor_FirstInvalid = 70,
1910 CXCursor_InvalidFile = 70,
1911 CXCursor_NoDeclFound = 71,
1912 CXCursor_NotImplemented = 72,
1913 CXCursor_InvalidCode = 73,
1914 CXCursor_LastInvalid = CXCursor_InvalidCode,
1915
1916 /* Expressions */
1917 CXCursor_FirstExpr = 100,
1918
1919 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001920 * An expression whose specific kind is not exposed via this
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001921 * interface.
1922 *
1923 * Unexposed expressions have the same operations as any other kind
1924 * of expression; one can extract their location information,
1925 * spelling, children, etc. However, the specific kind of the
1926 * expression is not reported.
1927 */
1928 CXCursor_UnexposedExpr = 100,
1929
1930 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001931 * An expression that refers to some value declaration, such
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001932 * as a function, variable, or enumerator.
1933 */
1934 CXCursor_DeclRefExpr = 101,
1935
1936 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001937 * An expression that refers to a member of a struct, union,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001938 * class, Objective-C class, etc.
1939 */
1940 CXCursor_MemberRefExpr = 102,
1941
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001942 /** An expression that calls a function. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001943 CXCursor_CallExpr = 103,
1944
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001945 /** An expression that sends a message to an Objective-C
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001946 object or class. */
1947 CXCursor_ObjCMessageExpr = 104,
1948
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001949 /** An expression that represents a block literal. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001950 CXCursor_BlockExpr = 105,
1951
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001952 /** An integer literal.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001953 */
1954 CXCursor_IntegerLiteral = 106,
1955
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001956 /** A floating point number literal.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001957 */
1958 CXCursor_FloatingLiteral = 107,
1959
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001960 /** An imaginary number literal.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001961 */
1962 CXCursor_ImaginaryLiteral = 108,
1963
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001964 /** A string literal.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001965 */
1966 CXCursor_StringLiteral = 109,
1967
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001968 /** A character literal.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001969 */
1970 CXCursor_CharacterLiteral = 110,
1971
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001972 /** A parenthesized expression, e.g. "(1)".
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001973 *
1974 * This AST node is only formed if full location information is requested.
1975 */
1976 CXCursor_ParenExpr = 111,
1977
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001978 /** This represents the unary-expression's (except sizeof and
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001979 * alignof).
1980 */
1981 CXCursor_UnaryOperator = 112,
1982
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001983 /** [C99 6.5.2.1] Array Subscripting.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001984 */
1985 CXCursor_ArraySubscriptExpr = 113,
1986
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001987 /** A builtin binary operation expression such as "x + y" or
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001988 * "x <= y".
1989 */
1990 CXCursor_BinaryOperator = 114,
1991
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001992 /** Compound assignment such as "+=".
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001993 */
1994 CXCursor_CompoundAssignOperator = 115,
1995
Andrew Scullcdfcccc2018-10-05 20:58:37 +01001996 /** The ?: ternary operator.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001997 */
1998 CXCursor_ConditionalOperator = 116,
1999
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002000 /** An explicit cast in C (C99 6.5.4) or a C-style cast in C++
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002001 * (C++ [expr.cast]), which uses the syntax (Type)expr.
2002 *
2003 * For example: (int)f.
2004 */
2005 CXCursor_CStyleCastExpr = 117,
2006
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002007 /** [C99 6.5.2.5]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002008 */
2009 CXCursor_CompoundLiteralExpr = 118,
2010
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002011 /** Describes an C or C++ initializer list.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002012 */
2013 CXCursor_InitListExpr = 119,
2014
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002015 /** The GNU address of label extension, representing &&label.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002016 */
2017 CXCursor_AddrLabelExpr = 120,
2018
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002019 /** This is the GNU Statement Expression extension: ({int X=4; X;})
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002020 */
2021 CXCursor_StmtExpr = 121,
2022
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002023 /** Represents a C11 generic selection.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002024 */
2025 CXCursor_GenericSelectionExpr = 122,
2026
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002027 /** Implements the GNU __null extension, which is a name for a null
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002028 * pointer constant that has integral type (e.g., int or long) and is the same
2029 * size and alignment as a pointer.
2030 *
2031 * The __null extension is typically only used by system headers, which define
2032 * NULL as __null in C++ rather than using 0 (which is an integer that may not
2033 * match the size of a pointer).
2034 */
2035 CXCursor_GNUNullExpr = 123,
2036
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002037 /** C++'s static_cast<> expression.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002038 */
2039 CXCursor_CXXStaticCastExpr = 124,
2040
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002041 /** C++'s dynamic_cast<> expression.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002042 */
2043 CXCursor_CXXDynamicCastExpr = 125,
2044
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002045 /** C++'s reinterpret_cast<> expression.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002046 */
2047 CXCursor_CXXReinterpretCastExpr = 126,
2048
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002049 /** C++'s const_cast<> expression.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002050 */
2051 CXCursor_CXXConstCastExpr = 127,
2052
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002053 /** Represents an explicit C++ type conversion that uses "functional"
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002054 * notion (C++ [expr.type.conv]).
2055 *
2056 * Example:
2057 * \code
2058 * x = int(0.5);
2059 * \endcode
2060 */
2061 CXCursor_CXXFunctionalCastExpr = 128,
2062
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002063 /** A C++ typeid expression (C++ [expr.typeid]).
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002064 */
2065 CXCursor_CXXTypeidExpr = 129,
2066
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002067 /** [C++ 2.13.5] C++ Boolean Literal.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002068 */
2069 CXCursor_CXXBoolLiteralExpr = 130,
2070
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002071 /** [C++0x 2.14.7] C++ Pointer Literal.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002072 */
2073 CXCursor_CXXNullPtrLiteralExpr = 131,
2074
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002075 /** Represents the "this" expression in C++
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002076 */
2077 CXCursor_CXXThisExpr = 132,
2078
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002079 /** [C++ 15] C++ Throw Expression.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002080 *
2081 * This handles 'throw' and 'throw' assignment-expression. When
2082 * assignment-expression isn't present, Op will be null.
2083 */
2084 CXCursor_CXXThrowExpr = 133,
2085
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002086 /** A new expression for memory allocation and constructor calls, e.g:
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002087 * "new CXXNewExpr(foo)".
2088 */
2089 CXCursor_CXXNewExpr = 134,
2090
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002091 /** A delete expression for memory deallocation and destructor calls,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002092 * e.g. "delete[] pArray".
2093 */
2094 CXCursor_CXXDeleteExpr = 135,
2095
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002096 /** A unary expression. (noexcept, sizeof, or other traits)
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002097 */
2098 CXCursor_UnaryExpr = 136,
2099
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002100 /** An Objective-C string literal i.e. @"foo".
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002101 */
2102 CXCursor_ObjCStringLiteral = 137,
2103
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002104 /** An Objective-C \@encode expression.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002105 */
2106 CXCursor_ObjCEncodeExpr = 138,
2107
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002108 /** An Objective-C \@selector expression.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002109 */
2110 CXCursor_ObjCSelectorExpr = 139,
2111
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002112 /** An Objective-C \@protocol expression.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002113 */
2114 CXCursor_ObjCProtocolExpr = 140,
2115
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002116 /** An Objective-C "bridged" cast expression, which casts between
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002117 * Objective-C pointers and C pointers, transferring ownership in the process.
2118 *
2119 * \code
2120 * NSString *str = (__bridge_transfer NSString *)CFCreateString();
2121 * \endcode
2122 */
2123 CXCursor_ObjCBridgedCastExpr = 141,
2124
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002125 /** Represents a C++0x pack expansion that produces a sequence of
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002126 * expressions.
2127 *
2128 * A pack expansion expression contains a pattern (which itself is an
2129 * expression) followed by an ellipsis. For example:
2130 *
2131 * \code
2132 * template<typename F, typename ...Types>
2133 * void forward(F f, Types &&...args) {
2134 * f(static_cast<Types&&>(args)...);
2135 * }
2136 * \endcode
2137 */
2138 CXCursor_PackExpansionExpr = 142,
2139
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002140 /** Represents an expression that computes the length of a parameter
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002141 * pack.
2142 *
2143 * \code
2144 * template<typename ...Types>
2145 * struct count {
2146 * static const unsigned value = sizeof...(Types);
2147 * };
2148 * \endcode
2149 */
2150 CXCursor_SizeOfPackExpr = 143,
2151
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002152 /* Represents a C++ lambda expression that produces a local function
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002153 * object.
2154 *
2155 * \code
2156 * void abssort(float *x, unsigned N) {
2157 * std::sort(x, x + N,
2158 * [](float a, float b) {
2159 * return std::abs(a) < std::abs(b);
2160 * });
2161 * }
2162 * \endcode
2163 */
2164 CXCursor_LambdaExpr = 144,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002165
2166 /** Objective-c Boolean Literal.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002167 */
2168 CXCursor_ObjCBoolLiteralExpr = 145,
2169
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002170 /** Represents the "self" expression in an Objective-C method.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002171 */
2172 CXCursor_ObjCSelfExpr = 146,
2173
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002174 /** OpenMP 4.0 [2.4, Array Section].
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002175 */
2176 CXCursor_OMPArraySectionExpr = 147,
2177
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002178 /** Represents an @available(...) check.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002179 */
2180 CXCursor_ObjCAvailabilityCheckExpr = 148,
2181
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002182 /**
2183 * Fixed point literal
2184 */
2185 CXCursor_FixedPointLiteral = 149,
2186
2187 CXCursor_LastExpr = CXCursor_FixedPointLiteral,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002188
2189 /* Statements */
2190 CXCursor_FirstStmt = 200,
2191 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002192 * A statement whose specific kind is not exposed via this
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002193 * interface.
2194 *
2195 * Unexposed statements have the same operations as any other kind of
2196 * statement; one can extract their location information, spelling,
2197 * children, etc. However, the specific kind of the statement is not
2198 * reported.
2199 */
2200 CXCursor_UnexposedStmt = 200,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002201
2202 /** A labelled statement in a function.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002203 *
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002204 * This cursor kind is used to describe the "start_over:" label statement in
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002205 * the following example:
2206 *
2207 * \code
2208 * start_over:
2209 * ++counter;
2210 * \endcode
2211 *
2212 */
2213 CXCursor_LabelStmt = 201,
2214
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002215 /** A group of statements like { stmt stmt }.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002216 *
2217 * This cursor kind is used to describe compound statements, e.g. function
2218 * bodies.
2219 */
2220 CXCursor_CompoundStmt = 202,
2221
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002222 /** A case statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002223 */
2224 CXCursor_CaseStmt = 203,
2225
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002226 /** A default statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002227 */
2228 CXCursor_DefaultStmt = 204,
2229
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002230 /** An if statement
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002231 */
2232 CXCursor_IfStmt = 205,
2233
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002234 /** A switch statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002235 */
2236 CXCursor_SwitchStmt = 206,
2237
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002238 /** A while statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002239 */
2240 CXCursor_WhileStmt = 207,
2241
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002242 /** A do statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002243 */
2244 CXCursor_DoStmt = 208,
2245
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002246 /** A for statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002247 */
2248 CXCursor_ForStmt = 209,
2249
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002250 /** A goto statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002251 */
2252 CXCursor_GotoStmt = 210,
2253
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002254 /** An indirect goto statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002255 */
2256 CXCursor_IndirectGotoStmt = 211,
2257
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002258 /** A continue statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002259 */
2260 CXCursor_ContinueStmt = 212,
2261
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002262 /** A break statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002263 */
2264 CXCursor_BreakStmt = 213,
2265
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002266 /** A return statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002267 */
2268 CXCursor_ReturnStmt = 214,
2269
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002270 /** A GCC inline assembly statement extension.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002271 */
2272 CXCursor_GCCAsmStmt = 215,
2273 CXCursor_AsmStmt = CXCursor_GCCAsmStmt,
2274
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002275 /** Objective-C's overall \@try-\@catch-\@finally statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002276 */
2277 CXCursor_ObjCAtTryStmt = 216,
2278
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002279 /** Objective-C's \@catch statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002280 */
2281 CXCursor_ObjCAtCatchStmt = 217,
2282
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002283 /** Objective-C's \@finally statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002284 */
2285 CXCursor_ObjCAtFinallyStmt = 218,
2286
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002287 /** Objective-C's \@throw statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002288 */
2289 CXCursor_ObjCAtThrowStmt = 219,
2290
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002291 /** Objective-C's \@synchronized statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002292 */
2293 CXCursor_ObjCAtSynchronizedStmt = 220,
2294
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002295 /** Objective-C's autorelease pool statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002296 */
2297 CXCursor_ObjCAutoreleasePoolStmt = 221,
2298
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002299 /** Objective-C's collection statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002300 */
2301 CXCursor_ObjCForCollectionStmt = 222,
2302
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002303 /** C++'s catch statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002304 */
2305 CXCursor_CXXCatchStmt = 223,
2306
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002307 /** C++'s try statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002308 */
2309 CXCursor_CXXTryStmt = 224,
2310
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002311 /** C++'s for (* : *) statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002312 */
2313 CXCursor_CXXForRangeStmt = 225,
2314
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002315 /** Windows Structured Exception Handling's try statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002316 */
2317 CXCursor_SEHTryStmt = 226,
2318
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002319 /** Windows Structured Exception Handling's except statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002320 */
2321 CXCursor_SEHExceptStmt = 227,
2322
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002323 /** Windows Structured Exception Handling's finally statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002324 */
2325 CXCursor_SEHFinallyStmt = 228,
2326
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002327 /** A MS inline assembly statement extension.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002328 */
2329 CXCursor_MSAsmStmt = 229,
2330
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002331 /** The null statement ";": C99 6.8.3p3.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002332 *
2333 * This cursor kind is used to describe the null statement.
2334 */
2335 CXCursor_NullStmt = 230,
2336
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002337 /** Adaptor class for mixing declarations with statements and
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002338 * expressions.
2339 */
2340 CXCursor_DeclStmt = 231,
2341
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002342 /** OpenMP parallel directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002343 */
2344 CXCursor_OMPParallelDirective = 232,
2345
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002346 /** OpenMP SIMD directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002347 */
2348 CXCursor_OMPSimdDirective = 233,
2349
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002350 /** OpenMP for directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002351 */
2352 CXCursor_OMPForDirective = 234,
2353
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002354 /** OpenMP sections directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002355 */
2356 CXCursor_OMPSectionsDirective = 235,
2357
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002358 /** OpenMP section directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002359 */
2360 CXCursor_OMPSectionDirective = 236,
2361
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002362 /** OpenMP single directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002363 */
2364 CXCursor_OMPSingleDirective = 237,
2365
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002366 /** OpenMP parallel for directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002367 */
2368 CXCursor_OMPParallelForDirective = 238,
2369
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002370 /** OpenMP parallel sections directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002371 */
2372 CXCursor_OMPParallelSectionsDirective = 239,
2373
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002374 /** OpenMP task directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002375 */
2376 CXCursor_OMPTaskDirective = 240,
2377
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002378 /** OpenMP master directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002379 */
2380 CXCursor_OMPMasterDirective = 241,
2381
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002382 /** OpenMP critical directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002383 */
2384 CXCursor_OMPCriticalDirective = 242,
2385
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002386 /** OpenMP taskyield directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002387 */
2388 CXCursor_OMPTaskyieldDirective = 243,
2389
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002390 /** OpenMP barrier directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002391 */
2392 CXCursor_OMPBarrierDirective = 244,
2393
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002394 /** OpenMP taskwait directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002395 */
2396 CXCursor_OMPTaskwaitDirective = 245,
2397
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002398 /** OpenMP flush directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002399 */
2400 CXCursor_OMPFlushDirective = 246,
2401
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002402 /** Windows Structured Exception Handling's leave statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002403 */
2404 CXCursor_SEHLeaveStmt = 247,
2405
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002406 /** OpenMP ordered directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002407 */
2408 CXCursor_OMPOrderedDirective = 248,
2409
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002410 /** OpenMP atomic directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002411 */
2412 CXCursor_OMPAtomicDirective = 249,
2413
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002414 /** OpenMP for SIMD directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002415 */
2416 CXCursor_OMPForSimdDirective = 250,
2417
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002418 /** OpenMP parallel for SIMD directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002419 */
2420 CXCursor_OMPParallelForSimdDirective = 251,
2421
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002422 /** OpenMP target directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002423 */
2424 CXCursor_OMPTargetDirective = 252,
2425
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002426 /** OpenMP teams directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002427 */
2428 CXCursor_OMPTeamsDirective = 253,
2429
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002430 /** OpenMP taskgroup directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002431 */
2432 CXCursor_OMPTaskgroupDirective = 254,
2433
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002434 /** OpenMP cancellation point directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002435 */
2436 CXCursor_OMPCancellationPointDirective = 255,
2437
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002438 /** OpenMP cancel directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002439 */
2440 CXCursor_OMPCancelDirective = 256,
2441
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002442 /** OpenMP target data directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002443 */
2444 CXCursor_OMPTargetDataDirective = 257,
2445
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002446 /** OpenMP taskloop directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002447 */
2448 CXCursor_OMPTaskLoopDirective = 258,
2449
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002450 /** OpenMP taskloop simd directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002451 */
2452 CXCursor_OMPTaskLoopSimdDirective = 259,
2453
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002454 /** OpenMP distribute directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002455 */
2456 CXCursor_OMPDistributeDirective = 260,
2457
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002458 /** OpenMP target enter data directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002459 */
2460 CXCursor_OMPTargetEnterDataDirective = 261,
2461
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002462 /** OpenMP target exit data directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002463 */
2464 CXCursor_OMPTargetExitDataDirective = 262,
2465
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002466 /** OpenMP target parallel directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002467 */
2468 CXCursor_OMPTargetParallelDirective = 263,
2469
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002470 /** OpenMP target parallel for directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002471 */
2472 CXCursor_OMPTargetParallelForDirective = 264,
2473
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002474 /** OpenMP target update directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002475 */
2476 CXCursor_OMPTargetUpdateDirective = 265,
2477
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002478 /** OpenMP distribute parallel for directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002479 */
2480 CXCursor_OMPDistributeParallelForDirective = 266,
2481
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002482 /** OpenMP distribute parallel for simd directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002483 */
2484 CXCursor_OMPDistributeParallelForSimdDirective = 267,
2485
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002486 /** OpenMP distribute simd directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002487 */
2488 CXCursor_OMPDistributeSimdDirective = 268,
2489
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002490 /** OpenMP target parallel for simd directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002491 */
2492 CXCursor_OMPTargetParallelForSimdDirective = 269,
2493
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002494 /** OpenMP target simd directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002495 */
2496 CXCursor_OMPTargetSimdDirective = 270,
2497
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002498 /** OpenMP teams distribute directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002499 */
2500 CXCursor_OMPTeamsDistributeDirective = 271,
2501
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002502 /** OpenMP teams distribute simd directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002503 */
2504 CXCursor_OMPTeamsDistributeSimdDirective = 272,
2505
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002506 /** OpenMP teams distribute parallel for simd directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002507 */
2508 CXCursor_OMPTeamsDistributeParallelForSimdDirective = 273,
2509
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002510 /** OpenMP teams distribute parallel for directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002511 */
2512 CXCursor_OMPTeamsDistributeParallelForDirective = 274,
2513
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002514 /** OpenMP target teams directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002515 */
2516 CXCursor_OMPTargetTeamsDirective = 275,
2517
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002518 /** OpenMP target teams distribute directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002519 */
2520 CXCursor_OMPTargetTeamsDistributeDirective = 276,
2521
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002522 /** OpenMP target teams distribute parallel for directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002523 */
2524 CXCursor_OMPTargetTeamsDistributeParallelForDirective = 277,
2525
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002526 /** OpenMP target teams distribute parallel for simd directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002527 */
2528 CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective = 278,
2529
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002530 /** OpenMP target teams distribute simd directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002531 */
2532 CXCursor_OMPTargetTeamsDistributeSimdDirective = 279,
2533
2534 CXCursor_LastStmt = CXCursor_OMPTargetTeamsDistributeSimdDirective,
2535
2536 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002537 * Cursor that represents the translation unit itself.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002538 *
2539 * The translation unit cursor exists primarily to act as the root
2540 * cursor for traversing the contents of a translation unit.
2541 */
2542 CXCursor_TranslationUnit = 300,
2543
2544 /* Attributes */
2545 CXCursor_FirstAttr = 400,
2546 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002547 * An attribute whose specific kind is not exposed via this
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002548 * interface.
2549 */
2550 CXCursor_UnexposedAttr = 400,
2551
2552 CXCursor_IBActionAttr = 401,
2553 CXCursor_IBOutletAttr = 402,
2554 CXCursor_IBOutletCollectionAttr = 403,
2555 CXCursor_CXXFinalAttr = 404,
2556 CXCursor_CXXOverrideAttr = 405,
2557 CXCursor_AnnotateAttr = 406,
2558 CXCursor_AsmLabelAttr = 407,
2559 CXCursor_PackedAttr = 408,
2560 CXCursor_PureAttr = 409,
2561 CXCursor_ConstAttr = 410,
2562 CXCursor_NoDuplicateAttr = 411,
2563 CXCursor_CUDAConstantAttr = 412,
2564 CXCursor_CUDADeviceAttr = 413,
2565 CXCursor_CUDAGlobalAttr = 414,
2566 CXCursor_CUDAHostAttr = 415,
2567 CXCursor_CUDASharedAttr = 416,
2568 CXCursor_VisibilityAttr = 417,
2569 CXCursor_DLLExport = 418,
2570 CXCursor_DLLImport = 419,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002571 CXCursor_NSReturnsRetained = 420,
2572 CXCursor_NSReturnsNotRetained = 421,
2573 CXCursor_NSReturnsAutoreleased = 422,
2574 CXCursor_NSConsumesSelf = 423,
2575 CXCursor_NSConsumed = 424,
2576 CXCursor_ObjCException = 425,
2577 CXCursor_ObjCNSObject = 426,
2578 CXCursor_ObjCIndependentClass = 427,
2579 CXCursor_ObjCPreciseLifetime = 428,
2580 CXCursor_ObjCReturnsInnerPointer = 429,
2581 CXCursor_ObjCRequiresSuper = 430,
2582 CXCursor_ObjCRootClass = 431,
2583 CXCursor_ObjCSubclassingRestricted = 432,
2584 CXCursor_ObjCExplicitProtocolImpl = 433,
2585 CXCursor_ObjCDesignatedInitializer = 434,
2586 CXCursor_ObjCRuntimeVisible = 435,
2587 CXCursor_ObjCBoxable = 436,
2588 CXCursor_FlagEnum = 437,
Andrew Walbran16937d02019-10-22 13:54:20 +01002589 CXCursor_ConvergentAttr = 438,
2590 CXCursor_LastAttr = CXCursor_ConvergentAttr,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002591
2592 /* Preprocessing */
2593 CXCursor_PreprocessingDirective = 500,
2594 CXCursor_MacroDefinition = 501,
2595 CXCursor_MacroExpansion = 502,
2596 CXCursor_MacroInstantiation = CXCursor_MacroExpansion,
2597 CXCursor_InclusionDirective = 503,
2598 CXCursor_FirstPreprocessing = CXCursor_PreprocessingDirective,
2599 CXCursor_LastPreprocessing = CXCursor_InclusionDirective,
2600
2601 /* Extra Declarations */
2602 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002603 * A module import declaration.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002604 */
2605 CXCursor_ModuleImportDecl = 600,
2606 CXCursor_TypeAliasTemplateDecl = 601,
2607 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002608 * A static_assert or _Static_assert node
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002609 */
2610 CXCursor_StaticAssert = 602,
2611 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002612 * a friend declaration.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002613 */
2614 CXCursor_FriendDecl = 603,
2615 CXCursor_FirstExtraDecl = CXCursor_ModuleImportDecl,
2616 CXCursor_LastExtraDecl = CXCursor_FriendDecl,
2617
2618 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002619 * A code completion overload candidate.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002620 */
2621 CXCursor_OverloadCandidate = 700
2622};
2623
2624/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002625 * A cursor representing some element in the abstract syntax tree for
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002626 * a translation unit.
2627 *
2628 * The cursor abstraction unifies the different kinds of entities in a
2629 * program--declaration, statements, expressions, references to declarations,
2630 * etc.--under a single "cursor" abstraction with a common set of operations.
2631 * Common operation for a cursor include: getting the physical location in
2632 * a source file where the cursor points, getting the name associated with a
2633 * cursor, and retrieving cursors for any child nodes of a particular cursor.
2634 *
2635 * Cursors can be produced in two specific ways.
2636 * clang_getTranslationUnitCursor() produces a cursor for a translation unit,
2637 * from which one can use clang_visitChildren() to explore the rest of the
2638 * translation unit. clang_getCursor() maps from a physical source location
2639 * to the entity that resides at that location, allowing one to map from the
2640 * source code into the AST.
2641 */
2642typedef struct {
2643 enum CXCursorKind kind;
2644 int xdata;
2645 const void *data[3];
2646} CXCursor;
2647
2648/**
2649 * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations
2650 *
2651 * @{
2652 */
2653
2654/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002655 * Retrieve the NULL cursor, which represents no entity.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002656 */
2657CINDEX_LINKAGE CXCursor clang_getNullCursor(void);
2658
2659/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002660 * Retrieve the cursor that represents the given translation unit.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002661 *
2662 * The translation unit cursor can be used to start traversing the
2663 * various declarations within the given translation unit.
2664 */
2665CINDEX_LINKAGE CXCursor clang_getTranslationUnitCursor(CXTranslationUnit);
2666
2667/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002668 * Determine whether two cursors are equivalent.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002669 */
2670CINDEX_LINKAGE unsigned clang_equalCursors(CXCursor, CXCursor);
2671
2672/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002673 * Returns non-zero if \p cursor is null.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002674 */
2675CINDEX_LINKAGE int clang_Cursor_isNull(CXCursor cursor);
2676
2677/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002678 * Compute a hash value for the given cursor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002679 */
2680CINDEX_LINKAGE unsigned clang_hashCursor(CXCursor);
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002681
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002682/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002683 * Retrieve the kind of the given cursor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002684 */
2685CINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor);
2686
2687/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002688 * Determine whether the given cursor kind represents a declaration.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002689 */
2690CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind);
2691
2692/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002693 * Determine whether the given declaration is invalid.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002694 *
2695 * A declaration is invalid if it could not be parsed successfully.
2696 *
2697 * \returns non-zero if the cursor represents a declaration and it is
2698 * invalid, otherwise NULL.
2699 */
2700CINDEX_LINKAGE unsigned clang_isInvalidDeclaration(CXCursor);
2701
2702/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002703 * Determine whether the given cursor kind represents a simple
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002704 * reference.
2705 *
2706 * Note that other kinds of cursors (such as expressions) can also refer to
2707 * other cursors. Use clang_getCursorReferenced() to determine whether a
2708 * particular cursor refers to another entity.
2709 */
2710CINDEX_LINKAGE unsigned clang_isReference(enum CXCursorKind);
2711
2712/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002713 * Determine whether the given cursor kind represents an expression.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002714 */
2715CINDEX_LINKAGE unsigned clang_isExpression(enum CXCursorKind);
2716
2717/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002718 * Determine whether the given cursor kind represents a statement.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002719 */
2720CINDEX_LINKAGE unsigned clang_isStatement(enum CXCursorKind);
2721
2722/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002723 * Determine whether the given cursor kind represents an attribute.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002724 */
2725CINDEX_LINKAGE unsigned clang_isAttribute(enum CXCursorKind);
2726
2727/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002728 * Determine whether the given cursor has any attributes.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002729 */
2730CINDEX_LINKAGE unsigned clang_Cursor_hasAttrs(CXCursor C);
2731
2732/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002733 * Determine whether the given cursor kind represents an invalid
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002734 * cursor.
2735 */
2736CINDEX_LINKAGE unsigned clang_isInvalid(enum CXCursorKind);
2737
2738/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002739 * Determine whether the given cursor kind represents a translation
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002740 * unit.
2741 */
2742CINDEX_LINKAGE unsigned clang_isTranslationUnit(enum CXCursorKind);
2743
2744/***
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002745 * Determine whether the given cursor represents a preprocessing
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002746 * element, such as a preprocessor directive or macro instantiation.
2747 */
2748CINDEX_LINKAGE unsigned clang_isPreprocessing(enum CXCursorKind);
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002749
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002750/***
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002751 * Determine whether the given cursor represents a currently
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002752 * unexposed piece of the AST (e.g., CXCursor_UnexposedStmt).
2753 */
2754CINDEX_LINKAGE unsigned clang_isUnexposed(enum CXCursorKind);
2755
2756/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002757 * Describe the linkage of the entity referred to by a cursor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002758 */
2759enum CXLinkageKind {
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002760 /** This value indicates that no linkage information is available
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002761 * for a provided CXCursor. */
2762 CXLinkage_Invalid,
2763 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002764 * This is the linkage for variables, parameters, and so on that
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002765 * have automatic storage. This covers normal (non-extern) local variables.
2766 */
2767 CXLinkage_NoLinkage,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002768 /** This is the linkage for static variables and static functions. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002769 CXLinkage_Internal,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002770 /** This is the linkage for entities with external linkage that live
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002771 * in C++ anonymous namespaces.*/
2772 CXLinkage_UniqueExternal,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002773 /** This is the linkage for entities with true, external linkage. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002774 CXLinkage_External
2775};
2776
2777/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002778 * Determine the linkage of the entity referred to by a given cursor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002779 */
2780CINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor);
2781
2782enum CXVisibilityKind {
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002783 /** This value indicates that no visibility information is available
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002784 * for a provided CXCursor. */
2785 CXVisibility_Invalid,
2786
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002787 /** Symbol not seen by the linker. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002788 CXVisibility_Hidden,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002789 /** Symbol seen by the linker but resolves to a symbol inside this object. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002790 CXVisibility_Protected,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002791 /** Symbol seen by the linker and acts like a normal symbol. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002792 CXVisibility_Default
2793};
2794
2795/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002796 * Describe the visibility of the entity referred to by a cursor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002797 *
2798 * This returns the default visibility if not explicitly specified by
2799 * a visibility attribute. The default visibility may be changed by
2800 * commandline arguments.
2801 *
2802 * \param cursor The cursor to query.
2803 *
2804 * \returns The visibility of the cursor.
2805 */
2806CINDEX_LINKAGE enum CXVisibilityKind clang_getCursorVisibility(CXCursor cursor);
2807
2808/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002809 * Determine the availability of the entity that this cursor refers to,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002810 * taking the current target platform into account.
2811 *
2812 * \param cursor The cursor to query.
2813 *
2814 * \returns The availability of the cursor.
2815 */
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002816CINDEX_LINKAGE enum CXAvailabilityKind
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002817clang_getCursorAvailability(CXCursor cursor);
2818
2819/**
2820 * Describes the availability of a given entity on a particular platform, e.g.,
2821 * a particular class might only be available on Mac OS 10.7 or newer.
2822 */
2823typedef struct CXPlatformAvailability {
2824 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002825 * A string that describes the platform for which this structure
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002826 * provides availability information.
2827 *
2828 * Possible values are "ios" or "macos".
2829 */
2830 CXString Platform;
2831 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002832 * The version number in which this entity was introduced.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002833 */
2834 CXVersion Introduced;
2835 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002836 * The version number in which this entity was deprecated (but is
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002837 * still available).
2838 */
2839 CXVersion Deprecated;
2840 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002841 * The version number in which this entity was obsoleted, and therefore
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002842 * is no longer available.
2843 */
2844 CXVersion Obsoleted;
2845 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002846 * Whether the entity is unconditionally unavailable on this platform.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002847 */
2848 int Unavailable;
2849 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002850 * An optional message to provide to a user of this API, e.g., to
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002851 * suggest replacement APIs.
2852 */
2853 CXString Message;
2854} CXPlatformAvailability;
2855
2856/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002857 * Determine the availability of the entity that this cursor refers to
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002858 * on any platforms for which availability information is known.
2859 *
2860 * \param cursor The cursor to query.
2861 *
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002862 * \param always_deprecated If non-NULL, will be set to indicate whether the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002863 * entity is deprecated on all platforms.
2864 *
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002865 * \param deprecated_message If non-NULL, will be set to the message text
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002866 * provided along with the unconditional deprecation of this entity. The client
2867 * is responsible for deallocating this string.
2868 *
2869 * \param always_unavailable If non-NULL, will be set to indicate whether the
2870 * entity is unavailable on all platforms.
2871 *
2872 * \param unavailable_message If non-NULL, will be set to the message text
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002873 * provided along with the unconditional unavailability of this entity. The
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002874 * client is responsible for deallocating this string.
2875 *
2876 * \param availability If non-NULL, an array of CXPlatformAvailability instances
2877 * that will be populated with platform availability information, up to either
2878 * the number of platforms for which availability information is available (as
2879 * returned by this function) or \c availability_size, whichever is smaller.
2880 *
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002881 * \param availability_size The number of elements available in the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002882 * \c availability array.
2883 *
2884 * \returns The number of platforms (N) for which availability information is
2885 * available (which is unrelated to \c availability_size).
2886 *
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002887 * Note that the client is responsible for calling
2888 * \c clang_disposeCXPlatformAvailability to free each of the
2889 * platform-availability structures returned. There are
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002890 * \c min(N, availability_size) such structures.
2891 */
2892CINDEX_LINKAGE int
2893clang_getCursorPlatformAvailability(CXCursor cursor,
2894 int *always_deprecated,
2895 CXString *deprecated_message,
2896 int *always_unavailable,
2897 CXString *unavailable_message,
2898 CXPlatformAvailability *availability,
2899 int availability_size);
2900
2901/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002902 * Free the memory associated with a \c CXPlatformAvailability structure.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002903 */
2904CINDEX_LINKAGE void
2905clang_disposeCXPlatformAvailability(CXPlatformAvailability *availability);
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002906
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002907/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002908 * Describe the "language" of the entity referred to by a cursor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002909 */
2910enum CXLanguageKind {
2911 CXLanguage_Invalid = 0,
2912 CXLanguage_C,
2913 CXLanguage_ObjC,
2914 CXLanguage_CPlusPlus
2915};
2916
2917/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002918 * Determine the "language" of the entity referred to by a given cursor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002919 */
2920CINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor);
2921
2922/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002923 * Describe the "thread-local storage (TLS) kind" of the declaration
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002924 * referred to by a cursor.
2925 */
2926enum CXTLSKind {
2927 CXTLS_None = 0,
2928 CXTLS_Dynamic,
2929 CXTLS_Static
2930};
2931
2932/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002933 * Determine the "thread-local storage (TLS) kind" of the declaration
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002934 * referred to by a cursor.
2935 */
2936CINDEX_LINKAGE enum CXTLSKind clang_getCursorTLSKind(CXCursor cursor);
2937
2938/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002939 * Returns the translation unit that a cursor originated from.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002940 */
2941CINDEX_LINKAGE CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor);
2942
2943/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002944 * A fast container representing a set of CXCursors.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002945 */
2946typedef struct CXCursorSetImpl *CXCursorSet;
2947
2948/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002949 * Creates an empty CXCursorSet.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002950 */
2951CINDEX_LINKAGE CXCursorSet clang_createCXCursorSet(void);
2952
2953/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002954 * Disposes a CXCursorSet and releases its associated memory.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002955 */
2956CINDEX_LINKAGE void clang_disposeCXCursorSet(CXCursorSet cset);
2957
2958/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002959 * Queries a CXCursorSet to see if it contains a specific CXCursor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002960 *
2961 * \returns non-zero if the set contains the specified cursor.
2962*/
2963CINDEX_LINKAGE unsigned clang_CXCursorSet_contains(CXCursorSet cset,
2964 CXCursor cursor);
2965
2966/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002967 * Inserts a CXCursor into a CXCursorSet.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002968 *
2969 * \returns zero if the CXCursor was already in the set, and non-zero otherwise.
2970*/
2971CINDEX_LINKAGE unsigned clang_CXCursorSet_insert(CXCursorSet cset,
2972 CXCursor cursor);
2973
2974/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002975 * Determine the semantic parent of the given cursor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002976 *
2977 * The semantic parent of a cursor is the cursor that semantically contains
2978 * the given \p cursor. For many declarations, the lexical and semantic parents
Andrew Scullcdfcccc2018-10-05 20:58:37 +01002979 * are equivalent (the lexical parent is returned by
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01002980 * \c clang_getCursorLexicalParent()). They diverge when declarations or
2981 * definitions are provided out-of-line. For example:
2982 *
2983 * \code
2984 * class C {
2985 * void f();
2986 * };
2987 *
2988 * void C::f() { }
2989 * \endcode
2990 *
2991 * In the out-of-line definition of \c C::f, the semantic parent is
2992 * the class \c C, of which this function is a member. The lexical parent is
2993 * the place where the declaration actually occurs in the source code; in this
2994 * case, the definition occurs in the translation unit. In general, the
2995 * lexical parent for a given entity can change without affecting the semantics
2996 * of the program, and the lexical parent of different declarations of the
2997 * same entity may be different. Changing the semantic parent of a declaration,
2998 * on the other hand, can have a major impact on semantics, and redeclarations
2999 * of a particular entity should all have the same semantic context.
3000 *
3001 * In the example above, both declarations of \c C::f have \c C as their
3002 * semantic context, while the lexical context of the first \c C::f is \c C
3003 * and the lexical context of the second \c C::f is the translation unit.
3004 *
3005 * For global declarations, the semantic parent is the translation unit.
3006 */
3007CINDEX_LINKAGE CXCursor clang_getCursorSemanticParent(CXCursor cursor);
3008
3009/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003010 * Determine the lexical parent of the given cursor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003011 *
3012 * The lexical parent of a cursor is the cursor in which the given \p cursor
3013 * was actually written. For many declarations, the lexical and semantic parents
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003014 * are equivalent (the semantic parent is returned by
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003015 * \c clang_getCursorSemanticParent()). They diverge when declarations or
3016 * definitions are provided out-of-line. For example:
3017 *
3018 * \code
3019 * class C {
3020 * void f();
3021 * };
3022 *
3023 * void C::f() { }
3024 * \endcode
3025 *
3026 * In the out-of-line definition of \c C::f, the semantic parent is
3027 * the class \c C, of which this function is a member. The lexical parent is
3028 * the place where the declaration actually occurs in the source code; in this
3029 * case, the definition occurs in the translation unit. In general, the
3030 * lexical parent for a given entity can change without affecting the semantics
3031 * of the program, and the lexical parent of different declarations of the
3032 * same entity may be different. Changing the semantic parent of a declaration,
3033 * on the other hand, can have a major impact on semantics, and redeclarations
3034 * of a particular entity should all have the same semantic context.
3035 *
3036 * In the example above, both declarations of \c C::f have \c C as their
3037 * semantic context, while the lexical context of the first \c C::f is \c C
3038 * and the lexical context of the second \c C::f is the translation unit.
3039 *
3040 * For declarations written in the global scope, the lexical parent is
3041 * the translation unit.
3042 */
3043CINDEX_LINKAGE CXCursor clang_getCursorLexicalParent(CXCursor cursor);
3044
3045/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003046 * Determine the set of methods that are overridden by the given
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003047 * method.
3048 *
3049 * In both Objective-C and C++, a method (aka virtual member function,
3050 * in C++) can override a virtual method in a base class. For
3051 * Objective-C, a method is said to override any method in the class's
3052 * base class, its protocols, or its categories' protocols, that has the same
3053 * selector and is of the same kind (class or instance).
3054 * If no such method exists, the search continues to the class's superclass,
3055 * its protocols, and its categories, and so on. A method from an Objective-C
3056 * implementation is considered to override the same methods as its
3057 * corresponding method in the interface.
3058 *
3059 * For C++, a virtual member function overrides any virtual member
3060 * function with the same signature that occurs in its base
3061 * classes. With multiple inheritance, a virtual member function can
3062 * override several virtual member functions coming from different
3063 * base classes.
3064 *
3065 * In all cases, this function determines the immediate overridden
3066 * method, rather than all of the overridden methods. For example, if
3067 * a method is originally declared in a class A, then overridden in B
3068 * (which in inherits from A) and also in C (which inherited from B),
3069 * then the only overridden method returned from this function when
3070 * invoked on C's method will be B's method. The client may then
3071 * invoke this function again, given the previously-found overridden
3072 * methods, to map out the complete method-override set.
3073 *
3074 * \param cursor A cursor representing an Objective-C or C++
3075 * method. This routine will compute the set of methods that this
3076 * method overrides.
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003077 *
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003078 * \param overridden A pointer whose pointee will be replaced with a
3079 * pointer to an array of cursors, representing the set of overridden
3080 * methods. If there are no overridden methods, the pointee will be
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003081 * set to NULL. The pointee must be freed via a call to
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003082 * \c clang_disposeOverriddenCursors().
3083 *
3084 * \param num_overridden A pointer to the number of overridden
3085 * functions, will be set to the number of overridden functions in the
3086 * array pointed to by \p overridden.
3087 */
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003088CINDEX_LINKAGE void clang_getOverriddenCursors(CXCursor cursor,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003089 CXCursor **overridden,
3090 unsigned *num_overridden);
3091
3092/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003093 * Free the set of overridden cursors returned by \c
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003094 * clang_getOverriddenCursors().
3095 */
3096CINDEX_LINKAGE void clang_disposeOverriddenCursors(CXCursor *overridden);
3097
3098/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003099 * Retrieve the file that is included by the given inclusion directive
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003100 * cursor.
3101 */
3102CINDEX_LINKAGE CXFile clang_getIncludedFile(CXCursor cursor);
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003103
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003104/**
3105 * @}
3106 */
3107
3108/**
3109 * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code
3110 *
3111 * Cursors represent a location within the Abstract Syntax Tree (AST). These
3112 * routines help map between cursors and the physical locations where the
3113 * described entities occur in the source code. The mapping is provided in
3114 * both directions, so one can map from source code to the AST and back.
3115 *
3116 * @{
3117 */
3118
3119/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003120 * Map a source location to the cursor that describes the entity at that
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003121 * location in the source code.
3122 *
3123 * clang_getCursor() maps an arbitrary source location within a translation
3124 * unit down to the most specific cursor that describes the entity at that
3125 * location. For example, given an expression \c x + y, invoking
3126 * clang_getCursor() with a source location pointing to "x" will return the
3127 * cursor for "x"; similarly for "y". If the cursor points anywhere between
3128 * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor()
3129 * will return a cursor referring to the "+" expression.
3130 *
3131 * \returns a cursor representing the entity at the given source location, or
3132 * a NULL cursor if no such entity can be found.
3133 */
3134CINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, CXSourceLocation);
3135
3136/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003137 * Retrieve the physical location of the source constructor referenced
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003138 * by the given cursor.
3139 *
3140 * The location of a declaration is typically the location of the name of that
3141 * declaration, where the name of that declaration would occur if it is
3142 * unnamed, or some keyword that introduces that particular declaration.
3143 * The location of a reference is where that reference occurs within the
3144 * source code.
3145 */
3146CINDEX_LINKAGE CXSourceLocation clang_getCursorLocation(CXCursor);
3147
3148/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003149 * Retrieve the physical extent of the source construct referenced by
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003150 * the given cursor.
3151 *
3152 * The extent of a cursor starts with the file/line/column pointing at the
3153 * first character within the source construct that the cursor refers to and
3154 * ends with the last character within that source construct. For a
3155 * declaration, the extent covers the declaration itself. For a reference,
3156 * the extent covers the location of the reference (e.g., where the referenced
3157 * entity was actually used).
3158 */
3159CINDEX_LINKAGE CXSourceRange clang_getCursorExtent(CXCursor);
3160
3161/**
3162 * @}
3163 */
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003164
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003165/**
3166 * \defgroup CINDEX_TYPES Type information for CXCursors
3167 *
3168 * @{
3169 */
3170
3171/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003172 * Describes the kind of type
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003173 */
3174enum CXTypeKind {
3175 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003176 * Represents an invalid type (e.g., where no type is available).
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003177 */
3178 CXType_Invalid = 0,
3179
3180 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003181 * A type whose specific kind is not exposed via this
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003182 * interface.
3183 */
3184 CXType_Unexposed = 1,
3185
3186 /* Builtin types */
3187 CXType_Void = 2,
3188 CXType_Bool = 3,
3189 CXType_Char_U = 4,
3190 CXType_UChar = 5,
3191 CXType_Char16 = 6,
3192 CXType_Char32 = 7,
3193 CXType_UShort = 8,
3194 CXType_UInt = 9,
3195 CXType_ULong = 10,
3196 CXType_ULongLong = 11,
3197 CXType_UInt128 = 12,
3198 CXType_Char_S = 13,
3199 CXType_SChar = 14,
3200 CXType_WChar = 15,
3201 CXType_Short = 16,
3202 CXType_Int = 17,
3203 CXType_Long = 18,
3204 CXType_LongLong = 19,
3205 CXType_Int128 = 20,
3206 CXType_Float = 21,
3207 CXType_Double = 22,
3208 CXType_LongDouble = 23,
3209 CXType_NullPtr = 24,
3210 CXType_Overload = 25,
3211 CXType_Dependent = 26,
3212 CXType_ObjCId = 27,
3213 CXType_ObjCClass = 28,
3214 CXType_ObjCSel = 29,
3215 CXType_Float128 = 30,
3216 CXType_Half = 31,
3217 CXType_Float16 = 32,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003218 CXType_ShortAccum = 33,
3219 CXType_Accum = 34,
3220 CXType_LongAccum = 35,
3221 CXType_UShortAccum = 36,
3222 CXType_UAccum = 37,
3223 CXType_ULongAccum = 38,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003224 CXType_FirstBuiltin = CXType_Void,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003225 CXType_LastBuiltin = CXType_ULongAccum,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003226
3227 CXType_Complex = 100,
3228 CXType_Pointer = 101,
3229 CXType_BlockPointer = 102,
3230 CXType_LValueReference = 103,
3231 CXType_RValueReference = 104,
3232 CXType_Record = 105,
3233 CXType_Enum = 106,
3234 CXType_Typedef = 107,
3235 CXType_ObjCInterface = 108,
3236 CXType_ObjCObjectPointer = 109,
3237 CXType_FunctionNoProto = 110,
3238 CXType_FunctionProto = 111,
3239 CXType_ConstantArray = 112,
3240 CXType_Vector = 113,
3241 CXType_IncompleteArray = 114,
3242 CXType_VariableArray = 115,
3243 CXType_DependentSizedArray = 116,
3244 CXType_MemberPointer = 117,
3245 CXType_Auto = 118,
3246
3247 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003248 * Represents a type that was referred to using an elaborated type keyword.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003249 *
3250 * E.g., struct S, or via a qualified name, e.g., N::M::type, or both.
3251 */
3252 CXType_Elaborated = 119,
3253
3254 /* OpenCL PipeType. */
3255 CXType_Pipe = 120,
3256
3257 /* OpenCL builtin types. */
3258 CXType_OCLImage1dRO = 121,
3259 CXType_OCLImage1dArrayRO = 122,
3260 CXType_OCLImage1dBufferRO = 123,
3261 CXType_OCLImage2dRO = 124,
3262 CXType_OCLImage2dArrayRO = 125,
3263 CXType_OCLImage2dDepthRO = 126,
3264 CXType_OCLImage2dArrayDepthRO = 127,
3265 CXType_OCLImage2dMSAARO = 128,
3266 CXType_OCLImage2dArrayMSAARO = 129,
3267 CXType_OCLImage2dMSAADepthRO = 130,
3268 CXType_OCLImage2dArrayMSAADepthRO = 131,
3269 CXType_OCLImage3dRO = 132,
3270 CXType_OCLImage1dWO = 133,
3271 CXType_OCLImage1dArrayWO = 134,
3272 CXType_OCLImage1dBufferWO = 135,
3273 CXType_OCLImage2dWO = 136,
3274 CXType_OCLImage2dArrayWO = 137,
3275 CXType_OCLImage2dDepthWO = 138,
3276 CXType_OCLImage2dArrayDepthWO = 139,
3277 CXType_OCLImage2dMSAAWO = 140,
3278 CXType_OCLImage2dArrayMSAAWO = 141,
3279 CXType_OCLImage2dMSAADepthWO = 142,
3280 CXType_OCLImage2dArrayMSAADepthWO = 143,
3281 CXType_OCLImage3dWO = 144,
3282 CXType_OCLImage1dRW = 145,
3283 CXType_OCLImage1dArrayRW = 146,
3284 CXType_OCLImage1dBufferRW = 147,
3285 CXType_OCLImage2dRW = 148,
3286 CXType_OCLImage2dArrayRW = 149,
3287 CXType_OCLImage2dDepthRW = 150,
3288 CXType_OCLImage2dArrayDepthRW = 151,
3289 CXType_OCLImage2dMSAARW = 152,
3290 CXType_OCLImage2dArrayMSAARW = 153,
3291 CXType_OCLImage2dMSAADepthRW = 154,
3292 CXType_OCLImage2dArrayMSAADepthRW = 155,
3293 CXType_OCLImage3dRW = 156,
3294 CXType_OCLSampler = 157,
3295 CXType_OCLEvent = 158,
3296 CXType_OCLQueue = 159,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003297 CXType_OCLReserveID = 160,
3298
3299 CXType_ObjCObject = 161,
3300 CXType_ObjCTypeParam = 162,
Andrew Walbran16937d02019-10-22 13:54:20 +01003301 CXType_Attributed = 163,
3302
3303 CXType_OCLIntelSubgroupAVCMcePayload = 164,
3304 CXType_OCLIntelSubgroupAVCImePayload = 165,
3305 CXType_OCLIntelSubgroupAVCRefPayload = 166,
3306 CXType_OCLIntelSubgroupAVCSicPayload = 167,
3307 CXType_OCLIntelSubgroupAVCMceResult = 168,
3308 CXType_OCLIntelSubgroupAVCImeResult = 169,
3309 CXType_OCLIntelSubgroupAVCRefResult = 170,
3310 CXType_OCLIntelSubgroupAVCSicResult = 171,
3311 CXType_OCLIntelSubgroupAVCImeResultSingleRefStreamout = 172,
3312 CXType_OCLIntelSubgroupAVCImeResultDualRefStreamout = 173,
3313 CXType_OCLIntelSubgroupAVCImeSingleRefStreamin = 174,
3314
3315 CXType_OCLIntelSubgroupAVCImeDualRefStreamin = 175
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003316};
3317
3318/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003319 * Describes the calling convention of a function type
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003320 */
3321enum CXCallingConv {
3322 CXCallingConv_Default = 0,
3323 CXCallingConv_C = 1,
3324 CXCallingConv_X86StdCall = 2,
3325 CXCallingConv_X86FastCall = 3,
3326 CXCallingConv_X86ThisCall = 4,
3327 CXCallingConv_X86Pascal = 5,
3328 CXCallingConv_AAPCS = 6,
3329 CXCallingConv_AAPCS_VFP = 7,
3330 CXCallingConv_X86RegCall = 8,
3331 CXCallingConv_IntelOclBicc = 9,
3332 CXCallingConv_Win64 = 10,
3333 /* Alias for compatibility with older versions of API. */
3334 CXCallingConv_X86_64Win64 = CXCallingConv_Win64,
3335 CXCallingConv_X86_64SysV = 11,
3336 CXCallingConv_X86VectorCall = 12,
3337 CXCallingConv_Swift = 13,
3338 CXCallingConv_PreserveMost = 14,
3339 CXCallingConv_PreserveAll = 15,
Andrew Walbran16937d02019-10-22 13:54:20 +01003340 CXCallingConv_AArch64VectorCall = 16,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003341
3342 CXCallingConv_Invalid = 100,
3343 CXCallingConv_Unexposed = 200
3344};
3345
3346/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003347 * The type of an element in the abstract syntax tree.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003348 *
3349 */
3350typedef struct {
3351 enum CXTypeKind kind;
3352 void *data[2];
3353} CXType;
3354
3355/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003356 * Retrieve the type of a CXCursor (if any).
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003357 */
3358CINDEX_LINKAGE CXType clang_getCursorType(CXCursor C);
3359
3360/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003361 * Pretty-print the underlying type using the rules of the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003362 * language of the translation unit from which it came.
3363 *
3364 * If the type is invalid, an empty string is returned.
3365 */
3366CINDEX_LINKAGE CXString clang_getTypeSpelling(CXType CT);
3367
3368/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003369 * Retrieve the underlying type of a typedef declaration.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003370 *
3371 * If the cursor does not reference a typedef declaration, an invalid type is
3372 * returned.
3373 */
3374CINDEX_LINKAGE CXType clang_getTypedefDeclUnderlyingType(CXCursor C);
3375
3376/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003377 * Retrieve the integer type of an enum declaration.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003378 *
3379 * If the cursor does not reference an enum declaration, an invalid type is
3380 * returned.
3381 */
3382CINDEX_LINKAGE CXType clang_getEnumDeclIntegerType(CXCursor C);
3383
3384/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003385 * Retrieve the integer value of an enum constant declaration as a signed
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003386 * long long.
3387 *
3388 * If the cursor does not reference an enum constant declaration, LLONG_MIN is returned.
3389 * Since this is also potentially a valid constant value, the kind of the cursor
3390 * must be verified before calling this function.
3391 */
3392CINDEX_LINKAGE long long clang_getEnumConstantDeclValue(CXCursor C);
3393
3394/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003395 * Retrieve the integer value of an enum constant declaration as an unsigned
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003396 * long long.
3397 *
3398 * If the cursor does not reference an enum constant declaration, ULLONG_MAX is returned.
3399 * Since this is also potentially a valid constant value, the kind of the cursor
3400 * must be verified before calling this function.
3401 */
3402CINDEX_LINKAGE unsigned long long clang_getEnumConstantDeclUnsignedValue(CXCursor C);
3403
3404/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003405 * Retrieve the bit width of a bit field declaration as an integer.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003406 *
3407 * If a cursor that is not a bit field declaration is passed in, -1 is returned.
3408 */
3409CINDEX_LINKAGE int clang_getFieldDeclBitWidth(CXCursor C);
3410
3411/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003412 * Retrieve the number of non-variadic arguments associated with a given
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003413 * cursor.
3414 *
3415 * The number of arguments can be determined for calls as well as for
3416 * declarations of functions or methods. For other cursors -1 is returned.
3417 */
3418CINDEX_LINKAGE int clang_Cursor_getNumArguments(CXCursor C);
3419
3420/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003421 * Retrieve the argument cursor of a function or method.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003422 *
3423 * The argument cursor can be determined for calls as well as for declarations
3424 * of functions or methods. For other cursors and for invalid indices, an
3425 * invalid cursor is returned.
3426 */
3427CINDEX_LINKAGE CXCursor clang_Cursor_getArgument(CXCursor C, unsigned i);
3428
3429/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003430 * Describes the kind of a template argument.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003431 *
3432 * See the definition of llvm::clang::TemplateArgument::ArgKind for full
3433 * element descriptions.
3434 */
3435enum CXTemplateArgumentKind {
3436 CXTemplateArgumentKind_Null,
3437 CXTemplateArgumentKind_Type,
3438 CXTemplateArgumentKind_Declaration,
3439 CXTemplateArgumentKind_NullPtr,
3440 CXTemplateArgumentKind_Integral,
3441 CXTemplateArgumentKind_Template,
3442 CXTemplateArgumentKind_TemplateExpansion,
3443 CXTemplateArgumentKind_Expression,
3444 CXTemplateArgumentKind_Pack,
3445 /* Indicates an error case, preventing the kind from being deduced. */
3446 CXTemplateArgumentKind_Invalid
3447};
3448
3449/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003450 *Returns the number of template args of a function decl representing a
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003451 * template specialization.
3452 *
3453 * If the argument cursor cannot be converted into a template function
3454 * declaration, -1 is returned.
3455 *
3456 * For example, for the following declaration and specialization:
3457 * template <typename T, int kInt, bool kBool>
3458 * void foo() { ... }
3459 *
3460 * template <>
3461 * void foo<float, -7, true>();
3462 *
3463 * The value 3 would be returned from this call.
3464 */
3465CINDEX_LINKAGE int clang_Cursor_getNumTemplateArguments(CXCursor C);
3466
3467/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003468 * Retrieve the kind of the I'th template argument of the CXCursor C.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003469 *
3470 * If the argument CXCursor does not represent a FunctionDecl, an invalid
3471 * template argument kind is returned.
3472 *
3473 * For example, for the following declaration and specialization:
3474 * template <typename T, int kInt, bool kBool>
3475 * void foo() { ... }
3476 *
3477 * template <>
3478 * void foo<float, -7, true>();
3479 *
3480 * For I = 0, 1, and 2, Type, Integral, and Integral will be returned,
3481 * respectively.
3482 */
3483CINDEX_LINKAGE enum CXTemplateArgumentKind clang_Cursor_getTemplateArgumentKind(
3484 CXCursor C, unsigned I);
3485
3486/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003487 * Retrieve a CXType representing the type of a TemplateArgument of a
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003488 * function decl representing a template specialization.
3489 *
3490 * If the argument CXCursor does not represent a FunctionDecl whose I'th
3491 * template argument has a kind of CXTemplateArgKind_Integral, an invalid type
3492 * is returned.
3493 *
3494 * For example, for the following declaration and specialization:
3495 * template <typename T, int kInt, bool kBool>
3496 * void foo() { ... }
3497 *
3498 * template <>
3499 * void foo<float, -7, true>();
3500 *
3501 * If called with I = 0, "float", will be returned.
3502 * Invalid types will be returned for I == 1 or 2.
3503 */
3504CINDEX_LINKAGE CXType clang_Cursor_getTemplateArgumentType(CXCursor C,
3505 unsigned I);
3506
3507/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003508 * Retrieve the value of an Integral TemplateArgument (of a function
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003509 * decl representing a template specialization) as a signed long long.
3510 *
3511 * It is undefined to call this function on a CXCursor that does not represent a
3512 * FunctionDecl or whose I'th template argument is not an integral value.
3513 *
3514 * For example, for the following declaration and specialization:
3515 * template <typename T, int kInt, bool kBool>
3516 * void foo() { ... }
3517 *
3518 * template <>
3519 * void foo<float, -7, true>();
3520 *
3521 * If called with I = 1 or 2, -7 or true will be returned, respectively.
3522 * For I == 0, this function's behavior is undefined.
3523 */
3524CINDEX_LINKAGE long long clang_Cursor_getTemplateArgumentValue(CXCursor C,
3525 unsigned I);
3526
3527/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003528 * Retrieve the value of an Integral TemplateArgument (of a function
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003529 * decl representing a template specialization) as an unsigned long long.
3530 *
3531 * It is undefined to call this function on a CXCursor that does not represent a
3532 * FunctionDecl or whose I'th template argument is not an integral value.
3533 *
3534 * For example, for the following declaration and specialization:
3535 * template <typename T, int kInt, bool kBool>
3536 * void foo() { ... }
3537 *
3538 * template <>
3539 * void foo<float, 2147483649, true>();
3540 *
3541 * If called with I = 1 or 2, 2147483649 or true will be returned, respectively.
3542 * For I == 0, this function's behavior is undefined.
3543 */
3544CINDEX_LINKAGE unsigned long long clang_Cursor_getTemplateArgumentUnsignedValue(
3545 CXCursor C, unsigned I);
3546
3547/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003548 * Determine whether two CXTypes represent the same type.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003549 *
3550 * \returns non-zero if the CXTypes represent the same type and
3551 * zero otherwise.
3552 */
3553CINDEX_LINKAGE unsigned clang_equalTypes(CXType A, CXType B);
3554
3555/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003556 * Return the canonical type for a CXType.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003557 *
3558 * Clang's type system explicitly models typedefs and all the ways
3559 * a specific type can be represented. The canonical type is the underlying
3560 * type with all the "sugar" removed. For example, if 'T' is a typedef
3561 * for 'int', the canonical type for 'T' would be 'int'.
3562 */
3563CINDEX_LINKAGE CXType clang_getCanonicalType(CXType T);
3564
3565/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003566 * Determine whether a CXType has the "const" qualifier set,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003567 * without looking through typedefs that may have added "const" at a
3568 * different level.
3569 */
3570CINDEX_LINKAGE unsigned clang_isConstQualifiedType(CXType T);
3571
3572/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003573 * Determine whether a CXCursor that is a macro, is
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003574 * function like.
3575 */
3576CINDEX_LINKAGE unsigned clang_Cursor_isMacroFunctionLike(CXCursor C);
3577
3578/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003579 * Determine whether a CXCursor that is a macro, is a
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003580 * builtin one.
3581 */
3582CINDEX_LINKAGE unsigned clang_Cursor_isMacroBuiltin(CXCursor C);
3583
3584/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003585 * Determine whether a CXCursor that is a function declaration, is an
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003586 * inline declaration.
3587 */
3588CINDEX_LINKAGE unsigned clang_Cursor_isFunctionInlined(CXCursor C);
3589
3590/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003591 * Determine whether a CXType has the "volatile" qualifier set,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003592 * without looking through typedefs that may have added "volatile" at
3593 * a different level.
3594 */
3595CINDEX_LINKAGE unsigned clang_isVolatileQualifiedType(CXType T);
3596
3597/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003598 * Determine whether a CXType has the "restrict" qualifier set,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003599 * without looking through typedefs that may have added "restrict" at a
3600 * different level.
3601 */
3602CINDEX_LINKAGE unsigned clang_isRestrictQualifiedType(CXType T);
3603
3604/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003605 * Returns the address space of the given type.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003606 */
3607CINDEX_LINKAGE unsigned clang_getAddressSpace(CXType T);
3608
3609/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003610 * Returns the typedef name of the given type.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003611 */
3612CINDEX_LINKAGE CXString clang_getTypedefName(CXType CT);
3613
3614/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003615 * For pointer types, returns the type of the pointee.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003616 */
3617CINDEX_LINKAGE CXType clang_getPointeeType(CXType T);
3618
3619/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003620 * Return the cursor for the declaration of the given type.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003621 */
3622CINDEX_LINKAGE CXCursor clang_getTypeDeclaration(CXType T);
3623
3624/**
3625 * Returns the Objective-C type encoding for the specified declaration.
3626 */
3627CINDEX_LINKAGE CXString clang_getDeclObjCTypeEncoding(CXCursor C);
3628
3629/**
3630 * Returns the Objective-C type encoding for the specified CXType.
3631 */
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003632CINDEX_LINKAGE CXString clang_Type_getObjCEncoding(CXType type);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003633
3634/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003635 * Retrieve the spelling of a given CXTypeKind.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003636 */
3637CINDEX_LINKAGE CXString clang_getTypeKindSpelling(enum CXTypeKind K);
3638
3639/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003640 * Retrieve the calling convention associated with a function type.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003641 *
3642 * If a non-function type is passed in, CXCallingConv_Invalid is returned.
3643 */
3644CINDEX_LINKAGE enum CXCallingConv clang_getFunctionTypeCallingConv(CXType T);
3645
3646/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003647 * Retrieve the return type associated with a function type.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003648 *
3649 * If a non-function type is passed in, an invalid type is returned.
3650 */
3651CINDEX_LINKAGE CXType clang_getResultType(CXType T);
3652
3653/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003654 * Retrieve the exception specification type associated with a function type.
3655 * This is a value of type CXCursor_ExceptionSpecificationKind.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003656 *
3657 * If a non-function type is passed in, an error code of -1 is returned.
3658 */
3659CINDEX_LINKAGE int clang_getExceptionSpecificationType(CXType T);
3660
3661/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003662 * Retrieve the number of non-variadic parameters associated with a
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003663 * function type.
3664 *
3665 * If a non-function type is passed in, -1 is returned.
3666 */
3667CINDEX_LINKAGE int clang_getNumArgTypes(CXType T);
3668
3669/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003670 * Retrieve the type of a parameter of a function type.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003671 *
3672 * If a non-function type is passed in or the function does not have enough
3673 * parameters, an invalid type is returned.
3674 */
3675CINDEX_LINKAGE CXType clang_getArgType(CXType T, unsigned i);
3676
3677/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003678 * Retrieves the base type of the ObjCObjectType.
3679 *
3680 * If the type is not an ObjC object, an invalid type is returned.
3681 */
3682CINDEX_LINKAGE CXType clang_Type_getObjCObjectBaseType(CXType T);
3683
3684/**
3685 * Retrieve the number of protocol references associated with an ObjC object/id.
3686 *
3687 * If the type is not an ObjC object, 0 is returned.
3688 */
3689CINDEX_LINKAGE unsigned clang_Type_getNumObjCProtocolRefs(CXType T);
3690
3691/**
3692 * Retrieve the decl for a protocol reference for an ObjC object/id.
3693 *
3694 * If the type is not an ObjC object or there are not enough protocol
3695 * references, an invalid cursor is returned.
3696 */
3697CINDEX_LINKAGE CXCursor clang_Type_getObjCProtocolDecl(CXType T, unsigned i);
3698
3699/**
3700 * Retreive the number of type arguments associated with an ObjC object.
3701 *
3702 * If the type is not an ObjC object, 0 is returned.
3703 */
3704CINDEX_LINKAGE unsigned clang_Type_getNumObjCTypeArgs(CXType T);
3705
3706/**
3707 * Retrieve a type argument associated with an ObjC object.
3708 *
3709 * If the type is not an ObjC or the index is not valid,
3710 * an invalid type is returned.
3711 */
3712CINDEX_LINKAGE CXType clang_Type_getObjCTypeArg(CXType T, unsigned i);
3713
3714/**
3715 * Return 1 if the CXType is a variadic function type, and 0 otherwise.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003716 */
3717CINDEX_LINKAGE unsigned clang_isFunctionTypeVariadic(CXType T);
3718
3719/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003720 * Retrieve the return type associated with a given cursor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003721 *
3722 * This only returns a valid type if the cursor refers to a function or method.
3723 */
3724CINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C);
3725
3726/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003727 * Retrieve the exception specification type associated with a given cursor.
3728 * This is a value of type CXCursor_ExceptionSpecificationKind.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003729 *
3730 * This only returns a valid result if the cursor refers to a function or method.
3731 */
3732CINDEX_LINKAGE int clang_getCursorExceptionSpecificationType(CXCursor C);
3733
3734/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003735 * Return 1 if the CXType is a POD (plain old data) type, and 0
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003736 * otherwise.
3737 */
3738CINDEX_LINKAGE unsigned clang_isPODType(CXType T);
3739
3740/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003741 * Return the element type of an array, complex, or vector type.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003742 *
3743 * If a type is passed in that is not an array, complex, or vector type,
3744 * an invalid type is returned.
3745 */
3746CINDEX_LINKAGE CXType clang_getElementType(CXType T);
3747
3748/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003749 * Return the number of elements of an array or vector type.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003750 *
3751 * If a type is passed in that is not an array or vector type,
3752 * -1 is returned.
3753 */
3754CINDEX_LINKAGE long long clang_getNumElements(CXType T);
3755
3756/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003757 * Return the element type of an array type.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003758 *
3759 * If a non-array type is passed in, an invalid type is returned.
3760 */
3761CINDEX_LINKAGE CXType clang_getArrayElementType(CXType T);
3762
3763/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003764 * Return the array size of a constant array.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003765 *
3766 * If a non-array type is passed in, -1 is returned.
3767 */
3768CINDEX_LINKAGE long long clang_getArraySize(CXType T);
3769
3770/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003771 * Retrieve the type named by the qualified-id.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003772 *
3773 * If a non-elaborated type is passed in, an invalid type is returned.
3774 */
3775CINDEX_LINKAGE CXType clang_Type_getNamedType(CXType T);
3776
3777/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003778 * Determine if a typedef is 'transparent' tag.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003779 *
3780 * A typedef is considered 'transparent' if it shares a name and spelling
3781 * location with its underlying tag type, as is the case with the NS_ENUM macro.
3782 *
3783 * \returns non-zero if transparent and zero otherwise.
3784 */
3785CINDEX_LINKAGE unsigned clang_Type_isTransparentTagTypedef(CXType T);
3786
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003787enum CXTypeNullabilityKind {
3788 /**
3789 * Values of this type can never be null.
3790 */
3791 CXTypeNullability_NonNull = 0,
3792 /**
3793 * Values of this type can be null.
3794 */
3795 CXTypeNullability_Nullable = 1,
3796 /**
3797 * Whether values of this type can be null is (explicitly)
3798 * unspecified. This captures a (fairly rare) case where we
3799 * can't conclude anything about the nullability of the type even
3800 * though it has been considered.
3801 */
3802 CXTypeNullability_Unspecified = 2,
3803 /**
3804 * Nullability is not applicable to this type.
3805 */
3806 CXTypeNullability_Invalid = 3
3807};
3808
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003809/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003810 * Retrieve the nullability kind of a pointer type.
3811 */
3812CINDEX_LINKAGE enum CXTypeNullabilityKind clang_Type_getNullability(CXType T);
3813
3814/**
3815 * List the possible error codes for \c clang_Type_getSizeOf,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003816 * \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf and
3817 * \c clang_Cursor_getOffsetOf.
3818 *
3819 * A value of this enumeration type can be returned if the target type is not
3820 * a valid argument to sizeof, alignof or offsetof.
3821 */
3822enum CXTypeLayoutError {
3823 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003824 * Type is of kind CXType_Invalid.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003825 */
3826 CXTypeLayoutError_Invalid = -1,
3827 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003828 * The type is an incomplete Type.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003829 */
3830 CXTypeLayoutError_Incomplete = -2,
3831 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003832 * The type is a dependent Type.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003833 */
3834 CXTypeLayoutError_Dependent = -3,
3835 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003836 * The type is not a constant size type.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003837 */
3838 CXTypeLayoutError_NotConstantSize = -4,
3839 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003840 * The Field name is not valid for this record.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003841 */
3842 CXTypeLayoutError_InvalidFieldName = -5
3843};
3844
3845/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003846 * Return the alignment of a type in bytes as per C++[expr.alignof]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003847 * standard.
3848 *
3849 * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
3850 * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
3851 * is returned.
3852 * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
3853 * returned.
3854 * If the type declaration is not a constant size type,
3855 * CXTypeLayoutError_NotConstantSize is returned.
3856 */
3857CINDEX_LINKAGE long long clang_Type_getAlignOf(CXType T);
3858
3859/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003860 * Return the class type of an member pointer type.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003861 *
3862 * If a non-member-pointer type is passed in, an invalid type is returned.
3863 */
3864CINDEX_LINKAGE CXType clang_Type_getClassType(CXType T);
3865
3866/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003867 * Return the size of a type in bytes as per C++[expr.sizeof] standard.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003868 *
3869 * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
3870 * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
3871 * is returned.
3872 * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
3873 * returned.
3874 */
3875CINDEX_LINKAGE long long clang_Type_getSizeOf(CXType T);
3876
3877/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003878 * Return the offset of a field named S in a record of type T in bits
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003879 * as it would be returned by __offsetof__ as per C++11[18.2p4]
3880 *
3881 * If the cursor is not a record field declaration, CXTypeLayoutError_Invalid
3882 * is returned.
3883 * If the field's type declaration is an incomplete type,
3884 * CXTypeLayoutError_Incomplete is returned.
3885 * If the field's type declaration is a dependent type,
3886 * CXTypeLayoutError_Dependent is returned.
3887 * If the field's name S is not found,
3888 * CXTypeLayoutError_InvalidFieldName is returned.
3889 */
3890CINDEX_LINKAGE long long clang_Type_getOffsetOf(CXType T, const char *S);
3891
3892/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003893 * Return the type that was modified by this attributed type.
3894 *
3895 * If the type is not an attributed type, an invalid type is returned.
3896 */
3897CINDEX_LINKAGE CXType clang_Type_getModifiedType(CXType T);
3898
3899/**
3900 * Return the offset of the field represented by the Cursor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003901 *
3902 * If the cursor is not a field declaration, -1 is returned.
3903 * If the cursor semantic parent is not a record field declaration,
3904 * CXTypeLayoutError_Invalid is returned.
3905 * If the field's type declaration is an incomplete type,
3906 * CXTypeLayoutError_Incomplete is returned.
3907 * If the field's type declaration is a dependent type,
3908 * CXTypeLayoutError_Dependent is returned.
3909 * If the field's name S is not found,
3910 * CXTypeLayoutError_InvalidFieldName is returned.
3911 */
3912CINDEX_LINKAGE long long clang_Cursor_getOffsetOfField(CXCursor C);
3913
3914/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003915 * Determine whether the given cursor represents an anonymous record
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003916 * declaration.
3917 */
3918CINDEX_LINKAGE unsigned clang_Cursor_isAnonymous(CXCursor C);
3919
3920enum CXRefQualifierKind {
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003921 /** No ref-qualifier was provided. */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003922 CXRefQualifier_None = 0,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003923 /** An lvalue ref-qualifier was provided (\c &). */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003924 CXRefQualifier_LValue,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003925 /** An rvalue ref-qualifier was provided (\c &&). */
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003926 CXRefQualifier_RValue
3927};
3928
3929/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003930 * Returns the number of template arguments for given template
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003931 * specialization, or -1 if type \c T is not a template specialization.
3932 */
3933CINDEX_LINKAGE int clang_Type_getNumTemplateArguments(CXType T);
3934
3935/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003936 * Returns the type template argument of a template class specialization
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003937 * at given index.
3938 *
3939 * This function only returns template type arguments and does not handle
3940 * template template arguments or variadic packs.
3941 */
3942CINDEX_LINKAGE CXType clang_Type_getTemplateArgumentAsType(CXType T, unsigned i);
3943
3944/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003945 * Retrieve the ref-qualifier kind of a function or method.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003946 *
3947 * The ref-qualifier is returned for C++ functions or methods. For other types
3948 * or non-C++ declarations, CXRefQualifier_None is returned.
3949 */
3950CINDEX_LINKAGE enum CXRefQualifierKind clang_Type_getCXXRefQualifier(CXType T);
3951
3952/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003953 * Returns non-zero if the cursor specifies a Record member that is a
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003954 * bitfield.
3955 */
3956CINDEX_LINKAGE unsigned clang_Cursor_isBitField(CXCursor C);
3957
3958/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003959 * Returns 1 if the base class specified by the cursor with kind
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003960 * CX_CXXBaseSpecifier is virtual.
3961 */
3962CINDEX_LINKAGE unsigned clang_isVirtualBase(CXCursor);
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003963
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003964/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003965 * Represents the C++ access control level to a base class for a
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003966 * cursor with kind CX_CXXBaseSpecifier.
3967 */
3968enum CX_CXXAccessSpecifier {
3969 CX_CXXInvalidAccessSpecifier,
3970 CX_CXXPublic,
3971 CX_CXXProtected,
3972 CX_CXXPrivate
3973};
3974
3975/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003976 * Returns the access control level for the referenced object.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003977 *
3978 * If the cursor refers to a C++ declaration, its access control level within its
3979 * parent scope is returned. Otherwise, if the cursor refers to a base specifier or
3980 * access specifier, the specifier itself is returned.
3981 */
3982CINDEX_LINKAGE enum CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor);
3983
3984/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01003985 * Represents the storage classes as declared in the source. CX_SC_Invalid
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01003986 * was added for the case that the passed cursor in not a declaration.
3987 */
3988enum CX_StorageClass {
3989 CX_SC_Invalid,
3990 CX_SC_None,
3991 CX_SC_Extern,
3992 CX_SC_Static,
3993 CX_SC_PrivateExtern,
3994 CX_SC_OpenCLWorkGroupLocal,
3995 CX_SC_Auto,
3996 CX_SC_Register
3997};
3998
3999/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004000 * Returns the storage class for a function or variable declaration.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004001 *
4002 * If the passed in Cursor is not a function or variable declaration,
4003 * CX_SC_Invalid is returned else the storage class.
4004 */
4005CINDEX_LINKAGE enum CX_StorageClass clang_Cursor_getStorageClass(CXCursor);
4006
4007/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004008 * Determine the number of overloaded declarations referenced by a
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004009 * \c CXCursor_OverloadedDeclRef cursor.
4010 *
4011 * \param cursor The cursor whose overloaded declarations are being queried.
4012 *
4013 * \returns The number of overloaded declarations referenced by \c cursor. If it
4014 * is not a \c CXCursor_OverloadedDeclRef cursor, returns 0.
4015 */
4016CINDEX_LINKAGE unsigned clang_getNumOverloadedDecls(CXCursor cursor);
4017
4018/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004019 * Retrieve a cursor for one of the overloaded declarations referenced
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004020 * by a \c CXCursor_OverloadedDeclRef cursor.
4021 *
4022 * \param cursor The cursor whose overloaded declarations are being queried.
4023 *
4024 * \param index The zero-based index into the set of overloaded declarations in
4025 * the cursor.
4026 *
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004027 * \returns A cursor representing the declaration referenced by the given
4028 * \c cursor at the specified \c index. If the cursor does not have an
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004029 * associated set of overloaded declarations, or if the index is out of bounds,
4030 * returns \c clang_getNullCursor();
4031 */
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004032CINDEX_LINKAGE CXCursor clang_getOverloadedDecl(CXCursor cursor,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004033 unsigned index);
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004034
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004035/**
4036 * @}
4037 */
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004038
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004039/**
4040 * \defgroup CINDEX_ATTRIBUTES Information for attributes
4041 *
4042 * @{
4043 */
4044
4045/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004046 * For cursors representing an iboutletcollection attribute,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004047 * this function returns the collection element type.
4048 *
4049 */
4050CINDEX_LINKAGE CXType clang_getIBOutletCollectionType(CXCursor);
4051
4052/**
4053 * @}
4054 */
4055
4056/**
4057 * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors
4058 *
4059 * These routines provide the ability to traverse the abstract syntax tree
4060 * using cursors.
4061 *
4062 * @{
4063 */
4064
4065/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004066 * Describes how the traversal of the children of a particular
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004067 * cursor should proceed after visiting a particular child cursor.
4068 *
4069 * A value of this enumeration type should be returned by each
4070 * \c CXCursorVisitor to indicate how clang_visitChildren() proceed.
4071 */
4072enum CXChildVisitResult {
4073 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004074 * Terminates the cursor traversal.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004075 */
4076 CXChildVisit_Break,
4077 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004078 * Continues the cursor traversal with the next sibling of
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004079 * the cursor just visited, without visiting its children.
4080 */
4081 CXChildVisit_Continue,
4082 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004083 * Recursively traverse the children of this cursor, using
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004084 * the same visitor and client data.
4085 */
4086 CXChildVisit_Recurse
4087};
4088
4089/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004090 * Visitor invoked for each cursor found by a traversal.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004091 *
4092 * This visitor function will be invoked for each cursor found by
4093 * clang_visitCursorChildren(). Its first argument is the cursor being
4094 * visited, its second argument is the parent visitor for that cursor,
4095 * and its third argument is the client data provided to
4096 * clang_visitCursorChildren().
4097 *
4098 * The visitor should return one of the \c CXChildVisitResult values
4099 * to direct clang_visitCursorChildren().
4100 */
4101typedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor,
4102 CXCursor parent,
4103 CXClientData client_data);
4104
4105/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004106 * Visit the children of a particular cursor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004107 *
4108 * This function visits all the direct children of the given cursor,
4109 * invoking the given \p visitor function with the cursors of each
4110 * visited child. The traversal may be recursive, if the visitor returns
4111 * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if
4112 * the visitor returns \c CXChildVisit_Break.
4113 *
4114 * \param parent the cursor whose child may be visited. All kinds of
4115 * cursors can be visited, including invalid cursors (which, by
4116 * definition, have no children).
4117 *
4118 * \param visitor the visitor function that will be invoked for each
4119 * child of \p parent.
4120 *
4121 * \param client_data pointer data supplied by the client, which will
4122 * be passed to the visitor each time it is invoked.
4123 *
4124 * \returns a non-zero value if the traversal was terminated
4125 * prematurely by the visitor returning \c CXChildVisit_Break.
4126 */
4127CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent,
4128 CXCursorVisitor visitor,
4129 CXClientData client_data);
4130#ifdef __has_feature
4131# if __has_feature(blocks)
4132/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004133 * Visitor invoked for each cursor found by a traversal.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004134 *
4135 * This visitor block will be invoked for each cursor found by
4136 * clang_visitChildrenWithBlock(). Its first argument is the cursor being
4137 * visited, its second argument is the parent visitor for that cursor.
4138 *
4139 * The visitor should return one of the \c CXChildVisitResult values
4140 * to direct clang_visitChildrenWithBlock().
4141 */
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004142typedef enum CXChildVisitResult
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004143 (^CXCursorVisitorBlock)(CXCursor cursor, CXCursor parent);
4144
4145/**
4146 * Visits the children of a cursor using the specified block. Behaves
4147 * identically to clang_visitChildren() in all other respects.
4148 */
4149CINDEX_LINKAGE unsigned clang_visitChildrenWithBlock(CXCursor parent,
4150 CXCursorVisitorBlock block);
4151# endif
4152#endif
4153
4154/**
4155 * @}
4156 */
4157
4158/**
4159 * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST
4160 *
4161 * These routines provide the ability to determine references within and
4162 * across translation units, by providing the names of the entities referenced
4163 * by cursors, follow reference cursors to the declarations they reference,
4164 * and associate declarations with their definitions.
4165 *
4166 * @{
4167 */
4168
4169/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004170 * Retrieve a Unified Symbol Resolution (USR) for the entity referenced
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004171 * by the given cursor.
4172 *
4173 * A Unified Symbol Resolution (USR) is a string that identifies a particular
4174 * entity (function, class, variable, etc.) within a program. USRs can be
4175 * compared across translation units to determine, e.g., when references in
4176 * one translation refer to an entity defined in another translation unit.
4177 */
4178CINDEX_LINKAGE CXString clang_getCursorUSR(CXCursor);
4179
4180/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004181 * Construct a USR for a specified Objective-C class.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004182 */
4183CINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name);
4184
4185/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004186 * Construct a USR for a specified Objective-C category.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004187 */
4188CINDEX_LINKAGE CXString
4189 clang_constructUSR_ObjCCategory(const char *class_name,
4190 const char *category_name);
4191
4192/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004193 * Construct a USR for a specified Objective-C protocol.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004194 */
4195CINDEX_LINKAGE CXString
4196 clang_constructUSR_ObjCProtocol(const char *protocol_name);
4197
4198/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004199 * Construct a USR for a specified Objective-C instance variable and
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004200 * the USR for its containing class.
4201 */
4202CINDEX_LINKAGE CXString clang_constructUSR_ObjCIvar(const char *name,
4203 CXString classUSR);
4204
4205/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004206 * Construct a USR for a specified Objective-C method and
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004207 * the USR for its containing class.
4208 */
4209CINDEX_LINKAGE CXString clang_constructUSR_ObjCMethod(const char *name,
4210 unsigned isInstanceMethod,
4211 CXString classUSR);
4212
4213/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004214 * Construct a USR for a specified Objective-C property and the USR
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004215 * for its containing class.
4216 */
4217CINDEX_LINKAGE CXString clang_constructUSR_ObjCProperty(const char *property,
4218 CXString classUSR);
4219
4220/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004221 * Retrieve a name for the entity referenced by this cursor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004222 */
4223CINDEX_LINKAGE CXString clang_getCursorSpelling(CXCursor);
4224
4225/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004226 * Retrieve a range for a piece that forms the cursors spelling name.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004227 * Most of the times there is only one range for the complete spelling but for
4228 * Objective-C methods and Objective-C message expressions, there are multiple
4229 * pieces for each selector identifier.
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004230 *
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004231 * \param pieceIndex the index of the spelling name piece. If this is greater
4232 * than the actual number of pieces, it will return a NULL (invalid) range.
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004233 *
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004234 * \param options Reserved.
4235 */
4236CINDEX_LINKAGE CXSourceRange clang_Cursor_getSpellingNameRange(CXCursor,
4237 unsigned pieceIndex,
4238 unsigned options);
4239
4240/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004241 * Opaque pointer representing a policy that controls pretty printing
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004242 * for \c clang_getCursorPrettyPrinted.
4243 */
4244typedef void *CXPrintingPolicy;
4245
4246/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004247 * Properties for the printing policy.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004248 *
4249 * See \c clang::PrintingPolicy for more information.
4250 */
4251enum CXPrintingPolicyProperty {
4252 CXPrintingPolicy_Indentation,
4253 CXPrintingPolicy_SuppressSpecifiers,
4254 CXPrintingPolicy_SuppressTagKeyword,
4255 CXPrintingPolicy_IncludeTagDefinition,
4256 CXPrintingPolicy_SuppressScope,
4257 CXPrintingPolicy_SuppressUnwrittenScope,
4258 CXPrintingPolicy_SuppressInitializers,
4259 CXPrintingPolicy_ConstantArraySizeAsWritten,
4260 CXPrintingPolicy_AnonymousTagLocations,
4261 CXPrintingPolicy_SuppressStrongLifetime,
4262 CXPrintingPolicy_SuppressLifetimeQualifiers,
4263 CXPrintingPolicy_SuppressTemplateArgsInCXXConstructors,
4264 CXPrintingPolicy_Bool,
4265 CXPrintingPolicy_Restrict,
4266 CXPrintingPolicy_Alignof,
4267 CXPrintingPolicy_UnderscoreAlignof,
4268 CXPrintingPolicy_UseVoidForZeroParams,
4269 CXPrintingPolicy_TerseOutput,
4270 CXPrintingPolicy_PolishForDeclaration,
4271 CXPrintingPolicy_Half,
4272 CXPrintingPolicy_MSWChar,
4273 CXPrintingPolicy_IncludeNewlines,
4274 CXPrintingPolicy_MSVCFormatting,
4275 CXPrintingPolicy_ConstantsAsWritten,
4276 CXPrintingPolicy_SuppressImplicitBase,
4277 CXPrintingPolicy_FullyQualifiedName,
4278
4279 CXPrintingPolicy_LastProperty = CXPrintingPolicy_FullyQualifiedName
4280};
4281
4282/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004283 * Get a property value for the given printing policy.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004284 */
4285CINDEX_LINKAGE unsigned
4286clang_PrintingPolicy_getProperty(CXPrintingPolicy Policy,
4287 enum CXPrintingPolicyProperty Property);
4288
4289/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004290 * Set a property value for the given printing policy.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004291 */
4292CINDEX_LINKAGE void clang_PrintingPolicy_setProperty(CXPrintingPolicy Policy,
4293 enum CXPrintingPolicyProperty Property,
4294 unsigned Value);
4295
4296/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004297 * Retrieve the default policy for the cursor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004298 *
4299 * The policy should be released after use with \c
4300 * clang_PrintingPolicy_dispose.
4301 */
4302CINDEX_LINKAGE CXPrintingPolicy clang_getCursorPrintingPolicy(CXCursor);
4303
4304/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004305 * Release a printing policy.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004306 */
4307CINDEX_LINKAGE void clang_PrintingPolicy_dispose(CXPrintingPolicy Policy);
4308
4309/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004310 * Pretty print declarations.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004311 *
4312 * \param Cursor The cursor representing a declaration.
4313 *
4314 * \param Policy The policy to control the entities being printed. If
4315 * NULL, a default policy is used.
4316 *
4317 * \returns The pretty printed declaration or the empty string for
4318 * other cursors.
4319 */
4320CINDEX_LINKAGE CXString clang_getCursorPrettyPrinted(CXCursor Cursor,
4321 CXPrintingPolicy Policy);
4322
4323/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004324 * Retrieve the display name for the entity referenced by this cursor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004325 *
4326 * The display name contains extra information that helps identify the cursor,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004327 * such as the parameters of a function or template or the arguments of a
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004328 * class template specialization.
4329 */
4330CINDEX_LINKAGE CXString clang_getCursorDisplayName(CXCursor);
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004331
4332/** For a cursor that is a reference, retrieve a cursor representing the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004333 * entity that it references.
4334 *
4335 * Reference cursors refer to other entities in the AST. For example, an
4336 * Objective-C superclass reference cursor refers to an Objective-C class.
4337 * This function produces the cursor for the Objective-C class from the
4338 * cursor for the superclass reference. If the input cursor is a declaration or
4339 * definition, it returns that declaration or definition unchanged.
4340 * Otherwise, returns the NULL cursor.
4341 */
4342CINDEX_LINKAGE CXCursor clang_getCursorReferenced(CXCursor);
4343
4344/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004345 * For a cursor that is either a reference to or a declaration
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004346 * of some entity, retrieve a cursor that describes the definition of
4347 * that entity.
4348 *
4349 * Some entities can be declared multiple times within a translation
4350 * unit, but only one of those declarations can also be a
4351 * definition. For example, given:
4352 *
4353 * \code
4354 * int f(int, int);
4355 * int g(int x, int y) { return f(x, y); }
4356 * int f(int a, int b) { return a + b; }
4357 * int f(int, int);
4358 * \endcode
4359 *
4360 * there are three declarations of the function "f", but only the
4361 * second one is a definition. The clang_getCursorDefinition()
4362 * function will take any cursor pointing to a declaration of "f"
4363 * (the first or fourth lines of the example) or a cursor referenced
4364 * that uses "f" (the call to "f' inside "g") and will return a
4365 * declaration cursor pointing to the definition (the second "f"
4366 * declaration).
4367 *
4368 * If given a cursor for which there is no corresponding definition,
4369 * e.g., because there is no definition of that entity within this
4370 * translation unit, returns a NULL cursor.
4371 */
4372CINDEX_LINKAGE CXCursor clang_getCursorDefinition(CXCursor);
4373
4374/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004375 * Determine whether the declaration pointed to by this cursor
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004376 * is also a definition of that entity.
4377 */
4378CINDEX_LINKAGE unsigned clang_isCursorDefinition(CXCursor);
4379
4380/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004381 * Retrieve the canonical cursor corresponding to the given cursor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004382 *
4383 * In the C family of languages, many kinds of entities can be declared several
4384 * times within a single translation unit. For example, a structure type can
4385 * be forward-declared (possibly multiple times) and later defined:
4386 *
4387 * \code
4388 * struct X;
4389 * struct X;
4390 * struct X {
4391 * int member;
4392 * };
4393 * \endcode
4394 *
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004395 * The declarations and the definition of \c X are represented by three
4396 * different cursors, all of which are declarations of the same underlying
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004397 * entity. One of these cursor is considered the "canonical" cursor, which
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004398 * is effectively the representative for the underlying entity. One can
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004399 * determine if two cursors are declarations of the same underlying entity by
4400 * comparing their canonical cursors.
4401 *
4402 * \returns The canonical cursor for the entity referred to by the given cursor.
4403 */
4404CINDEX_LINKAGE CXCursor clang_getCanonicalCursor(CXCursor);
4405
4406/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004407 * If the cursor points to a selector identifier in an Objective-C
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004408 * method or message expression, this returns the selector index.
4409 *
4410 * After getting a cursor with #clang_getCursor, this can be called to
4411 * determine if the location points to a selector identifier.
4412 *
4413 * \returns The selector index if the cursor is an Objective-C method or message
4414 * expression and the cursor is pointing to a selector identifier, or -1
4415 * otherwise.
4416 */
4417CINDEX_LINKAGE int clang_Cursor_getObjCSelectorIndex(CXCursor);
4418
4419/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004420 * Given a cursor pointing to a C++ method call or an Objective-C
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004421 * message, returns non-zero if the method/message is "dynamic", meaning:
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004422 *
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004423 * For a C++ method: the call is virtual.
4424 * For an Objective-C message: the receiver is an object instance, not 'super'
4425 * or a specific class.
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004426 *
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004427 * If the method/message is "static" or the cursor does not point to a
4428 * method/message, it will return zero.
4429 */
4430CINDEX_LINKAGE int clang_Cursor_isDynamicCall(CXCursor C);
4431
4432/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004433 * Given a cursor pointing to an Objective-C message or property
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004434 * reference, or C++ method call, returns the CXType of the receiver.
4435 */
4436CINDEX_LINKAGE CXType clang_Cursor_getReceiverType(CXCursor C);
4437
4438/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004439 * Property attributes for a \c CXCursor_ObjCPropertyDecl.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004440 */
4441typedef enum {
4442 CXObjCPropertyAttr_noattr = 0x00,
4443 CXObjCPropertyAttr_readonly = 0x01,
4444 CXObjCPropertyAttr_getter = 0x02,
4445 CXObjCPropertyAttr_assign = 0x04,
4446 CXObjCPropertyAttr_readwrite = 0x08,
4447 CXObjCPropertyAttr_retain = 0x10,
4448 CXObjCPropertyAttr_copy = 0x20,
4449 CXObjCPropertyAttr_nonatomic = 0x40,
4450 CXObjCPropertyAttr_setter = 0x80,
4451 CXObjCPropertyAttr_atomic = 0x100,
4452 CXObjCPropertyAttr_weak = 0x200,
4453 CXObjCPropertyAttr_strong = 0x400,
4454 CXObjCPropertyAttr_unsafe_unretained = 0x800,
4455 CXObjCPropertyAttr_class = 0x1000
4456} CXObjCPropertyAttrKind;
4457
4458/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004459 * Given a cursor that represents a property declaration, return the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004460 * associated property attributes. The bits are formed from
4461 * \c CXObjCPropertyAttrKind.
4462 *
4463 * \param reserved Reserved for future use, pass 0.
4464 */
4465CINDEX_LINKAGE unsigned clang_Cursor_getObjCPropertyAttributes(CXCursor C,
4466 unsigned reserved);
4467
4468/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004469 * Given a cursor that represents a property declaration, return the
4470 * name of the method that implements the getter.
4471 */
4472CINDEX_LINKAGE CXString clang_Cursor_getObjCPropertyGetterName(CXCursor C);
4473
4474/**
4475 * Given a cursor that represents a property declaration, return the
4476 * name of the method that implements the setter, if any.
4477 */
4478CINDEX_LINKAGE CXString clang_Cursor_getObjCPropertySetterName(CXCursor C);
4479
4480/**
4481 * 'Qualifiers' written next to the return and parameter types in
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004482 * Objective-C method declarations.
4483 */
4484typedef enum {
4485 CXObjCDeclQualifier_None = 0x0,
4486 CXObjCDeclQualifier_In = 0x1,
4487 CXObjCDeclQualifier_Inout = 0x2,
4488 CXObjCDeclQualifier_Out = 0x4,
4489 CXObjCDeclQualifier_Bycopy = 0x8,
4490 CXObjCDeclQualifier_Byref = 0x10,
4491 CXObjCDeclQualifier_Oneway = 0x20
4492} CXObjCDeclQualifierKind;
4493
4494/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004495 * Given a cursor that represents an Objective-C method or parameter
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004496 * declaration, return the associated Objective-C qualifiers for the return
4497 * type or the parameter respectively. The bits are formed from
4498 * CXObjCDeclQualifierKind.
4499 */
4500CINDEX_LINKAGE unsigned clang_Cursor_getObjCDeclQualifiers(CXCursor C);
4501
4502/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004503 * Given a cursor that represents an Objective-C method or property
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004504 * declaration, return non-zero if the declaration was affected by "\@optional".
4505 * Returns zero if the cursor is not such a declaration or it is "\@required".
4506 */
4507CINDEX_LINKAGE unsigned clang_Cursor_isObjCOptional(CXCursor C);
4508
4509/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004510 * Returns non-zero if the given cursor is a variadic function or method.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004511 */
4512CINDEX_LINKAGE unsigned clang_Cursor_isVariadic(CXCursor C);
4513
4514/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004515 * Returns non-zero if the given cursor points to a symbol marked with
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004516 * external_source_symbol attribute.
4517 *
4518 * \param language If non-NULL, and the attribute is present, will be set to
4519 * the 'language' string from the attribute.
4520 *
4521 * \param definedIn If non-NULL, and the attribute is present, will be set to
4522 * the 'definedIn' string from the attribute.
4523 *
4524 * \param isGenerated If non-NULL, and the attribute is present, will be set to
4525 * non-zero if the 'generated_declaration' is set in the attribute.
4526 */
4527CINDEX_LINKAGE unsigned clang_Cursor_isExternalSymbol(CXCursor C,
4528 CXString *language, CXString *definedIn,
4529 unsigned *isGenerated);
4530
4531/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004532 * Given a cursor that represents a declaration, return the associated
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004533 * comment's source range. The range may include multiple consecutive comments
4534 * with whitespace in between.
4535 */
4536CINDEX_LINKAGE CXSourceRange clang_Cursor_getCommentRange(CXCursor C);
4537
4538/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004539 * Given a cursor that represents a declaration, return the associated
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004540 * comment text, including comment markers.
4541 */
4542CINDEX_LINKAGE CXString clang_Cursor_getRawCommentText(CXCursor C);
4543
4544/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004545 * Given a cursor that represents a documentable entity (e.g.,
4546 * declaration), return the associated \paragraph; otherwise return the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004547 * first paragraph.
4548 */
4549CINDEX_LINKAGE CXString clang_Cursor_getBriefCommentText(CXCursor C);
4550
4551/**
4552 * @}
4553 */
4554
4555/** \defgroup CINDEX_MANGLE Name Mangling API Functions
4556 *
4557 * @{
4558 */
4559
4560/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004561 * Retrieve the CXString representing the mangled name of the cursor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004562 */
4563CINDEX_LINKAGE CXString clang_Cursor_getMangling(CXCursor);
4564
4565/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004566 * Retrieve the CXStrings representing the mangled symbols of the C++
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004567 * constructor or destructor at the cursor.
4568 */
4569CINDEX_LINKAGE CXStringSet *clang_Cursor_getCXXManglings(CXCursor);
4570
4571/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004572 * Retrieve the CXStrings representing the mangled symbols of the ObjC
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004573 * class interface or implementation at the cursor.
4574 */
4575CINDEX_LINKAGE CXStringSet *clang_Cursor_getObjCManglings(CXCursor);
4576
4577/**
4578 * @}
4579 */
4580
4581/**
4582 * \defgroup CINDEX_MODULE Module introspection
4583 *
4584 * The functions in this group provide access to information about modules.
4585 *
4586 * @{
4587 */
4588
4589typedef void *CXModule;
4590
4591/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004592 * Given a CXCursor_ModuleImportDecl cursor, return the associated module.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004593 */
4594CINDEX_LINKAGE CXModule clang_Cursor_getModule(CXCursor C);
4595
4596/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004597 * Given a CXFile header file, return the module that contains it, if one
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004598 * exists.
4599 */
4600CINDEX_LINKAGE CXModule clang_getModuleForFile(CXTranslationUnit, CXFile);
4601
4602/**
4603 * \param Module a module object.
4604 *
4605 * \returns the module file where the provided module object came from.
4606 */
4607CINDEX_LINKAGE CXFile clang_Module_getASTFile(CXModule Module);
4608
4609/**
4610 * \param Module a module object.
4611 *
4612 * \returns the parent of a sub-module or NULL if the given module is top-level,
4613 * e.g. for 'std.vector' it will return the 'std' module.
4614 */
4615CINDEX_LINKAGE CXModule clang_Module_getParent(CXModule Module);
4616
4617/**
4618 * \param Module a module object.
4619 *
4620 * \returns the name of the module, e.g. for the 'std.vector' sub-module it
4621 * will return "vector".
4622 */
4623CINDEX_LINKAGE CXString clang_Module_getName(CXModule Module);
4624
4625/**
4626 * \param Module a module object.
4627 *
4628 * \returns the full name of the module, e.g. "std.vector".
4629 */
4630CINDEX_LINKAGE CXString clang_Module_getFullName(CXModule Module);
4631
4632/**
4633 * \param Module a module object.
4634 *
4635 * \returns non-zero if the module is a system one.
4636 */
4637CINDEX_LINKAGE int clang_Module_isSystem(CXModule Module);
4638
4639/**
4640 * \param Module a module object.
4641 *
4642 * \returns the number of top level headers associated with this module.
4643 */
4644CINDEX_LINKAGE unsigned clang_Module_getNumTopLevelHeaders(CXTranslationUnit,
4645 CXModule Module);
4646
4647/**
4648 * \param Module a module object.
4649 *
4650 * \param Index top level header index (zero-based).
4651 *
4652 * \returns the specified top level header associated with the module.
4653 */
4654CINDEX_LINKAGE
4655CXFile clang_Module_getTopLevelHeader(CXTranslationUnit,
4656 CXModule Module, unsigned Index);
4657
4658/**
4659 * @}
4660 */
4661
4662/**
4663 * \defgroup CINDEX_CPP C++ AST introspection
4664 *
4665 * The routines in this group provide access information in the ASTs specific
4666 * to C++ language features.
4667 *
4668 * @{
4669 */
4670
4671/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004672 * Determine if a C++ constructor is a converting constructor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004673 */
4674CINDEX_LINKAGE unsigned clang_CXXConstructor_isConvertingConstructor(CXCursor C);
4675
4676/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004677 * Determine if a C++ constructor is a copy constructor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004678 */
4679CINDEX_LINKAGE unsigned clang_CXXConstructor_isCopyConstructor(CXCursor C);
4680
4681/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004682 * Determine if a C++ constructor is the default constructor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004683 */
4684CINDEX_LINKAGE unsigned clang_CXXConstructor_isDefaultConstructor(CXCursor C);
4685
4686/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004687 * Determine if a C++ constructor is a move constructor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004688 */
4689CINDEX_LINKAGE unsigned clang_CXXConstructor_isMoveConstructor(CXCursor C);
4690
4691/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004692 * Determine if a C++ field is declared 'mutable'.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004693 */
4694CINDEX_LINKAGE unsigned clang_CXXField_isMutable(CXCursor C);
4695
4696/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004697 * Determine if a C++ method is declared '= default'.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004698 */
4699CINDEX_LINKAGE unsigned clang_CXXMethod_isDefaulted(CXCursor C);
4700
4701/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004702 * Determine if a C++ member function or member function template is
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004703 * pure virtual.
4704 */
4705CINDEX_LINKAGE unsigned clang_CXXMethod_isPureVirtual(CXCursor C);
4706
4707/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004708 * Determine if a C++ member function or member function template is
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004709 * declared 'static'.
4710 */
4711CINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C);
4712
4713/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004714 * Determine if a C++ member function or member function template is
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004715 * explicitly declared 'virtual' or if it overrides a virtual method from
4716 * one of the base classes.
4717 */
4718CINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual(CXCursor C);
4719
4720/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004721 * Determine if a C++ record is abstract, i.e. whether a class or struct
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004722 * has a pure virtual member function.
4723 */
4724CINDEX_LINKAGE unsigned clang_CXXRecord_isAbstract(CXCursor C);
4725
4726/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004727 * Determine if an enum declaration refers to a scoped enum.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004728 */
4729CINDEX_LINKAGE unsigned clang_EnumDecl_isScoped(CXCursor C);
4730
4731/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004732 * Determine if a C++ member function or member function template is
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004733 * declared 'const'.
4734 */
4735CINDEX_LINKAGE unsigned clang_CXXMethod_isConst(CXCursor C);
4736
4737/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004738 * Given a cursor that represents a template, determine
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004739 * the cursor kind of the specializations would be generated by instantiating
4740 * the template.
4741 *
4742 * This routine can be used to determine what flavor of function template,
4743 * class template, or class template partial specialization is stored in the
4744 * cursor. For example, it can describe whether a class template cursor is
4745 * declared with "struct", "class" or "union".
4746 *
4747 * \param C The cursor to query. This cursor should represent a template
4748 * declaration.
4749 *
4750 * \returns The cursor kind of the specializations that would be generated
4751 * by instantiating the template \p C. If \p C is not a template, returns
4752 * \c CXCursor_NoDeclFound.
4753 */
4754CINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind(CXCursor C);
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004755
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004756/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004757 * Given a cursor that may represent a specialization or instantiation
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004758 * of a template, retrieve the cursor that represents the template that it
4759 * specializes or from which it was instantiated.
4760 *
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004761 * This routine determines the template involved both for explicit
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004762 * specializations of templates and for implicit instantiations of the template,
4763 * both of which are referred to as "specializations". For a class template
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004764 * specialization (e.g., \c std::vector<bool>), this routine will return
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004765 * either the primary template (\c std::vector) or, if the specialization was
4766 * instantiated from a class template partial specialization, the class template
4767 * partial specialization. For a class template partial specialization and a
4768 * function template specialization (including instantiations), this
4769 * this routine will return the specialized template.
4770 *
4771 * For members of a class template (e.g., member functions, member classes, or
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004772 * static data members), returns the specialized or instantiated member.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004773 * Although not strictly "templates" in the C++ language, members of class
4774 * templates have the same notions of specializations and instantiations that
4775 * templates do, so this routine treats them similarly.
4776 *
4777 * \param C A cursor that may be a specialization of a template or a member
4778 * of a template.
4779 *
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004780 * \returns If the given cursor is a specialization or instantiation of a
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004781 * template or a member thereof, the template or member that it specializes or
4782 * from which it was instantiated. Otherwise, returns a NULL cursor.
4783 */
4784CINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate(CXCursor C);
4785
4786/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004787 * Given a cursor that references something else, return the source range
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004788 * covering that reference.
4789 *
4790 * \param C A cursor pointing to a member reference, a declaration reference, or
4791 * an operator call.
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004792 * \param NameFlags A bitset with three independent flags:
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004793 * CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and
4794 * CXNameRange_WantSinglePiece.
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004795 * \param PieceIndex For contiguous names or when passing the flag
4796 * CXNameRange_WantSinglePiece, only one piece with index 0 is
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004797 * available. When the CXNameRange_WantSinglePiece flag is not passed for a
4798 * non-contiguous names, this index can be used to retrieve the individual
4799 * pieces of the name. See also CXNameRange_WantSinglePiece.
4800 *
4801 * \returns The piece of the name pointed to by the given cursor. If there is no
4802 * name, or if the PieceIndex is out-of-range, a null-cursor will be returned.
4803 */
4804CINDEX_LINKAGE CXSourceRange clang_getCursorReferenceNameRange(CXCursor C,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004805 unsigned NameFlags,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004806 unsigned PieceIndex);
4807
4808enum CXNameRefFlags {
4809 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004810 * Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004811 * range.
4812 */
4813 CXNameRange_WantQualifier = 0x1,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004814
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004815 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004816 * Include the explicit template arguments, e.g. \<int> in x.f<int>,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004817 * in the range.
4818 */
4819 CXNameRange_WantTemplateArgs = 0x2,
4820
4821 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004822 * If the name is non-contiguous, return the full spanning range.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004823 *
4824 * Non-contiguous names occur in Objective-C when a selector with two or more
4825 * parameters is used, or in C++ when using an operator:
4826 * \code
4827 * [object doSomething:here withValue:there]; // Objective-C
4828 * return some_vector[1]; // C++
4829 * \endcode
4830 */
4831 CXNameRange_WantSinglePiece = 0x4
4832};
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004833
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004834/**
4835 * @}
4836 */
4837
4838/**
4839 * \defgroup CINDEX_LEX Token extraction and manipulation
4840 *
4841 * The routines in this group provide access to the tokens within a
4842 * translation unit, along with a semantic mapping of those tokens to
4843 * their corresponding cursors.
4844 *
4845 * @{
4846 */
4847
4848/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004849 * Describes a kind of token.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004850 */
4851typedef enum CXTokenKind {
4852 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004853 * A token that contains some kind of punctuation.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004854 */
4855 CXToken_Punctuation,
4856
4857 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004858 * A language keyword.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004859 */
4860 CXToken_Keyword,
4861
4862 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004863 * An identifier (that is not a keyword).
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004864 */
4865 CXToken_Identifier,
4866
4867 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004868 * A numeric, string, or character literal.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004869 */
4870 CXToken_Literal,
4871
4872 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004873 * A comment.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004874 */
4875 CXToken_Comment
4876} CXTokenKind;
4877
4878/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004879 * Describes a single preprocessing token.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004880 */
4881typedef struct {
4882 unsigned int_data[4];
4883 void *ptr_data;
4884} CXToken;
4885
4886/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004887 * Get the raw lexical token starting with the given location.
4888 *
4889 * \param TU the translation unit whose text is being tokenized.
4890 *
4891 * \param Location the source location with which the token starts.
4892 *
4893 * \returns The token starting with the given location or NULL if no such token
4894 * exist. The returned pointer must be freed with clang_disposeTokens before the
4895 * translation unit is destroyed.
4896 */
4897CINDEX_LINKAGE CXToken *clang_getToken(CXTranslationUnit TU,
4898 CXSourceLocation Location);
4899
4900/**
4901 * Determine the kind of the given token.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004902 */
4903CINDEX_LINKAGE CXTokenKind clang_getTokenKind(CXToken);
4904
4905/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004906 * Determine the spelling of the given token.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004907 *
4908 * The spelling of a token is the textual representation of that token, e.g.,
4909 * the text of an identifier or keyword.
4910 */
4911CINDEX_LINKAGE CXString clang_getTokenSpelling(CXTranslationUnit, CXToken);
4912
4913/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004914 * Retrieve the source location of the given token.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004915 */
4916CINDEX_LINKAGE CXSourceLocation clang_getTokenLocation(CXTranslationUnit,
4917 CXToken);
4918
4919/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004920 * Retrieve a source range that covers the given token.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004921 */
4922CINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken);
4923
4924/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004925 * Tokenize the source code described by the given range into raw
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004926 * lexical tokens.
4927 *
4928 * \param TU the translation unit whose text is being tokenized.
4929 *
4930 * \param Range the source range in which text should be tokenized. All of the
4931 * tokens produced by tokenization will fall within this source range,
4932 *
4933 * \param Tokens this pointer will be set to point to the array of tokens
4934 * that occur within the given source range. The returned pointer must be
4935 * freed with clang_disposeTokens() before the translation unit is destroyed.
4936 *
4937 * \param NumTokens will be set to the number of tokens in the \c *Tokens
4938 * array.
4939 *
4940 */
4941CINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
4942 CXToken **Tokens, unsigned *NumTokens);
4943
4944/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004945 * Annotate the given set of tokens by providing cursors for each token
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004946 * that can be mapped to a specific entity within the abstract syntax tree.
4947 *
4948 * This token-annotation routine is equivalent to invoking
4949 * clang_getCursor() for the source locations of each of the
4950 * tokens. The cursors provided are filtered, so that only those
4951 * cursors that have a direct correspondence to the token are
4952 * accepted. For example, given a function call \c f(x),
4953 * clang_getCursor() would provide the following cursors:
4954 *
4955 * * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'.
4956 * * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'.
4957 * * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'.
4958 *
4959 * Only the first and last of these cursors will occur within the
4960 * annotate, since the tokens "f" and "x' directly refer to a function
4961 * and a variable, respectively, but the parentheses are just a small
4962 * part of the full syntax of the function call expression, which is
4963 * not provided as an annotation.
4964 *
4965 * \param TU the translation unit that owns the given tokens.
4966 *
4967 * \param Tokens the set of tokens to annotate.
4968 *
4969 * \param NumTokens the number of tokens in \p Tokens.
4970 *
4971 * \param Cursors an array of \p NumTokens cursors, whose contents will be
4972 * replaced with the cursors corresponding to each token.
4973 */
4974CINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU,
4975 CXToken *Tokens, unsigned NumTokens,
4976 CXCursor *Cursors);
4977
4978/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01004979 * Free the given set of tokens.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01004980 */
4981CINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU,
4982 CXToken *Tokens, unsigned NumTokens);
4983
4984/**
4985 * @}
4986 */
4987
4988/**
4989 * \defgroup CINDEX_DEBUG Debugging facilities
4990 *
4991 * These routines are used for testing and debugging, only, and should not
4992 * be relied upon.
4993 *
4994 * @{
4995 */
4996
4997/* for debug/testing */
4998CINDEX_LINKAGE CXString clang_getCursorKindSpelling(enum CXCursorKind Kind);
4999CINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(CXCursor,
5000 const char **startBuf,
5001 const char **endBuf,
5002 unsigned *startLine,
5003 unsigned *startColumn,
5004 unsigned *endLine,
5005 unsigned *endColumn);
5006CINDEX_LINKAGE void clang_enableStackTraces(void);
5007CINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void*), void *user_data,
5008 unsigned stack_size);
5009
5010/**
5011 * @}
5012 */
5013
5014/**
5015 * \defgroup CINDEX_CODE_COMPLET Code completion
5016 *
5017 * Code completion involves taking an (incomplete) source file, along with
5018 * knowledge of where the user is actively editing that file, and suggesting
5019 * syntactically- and semantically-valid constructs that the user might want to
5020 * use at that particular point in the source code. These data structures and
5021 * routines provide support for code completion.
5022 *
5023 * @{
5024 */
5025
5026/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005027 * A semantic string that describes a code-completion result.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005028 *
5029 * A semantic string that describes the formatting of a code-completion
5030 * result as a single "template" of text that should be inserted into the
5031 * source buffer when a particular code-completion result is selected.
5032 * Each semantic string is made up of some number of "chunks", each of which
5033 * contains some text along with a description of what that text means, e.g.,
5034 * the name of the entity being referenced, whether the text chunk is part of
5035 * the template, or whether it is a "placeholder" that the user should replace
5036 * with actual code,of a specific kind. See \c CXCompletionChunkKind for a
5037 * description of the different kinds of chunks.
5038 */
5039typedef void *CXCompletionString;
5040
5041/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005042 * A single result of code completion.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005043 */
5044typedef struct {
5045 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005046 * The kind of entity that this completion refers to.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005047 *
5048 * The cursor kind will be a macro, keyword, or a declaration (one of the
5049 * *Decl cursor kinds), describing the entity that the completion is
5050 * referring to.
5051 *
5052 * \todo In the future, we would like to provide a full cursor, to allow
5053 * the client to extract additional information from declaration.
5054 */
5055 enum CXCursorKind CursorKind;
5056
5057 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005058 * The code-completion string that describes how to insert this
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005059 * code-completion result into the editing buffer.
5060 */
5061 CXCompletionString CompletionString;
5062} CXCompletionResult;
5063
5064/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005065 * Describes a single piece of text within a code-completion string.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005066 *
5067 * Each "chunk" within a code-completion string (\c CXCompletionString) is
5068 * either a piece of text with a specific "kind" that describes how that text
5069 * should be interpreted by the client or is another completion string.
5070 */
5071enum CXCompletionChunkKind {
5072 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005073 * A code-completion string that describes "optional" text that
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005074 * could be a part of the template (but is not required).
5075 *
5076 * The Optional chunk is the only kind of chunk that has a code-completion
5077 * string for its representation, which is accessible via
5078 * \c clang_getCompletionChunkCompletionString(). The code-completion string
5079 * describes an additional part of the template that is completely optional.
5080 * For example, optional chunks can be used to describe the placeholders for
5081 * arguments that match up with defaulted function parameters, e.g. given:
5082 *
5083 * \code
5084 * void f(int x, float y = 3.14, double z = 2.71828);
5085 * \endcode
5086 *
5087 * The code-completion string for this function would contain:
5088 * - a TypedText chunk for "f".
5089 * - a LeftParen chunk for "(".
5090 * - a Placeholder chunk for "int x"
5091 * - an Optional chunk containing the remaining defaulted arguments, e.g.,
5092 * - a Comma chunk for ","
5093 * - a Placeholder chunk for "float y"
5094 * - an Optional chunk containing the last defaulted argument:
5095 * - a Comma chunk for ","
5096 * - a Placeholder chunk for "double z"
5097 * - a RightParen chunk for ")"
5098 *
5099 * There are many ways to handle Optional chunks. Two simple approaches are:
5100 * - Completely ignore optional chunks, in which case the template for the
5101 * function "f" would only include the first parameter ("int x").
5102 * - Fully expand all optional chunks, in which case the template for the
5103 * function "f" would have all of the parameters.
5104 */
5105 CXCompletionChunk_Optional,
5106 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005107 * Text that a user would be expected to type to get this
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005108 * code-completion result.
5109 *
5110 * There will be exactly one "typed text" chunk in a semantic string, which
5111 * will typically provide the spelling of a keyword or the name of a
5112 * declaration that could be used at the current code point. Clients are
5113 * expected to filter the code-completion results based on the text in this
5114 * chunk.
5115 */
5116 CXCompletionChunk_TypedText,
5117 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005118 * Text that should be inserted as part of a code-completion result.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005119 *
5120 * A "text" chunk represents text that is part of the template to be
5121 * inserted into user code should this particular code-completion result
5122 * be selected.
5123 */
5124 CXCompletionChunk_Text,
5125 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005126 * Placeholder text that should be replaced by the user.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005127 *
5128 * A "placeholder" chunk marks a place where the user should insert text
5129 * into the code-completion template. For example, placeholders might mark
5130 * the function parameters for a function declaration, to indicate that the
5131 * user should provide arguments for each of those parameters. The actual
5132 * text in a placeholder is a suggestion for the text to display before
5133 * the user replaces the placeholder with real code.
5134 */
5135 CXCompletionChunk_Placeholder,
5136 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005137 * Informative text that should be displayed but never inserted as
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005138 * part of the template.
5139 *
5140 * An "informative" chunk contains annotations that can be displayed to
5141 * help the user decide whether a particular code-completion result is the
5142 * right option, but which is not part of the actual template to be inserted
5143 * by code completion.
5144 */
5145 CXCompletionChunk_Informative,
5146 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005147 * Text that describes the current parameter when code-completion is
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005148 * referring to function call, message send, or template specialization.
5149 *
5150 * A "current parameter" chunk occurs when code-completion is providing
5151 * information about a parameter corresponding to the argument at the
5152 * code-completion point. For example, given a function
5153 *
5154 * \code
5155 * int add(int x, int y);
5156 * \endcode
5157 *
5158 * and the source code \c add(, where the code-completion point is after the
5159 * "(", the code-completion string will contain a "current parameter" chunk
5160 * for "int x", indicating that the current argument will initialize that
5161 * parameter. After typing further, to \c add(17, (where the code-completion
5162 * point is after the ","), the code-completion string will contain a
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005163 * "current parameter" chunk to "int y".
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005164 */
5165 CXCompletionChunk_CurrentParameter,
5166 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005167 * A left parenthesis ('('), used to initiate a function call or
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005168 * signal the beginning of a function parameter list.
5169 */
5170 CXCompletionChunk_LeftParen,
5171 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005172 * A right parenthesis (')'), used to finish a function call or
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005173 * signal the end of a function parameter list.
5174 */
5175 CXCompletionChunk_RightParen,
5176 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005177 * A left bracket ('[').
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005178 */
5179 CXCompletionChunk_LeftBracket,
5180 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005181 * A right bracket (']').
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005182 */
5183 CXCompletionChunk_RightBracket,
5184 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005185 * A left brace ('{').
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005186 */
5187 CXCompletionChunk_LeftBrace,
5188 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005189 * A right brace ('}').
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005190 */
5191 CXCompletionChunk_RightBrace,
5192 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005193 * A left angle bracket ('<').
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005194 */
5195 CXCompletionChunk_LeftAngle,
5196 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005197 * A right angle bracket ('>').
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005198 */
5199 CXCompletionChunk_RightAngle,
5200 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005201 * A comma separator (',').
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005202 */
5203 CXCompletionChunk_Comma,
5204 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005205 * Text that specifies the result type of a given result.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005206 *
5207 * This special kind of informative chunk is not meant to be inserted into
5208 * the text buffer. Rather, it is meant to illustrate the type that an
5209 * expression using the given completion string would have.
5210 */
5211 CXCompletionChunk_ResultType,
5212 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005213 * A colon (':').
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005214 */
5215 CXCompletionChunk_Colon,
5216 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005217 * A semicolon (';').
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005218 */
5219 CXCompletionChunk_SemiColon,
5220 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005221 * An '=' sign.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005222 */
5223 CXCompletionChunk_Equal,
5224 /**
5225 * Horizontal space (' ').
5226 */
5227 CXCompletionChunk_HorizontalSpace,
5228 /**
5229 * Vertical space ('\\n'), after which it is generally a good idea to
5230 * perform indentation.
5231 */
5232 CXCompletionChunk_VerticalSpace
5233};
5234
5235/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005236 * Determine the kind of a particular chunk within a completion string.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005237 *
5238 * \param completion_string the completion string to query.
5239 *
5240 * \param chunk_number the 0-based index of the chunk in the completion string.
5241 *
5242 * \returns the kind of the chunk at the index \c chunk_number.
5243 */
5244CINDEX_LINKAGE enum CXCompletionChunkKind
5245clang_getCompletionChunkKind(CXCompletionString completion_string,
5246 unsigned chunk_number);
5247
5248/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005249 * Retrieve the text associated with a particular chunk within a
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005250 * completion string.
5251 *
5252 * \param completion_string the completion string to query.
5253 *
5254 * \param chunk_number the 0-based index of the chunk in the completion string.
5255 *
5256 * \returns the text associated with the chunk at index \c chunk_number.
5257 */
5258CINDEX_LINKAGE CXString
5259clang_getCompletionChunkText(CXCompletionString completion_string,
5260 unsigned chunk_number);
5261
5262/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005263 * Retrieve the completion string associated with a particular chunk
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005264 * within a completion string.
5265 *
5266 * \param completion_string the completion string to query.
5267 *
5268 * \param chunk_number the 0-based index of the chunk in the completion string.
5269 *
5270 * \returns the completion string associated with the chunk at index
5271 * \c chunk_number.
5272 */
5273CINDEX_LINKAGE CXCompletionString
5274clang_getCompletionChunkCompletionString(CXCompletionString completion_string,
5275 unsigned chunk_number);
5276
5277/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005278 * Retrieve the number of chunks in the given code-completion string.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005279 */
5280CINDEX_LINKAGE unsigned
5281clang_getNumCompletionChunks(CXCompletionString completion_string);
5282
5283/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005284 * Determine the priority of this code completion.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005285 *
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005286 * The priority of a code completion indicates how likely it is that this
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005287 * particular completion is the completion that the user will select. The
5288 * priority is selected by various internal heuristics.
5289 *
5290 * \param completion_string The completion string to query.
5291 *
5292 * \returns The priority of this completion string. Smaller values indicate
5293 * higher-priority (more likely) completions.
5294 */
5295CINDEX_LINKAGE unsigned
5296clang_getCompletionPriority(CXCompletionString completion_string);
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005297
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005298/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005299 * Determine the availability of the entity that this code-completion
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005300 * string refers to.
5301 *
5302 * \param completion_string The completion string to query.
5303 *
5304 * \returns The availability of the completion string.
5305 */
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005306CINDEX_LINKAGE enum CXAvailabilityKind
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005307clang_getCompletionAvailability(CXCompletionString completion_string);
5308
5309/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005310 * Retrieve the number of annotations associated with the given
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005311 * completion string.
5312 *
5313 * \param completion_string the completion string to query.
5314 *
5315 * \returns the number of annotations associated with the given completion
5316 * string.
5317 */
5318CINDEX_LINKAGE unsigned
5319clang_getCompletionNumAnnotations(CXCompletionString completion_string);
5320
5321/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005322 * Retrieve the annotation associated with the given completion string.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005323 *
5324 * \param completion_string the completion string to query.
5325 *
5326 * \param annotation_number the 0-based index of the annotation of the
5327 * completion string.
5328 *
5329 * \returns annotation string associated with the completion at index
5330 * \c annotation_number, or a NULL string if that annotation is not available.
5331 */
5332CINDEX_LINKAGE CXString
5333clang_getCompletionAnnotation(CXCompletionString completion_string,
5334 unsigned annotation_number);
5335
5336/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005337 * Retrieve the parent context of the given completion string.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005338 *
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005339 * The parent context of a completion string is the semantic parent of
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005340 * the declaration (if any) that the code completion represents. For example,
5341 * a code completion for an Objective-C method would have the method's class
5342 * or protocol as its context.
5343 *
5344 * \param completion_string The code completion string whose parent is
5345 * being queried.
5346 *
5347 * \param kind DEPRECATED: always set to CXCursor_NotImplemented if non-NULL.
5348 *
5349 * \returns The name of the completion parent, e.g., "NSObject" if
5350 * the completion string represents a method in the NSObject class.
5351 */
5352CINDEX_LINKAGE CXString
5353clang_getCompletionParent(CXCompletionString completion_string,
5354 enum CXCursorKind *kind);
5355
5356/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005357 * Retrieve the brief documentation comment attached to the declaration
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005358 * that corresponds to the given completion string.
5359 */
5360CINDEX_LINKAGE CXString
5361clang_getCompletionBriefComment(CXCompletionString completion_string);
5362
5363/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005364 * Retrieve a completion string for an arbitrary declaration or macro
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005365 * definition cursor.
5366 *
5367 * \param cursor The cursor to query.
5368 *
5369 * \returns A non-context-sensitive completion string for declaration and macro
5370 * definition cursors, or NULL for other kinds of cursors.
5371 */
5372CINDEX_LINKAGE CXCompletionString
5373clang_getCursorCompletionString(CXCursor cursor);
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005374
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005375/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005376 * Contains the results of code-completion.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005377 *
5378 * This data structure contains the results of code completion, as
5379 * produced by \c clang_codeCompleteAt(). Its contents must be freed by
5380 * \c clang_disposeCodeCompleteResults.
5381 */
5382typedef struct {
5383 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005384 * The code-completion results.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005385 */
5386 CXCompletionResult *Results;
5387
5388 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005389 * The number of code-completion results stored in the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005390 * \c Results array.
5391 */
5392 unsigned NumResults;
5393} CXCodeCompleteResults;
5394
5395/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005396 * Retrieve the number of fix-its for the given completion index.
5397 *
5398 * Calling this makes sense only if CXCodeComplete_IncludeCompletionsWithFixIts
5399 * option was set.
5400 *
5401 * \param results The structure keeping all completion results
5402 *
5403 * \param completion_index The index of the completion
5404 *
5405 * \return The number of fix-its which must be applied before the completion at
5406 * completion_index can be applied
5407 */
5408CINDEX_LINKAGE unsigned
5409clang_getCompletionNumFixIts(CXCodeCompleteResults *results,
5410 unsigned completion_index);
5411
5412/**
5413 * Fix-its that *must* be applied before inserting the text for the
5414 * corresponding completion.
5415 *
5416 * By default, clang_codeCompleteAt() only returns completions with empty
5417 * fix-its. Extra completions with non-empty fix-its should be explicitly
5418 * requested by setting CXCodeComplete_IncludeCompletionsWithFixIts.
5419 *
5420 * For the clients to be able to compute position of the cursor after applying
5421 * fix-its, the following conditions are guaranteed to hold for
5422 * replacement_range of the stored fix-its:
5423 * - Ranges in the fix-its are guaranteed to never contain the completion
5424 * point (or identifier under completion point, if any) inside them, except
5425 * at the start or at the end of the range.
5426 * - If a fix-it range starts or ends with completion point (or starts or
5427 * ends after the identifier under completion point), it will contain at
5428 * least one character. It allows to unambiguously recompute completion
5429 * point after applying the fix-it.
5430 *
5431 * The intuition is that provided fix-its change code around the identifier we
5432 * complete, but are not allowed to touch the identifier itself or the
5433 * completion point. One example of completions with corrections are the ones
5434 * replacing '.' with '->' and vice versa:
5435 *
5436 * std::unique_ptr<std::vector<int>> vec_ptr;
5437 * In 'vec_ptr.^', one of the completions is 'push_back', it requires
5438 * replacing '.' with '->'.
5439 * In 'vec_ptr->^', one of the completions is 'release', it requires
5440 * replacing '->' with '.'.
5441 *
5442 * \param results The structure keeping all completion results
5443 *
5444 * \param completion_index The index of the completion
5445 *
5446 * \param fixit_index The index of the fix-it for the completion at
5447 * completion_index
5448 *
5449 * \param replacement_range The fix-it range that must be replaced before the
5450 * completion at completion_index can be applied
5451 *
5452 * \returns The fix-it string that must replace the code at replacement_range
5453 * before the completion at completion_index can be applied
5454 */
5455CINDEX_LINKAGE CXString clang_getCompletionFixIt(
5456 CXCodeCompleteResults *results, unsigned completion_index,
5457 unsigned fixit_index, CXSourceRange *replacement_range);
5458
5459/**
5460 * Flags that can be passed to \c clang_codeCompleteAt() to
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005461 * modify its behavior.
5462 *
5463 * The enumerators in this enumeration can be bitwise-OR'd together to
5464 * provide multiple options to \c clang_codeCompleteAt().
5465 */
5466enum CXCodeComplete_Flags {
5467 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005468 * Whether to include macros within the set of code
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005469 * completions returned.
5470 */
5471 CXCodeComplete_IncludeMacros = 0x01,
5472
5473 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005474 * Whether to include code patterns for language constructs
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005475 * within the set of code completions, e.g., for loops.
5476 */
5477 CXCodeComplete_IncludeCodePatterns = 0x02,
5478
5479 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005480 * Whether to include brief documentation within the set of code
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005481 * completions returned.
5482 */
5483 CXCodeComplete_IncludeBriefComments = 0x04,
5484
5485 /**
5486 * Whether to speed up completion by omitting top- or namespace-level entities
5487 * defined in the preamble. There's no guarantee any particular entity is
5488 * omitted. This may be useful if the headers are indexed externally.
5489 */
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005490 CXCodeComplete_SkipPreamble = 0x08,
5491
5492 /**
5493 * Whether to include completions with small
5494 * fix-its, e.g. change '.' to '->' on member access, etc.
5495 */
5496 CXCodeComplete_IncludeCompletionsWithFixIts = 0x10
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005497};
5498
5499/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005500 * Bits that represent the context under which completion is occurring.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005501 *
5502 * The enumerators in this enumeration may be bitwise-OR'd together if multiple
5503 * contexts are occurring simultaneously.
5504 */
5505enum CXCompletionContext {
5506 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005507 * The context for completions is unexposed, as only Clang results
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005508 * should be included. (This is equivalent to having no context bits set.)
5509 */
5510 CXCompletionContext_Unexposed = 0,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005511
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005512 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005513 * Completions for any possible type should be included in the results.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005514 */
5515 CXCompletionContext_AnyType = 1 << 0,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005516
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005517 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005518 * Completions for any possible value (variables, function calls, etc.)
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005519 * should be included in the results.
5520 */
5521 CXCompletionContext_AnyValue = 1 << 1,
5522 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005523 * Completions for values that resolve to an Objective-C object should
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005524 * be included in the results.
5525 */
5526 CXCompletionContext_ObjCObjectValue = 1 << 2,
5527 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005528 * Completions for values that resolve to an Objective-C selector
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005529 * should be included in the results.
5530 */
5531 CXCompletionContext_ObjCSelectorValue = 1 << 3,
5532 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005533 * Completions for values that resolve to a C++ class type should be
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005534 * included in the results.
5535 */
5536 CXCompletionContext_CXXClassTypeValue = 1 << 4,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005537
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005538 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005539 * Completions for fields of the member being accessed using the dot
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005540 * operator should be included in the results.
5541 */
5542 CXCompletionContext_DotMemberAccess = 1 << 5,
5543 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005544 * Completions for fields of the member being accessed using the arrow
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005545 * operator should be included in the results.
5546 */
5547 CXCompletionContext_ArrowMemberAccess = 1 << 6,
5548 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005549 * Completions for properties of the Objective-C object being accessed
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005550 * using the dot operator should be included in the results.
5551 */
5552 CXCompletionContext_ObjCPropertyAccess = 1 << 7,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005553
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005554 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005555 * Completions for enum tags should be included in the results.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005556 */
5557 CXCompletionContext_EnumTag = 1 << 8,
5558 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005559 * Completions for union tags should be included in the results.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005560 */
5561 CXCompletionContext_UnionTag = 1 << 9,
5562 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005563 * Completions for struct tags should be included in the results.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005564 */
5565 CXCompletionContext_StructTag = 1 << 10,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005566
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005567 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005568 * Completions for C++ class names should be included in the results.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005569 */
5570 CXCompletionContext_ClassTag = 1 << 11,
5571 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005572 * Completions for C++ namespaces and namespace aliases should be
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005573 * included in the results.
5574 */
5575 CXCompletionContext_Namespace = 1 << 12,
5576 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005577 * Completions for C++ nested name specifiers should be included in
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005578 * the results.
5579 */
5580 CXCompletionContext_NestedNameSpecifier = 1 << 13,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005581
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005582 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005583 * Completions for Objective-C interfaces (classes) should be included
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005584 * in the results.
5585 */
5586 CXCompletionContext_ObjCInterface = 1 << 14,
5587 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005588 * Completions for Objective-C protocols should be included in
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005589 * the results.
5590 */
5591 CXCompletionContext_ObjCProtocol = 1 << 15,
5592 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005593 * Completions for Objective-C categories should be included in
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005594 * the results.
5595 */
5596 CXCompletionContext_ObjCCategory = 1 << 16,
5597 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005598 * Completions for Objective-C instance messages should be included
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005599 * in the results.
5600 */
5601 CXCompletionContext_ObjCInstanceMessage = 1 << 17,
5602 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005603 * Completions for Objective-C class messages should be included in
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005604 * the results.
5605 */
5606 CXCompletionContext_ObjCClassMessage = 1 << 18,
5607 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005608 * Completions for Objective-C selector names should be included in
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005609 * the results.
5610 */
5611 CXCompletionContext_ObjCSelectorName = 1 << 19,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005612
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005613 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005614 * Completions for preprocessor macro names should be included in
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005615 * the results.
5616 */
5617 CXCompletionContext_MacroName = 1 << 20,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005618
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005619 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005620 * Natural language completions should be included in the results.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005621 */
5622 CXCompletionContext_NaturalLanguage = 1 << 21,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005623
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005624 /**
Andrew Scull0372a572018-11-16 15:47:06 +00005625 * #include file completions should be included in the results.
5626 */
5627 CXCompletionContext_IncludedFile = 1 << 22,
5628
5629 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005630 * The current context is unknown, so set all contexts.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005631 */
Andrew Scull0372a572018-11-16 15:47:06 +00005632 CXCompletionContext_Unknown = ((1 << 23) - 1)
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005633};
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005634
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005635/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005636 * Returns a default set of code-completion options that can be
5637 * passed to\c clang_codeCompleteAt().
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005638 */
5639CINDEX_LINKAGE unsigned clang_defaultCodeCompleteOptions(void);
5640
5641/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005642 * Perform code completion at a given location in a translation unit.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005643 *
5644 * This function performs code completion at a particular file, line, and
5645 * column within source code, providing results that suggest potential
5646 * code snippets based on the context of the completion. The basic model
5647 * for code completion is that Clang will parse a complete source file,
5648 * performing syntax checking up to the location where code-completion has
5649 * been requested. At that point, a special code-completion token is passed
5650 * to the parser, which recognizes this token and determines, based on the
5651 * current location in the C/Objective-C/C++ grammar and the state of
5652 * semantic analysis, what completions to provide. These completions are
5653 * returned via a new \c CXCodeCompleteResults structure.
5654 *
5655 * Code completion itself is meant to be triggered by the client when the
5656 * user types punctuation characters or whitespace, at which point the
5657 * code-completion location will coincide with the cursor. For example, if \c p
5658 * is a pointer, code-completion might be triggered after the "-" and then
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005659 * after the ">" in \c p->. When the code-completion location is after the ">",
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005660 * the completion results will provide, e.g., the members of the struct that
5661 * "p" points to. The client is responsible for placing the cursor at the
5662 * beginning of the token currently being typed, then filtering the results
5663 * based on the contents of the token. For example, when code-completing for
5664 * the expression \c p->get, the client should provide the location just after
5665 * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the
5666 * client can filter the results based on the current token text ("get"), only
5667 * showing those results that start with "get". The intent of this interface
5668 * is to separate the relatively high-latency acquisition of code-completion
5669 * results from the filtering of results on a per-character basis, which must
5670 * have a lower latency.
5671 *
5672 * \param TU The translation unit in which code-completion should
5673 * occur. The source files for this translation unit need not be
5674 * completely up-to-date (and the contents of those source files may
5675 * be overridden via \p unsaved_files). Cursors referring into the
5676 * translation unit may be invalidated by this invocation.
5677 *
5678 * \param complete_filename The name of the source file where code
5679 * completion should be performed. This filename may be any file
5680 * included in the translation unit.
5681 *
5682 * \param complete_line The line at which code-completion should occur.
5683 *
5684 * \param complete_column The column at which code-completion should occur.
5685 * Note that the column should point just after the syntactic construct that
5686 * initiated code completion, and not in the middle of a lexical token.
5687 *
5688 * \param unsaved_files the Files that have not yet been saved to disk
5689 * but may be required for parsing or code completion, including the
5690 * contents of those files. The contents and name of these files (as
5691 * specified by CXUnsavedFile) are copied when necessary, so the
5692 * client only needs to guarantee their validity until the call to
5693 * this function returns.
5694 *
5695 * \param num_unsaved_files The number of unsaved file entries in \p
5696 * unsaved_files.
5697 *
5698 * \param options Extra options that control the behavior of code
5699 * completion, expressed as a bitwise OR of the enumerators of the
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005700 * CXCodeComplete_Flags enumeration. The
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005701 * \c clang_defaultCodeCompleteOptions() function returns a default set
5702 * of code-completion options.
5703 *
5704 * \returns If successful, a new \c CXCodeCompleteResults structure
5705 * containing code-completion results, which should eventually be
5706 * freed with \c clang_disposeCodeCompleteResults(). If code
5707 * completion fails, returns NULL.
5708 */
5709CINDEX_LINKAGE
5710CXCodeCompleteResults *clang_codeCompleteAt(CXTranslationUnit TU,
5711 const char *complete_filename,
5712 unsigned complete_line,
5713 unsigned complete_column,
5714 struct CXUnsavedFile *unsaved_files,
5715 unsigned num_unsaved_files,
5716 unsigned options);
5717
5718/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005719 * Sort the code-completion results in case-insensitive alphabetical
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005720 * order.
5721 *
5722 * \param Results The set of results to sort.
5723 * \param NumResults The number of results in \p Results.
5724 */
5725CINDEX_LINKAGE
5726void clang_sortCodeCompletionResults(CXCompletionResult *Results,
5727 unsigned NumResults);
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005728
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005729/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005730 * Free the given set of code-completion results.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005731 */
5732CINDEX_LINKAGE
5733void clang_disposeCodeCompleteResults(CXCodeCompleteResults *Results);
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005734
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005735/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005736 * Determine the number of diagnostics produced prior to the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005737 * location where code completion was performed.
5738 */
5739CINDEX_LINKAGE
5740unsigned clang_codeCompleteGetNumDiagnostics(CXCodeCompleteResults *Results);
5741
5742/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005743 * Retrieve a diagnostic associated with the given code completion.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005744 *
5745 * \param Results the code completion results to query.
5746 * \param Index the zero-based diagnostic number to retrieve.
5747 *
5748 * \returns the requested diagnostic. This diagnostic must be freed
5749 * via a call to \c clang_disposeDiagnostic().
5750 */
5751CINDEX_LINKAGE
5752CXDiagnostic clang_codeCompleteGetDiagnostic(CXCodeCompleteResults *Results,
5753 unsigned Index);
5754
5755/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005756 * Determines what completions are appropriate for the context
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005757 * the given code completion.
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005758 *
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005759 * \param Results the code completion results to query
5760 *
5761 * \returns the kinds of completions that are appropriate for use
5762 * along with the given code completion results.
5763 */
5764CINDEX_LINKAGE
5765unsigned long long clang_codeCompleteGetContexts(
5766 CXCodeCompleteResults *Results);
5767
5768/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005769 * Returns the cursor kind for the container for the current code
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005770 * completion context. The container is only guaranteed to be set for
5771 * contexts where a container exists (i.e. member accesses or Objective-C
5772 * message sends); if there is not a container, this function will return
5773 * CXCursor_InvalidCode.
5774 *
5775 * \param Results the code completion results to query
5776 *
5777 * \param IsIncomplete on return, this value will be false if Clang has complete
5778 * information about the container. If Clang does not have complete
5779 * information, this value will be true.
5780 *
5781 * \returns the container kind, or CXCursor_InvalidCode if there is not a
5782 * container
5783 */
5784CINDEX_LINKAGE
5785enum CXCursorKind clang_codeCompleteGetContainerKind(
5786 CXCodeCompleteResults *Results,
5787 unsigned *IsIncomplete);
5788
5789/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005790 * Returns the USR for the container for the current code completion
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005791 * context. If there is not a container for the current context, this
5792 * function will return the empty string.
5793 *
5794 * \param Results the code completion results to query
5795 *
5796 * \returns the USR for the container
5797 */
5798CINDEX_LINKAGE
5799CXString clang_codeCompleteGetContainerUSR(CXCodeCompleteResults *Results);
5800
5801/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005802 * Returns the currently-entered selector for an Objective-C message
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005803 * send, formatted like "initWithFoo:bar:". Only guaranteed to return a
5804 * non-empty string for CXCompletionContext_ObjCInstanceMessage and
5805 * CXCompletionContext_ObjCClassMessage.
5806 *
5807 * \param Results the code completion results to query
5808 *
5809 * \returns the selector (or partial selector) that has been entered thus far
5810 * for an Objective-C message send.
5811 */
5812CINDEX_LINKAGE
5813CXString clang_codeCompleteGetObjCSelector(CXCodeCompleteResults *Results);
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005814
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005815/**
5816 * @}
5817 */
5818
5819/**
5820 * \defgroup CINDEX_MISC Miscellaneous utility functions
5821 *
5822 * @{
5823 */
5824
5825/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005826 * Return a version string, suitable for showing to a user, but not
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005827 * intended to be parsed (the format is not guaranteed to be stable).
5828 */
5829CINDEX_LINKAGE CXString clang_getClangVersion(void);
5830
5831/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005832 * Enable/disable crash recovery.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005833 *
5834 * \param isEnabled Flag to indicate if crash recovery is enabled. A non-zero
5835 * value enables crash recovery, while 0 disables it.
5836 */
5837CINDEX_LINKAGE void clang_toggleCrashRecovery(unsigned isEnabled);
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005838
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005839 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005840 * Visitor invoked for each file in a translation unit
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005841 * (used with clang_getInclusions()).
5842 *
5843 * This visitor function will be invoked by clang_getInclusions() for each
5844 * file included (either at the top-level or by \#include directives) within
5845 * a translation unit. The first argument is the file being included, and
5846 * the second and third arguments provide the inclusion stack. The
5847 * array is sorted in order of immediate inclusion. For example,
5848 * the first element refers to the location that included 'included_file'.
5849 */
5850typedef void (*CXInclusionVisitor)(CXFile included_file,
5851 CXSourceLocation* inclusion_stack,
5852 unsigned include_len,
5853 CXClientData client_data);
5854
5855/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005856 * Visit the set of preprocessor inclusions in a translation unit.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005857 * The visitor function is called with the provided data for every included
5858 * file. This does not include headers included by the PCH file (unless one
5859 * is inspecting the inclusions in the PCH file itself).
5860 */
5861CINDEX_LINKAGE void clang_getInclusions(CXTranslationUnit tu,
5862 CXInclusionVisitor visitor,
5863 CXClientData client_data);
5864
5865typedef enum {
5866 CXEval_Int = 1 ,
5867 CXEval_Float = 2,
5868 CXEval_ObjCStrLiteral = 3,
5869 CXEval_StrLiteral = 4,
5870 CXEval_CFStr = 5,
5871 CXEval_Other = 6,
5872
5873 CXEval_UnExposed = 0
5874
5875} CXEvalResultKind ;
5876
5877/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005878 * Evaluation result of a cursor
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005879 */
5880typedef void * CXEvalResult;
5881
5882/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005883 * If cursor is a statement declaration tries to evaluate the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005884 * statement and if its variable, tries to evaluate its initializer,
5885 * into its corresponding type.
5886 */
5887CINDEX_LINKAGE CXEvalResult clang_Cursor_Evaluate(CXCursor C);
5888
5889/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005890 * Returns the kind of the evaluated result.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005891 */
5892CINDEX_LINKAGE CXEvalResultKind clang_EvalResult_getKind(CXEvalResult E);
5893
5894/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005895 * Returns the evaluation result as integer if the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005896 * kind is Int.
5897 */
5898CINDEX_LINKAGE int clang_EvalResult_getAsInt(CXEvalResult E);
5899
5900/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005901 * Returns the evaluation result as a long long integer if the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005902 * kind is Int. This prevents overflows that may happen if the result is
5903 * returned with clang_EvalResult_getAsInt.
5904 */
5905CINDEX_LINKAGE long long clang_EvalResult_getAsLongLong(CXEvalResult E);
5906
5907/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005908 * Returns a non-zero value if the kind is Int and the evaluation
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005909 * result resulted in an unsigned integer.
5910 */
5911CINDEX_LINKAGE unsigned clang_EvalResult_isUnsignedInt(CXEvalResult E);
5912
5913/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005914 * Returns the evaluation result as an unsigned integer if
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005915 * the kind is Int and clang_EvalResult_isUnsignedInt is non-zero.
5916 */
5917CINDEX_LINKAGE unsigned long long clang_EvalResult_getAsUnsigned(CXEvalResult E);
5918
5919/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005920 * Returns the evaluation result as double if the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005921 * kind is double.
5922 */
5923CINDEX_LINKAGE double clang_EvalResult_getAsDouble(CXEvalResult E);
5924
5925/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005926 * Returns the evaluation result as a constant string if the
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005927 * kind is other than Int or float. User must not free this pointer,
5928 * instead call clang_EvalResult_dispose on the CXEvalResult returned
5929 * by clang_Cursor_Evaluate.
5930 */
5931CINDEX_LINKAGE const char* clang_EvalResult_getAsStr(CXEvalResult E);
5932
5933/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005934 * Disposes the created Eval memory.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005935 */
5936CINDEX_LINKAGE void clang_EvalResult_dispose(CXEvalResult E);
5937/**
5938 * @}
5939 */
5940
5941/** \defgroup CINDEX_REMAPPING Remapping functions
5942 *
5943 * @{
5944 */
5945
5946/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005947 * A remapping of original source files and their translated files.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005948 */
5949typedef void *CXRemapping;
5950
5951/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005952 * Retrieve a remapping.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005953 *
5954 * \param path the path that contains metadata about remappings.
5955 *
5956 * \returns the requested remapping. This remapping must be freed
5957 * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
5958 */
5959CINDEX_LINKAGE CXRemapping clang_getRemappings(const char *path);
5960
5961/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005962 * Retrieve a remapping.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005963 *
5964 * \param filePaths pointer to an array of file paths containing remapping info.
5965 *
5966 * \param numFiles number of file paths.
5967 *
5968 * \returns the requested remapping. This remapping must be freed
5969 * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
5970 */
5971CINDEX_LINKAGE
5972CXRemapping clang_getRemappingsFromFileList(const char **filePaths,
5973 unsigned numFiles);
5974
5975/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005976 * Determine the number of remappings.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005977 */
5978CINDEX_LINKAGE unsigned clang_remap_getNumFiles(CXRemapping);
5979
5980/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005981 * Get the original and the associated filename from the remapping.
5982 *
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005983 * \param original If non-NULL, will be set to the original filename.
5984 *
5985 * \param transformed If non-NULL, will be set to the filename that the original
5986 * is associated with.
5987 */
5988CINDEX_LINKAGE void clang_remap_getFilenames(CXRemapping, unsigned index,
5989 CXString *original, CXString *transformed);
5990
5991/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01005992 * Dispose the remapping.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01005993 */
5994CINDEX_LINKAGE void clang_remap_dispose(CXRemapping);
5995
5996/**
5997 * @}
5998 */
5999
6000/** \defgroup CINDEX_HIGH Higher level API functions
6001 *
6002 * @{
6003 */
6004
6005enum CXVisitorResult {
6006 CXVisit_Break,
6007 CXVisit_Continue
6008};
6009
6010typedef struct CXCursorAndRangeVisitor {
6011 void *context;
6012 enum CXVisitorResult (*visit)(void *context, CXCursor, CXSourceRange);
6013} CXCursorAndRangeVisitor;
6014
6015typedef enum {
6016 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006017 * Function returned successfully.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006018 */
6019 CXResult_Success = 0,
6020 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006021 * One of the parameters was invalid for the function.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006022 */
6023 CXResult_Invalid = 1,
6024 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006025 * The function was terminated by a callback (e.g. it returned
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006026 * CXVisit_Break)
6027 */
6028 CXResult_VisitBreak = 2
6029
6030} CXResult;
6031
6032/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006033 * Find references of a declaration in a specific file.
6034 *
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006035 * \param cursor pointing to a declaration or a reference of one.
6036 *
6037 * \param file to search for references.
6038 *
6039 * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
6040 * each reference found.
6041 * The CXSourceRange will point inside the file; if the reference is inside
6042 * a macro (and not a macro argument) the CXSourceRange will be invalid.
6043 *
6044 * \returns one of the CXResult enumerators.
6045 */
6046CINDEX_LINKAGE CXResult clang_findReferencesInFile(CXCursor cursor, CXFile file,
6047 CXCursorAndRangeVisitor visitor);
6048
6049/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006050 * Find #import/#include directives in a specific file.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006051 *
6052 * \param TU translation unit containing the file to query.
6053 *
6054 * \param file to search for #import/#include directives.
6055 *
6056 * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
6057 * each directive found.
6058 *
6059 * \returns one of the CXResult enumerators.
6060 */
6061CINDEX_LINKAGE CXResult clang_findIncludesInFile(CXTranslationUnit TU,
6062 CXFile file,
6063 CXCursorAndRangeVisitor visitor);
6064
6065#ifdef __has_feature
6066# if __has_feature(blocks)
6067
6068typedef enum CXVisitorResult
6069 (^CXCursorAndRangeVisitorBlock)(CXCursor, CXSourceRange);
6070
6071CINDEX_LINKAGE
6072CXResult clang_findReferencesInFileWithBlock(CXCursor, CXFile,
6073 CXCursorAndRangeVisitorBlock);
6074
6075CINDEX_LINKAGE
6076CXResult clang_findIncludesInFileWithBlock(CXTranslationUnit, CXFile,
6077 CXCursorAndRangeVisitorBlock);
6078
6079# endif
6080#endif
6081
6082/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006083 * The client's data object that is associated with a CXFile.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006084 */
6085typedef void *CXIdxClientFile;
6086
6087/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006088 * The client's data object that is associated with a semantic entity.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006089 */
6090typedef void *CXIdxClientEntity;
6091
6092/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006093 * The client's data object that is associated with a semantic container
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006094 * of entities.
6095 */
6096typedef void *CXIdxClientContainer;
6097
6098/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006099 * The client's data object that is associated with an AST file (PCH
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006100 * or module).
6101 */
6102typedef void *CXIdxClientASTFile;
6103
6104/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006105 * Source location passed to index callbacks.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006106 */
6107typedef struct {
6108 void *ptr_data[2];
6109 unsigned int_data;
6110} CXIdxLoc;
6111
6112/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006113 * Data for ppIncludedFile callback.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006114 */
6115typedef struct {
6116 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006117 * Location of '#' in the \#include/\#import directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006118 */
6119 CXIdxLoc hashLoc;
6120 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006121 * Filename as written in the \#include/\#import directive.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006122 */
6123 const char *filename;
6124 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006125 * The actual file that the \#include/\#import directive resolved to.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006126 */
6127 CXFile file;
6128 int isImport;
6129 int isAngled;
6130 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006131 * Non-zero if the directive was automatically turned into a module
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006132 * import.
6133 */
6134 int isModuleImport;
6135} CXIdxIncludedFileInfo;
6136
6137/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006138 * Data for IndexerCallbacks#importedASTFile.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006139 */
6140typedef struct {
6141 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006142 * Top level AST file containing the imported PCH, module or submodule.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006143 */
6144 CXFile file;
6145 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006146 * The imported module or NULL if the AST file is a PCH.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006147 */
6148 CXModule module;
6149 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006150 * Location where the file is imported. Applicable only for modules.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006151 */
6152 CXIdxLoc loc;
6153 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006154 * Non-zero if an inclusion directive was automatically turned into
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006155 * a module import. Applicable only for modules.
6156 */
6157 int isImplicit;
6158
6159} CXIdxImportedASTFileInfo;
6160
6161typedef enum {
6162 CXIdxEntity_Unexposed = 0,
6163 CXIdxEntity_Typedef = 1,
6164 CXIdxEntity_Function = 2,
6165 CXIdxEntity_Variable = 3,
6166 CXIdxEntity_Field = 4,
6167 CXIdxEntity_EnumConstant = 5,
6168
6169 CXIdxEntity_ObjCClass = 6,
6170 CXIdxEntity_ObjCProtocol = 7,
6171 CXIdxEntity_ObjCCategory = 8,
6172
6173 CXIdxEntity_ObjCInstanceMethod = 9,
6174 CXIdxEntity_ObjCClassMethod = 10,
6175 CXIdxEntity_ObjCProperty = 11,
6176 CXIdxEntity_ObjCIvar = 12,
6177
6178 CXIdxEntity_Enum = 13,
6179 CXIdxEntity_Struct = 14,
6180 CXIdxEntity_Union = 15,
6181
6182 CXIdxEntity_CXXClass = 16,
6183 CXIdxEntity_CXXNamespace = 17,
6184 CXIdxEntity_CXXNamespaceAlias = 18,
6185 CXIdxEntity_CXXStaticVariable = 19,
6186 CXIdxEntity_CXXStaticMethod = 20,
6187 CXIdxEntity_CXXInstanceMethod = 21,
6188 CXIdxEntity_CXXConstructor = 22,
6189 CXIdxEntity_CXXDestructor = 23,
6190 CXIdxEntity_CXXConversionFunction = 24,
6191 CXIdxEntity_CXXTypeAlias = 25,
6192 CXIdxEntity_CXXInterface = 26
6193
6194} CXIdxEntityKind;
6195
6196typedef enum {
6197 CXIdxEntityLang_None = 0,
6198 CXIdxEntityLang_C = 1,
6199 CXIdxEntityLang_ObjC = 2,
6200 CXIdxEntityLang_CXX = 3,
6201 CXIdxEntityLang_Swift = 4
6202} CXIdxEntityLanguage;
6203
6204/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006205 * Extra C++ template information for an entity. This can apply to:
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006206 * CXIdxEntity_Function
6207 * CXIdxEntity_CXXClass
6208 * CXIdxEntity_CXXStaticMethod
6209 * CXIdxEntity_CXXInstanceMethod
6210 * CXIdxEntity_CXXConstructor
6211 * CXIdxEntity_CXXConversionFunction
6212 * CXIdxEntity_CXXTypeAlias
6213 */
6214typedef enum {
6215 CXIdxEntity_NonTemplate = 0,
6216 CXIdxEntity_Template = 1,
6217 CXIdxEntity_TemplatePartialSpecialization = 2,
6218 CXIdxEntity_TemplateSpecialization = 3
6219} CXIdxEntityCXXTemplateKind;
6220
6221typedef enum {
6222 CXIdxAttr_Unexposed = 0,
6223 CXIdxAttr_IBAction = 1,
6224 CXIdxAttr_IBOutlet = 2,
6225 CXIdxAttr_IBOutletCollection = 3
6226} CXIdxAttrKind;
6227
6228typedef struct {
6229 CXIdxAttrKind kind;
6230 CXCursor cursor;
6231 CXIdxLoc loc;
6232} CXIdxAttrInfo;
6233
6234typedef struct {
6235 CXIdxEntityKind kind;
6236 CXIdxEntityCXXTemplateKind templateKind;
6237 CXIdxEntityLanguage lang;
6238 const char *name;
6239 const char *USR;
6240 CXCursor cursor;
6241 const CXIdxAttrInfo *const *attributes;
6242 unsigned numAttributes;
6243} CXIdxEntityInfo;
6244
6245typedef struct {
6246 CXCursor cursor;
6247} CXIdxContainerInfo;
6248
6249typedef struct {
6250 const CXIdxAttrInfo *attrInfo;
6251 const CXIdxEntityInfo *objcClass;
6252 CXCursor classCursor;
6253 CXIdxLoc classLoc;
6254} CXIdxIBOutletCollectionAttrInfo;
6255
6256typedef enum {
6257 CXIdxDeclFlag_Skipped = 0x1
6258} CXIdxDeclInfoFlags;
6259
6260typedef struct {
6261 const CXIdxEntityInfo *entityInfo;
6262 CXCursor cursor;
6263 CXIdxLoc loc;
6264 const CXIdxContainerInfo *semanticContainer;
6265 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006266 * Generally same as #semanticContainer but can be different in
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006267 * cases like out-of-line C++ member functions.
6268 */
6269 const CXIdxContainerInfo *lexicalContainer;
6270 int isRedeclaration;
6271 int isDefinition;
6272 int isContainer;
6273 const CXIdxContainerInfo *declAsContainer;
6274 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006275 * Whether the declaration exists in code or was created implicitly
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006276 * by the compiler, e.g. implicit Objective-C methods for properties.
6277 */
6278 int isImplicit;
6279 const CXIdxAttrInfo *const *attributes;
6280 unsigned numAttributes;
6281
6282 unsigned flags;
6283
6284} CXIdxDeclInfo;
6285
6286typedef enum {
6287 CXIdxObjCContainer_ForwardRef = 0,
6288 CXIdxObjCContainer_Interface = 1,
6289 CXIdxObjCContainer_Implementation = 2
6290} CXIdxObjCContainerKind;
6291
6292typedef struct {
6293 const CXIdxDeclInfo *declInfo;
6294 CXIdxObjCContainerKind kind;
6295} CXIdxObjCContainerDeclInfo;
6296
6297typedef struct {
6298 const CXIdxEntityInfo *base;
6299 CXCursor cursor;
6300 CXIdxLoc loc;
6301} CXIdxBaseClassInfo;
6302
6303typedef struct {
6304 const CXIdxEntityInfo *protocol;
6305 CXCursor cursor;
6306 CXIdxLoc loc;
6307} CXIdxObjCProtocolRefInfo;
6308
6309typedef struct {
6310 const CXIdxObjCProtocolRefInfo *const *protocols;
6311 unsigned numProtocols;
6312} CXIdxObjCProtocolRefListInfo;
6313
6314typedef struct {
6315 const CXIdxObjCContainerDeclInfo *containerInfo;
6316 const CXIdxBaseClassInfo *superInfo;
6317 const CXIdxObjCProtocolRefListInfo *protocols;
6318} CXIdxObjCInterfaceDeclInfo;
6319
6320typedef struct {
6321 const CXIdxObjCContainerDeclInfo *containerInfo;
6322 const CXIdxEntityInfo *objcClass;
6323 CXCursor classCursor;
6324 CXIdxLoc classLoc;
6325 const CXIdxObjCProtocolRefListInfo *protocols;
6326} CXIdxObjCCategoryDeclInfo;
6327
6328typedef struct {
6329 const CXIdxDeclInfo *declInfo;
6330 const CXIdxEntityInfo *getter;
6331 const CXIdxEntityInfo *setter;
6332} CXIdxObjCPropertyDeclInfo;
6333
6334typedef struct {
6335 const CXIdxDeclInfo *declInfo;
6336 const CXIdxBaseClassInfo *const *bases;
6337 unsigned numBases;
6338} CXIdxCXXClassDeclInfo;
6339
6340/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006341 * Data for IndexerCallbacks#indexEntityReference.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006342 *
6343 * This may be deprecated in a future version as this duplicates
6344 * the \c CXSymbolRole_Implicit bit in \c CXSymbolRole.
6345 */
6346typedef enum {
6347 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006348 * The entity is referenced directly in user's code.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006349 */
6350 CXIdxEntityRef_Direct = 1,
6351 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006352 * An implicit reference, e.g. a reference of an Objective-C method
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006353 * via the dot syntax.
6354 */
6355 CXIdxEntityRef_Implicit = 2
6356} CXIdxEntityRefKind;
6357
6358/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006359 * Roles that are attributed to symbol occurrences.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006360 *
6361 * Internal: this currently mirrors low 9 bits of clang::index::SymbolRole with
6362 * higher bits zeroed. These high bits may be exposed in the future.
6363 */
6364typedef enum {
6365 CXSymbolRole_None = 0,
6366 CXSymbolRole_Declaration = 1 << 0,
6367 CXSymbolRole_Definition = 1 << 1,
6368 CXSymbolRole_Reference = 1 << 2,
6369 CXSymbolRole_Read = 1 << 3,
6370 CXSymbolRole_Write = 1 << 4,
6371 CXSymbolRole_Call = 1 << 5,
6372 CXSymbolRole_Dynamic = 1 << 6,
6373 CXSymbolRole_AddressOf = 1 << 7,
6374 CXSymbolRole_Implicit = 1 << 8
6375} CXSymbolRole;
6376
6377/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006378 * Data for IndexerCallbacks#indexEntityReference.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006379 */
6380typedef struct {
6381 CXIdxEntityRefKind kind;
6382 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006383 * Reference cursor.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006384 */
6385 CXCursor cursor;
6386 CXIdxLoc loc;
6387 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006388 * The entity that gets referenced.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006389 */
6390 const CXIdxEntityInfo *referencedEntity;
6391 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006392 * Immediate "parent" of the reference. For example:
6393 *
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006394 * \code
6395 * Foo *var;
6396 * \endcode
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006397 *
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006398 * The parent of reference of type 'Foo' is the variable 'var'.
6399 * For references inside statement bodies of functions/methods,
6400 * the parentEntity will be the function/method.
6401 */
6402 const CXIdxEntityInfo *parentEntity;
6403 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006404 * Lexical container context of the reference.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006405 */
6406 const CXIdxContainerInfo *container;
6407 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006408 * Sets of symbol roles of the reference.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006409 */
6410 CXSymbolRole role;
6411} CXIdxEntityRefInfo;
6412
6413/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006414 * A group of callbacks used by #clang_indexSourceFile and
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006415 * #clang_indexTranslationUnit.
6416 */
6417typedef struct {
6418 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006419 * Called periodically to check whether indexing should be aborted.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006420 * Should return 0 to continue, and non-zero to abort.
6421 */
6422 int (*abortQuery)(CXClientData client_data, void *reserved);
6423
6424 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006425 * Called at the end of indexing; passes the complete diagnostic set.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006426 */
6427 void (*diagnostic)(CXClientData client_data,
6428 CXDiagnosticSet, void *reserved);
6429
6430 CXIdxClientFile (*enteredMainFile)(CXClientData client_data,
6431 CXFile mainFile, void *reserved);
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006432
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006433 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006434 * Called when a file gets \#included/\#imported.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006435 */
6436 CXIdxClientFile (*ppIncludedFile)(CXClientData client_data,
6437 const CXIdxIncludedFileInfo *);
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006438
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006439 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006440 * Called when a AST file (PCH or module) gets imported.
6441 *
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006442 * AST files will not get indexed (there will not be callbacks to index all
6443 * the entities in an AST file). The recommended action is that, if the AST
6444 * file is not already indexed, to initiate a new indexing job specific to
6445 * the AST file.
6446 */
6447 CXIdxClientASTFile (*importedASTFile)(CXClientData client_data,
6448 const CXIdxImportedASTFileInfo *);
6449
6450 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006451 * Called at the beginning of indexing a translation unit.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006452 */
6453 CXIdxClientContainer (*startedTranslationUnit)(CXClientData client_data,
6454 void *reserved);
6455
6456 void (*indexDeclaration)(CXClientData client_data,
6457 const CXIdxDeclInfo *);
6458
6459 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006460 * Called to index a reference of an entity.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006461 */
6462 void (*indexEntityReference)(CXClientData client_data,
6463 const CXIdxEntityRefInfo *);
6464
6465} IndexerCallbacks;
6466
6467CINDEX_LINKAGE int clang_index_isEntityObjCContainerKind(CXIdxEntityKind);
6468CINDEX_LINKAGE const CXIdxObjCContainerDeclInfo *
6469clang_index_getObjCContainerDeclInfo(const CXIdxDeclInfo *);
6470
6471CINDEX_LINKAGE const CXIdxObjCInterfaceDeclInfo *
6472clang_index_getObjCInterfaceDeclInfo(const CXIdxDeclInfo *);
6473
6474CINDEX_LINKAGE
6475const CXIdxObjCCategoryDeclInfo *
6476clang_index_getObjCCategoryDeclInfo(const CXIdxDeclInfo *);
6477
6478CINDEX_LINKAGE const CXIdxObjCProtocolRefListInfo *
6479clang_index_getObjCProtocolRefListInfo(const CXIdxDeclInfo *);
6480
6481CINDEX_LINKAGE const CXIdxObjCPropertyDeclInfo *
6482clang_index_getObjCPropertyDeclInfo(const CXIdxDeclInfo *);
6483
6484CINDEX_LINKAGE const CXIdxIBOutletCollectionAttrInfo *
6485clang_index_getIBOutletCollectionAttrInfo(const CXIdxAttrInfo *);
6486
6487CINDEX_LINKAGE const CXIdxCXXClassDeclInfo *
6488clang_index_getCXXClassDeclInfo(const CXIdxDeclInfo *);
6489
6490/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006491 * For retrieving a custom CXIdxClientContainer attached to a
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006492 * container.
6493 */
6494CINDEX_LINKAGE CXIdxClientContainer
6495clang_index_getClientContainer(const CXIdxContainerInfo *);
6496
6497/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006498 * For setting a custom CXIdxClientContainer attached to a
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006499 * container.
6500 */
6501CINDEX_LINKAGE void
6502clang_index_setClientContainer(const CXIdxContainerInfo *,CXIdxClientContainer);
6503
6504/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006505 * For retrieving a custom CXIdxClientEntity attached to an entity.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006506 */
6507CINDEX_LINKAGE CXIdxClientEntity
6508clang_index_getClientEntity(const CXIdxEntityInfo *);
6509
6510/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006511 * For setting a custom CXIdxClientEntity attached to an entity.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006512 */
6513CINDEX_LINKAGE void
6514clang_index_setClientEntity(const CXIdxEntityInfo *, CXIdxClientEntity);
6515
6516/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006517 * An indexing action/session, to be applied to one or multiple
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006518 * translation units.
6519 */
6520typedef void *CXIndexAction;
6521
6522/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006523 * An indexing action/session, to be applied to one or multiple
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006524 * translation units.
6525 *
6526 * \param CIdx The index object with which the index action will be associated.
6527 */
6528CINDEX_LINKAGE CXIndexAction clang_IndexAction_create(CXIndex CIdx);
6529
6530/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006531 * Destroy the given index action.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006532 *
6533 * The index action must not be destroyed until all of the translation units
6534 * created within that index action have been destroyed.
6535 */
6536CINDEX_LINKAGE void clang_IndexAction_dispose(CXIndexAction);
6537
6538typedef enum {
6539 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006540 * Used to indicate that no special indexing options are needed.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006541 */
6542 CXIndexOpt_None = 0x0,
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006543
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006544 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006545 * Used to indicate that IndexerCallbacks#indexEntityReference should
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006546 * be invoked for only one reference of an entity per source file that does
6547 * not also include a declaration/definition of the entity.
6548 */
6549 CXIndexOpt_SuppressRedundantRefs = 0x1,
6550
6551 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006552 * Function-local symbols should be indexed. If this is not set
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006553 * function-local symbols will be ignored.
6554 */
6555 CXIndexOpt_IndexFunctionLocalSymbols = 0x2,
6556
6557 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006558 * Implicit function/class template instantiations should be indexed.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006559 * If this is not set, implicit instantiations will be ignored.
6560 */
6561 CXIndexOpt_IndexImplicitTemplateInstantiations = 0x4,
6562
6563 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006564 * Suppress all compiler warnings when parsing for indexing.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006565 */
6566 CXIndexOpt_SuppressWarnings = 0x8,
6567
6568 /**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006569 * Skip a function/method body that was already parsed during an
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006570 * indexing session associated with a \c CXIndexAction object.
6571 * Bodies in system headers are always skipped.
6572 */
6573 CXIndexOpt_SkipParsedBodiesInSession = 0x10
6574
6575} CXIndexOptFlags;
6576
6577/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006578 * Index the given source file and the translation unit corresponding
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006579 * to that file via callbacks implemented through #IndexerCallbacks.
6580 *
6581 * \param client_data pointer data supplied by the client, which will
6582 * be passed to the invoked callbacks.
6583 *
6584 * \param index_callbacks Pointer to indexing callbacks that the client
6585 * implements.
6586 *
6587 * \param index_callbacks_size Size of #IndexerCallbacks structure that gets
6588 * passed in index_callbacks.
6589 *
6590 * \param index_options A bitmask of options that affects how indexing is
6591 * performed. This should be a bitwise OR of the CXIndexOpt_XXX flags.
6592 *
6593 * \param[out] out_TU pointer to store a \c CXTranslationUnit that can be
6594 * reused after indexing is finished. Set to \c NULL if you do not require it.
6595 *
6596 * \returns 0 on success or if there were errors from which the compiler could
6597 * recover. If there is a failure from which there is no recovery, returns
6598 * a non-zero \c CXErrorCode.
6599 *
6600 * The rest of the parameters are the same as #clang_parseTranslationUnit.
6601 */
6602CINDEX_LINKAGE int clang_indexSourceFile(CXIndexAction,
6603 CXClientData client_data,
6604 IndexerCallbacks *index_callbacks,
6605 unsigned index_callbacks_size,
6606 unsigned index_options,
6607 const char *source_filename,
6608 const char * const *command_line_args,
6609 int num_command_line_args,
6610 struct CXUnsavedFile *unsaved_files,
6611 unsigned num_unsaved_files,
6612 CXTranslationUnit *out_TU,
6613 unsigned TU_options);
6614
6615/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006616 * Same as clang_indexSourceFile but requires a full command line
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006617 * for \c command_line_args including argv[0]. This is useful if the standard
6618 * library paths are relative to the binary.
6619 */
6620CINDEX_LINKAGE int clang_indexSourceFileFullArgv(
6621 CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks,
6622 unsigned index_callbacks_size, unsigned index_options,
6623 const char *source_filename, const char *const *command_line_args,
6624 int num_command_line_args, struct CXUnsavedFile *unsaved_files,
6625 unsigned num_unsaved_files, CXTranslationUnit *out_TU, unsigned TU_options);
6626
6627/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006628 * Index the given translation unit via callbacks implemented through
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006629 * #IndexerCallbacks.
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006630 *
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006631 * The order of callback invocations is not guaranteed to be the same as
6632 * when indexing a source file. The high level order will be:
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006633 *
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006634 * -Preprocessor callbacks invocations
6635 * -Declaration/reference callbacks invocations
6636 * -Diagnostic callback invocations
6637 *
6638 * The parameters are the same as #clang_indexSourceFile.
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006639 *
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006640 * \returns If there is a failure from which there is no recovery, returns
6641 * non-zero, otherwise returns 0.
6642 */
6643CINDEX_LINKAGE int clang_indexTranslationUnit(CXIndexAction,
6644 CXClientData client_data,
6645 IndexerCallbacks *index_callbacks,
6646 unsigned index_callbacks_size,
6647 unsigned index_options,
6648 CXTranslationUnit);
6649
6650/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006651 * Retrieve the CXIdxFile, file, line, column, and offset represented by
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006652 * the given CXIdxLoc.
6653 *
6654 * If the location refers into a macro expansion, retrieves the
6655 * location of the macro expansion and if it refers into a macro argument
6656 * retrieves the location of the argument.
6657 */
6658CINDEX_LINKAGE void clang_indexLoc_getFileLocation(CXIdxLoc loc,
6659 CXIdxClientFile *indexFile,
6660 CXFile *file,
6661 unsigned *line,
6662 unsigned *column,
6663 unsigned *offset);
6664
6665/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006666 * Retrieve the CXSourceLocation represented by the given CXIdxLoc.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006667 */
6668CINDEX_LINKAGE
6669CXSourceLocation clang_indexLoc_getCXSourceLocation(CXIdxLoc loc);
6670
6671/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006672 * Visitor invoked for each field found by a traversal.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006673 *
6674 * This visitor function will be invoked for each field found by
6675 * \c clang_Type_visitFields. Its first argument is the cursor being
6676 * visited, its second argument is the client data provided to
6677 * \c clang_Type_visitFields.
6678 *
6679 * The visitor should return one of the \c CXVisitorResult values
6680 * to direct \c clang_Type_visitFields.
6681 */
6682typedef enum CXVisitorResult (*CXFieldVisitor)(CXCursor C,
6683 CXClientData client_data);
6684
6685/**
Andrew Scullcdfcccc2018-10-05 20:58:37 +01006686 * Visit the fields of a particular type.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006687 *
6688 * This function visits all the direct fields of the given cursor,
6689 * invoking the given \p visitor function with the cursors of each
6690 * visited field. The traversal may be ended prematurely, if
6691 * the visitor returns \c CXFieldVisit_Break.
6692 *
6693 * \param T the record type whose field may be visited.
6694 *
6695 * \param visitor the visitor function that will be invoked for each
6696 * field of \p T.
6697 *
6698 * \param client_data pointer data supplied by the client, which will
6699 * be passed to the visitor each time it is invoked.
6700 *
6701 * \returns a non-zero value if the traversal was terminated
6702 * prematurely by the visitor returning \c CXFieldVisit_Break.
6703 */
6704CINDEX_LINKAGE unsigned clang_Type_visitFields(CXType T,
6705 CXFieldVisitor visitor,
6706 CXClientData client_data);
6707
6708/**
6709 * @}
6710 */
6711
6712/**
6713 * @}
6714 */
6715
6716#ifdef __cplusplus
6717}
6718#endif
6719#endif