1/*===-- clang-c/Index.h - Indexing Public C Interface -------------*- C -*-===*\
2|* *|
3|* 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 *|
7|* *|
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 "clang-c/BuildSystem.h"
20#include "clang-c/CXDiagnostic.h"
21#include "clang-c/CXErrorCode.h"
22#include "clang-c/CXFile.h"
23#include "clang-c/CXSourceLocation.h"
24#include "clang-c/CXString.h"
25#include "clang-c/ExternC.h"
26#include "clang-c/Platform.h"
27
28/**
29 * The version constants for the libclang API.
30 * CINDEX_VERSION_MINOR should increase when there are API additions.
31 * CINDEX_VERSION_MAJOR is intended for "major" source/ABI breaking changes.
32 *
33 * The policy about the libclang API was always to keep it source and ABI
34 * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
35 */
36#define CINDEX_VERSION_MAJOR 0
37#define CINDEX_VERSION_MINOR 64
38
39#define CINDEX_VERSION_ENCODE(major, minor) (((major)*10000) + ((minor)*1))
40
41#define CINDEX_VERSION \
42 CINDEX_VERSION_ENCODE(CINDEX_VERSION_MAJOR, CINDEX_VERSION_MINOR)
43
44#define CINDEX_VERSION_STRINGIZE_(major, minor) #major "." #minor
45#define CINDEX_VERSION_STRINGIZE(major, minor) \
46 CINDEX_VERSION_STRINGIZE_(major, minor)
47
48#define CINDEX_VERSION_STRING \
49 CINDEX_VERSION_STRINGIZE(CINDEX_VERSION_MAJOR, CINDEX_VERSION_MINOR)
50
51#ifndef __has_feature
52#define __has_feature(feature) 0
53#endif
54
55LLVM_CLANG_C_EXTERN_C_BEGIN
56
57/** \defgroup CINDEX libclang: C Interface to Clang
58 *
59 * The C Interface to Clang provides a relatively small API that exposes
60 * facilities for parsing source code into an abstract syntax tree (AST),
61 * loading already-parsed ASTs, traversing the AST, associating
62 * physical source locations with elements within the AST, and other
63 * facilities that support Clang-based development tools.
64 *
65 * This C interface to Clang will never provide all of the information
66 * representation stored in Clang's C++ AST, nor should it: the intent is to
67 * maintain an API that is relatively stable from one release to the next,
68 * providing only the basic functionality needed to support development tools.
69 *
70 * To avoid namespace pollution, data types are prefixed with "CX" and
71 * functions are prefixed with "clang_".
72 *
73 * @{
74 */
75
76/**
77 * An "index" that consists of a set of translation units that would
78 * typically be linked together into an executable or library.
79 */
80typedef void *CXIndex;
81
82/**
83 * An opaque type representing target information for a given translation
84 * unit.
85 */
86typedef struct CXTargetInfoImpl *CXTargetInfo;
87
88/**
89 * A single translation unit, which resides in an index.
90 */
91typedef struct CXTranslationUnitImpl *CXTranslationUnit;
92
93/**
94 * Opaque pointer representing client data that will be passed through
95 * to various callbacks and visitors.
96 */
97typedef void *CXClientData;
98
99/**
100 * Provides the contents of a file that has not yet been saved to disk.
101 *
102 * Each CXUnsavedFile instance provides the name of a file on the
103 * system along with the current contents of that file that have not
104 * yet been saved to disk.
105 */
106struct CXUnsavedFile {
107 /**
108 * The file whose contents have not yet been saved.
109 *
110 * This file must already exist in the file system.
111 */
112 const char *Filename;
113
114 /**
115 * A buffer containing the unsaved contents of this file.
116 */
117 const char *Contents;
118
119 /**
120 * The length of the unsaved contents of this buffer.
121 */
122 unsigned long Length;
123};
124
125/**
126 * Describes the availability of a particular entity, which indicates
127 * whether the use of this entity will result in a warning or error due to
128 * it being deprecated or unavailable.
129 */
130enum CXAvailabilityKind {
131 /**
132 * The entity is available.
133 */
134 CXAvailability_Available,
135 /**
136 * The entity is available, but has been deprecated (and its use is
137 * not recommended).
138 */
139 CXAvailability_Deprecated,
140 /**
141 * The entity is not available; any use of it will be an error.
142 */
143 CXAvailability_NotAvailable,
144 /**
145 * The entity is available, but not accessible; any use of it will be
146 * an error.
147 */
148 CXAvailability_NotAccessible
149};
150
151/**
152 * Describes a version number of the form major.minor.subminor.
153 */
154typedef struct CXVersion {
155 /**
156 * The major version number, e.g., the '10' in '10.7.3'. A negative
157 * value indicates that there is no version number at all.
158 */
159 int Major;
160 /**
161 * The minor version number, e.g., the '7' in '10.7.3'. This value
162 * will be negative if no minor version number was provided, e.g., for
163 * version '10'.
164 */
165 int Minor;
166 /**
167 * The subminor version number, e.g., the '3' in '10.7.3'. This value
168 * will be negative if no minor or subminor version number was provided,
169 * e.g., in version '10' or '10.7'.
170 */
171 int Subminor;
172} CXVersion;
173
174/**
175 * Describes the exception specification of a cursor.
176 *
177 * A negative value indicates that the cursor is not a function declaration.
178 */
179enum CXCursor_ExceptionSpecificationKind {
180 /**
181 * The cursor has no exception specification.
182 */
183 CXCursor_ExceptionSpecificationKind_None,
184
185 /**
186 * The cursor has exception specification throw()
187 */
188 CXCursor_ExceptionSpecificationKind_DynamicNone,
189
190 /**
191 * The cursor has exception specification throw(T1, T2)
192 */
193 CXCursor_ExceptionSpecificationKind_Dynamic,
194
195 /**
196 * The cursor has exception specification throw(...).
197 */
198 CXCursor_ExceptionSpecificationKind_MSAny,
199
200 /**
201 * The cursor has exception specification basic noexcept.
202 */
203 CXCursor_ExceptionSpecificationKind_BasicNoexcept,
204
205 /**
206 * The cursor has exception specification computed noexcept.
207 */
208 CXCursor_ExceptionSpecificationKind_ComputedNoexcept,
209
210 /**
211 * The exception specification has not yet been evaluated.
212 */
213 CXCursor_ExceptionSpecificationKind_Unevaluated,
214
215 /**
216 * The exception specification has not yet been instantiated.
217 */
218 CXCursor_ExceptionSpecificationKind_Uninstantiated,
219
220 /**
221 * The exception specification has not been parsed yet.
222 */
223 CXCursor_ExceptionSpecificationKind_Unparsed,
224
225 /**
226 * The cursor has a __declspec(nothrow) exception specification.
227 */
228 CXCursor_ExceptionSpecificationKind_NoThrow
229};
230
231/**
232 * Provides a shared context for creating translation units.
233 *
234 * It provides two options:
235 *
236 * - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local"
237 * declarations (when loading any new translation units). A "local" declaration
238 * is one that belongs in the translation unit itself and not in a precompiled
239 * header that was used by the translation unit. If zero, all declarations
240 * will be enumerated.
241 *
242 * Here is an example:
243 *
244 * \code
245 * // excludeDeclsFromPCH = 1, displayDiagnostics=1
246 * Idx = clang_createIndex(1, 1);
247 *
248 * // IndexTest.pch was produced with the following command:
249 * // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch"
250 * TU = clang_createTranslationUnit(Idx, "IndexTest.pch");
251 *
252 * // This will load all the symbols from 'IndexTest.pch'
253 * clang_visitChildren(clang_getTranslationUnitCursor(TU),
254 * TranslationUnitVisitor, 0);
255 * clang_disposeTranslationUnit(TU);
256 *
257 * // This will load all the symbols from 'IndexTest.c', excluding symbols
258 * // from 'IndexTest.pch'.
259 * char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" };
260 * TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args,
261 * 0, 0);
262 * clang_visitChildren(clang_getTranslationUnitCursor(TU),
263 * TranslationUnitVisitor, 0);
264 * clang_disposeTranslationUnit(TU);
265 * \endcode
266 *
267 * This process of creating the 'pch', loading it separately, and using it (via
268 * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks
269 * (which gives the indexer the same performance benefit as the compiler).
270 */
271CINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH,
272 int displayDiagnostics);
273
274/**
275 * Destroy the given index.
276 *
277 * The index must not be destroyed until all of the translation units created
278 * within that index have been destroyed.
279 */
280CINDEX_LINKAGE void clang_disposeIndex(CXIndex index);
281
282typedef enum {
283 /**
284 * Use the default value of an option that may depend on the process
285 * environment.
286 */
287 CXChoice_Default = 0,
288 /**
289 * Enable the option.
290 */
291 CXChoice_Enabled = 1,
292 /**
293 * Disable the option.
294 */
295 CXChoice_Disabled = 2
296} CXChoice;
297
298typedef enum {
299 /**
300 * Used to indicate that no special CXIndex options are needed.
301 */
302 CXGlobalOpt_None = 0x0,
303
304 /**
305 * Used to indicate that threads that libclang creates for indexing
306 * purposes should use background priority.
307 *
308 * Affects #clang_indexSourceFile, #clang_indexTranslationUnit,
309 * #clang_parseTranslationUnit, #clang_saveTranslationUnit.
310 */
311 CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1,
312
313 /**
314 * Used to indicate that threads that libclang creates for editing
315 * purposes should use background priority.
316 *
317 * Affects #clang_reparseTranslationUnit, #clang_codeCompleteAt,
318 * #clang_annotateTokens
319 */
320 CXGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2,
321
322 /**
323 * Used to indicate that all threads that libclang creates should use
324 * background priority.
325 */
326 CXGlobalOpt_ThreadBackgroundPriorityForAll =
327 CXGlobalOpt_ThreadBackgroundPriorityForIndexing |
328 CXGlobalOpt_ThreadBackgroundPriorityForEditing
329
330} CXGlobalOptFlags;
331
332/**
333 * Index initialization options.
334 *
335 * 0 is the default value of each member of this struct except for Size.
336 * Initialize the struct in one of the following three ways to avoid adapting
337 * code each time a new member is added to it:
338 * \code
339 * CXIndexOptions Opts;
340 * memset(&Opts, 0, sizeof(Opts));
341 * Opts.Size = sizeof(CXIndexOptions);
342 * \endcode
343 * or explicitly initialize the first data member and zero-initialize the rest:
344 * \code
345 * CXIndexOptions Opts = { sizeof(CXIndexOptions) };
346 * \endcode
347 * or to prevent the -Wmissing-field-initializers warning for the above version:
348 * \code
349 * CXIndexOptions Opts{};
350 * Opts.Size = sizeof(CXIndexOptions);
351 * \endcode
352 */
353typedef struct CXIndexOptions {
354 /**
355 * The size of struct CXIndexOptions used for option versioning.
356 *
357 * Always initialize this member to sizeof(CXIndexOptions), or assign
358 * sizeof(CXIndexOptions) to it right after creating a CXIndexOptions object.
359 */
360 unsigned Size;
361 /**
362 * A CXChoice enumerator that specifies the indexing priority policy.
363 * \sa CXGlobalOpt_ThreadBackgroundPriorityForIndexing
364 */
365 unsigned char ThreadBackgroundPriorityForIndexing;
366 /**
367 * A CXChoice enumerator that specifies the editing priority policy.
368 * \sa CXGlobalOpt_ThreadBackgroundPriorityForEditing
369 */
370 unsigned char ThreadBackgroundPriorityForEditing;
371 /**
372 * \see clang_createIndex()
373 */
374 unsigned ExcludeDeclarationsFromPCH : 1;
375 /**
376 * \see clang_createIndex()
377 */
378 unsigned DisplayDiagnostics : 1;
379 /**
380 * Store PCH in memory. If zero, PCH are stored in temporary files.
381 */
382 unsigned StorePreamblesInMemory : 1;
383 unsigned /*Reserved*/ : 13;
384
385 /**
386 * The path to a directory, in which to store temporary PCH files. If null or
387 * empty, the default system temporary directory is used. These PCH files are
388 * deleted on clean exit but stay on disk if the program crashes or is killed.
389 *
390 * This option is ignored if \a StorePreamblesInMemory is non-zero.
391 *
392 * Libclang does not create the directory at the specified path in the file
393 * system. Therefore it must exist, or storing PCH files will fail.
394 */
395 const char *PreambleStoragePath;
396 /**
397 * Specifies a path which will contain log files for certain libclang
398 * invocations. A null value implies that libclang invocations are not logged.
399 */
400 const char *InvocationEmissionPath;
401} CXIndexOptions;
402
403/**
404 * Provides a shared context for creating translation units.
405 *
406 * Call this function instead of clang_createIndex() if you need to configure
407 * the additional options in CXIndexOptions.
408 *
409 * \returns The created index or null in case of error, such as an unsupported
410 * value of options->Size.
411 *
412 * For example:
413 * \code
414 * CXIndex createIndex(const char *ApplicationTemporaryPath) {
415 * const int ExcludeDeclarationsFromPCH = 1;
416 * const int DisplayDiagnostics = 1;
417 * CXIndex Idx;
418 * #if CINDEX_VERSION_MINOR >= 64
419 * CXIndexOptions Opts;
420 * memset(&Opts, 0, sizeof(Opts));
421 * Opts.Size = sizeof(CXIndexOptions);
422 * Opts.ThreadBackgroundPriorityForIndexing = 1;
423 * Opts.ExcludeDeclarationsFromPCH = ExcludeDeclarationsFromPCH;
424 * Opts.DisplayDiagnostics = DisplayDiagnostics;
425 * Opts.PreambleStoragePath = ApplicationTemporaryPath;
426 * Idx = clang_createIndexWithOptions(&Opts);
427 * if (Idx)
428 * return Idx;
429 * fprintf(stderr,
430 * "clang_createIndexWithOptions() failed. "
431 * "CINDEX_VERSION_MINOR = %d, sizeof(CXIndexOptions) = %u\n",
432 * CINDEX_VERSION_MINOR, Opts.Size);
433 * #else
434 * (void)ApplicationTemporaryPath;
435 * #endif
436 * Idx = clang_createIndex(ExcludeDeclarationsFromPCH, DisplayDiagnostics);
437 * clang_CXIndex_setGlobalOptions(
438 * Idx, clang_CXIndex_getGlobalOptions(Idx) |
439 * CXGlobalOpt_ThreadBackgroundPriorityForIndexing);
440 * return Idx;
441 * }
442 * \endcode
443 *
444 * \sa clang_createIndex()
445 */
446CINDEX_LINKAGE CXIndex
447clang_createIndexWithOptions(const CXIndexOptions *options);
448
449/**
450 * Sets general options associated with a CXIndex.
451 *
452 * This function is DEPRECATED. Set
453 * CXIndexOptions::ThreadBackgroundPriorityForIndexing and/or
454 * CXIndexOptions::ThreadBackgroundPriorityForEditing and call
455 * clang_createIndexWithOptions() instead.
456 *
457 * For example:
458 * \code
459 * CXIndex idx = ...;
460 * clang_CXIndex_setGlobalOptions(idx,
461 * clang_CXIndex_getGlobalOptions(idx) |
462 * CXGlobalOpt_ThreadBackgroundPriorityForIndexing);
463 * \endcode
464 *
465 * \param options A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags.
466 */
467CINDEX_LINKAGE void clang_CXIndex_setGlobalOptions(CXIndex, unsigned options);
468
469/**
470 * Gets the general options associated with a CXIndex.
471 *
472 * This function allows to obtain the final option values used by libclang after
473 * specifying the option policies via CXChoice enumerators.
474 *
475 * \returns A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags that
476 * are associated with the given CXIndex object.
477 */
478CINDEX_LINKAGE unsigned clang_CXIndex_getGlobalOptions(CXIndex);
479
480/**
481 * Sets the invocation emission path option in a CXIndex.
482 *
483 * This function is DEPRECATED. Set CXIndexOptions::InvocationEmissionPath and
484 * call clang_createIndexWithOptions() instead.
485 *
486 * The invocation emission path specifies a path which will contain log
487 * files for certain libclang invocations. A null value (default) implies that
488 * libclang invocations are not logged..
489 */
490CINDEX_LINKAGE void
491clang_CXIndex_setInvocationEmissionPathOption(CXIndex, const char *Path);
492
493/**
494 * Determine whether the given header is guarded against
495 * multiple inclusions, either with the conventional
496 * \#ifndef/\#define/\#endif macro guards or with \#pragma once.
497 */
498CINDEX_LINKAGE unsigned clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu,
499 CXFile file);
500
501/**
502 * Retrieve a file handle within the given translation unit.
503 *
504 * \param tu the translation unit
505 *
506 * \param file_name the name of the file.
507 *
508 * \returns the file handle for the named file in the translation unit \p tu,
509 * or a NULL file handle if the file was not a part of this translation unit.
510 */
511CINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu,
512 const char *file_name);
513
514/**
515 * Retrieve the buffer associated with the given file.
516 *
517 * \param tu the translation unit
518 *
519 * \param file the file for which to retrieve the buffer.
520 *
521 * \param size [out] if non-NULL, will be set to the size of the buffer.
522 *
523 * \returns a pointer to the buffer in memory that holds the contents of
524 * \p file, or a NULL pointer when the file is not loaded.
525 */
526CINDEX_LINKAGE const char *clang_getFileContents(CXTranslationUnit tu,
527 CXFile file, size_t *size);
528
529/**
530 * Retrieves the source location associated with a given file/line/column
531 * in a particular translation unit.
532 */
533CINDEX_LINKAGE CXSourceLocation clang_getLocation(CXTranslationUnit tu,
534 CXFile file, unsigned line,
535 unsigned column);
536/**
537 * Retrieves the source location associated with a given character offset
538 * in a particular translation unit.
539 */
540CINDEX_LINKAGE CXSourceLocation clang_getLocationForOffset(CXTranslationUnit tu,
541 CXFile file,
542 unsigned offset);
543
544/**
545 * Retrieve all ranges that were skipped by the preprocessor.
546 *
547 * The preprocessor will skip lines when they are surrounded by an
548 * if/ifdef/ifndef directive whose condition does not evaluate to true.
549 */
550CINDEX_LINKAGE CXSourceRangeList *clang_getSkippedRanges(CXTranslationUnit tu,
551 CXFile file);
552
553/**
554 * Retrieve all ranges from all files that were skipped by the
555 * preprocessor.
556 *
557 * The preprocessor will skip lines when they are surrounded by an
558 * if/ifdef/ifndef directive whose condition does not evaluate to true.
559 */
560CINDEX_LINKAGE CXSourceRangeList *
561clang_getAllSkippedRanges(CXTranslationUnit tu);
562
563/**
564 * Determine the number of diagnostics produced for the given
565 * translation unit.
566 */
567CINDEX_LINKAGE unsigned clang_getNumDiagnostics(CXTranslationUnit Unit);
568
569/**
570 * Retrieve a diagnostic associated with the given translation unit.
571 *
572 * \param Unit the translation unit to query.
573 * \param Index the zero-based diagnostic number to retrieve.
574 *
575 * \returns the requested diagnostic. This diagnostic must be freed
576 * via a call to \c clang_disposeDiagnostic().
577 */
578CINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit,
579 unsigned Index);
580
581/**
582 * Retrieve the complete set of diagnostics associated with a
583 * translation unit.
584 *
585 * \param Unit the translation unit to query.
586 */
587CINDEX_LINKAGE CXDiagnosticSet
588clang_getDiagnosticSetFromTU(CXTranslationUnit Unit);
589
590/**
591 * \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation
592 *
593 * The routines in this group provide the ability to create and destroy
594 * translation units from files, either by parsing the contents of the files or
595 * by reading in a serialized representation of a translation unit.
596 *
597 * @{
598 */
599
600/**
601 * Get the original translation unit source file name.
602 */
603CINDEX_LINKAGE CXString
604clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit);
605
606/**
607 * Return the CXTranslationUnit for a given source file and the provided
608 * command line arguments one would pass to the compiler.
609 *
610 * Note: The 'source_filename' argument is optional. If the caller provides a
611 * NULL pointer, the name of the source file is expected to reside in the
612 * specified command line arguments.
613 *
614 * Note: When encountered in 'clang_command_line_args', the following options
615 * are ignored:
616 *
617 * '-c'
618 * '-emit-ast'
619 * '-fsyntax-only'
620 * '-o \<output file>' (both '-o' and '\<output file>' are ignored)
621 *
622 * \param CIdx The index object with which the translation unit will be
623 * associated.
624 *
625 * \param source_filename The name of the source file to load, or NULL if the
626 * source file is included in \p clang_command_line_args.
627 *
628 * \param num_clang_command_line_args The number of command-line arguments in
629 * \p clang_command_line_args.
630 *
631 * \param clang_command_line_args The command-line arguments that would be
632 * passed to the \c clang executable if it were being invoked out-of-process.
633 * These command-line options will be parsed and will affect how the translation
634 * unit is parsed. Note that the following options are ignored: '-c',
635 * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
636 *
637 * \param num_unsaved_files the number of unsaved file entries in \p
638 * unsaved_files.
639 *
640 * \param unsaved_files the files that have not yet been saved to disk
641 * but may be required for code completion, including the contents of
642 * those files. The contents and name of these files (as specified by
643 * CXUnsavedFile) are copied when necessary, so the client only needs to
644 * guarantee their validity until the call to this function returns.
645 */
646CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnitFromSourceFile(
647 CXIndex CIdx, const char *source_filename, int num_clang_command_line_args,
648 const char *const *clang_command_line_args, unsigned num_unsaved_files,
649 struct CXUnsavedFile *unsaved_files);
650
651/**
652 * Same as \c clang_createTranslationUnit2, but returns
653 * the \c CXTranslationUnit instead of an error code. In case of an error this
654 * routine returns a \c NULL \c CXTranslationUnit, without further detailed
655 * error codes.
656 */
657CINDEX_LINKAGE CXTranslationUnit
658clang_createTranslationUnit(CXIndex CIdx, const char *ast_filename);
659
660/**
661 * Create a translation unit from an AST file (\c -emit-ast).
662 *
663 * \param[out] out_TU A non-NULL pointer to store the created
664 * \c CXTranslationUnit.
665 *
666 * \returns Zero on success, otherwise returns an error code.
667 */
668CINDEX_LINKAGE enum CXErrorCode
669clang_createTranslationUnit2(CXIndex CIdx, const char *ast_filename,
670 CXTranslationUnit *out_TU);
671
672/**
673 * Flags that control the creation of translation units.
674 *
675 * The enumerators in this enumeration type are meant to be bitwise
676 * ORed together to specify which options should be used when
677 * constructing the translation unit.
678 */
679enum CXTranslationUnit_Flags {
680 /**
681 * Used to indicate that no special translation-unit options are
682 * needed.
683 */
684 CXTranslationUnit_None = 0x0,
685
686 /**
687 * Used to indicate that the parser should construct a "detailed"
688 * preprocessing record, including all macro definitions and instantiations.
689 *
690 * Constructing a detailed preprocessing record requires more memory
691 * and time to parse, since the information contained in the record
692 * is usually not retained. However, it can be useful for
693 * applications that require more detailed information about the
694 * behavior of the preprocessor.
695 */
696 CXTranslationUnit_DetailedPreprocessingRecord = 0x01,
697
698 /**
699 * Used to indicate that the translation unit is incomplete.
700 *
701 * When a translation unit is considered "incomplete", semantic
702 * analysis that is typically performed at the end of the
703 * translation unit will be suppressed. For example, this suppresses
704 * the completion of tentative declarations in C and of
705 * instantiation of implicitly-instantiation function templates in
706 * C++. This option is typically used when parsing a header with the
707 * intent of producing a precompiled header.
708 */
709 CXTranslationUnit_Incomplete = 0x02,
710
711 /**
712 * Used to indicate that the translation unit should be built with an
713 * implicit precompiled header for the preamble.
714 *
715 * An implicit precompiled header is used as an optimization when a
716 * particular translation unit is likely to be reparsed many times
717 * when the sources aren't changing that often. In this case, an
718 * implicit precompiled header will be built containing all of the
719 * initial includes at the top of the main file (what we refer to as
720 * the "preamble" of the file). In subsequent parses, if the
721 * preamble or the files in it have not changed, \c
722 * clang_reparseTranslationUnit() will re-use the implicit
723 * precompiled header to improve parsing performance.
724 */
725 CXTranslationUnit_PrecompiledPreamble = 0x04,
726
727 /**
728 * Used to indicate that the translation unit should cache some
729 * code-completion results with each reparse of the source file.
730 *
731 * Caching of code-completion results is a performance optimization that
732 * introduces some overhead to reparsing but improves the performance of
733 * code-completion operations.
734 */
735 CXTranslationUnit_CacheCompletionResults = 0x08,
736
737 /**
738 * Used to indicate that the translation unit will be serialized with
739 * \c clang_saveTranslationUnit.
740 *
741 * This option is typically used when parsing a header with the intent of
742 * producing a precompiled header.
743 */
744 CXTranslationUnit_ForSerialization = 0x10,
745
746 /**
747 * DEPRECATED: Enabled chained precompiled preambles in C++.
748 *
749 * Note: this is a *temporary* option that is available only while
750 * we are testing C++ precompiled preamble support. It is deprecated.
751 */
752 CXTranslationUnit_CXXChainedPCH = 0x20,
753
754 /**
755 * Used to indicate that function/method bodies should be skipped while
756 * parsing.
757 *
758 * This option can be used to search for declarations/definitions while
759 * ignoring the usages.
760 */
761 CXTranslationUnit_SkipFunctionBodies = 0x40,
762
763 /**
764 * Used to indicate that brief documentation comments should be
765 * included into the set of code completions returned from this translation
766 * unit.
767 */
768 CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 0x80,
769
770 /**
771 * Used to indicate that the precompiled preamble should be created on
772 * the first parse. Otherwise it will be created on the first reparse. This
773 * trades runtime on the first parse (serializing the preamble takes time) for
774 * reduced runtime on the second parse (can now reuse the preamble).
775 */
776 CXTranslationUnit_CreatePreambleOnFirstParse = 0x100,
777
778 /**
779 * Do not stop processing when fatal errors are encountered.
780 *
781 * When fatal errors are encountered while parsing a translation unit,
782 * semantic analysis is typically stopped early when compiling code. A common
783 * source for fatal errors are unresolvable include files. For the
784 * purposes of an IDE, this is undesirable behavior and as much information
785 * as possible should be reported. Use this flag to enable this behavior.
786 */
787 CXTranslationUnit_KeepGoing = 0x200,
788
789 /**
790 * Sets the preprocessor in a mode for parsing a single file only.
791 */
792 CXTranslationUnit_SingleFileParse = 0x400,
793
794 /**
795 * Used in combination with CXTranslationUnit_SkipFunctionBodies to
796 * constrain the skipping of function bodies to the preamble.
797 *
798 * The function bodies of the main file are not skipped.
799 */
800 CXTranslationUnit_LimitSkipFunctionBodiesToPreamble = 0x800,
801
802 /**
803 * Used to indicate that attributed types should be included in CXType.
804 */
805 CXTranslationUnit_IncludeAttributedTypes = 0x1000,
806
807 /**
808 * Used to indicate that implicit attributes should be visited.
809 */
810 CXTranslationUnit_VisitImplicitAttributes = 0x2000,
811
812 /**
813 * Used to indicate that non-errors from included files should be ignored.
814 *
815 * If set, clang_getDiagnosticSetFromTU() will not report e.g. warnings from
816 * included files anymore. This speeds up clang_getDiagnosticSetFromTU() for
817 * the case where these warnings are not of interest, as for an IDE for
818 * example, which typically shows only the diagnostics in the main file.
819 */
820 CXTranslationUnit_IgnoreNonErrorsFromIncludedFiles = 0x4000,
821
822 /**
823 * Tells the preprocessor not to skip excluded conditional blocks.
824 */
825 CXTranslationUnit_RetainExcludedConditionalBlocks = 0x8000
826};
827
828/**
829 * Returns the set of flags that is suitable for parsing a translation
830 * unit that is being edited.
831 *
832 * The set of flags returned provide options for \c clang_parseTranslationUnit()
833 * to indicate that the translation unit is likely to be reparsed many times,
834 * either explicitly (via \c clang_reparseTranslationUnit()) or implicitly
835 * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag
836 * set contains an unspecified set of optimizations (e.g., the precompiled
837 * preamble) geared toward improving the performance of these routines. The
838 * set of optimizations enabled may change from one version to the next.
839 */
840CINDEX_LINKAGE unsigned clang_defaultEditingTranslationUnitOptions(void);
841
842/**
843 * Same as \c clang_parseTranslationUnit2, but returns
844 * the \c CXTranslationUnit instead of an error code. In case of an error this
845 * routine returns a \c NULL \c CXTranslationUnit, without further detailed
846 * error codes.
847 */
848CINDEX_LINKAGE CXTranslationUnit clang_parseTranslationUnit(
849 CXIndex CIdx, const char *source_filename,
850 const char *const *command_line_args, int num_command_line_args,
851 struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files,
852 unsigned options);
853
854/**
855 * Parse the given source file and the translation unit corresponding
856 * to that file.
857 *
858 * This routine is the main entry point for the Clang C API, providing the
859 * ability to parse a source file into a translation unit that can then be
860 * queried by other functions in the API. This routine accepts a set of
861 * command-line arguments so that the compilation can be configured in the same
862 * way that the compiler is configured on the command line.
863 *
864 * \param CIdx The index object with which the translation unit will be
865 * associated.
866 *
867 * \param source_filename The name of the source file to load, or NULL if the
868 * source file is included in \c command_line_args.
869 *
870 * \param command_line_args The command-line arguments that would be
871 * passed to the \c clang executable if it were being invoked out-of-process.
872 * These command-line options will be parsed and will affect how the translation
873 * unit is parsed. Note that the following options are ignored: '-c',
874 * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
875 *
876 * \param num_command_line_args The number of command-line arguments in
877 * \c command_line_args.
878 *
879 * \param unsaved_files the files that have not yet been saved to disk
880 * but may be required for parsing, including the contents of
881 * those files. The contents and name of these files (as specified by
882 * CXUnsavedFile) are copied when necessary, so the client only needs to
883 * guarantee their validity until the call to this function returns.
884 *
885 * \param num_unsaved_files the number of unsaved file entries in \p
886 * unsaved_files.
887 *
888 * \param options A bitmask of options that affects how the translation unit
889 * is managed but not its compilation. This should be a bitwise OR of the
890 * CXTranslationUnit_XXX flags.
891 *
892 * \param[out] out_TU A non-NULL pointer to store the created
893 * \c CXTranslationUnit, describing the parsed code and containing any
894 * diagnostics produced by the compiler.
895 *
896 * \returns Zero on success, otherwise returns an error code.
897 */
898CINDEX_LINKAGE enum CXErrorCode clang_parseTranslationUnit2(
899 CXIndex CIdx, const char *source_filename,
900 const char *const *command_line_args, int num_command_line_args,
901 struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files,
902 unsigned options, CXTranslationUnit *out_TU);
903
904/**
905 * Same as clang_parseTranslationUnit2 but requires a full command line
906 * for \c command_line_args including argv[0]. This is useful if the standard
907 * library paths are relative to the binary.
908 */
909CINDEX_LINKAGE enum CXErrorCode clang_parseTranslationUnit2FullArgv(
910 CXIndex CIdx, const char *source_filename,
911 const char *const *command_line_args, int num_command_line_args,
912 struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files,
913 unsigned options, CXTranslationUnit *out_TU);
914
915/**
916 * Flags that control how translation units are saved.
917 *
918 * The enumerators in this enumeration type are meant to be bitwise
919 * ORed together to specify which options should be used when
920 * saving the translation unit.
921 */
922enum CXSaveTranslationUnit_Flags {
923 /**
924 * Used to indicate that no special saving options are needed.
925 */
926 CXSaveTranslationUnit_None = 0x0
927};
928
929/**
930 * Returns the set of flags that is suitable for saving a translation
931 * unit.
932 *
933 * The set of flags returned provide options for
934 * \c clang_saveTranslationUnit() by default. The returned flag
935 * set contains an unspecified set of options that save translation units with
936 * the most commonly-requested data.
937 */
938CINDEX_LINKAGE unsigned clang_defaultSaveOptions(CXTranslationUnit TU);
939
940/**
941 * Describes the kind of error that occurred (if any) in a call to
942 * \c clang_saveTranslationUnit().
943 */
944enum CXSaveError {
945 /**
946 * Indicates that no error occurred while saving a translation unit.
947 */
948 CXSaveError_None = 0,
949
950 /**
951 * Indicates that an unknown error occurred while attempting to save
952 * the file.
953 *
954 * This error typically indicates that file I/O failed when attempting to
955 * write the file.
956 */
957 CXSaveError_Unknown = 1,
958
959 /**
960 * Indicates that errors during translation prevented this attempt
961 * to save the translation unit.
962 *
963 * Errors that prevent the translation unit from being saved can be
964 * extracted using \c clang_getNumDiagnostics() and \c clang_getDiagnostic().
965 */
966 CXSaveError_TranslationErrors = 2,
967
968 /**
969 * Indicates that the translation unit to be saved was somehow
970 * invalid (e.g., NULL).
971 */
972 CXSaveError_InvalidTU = 3
973};
974
975/**
976 * Saves a translation unit into a serialized representation of
977 * that translation unit on disk.
978 *
979 * Any translation unit that was parsed without error can be saved
980 * into a file. The translation unit can then be deserialized into a
981 * new \c CXTranslationUnit with \c clang_createTranslationUnit() or,
982 * if it is an incomplete translation unit that corresponds to a
983 * header, used as a precompiled header when parsing other translation
984 * units.
985 *
986 * \param TU The translation unit to save.
987 *
988 * \param FileName The file to which the translation unit will be saved.
989 *
990 * \param options A bitmask of options that affects how the translation unit
991 * is saved. This should be a bitwise OR of the
992 * CXSaveTranslationUnit_XXX flags.
993 *
994 * \returns A value that will match one of the enumerators of the CXSaveError
995 * enumeration. Zero (CXSaveError_None) indicates that the translation unit was
996 * saved successfully, while a non-zero value indicates that a problem occurred.
997 */
998CINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU,
999 const char *FileName,
1000 unsigned options);
1001
1002/**
1003 * Suspend a translation unit in order to free memory associated with it.
1004 *
1005 * A suspended translation unit uses significantly less memory but on the other
1006 * side does not support any other calls than \c clang_reparseTranslationUnit
1007 * to resume it or \c clang_disposeTranslationUnit to dispose it completely.
1008 */
1009CINDEX_LINKAGE unsigned clang_suspendTranslationUnit(CXTranslationUnit);
1010
1011/**
1012 * Destroy the specified CXTranslationUnit object.
1013 */
1014CINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit);
1015
1016/**
1017 * Flags that control the reparsing of translation units.
1018 *
1019 * The enumerators in this enumeration type are meant to be bitwise
1020 * ORed together to specify which options should be used when
1021 * reparsing the translation unit.
1022 */
1023enum CXReparse_Flags {
1024 /**
1025 * Used to indicate that no special reparsing options are needed.
1026 */
1027 CXReparse_None = 0x0
1028};
1029
1030/**
1031 * Returns the set of flags that is suitable for reparsing a translation
1032 * unit.
1033 *
1034 * The set of flags returned provide options for
1035 * \c clang_reparseTranslationUnit() by default. The returned flag
1036 * set contains an unspecified set of optimizations geared toward common uses
1037 * of reparsing. The set of optimizations enabled may change from one version
1038 * to the next.
1039 */
1040CINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU);
1041
1042/**
1043 * Reparse the source files that produced this translation unit.
1044 *
1045 * This routine can be used to re-parse the source files that originally
1046 * created the given translation unit, for example because those source files
1047 * have changed (either on disk or as passed via \p unsaved_files). The
1048 * source code will be reparsed with the same command-line options as it
1049 * was originally parsed.
1050 *
1051 * Reparsing a translation unit invalidates all cursors and source locations
1052 * that refer into that translation unit. This makes reparsing a translation
1053 * unit semantically equivalent to destroying the translation unit and then
1054 * creating a new translation unit with the same command-line arguments.
1055 * However, it may be more efficient to reparse a translation
1056 * unit using this routine.
1057 *
1058 * \param TU The translation unit whose contents will be re-parsed. The
1059 * translation unit must originally have been built with
1060 * \c clang_createTranslationUnitFromSourceFile().
1061 *
1062 * \param num_unsaved_files The number of unsaved file entries in \p
1063 * unsaved_files.
1064 *
1065 * \param unsaved_files The files that have not yet been saved to disk
1066 * but may be required for parsing, including the contents of
1067 * those files. The contents and name of these files (as specified by
1068 * CXUnsavedFile) are copied when necessary, so the client only needs to
1069 * guarantee their validity until the call to this function returns.
1070 *
1071 * \param options A bitset of options composed of the flags in CXReparse_Flags.
1072 * The function \c clang_defaultReparseOptions() produces a default set of
1073 * options recommended for most uses, based on the translation unit.
1074 *
1075 * \returns 0 if the sources could be reparsed. A non-zero error code will be
1076 * returned if reparsing was impossible, such that the translation unit is
1077 * invalid. In such cases, the only valid call for \c TU is
1078 * \c clang_disposeTranslationUnit(TU). The error codes returned by this
1079 * routine are described by the \c CXErrorCode enum.
1080 */
1081CINDEX_LINKAGE int
1082clang_reparseTranslationUnit(CXTranslationUnit TU, unsigned num_unsaved_files,
1083 struct CXUnsavedFile *unsaved_files,
1084 unsigned options);
1085
1086/**
1087 * Categorizes how memory is being used by a translation unit.
1088 */
1089enum CXTUResourceUsageKind {
1090 CXTUResourceUsage_AST = 1,
1091 CXTUResourceUsage_Identifiers = 2,
1092 CXTUResourceUsage_Selectors = 3,
1093 CXTUResourceUsage_GlobalCompletionResults = 4,
1094 CXTUResourceUsage_SourceManagerContentCache = 5,
1095 CXTUResourceUsage_AST_SideTables = 6,
1096 CXTUResourceUsage_SourceManager_Membuffer_Malloc = 7,
1097 CXTUResourceUsage_SourceManager_Membuffer_MMap = 8,
1098 CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc = 9,
1099 CXTUResourceUsage_ExternalASTSource_Membuffer_MMap = 10,
1100 CXTUResourceUsage_Preprocessor = 11,
1101 CXTUResourceUsage_PreprocessingRecord = 12,
1102 CXTUResourceUsage_SourceManager_DataStructures = 13,
1103 CXTUResourceUsage_Preprocessor_HeaderSearch = 14,
1104 CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST,
1105 CXTUResourceUsage_MEMORY_IN_BYTES_END =
1106 CXTUResourceUsage_Preprocessor_HeaderSearch,
1107
1108 CXTUResourceUsage_First = CXTUResourceUsage_AST,
1109 CXTUResourceUsage_Last = CXTUResourceUsage_Preprocessor_HeaderSearch
1110};
1111
1112/**
1113 * Returns the human-readable null-terminated C string that represents
1114 * the name of the memory category. This string should never be freed.
1115 */
1116CINDEX_LINKAGE
1117const char *clang_getTUResourceUsageName(enum CXTUResourceUsageKind kind);
1118
1119typedef struct CXTUResourceUsageEntry {
1120 /* The memory usage category. */
1121 enum CXTUResourceUsageKind kind;
1122 /* Amount of resources used.
1123 The units will depend on the resource kind. */
1124 unsigned long amount;
1125} CXTUResourceUsageEntry;
1126
1127/**
1128 * The memory usage of a CXTranslationUnit, broken into categories.
1129 */
1130typedef struct CXTUResourceUsage {
1131 /* Private data member, used for queries. */
1132 void *data;
1133
1134 /* The number of entries in the 'entries' array. */
1135 unsigned numEntries;
1136
1137 /* An array of key-value pairs, representing the breakdown of memory
1138 usage. */
1139 CXTUResourceUsageEntry *entries;
1140
1141} CXTUResourceUsage;
1142
1143/**
1144 * Return the memory usage of a translation unit. This object
1145 * should be released with clang_disposeCXTUResourceUsage().
1146 */
1147CINDEX_LINKAGE CXTUResourceUsage
1148clang_getCXTUResourceUsage(CXTranslationUnit TU);
1149
1150CINDEX_LINKAGE void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage);
1151
1152/**
1153 * Get target information for this translation unit.
1154 *
1155 * The CXTargetInfo object cannot outlive the CXTranslationUnit object.
1156 */
1157CINDEX_LINKAGE CXTargetInfo
1158clang_getTranslationUnitTargetInfo(CXTranslationUnit CTUnit);
1159
1160/**
1161 * Destroy the CXTargetInfo object.
1162 */
1163CINDEX_LINKAGE void clang_TargetInfo_dispose(CXTargetInfo Info);
1164
1165/**
1166 * Get the normalized target triple as a string.
1167 *
1168 * Returns the empty string in case of any error.
1169 */
1170CINDEX_LINKAGE CXString clang_TargetInfo_getTriple(CXTargetInfo Info);
1171
1172/**
1173 * Get the pointer width of the target in bits.
1174 *
1175 * Returns -1 in case of error.
1176 */
1177CINDEX_LINKAGE int clang_TargetInfo_getPointerWidth(CXTargetInfo Info);
1178
1179/**
1180 * @}
1181 */
1182
1183/**
1184 * Describes the kind of entity that a cursor refers to.
1185 */
1186enum CXCursorKind {
1187 /* Declarations */
1188 /**
1189 * A declaration whose specific kind is not exposed via this
1190 * interface.
1191 *
1192 * Unexposed declarations have the same operations as any other kind
1193 * of declaration; one can extract their location information,
1194 * spelling, find their definitions, etc. However, the specific kind
1195 * of the declaration is not reported.
1196 */
1197 CXCursor_UnexposedDecl = 1,
1198 /** A C or C++ struct. */
1199 CXCursor_StructDecl = 2,
1200 /** A C or C++ union. */
1201 CXCursor_UnionDecl = 3,
1202 /** A C++ class. */
1203 CXCursor_ClassDecl = 4,
1204 /** An enumeration. */
1205 CXCursor_EnumDecl = 5,
1206 /**
1207 * A field (in C) or non-static data member (in C++) in a
1208 * struct, union, or C++ class.
1209 */
1210 CXCursor_FieldDecl = 6,
1211 /** An enumerator constant. */
1212 CXCursor_EnumConstantDecl = 7,
1213 /** A function. */
1214 CXCursor_FunctionDecl = 8,
1215 /** A variable. */
1216 CXCursor_VarDecl = 9,
1217 /** A function or method parameter. */
1218 CXCursor_ParmDecl = 10,
1219 /** An Objective-C \@interface. */
1220 CXCursor_ObjCInterfaceDecl = 11,
1221 /** An Objective-C \@interface for a category. */
1222 CXCursor_ObjCCategoryDecl = 12,
1223 /** An Objective-C \@protocol declaration. */
1224 CXCursor_ObjCProtocolDecl = 13,
1225 /** An Objective-C \@property declaration. */
1226 CXCursor_ObjCPropertyDecl = 14,
1227 /** An Objective-C instance variable. */
1228 CXCursor_ObjCIvarDecl = 15,
1229 /** An Objective-C instance method. */
1230 CXCursor_ObjCInstanceMethodDecl = 16,
1231 /** An Objective-C class method. */
1232 CXCursor_ObjCClassMethodDecl = 17,
1233 /** An Objective-C \@implementation. */
1234 CXCursor_ObjCImplementationDecl = 18,
1235 /** An Objective-C \@implementation for a category. */
1236 CXCursor_ObjCCategoryImplDecl = 19,
1237 /** A typedef. */
1238 CXCursor_TypedefDecl = 20,
1239 /** A C++ class method. */
1240 CXCursor_CXXMethod = 21,
1241 /** A C++ namespace. */
1242 CXCursor_Namespace = 22,
1243 /** A linkage specification, e.g. 'extern "C"'. */
1244 CXCursor_LinkageSpec = 23,
1245 /** A C++ constructor. */
1246 CXCursor_Constructor = 24,
1247 /** A C++ destructor. */
1248 CXCursor_Destructor = 25,
1249 /** A C++ conversion function. */
1250 CXCursor_ConversionFunction = 26,
1251 /** A C++ template type parameter. */
1252 CXCursor_TemplateTypeParameter = 27,
1253 /** A C++ non-type template parameter. */
1254 CXCursor_NonTypeTemplateParameter = 28,
1255 /** A C++ template template parameter. */
1256 CXCursor_TemplateTemplateParameter = 29,
1257 /** A C++ function template. */
1258 CXCursor_FunctionTemplate = 30,
1259 /** A C++ class template. */
1260 CXCursor_ClassTemplate = 31,
1261 /** A C++ class template partial specialization. */
1262 CXCursor_ClassTemplatePartialSpecialization = 32,
1263 /** A C++ namespace alias declaration. */
1264 CXCursor_NamespaceAlias = 33,
1265 /** A C++ using directive. */
1266 CXCursor_UsingDirective = 34,
1267 /** A C++ using declaration. */
1268 CXCursor_UsingDeclaration = 35,
1269 /** A C++ alias declaration */
1270 CXCursor_TypeAliasDecl = 36,
1271 /** An Objective-C \@synthesize definition. */
1272 CXCursor_ObjCSynthesizeDecl = 37,
1273 /** An Objective-C \@dynamic definition. */
1274 CXCursor_ObjCDynamicDecl = 38,
1275 /** An access specifier. */
1276 CXCursor_CXXAccessSpecifier = 39,
1277
1278 CXCursor_FirstDecl = CXCursor_UnexposedDecl,
1279 CXCursor_LastDecl = CXCursor_CXXAccessSpecifier,
1280
1281 /* References */
1282 CXCursor_FirstRef = 40, /* Decl references */
1283 CXCursor_ObjCSuperClassRef = 40,
1284 CXCursor_ObjCProtocolRef = 41,
1285 CXCursor_ObjCClassRef = 42,
1286 /**
1287 * A reference to a type declaration.
1288 *
1289 * A type reference occurs anywhere where a type is named but not
1290 * declared. For example, given:
1291 *
1292 * \code
1293 * typedef unsigned size_type;
1294 * size_type size;
1295 * \endcode
1296 *
1297 * The typedef is a declaration of size_type (CXCursor_TypedefDecl),
1298 * while the type of the variable "size" is referenced. The cursor
1299 * referenced by the type of size is the typedef for size_type.
1300 */
1301 CXCursor_TypeRef = 43,
1302 CXCursor_CXXBaseSpecifier = 44,
1303 /**
1304 * A reference to a class template, function template, template
1305 * template parameter, or class template partial specialization.
1306 */
1307 CXCursor_TemplateRef = 45,
1308 /**
1309 * A reference to a namespace or namespace alias.
1310 */
1311 CXCursor_NamespaceRef = 46,
1312 /**
1313 * A reference to a member of a struct, union, or class that occurs in
1314 * some non-expression context, e.g., a designated initializer.
1315 */
1316 CXCursor_MemberRef = 47,
1317 /**
1318 * A reference to a labeled statement.
1319 *
1320 * This cursor kind is used to describe the jump to "start_over" in the
1321 * goto statement in the following example:
1322 *
1323 * \code
1324 * start_over:
1325 * ++counter;
1326 *
1327 * goto start_over;
1328 * \endcode
1329 *
1330 * A label reference cursor refers to a label statement.
1331 */
1332 CXCursor_LabelRef = 48,
1333
1334 /**
1335 * A reference to a set of overloaded functions or function templates
1336 * that has not yet been resolved to a specific function or function template.
1337 *
1338 * An overloaded declaration reference cursor occurs in C++ templates where
1339 * a dependent name refers to a function. For example:
1340 *
1341 * \code
1342 * template<typename T> void swap(T&, T&);
1343 *
1344 * struct X { ... };
1345 * void swap(X&, X&);
1346 *
1347 * template<typename T>
1348 * void reverse(T* first, T* last) {
1349 * while (first < last - 1) {
1350 * swap(*first, *--last);
1351 * ++first;
1352 * }
1353 * }
1354 *
1355 * struct Y { };
1356 * void swap(Y&, Y&);
1357 * \endcode
1358 *
1359 * Here, the identifier "swap" is associated with an overloaded declaration
1360 * reference. In the template definition, "swap" refers to either of the two
1361 * "swap" functions declared above, so both results will be available. At
1362 * instantiation time, "swap" may also refer to other functions found via
1363 * argument-dependent lookup (e.g., the "swap" function at the end of the
1364 * example).
1365 *
1366 * The functions \c clang_getNumOverloadedDecls() and
1367 * \c clang_getOverloadedDecl() can be used to retrieve the definitions
1368 * referenced by this cursor.
1369 */
1370 CXCursor_OverloadedDeclRef = 49,
1371
1372 /**
1373 * A reference to a variable that occurs in some non-expression
1374 * context, e.g., a C++ lambda capture list.
1375 */
1376 CXCursor_VariableRef = 50,
1377
1378 CXCursor_LastRef = CXCursor_VariableRef,
1379
1380 /* Error conditions */
1381 CXCursor_FirstInvalid = 70,
1382 CXCursor_InvalidFile = 70,
1383 CXCursor_NoDeclFound = 71,
1384 CXCursor_NotImplemented = 72,
1385 CXCursor_InvalidCode = 73,
1386 CXCursor_LastInvalid = CXCursor_InvalidCode,
1387
1388 /* Expressions */
1389 CXCursor_FirstExpr = 100,
1390
1391 /**
1392 * An expression whose specific kind is not exposed via this
1393 * interface.
1394 *
1395 * Unexposed expressions have the same operations as any other kind
1396 * of expression; one can extract their location information,
1397 * spelling, children, etc. However, the specific kind of the
1398 * expression is not reported.
1399 */
1400 CXCursor_UnexposedExpr = 100,
1401
1402 /**
1403 * An expression that refers to some value declaration, such
1404 * as a function, variable, or enumerator.
1405 */
1406 CXCursor_DeclRefExpr = 101,
1407
1408 /**
1409 * An expression that refers to a member of a struct, union,
1410 * class, Objective-C class, etc.
1411 */
1412 CXCursor_MemberRefExpr = 102,
1413
1414 /** An expression that calls a function. */
1415 CXCursor_CallExpr = 103,
1416
1417 /** An expression that sends a message to an Objective-C
1418 object or class. */
1419 CXCursor_ObjCMessageExpr = 104,
1420
1421 /** An expression that represents a block literal. */
1422 CXCursor_BlockExpr = 105,
1423
1424 /** An integer literal.
1425 */
1426 CXCursor_IntegerLiteral = 106,
1427
1428 /** A floating point number literal.
1429 */
1430 CXCursor_FloatingLiteral = 107,
1431
1432 /** An imaginary number literal.
1433 */
1434 CXCursor_ImaginaryLiteral = 108,
1435
1436 /** A string literal.
1437 */
1438 CXCursor_StringLiteral = 109,
1439
1440 /** A character literal.
1441 */
1442 CXCursor_CharacterLiteral = 110,
1443
1444 /** A parenthesized expression, e.g. "(1)".
1445 *
1446 * This AST node is only formed if full location information is requested.
1447 */
1448 CXCursor_ParenExpr = 111,
1449
1450 /** This represents the unary-expression's (except sizeof and
1451 * alignof).
1452 */
1453 CXCursor_UnaryOperator = 112,
1454
1455 /** [C99 6.5.2.1] Array Subscripting.
1456 */
1457 CXCursor_ArraySubscriptExpr = 113,
1458
1459 /** A builtin binary operation expression such as "x + y" or
1460 * "x <= y".
1461 */
1462 CXCursor_BinaryOperator = 114,
1463
1464 /** Compound assignment such as "+=".
1465 */
1466 CXCursor_CompoundAssignOperator = 115,
1467
1468 /** The ?: ternary operator.
1469 */
1470 CXCursor_ConditionalOperator = 116,
1471
1472 /** An explicit cast in C (C99 6.5.4) or a C-style cast in C++
1473 * (C++ [expr.cast]), which uses the syntax (Type)expr.
1474 *
1475 * For example: (int)f.
1476 */
1477 CXCursor_CStyleCastExpr = 117,
1478
1479 /** [C99 6.5.2.5]
1480 */
1481 CXCursor_CompoundLiteralExpr = 118,
1482
1483 /** Describes an C or C++ initializer list.
1484 */
1485 CXCursor_InitListExpr = 119,
1486
1487 /** The GNU address of label extension, representing &&label.
1488 */
1489 CXCursor_AddrLabelExpr = 120,
1490
1491 /** This is the GNU Statement Expression extension: ({int X=4; X;})
1492 */
1493 CXCursor_StmtExpr = 121,
1494
1495 /** Represents a C11 generic selection.
1496 */
1497 CXCursor_GenericSelectionExpr = 122,
1498
1499 /** Implements the GNU __null extension, which is a name for a null
1500 * pointer constant that has integral type (e.g., int or long) and is the same
1501 * size and alignment as a pointer.
1502 *
1503 * The __null extension is typically only used by system headers, which define
1504 * NULL as __null in C++ rather than using 0 (which is an integer that may not
1505 * match the size of a pointer).
1506 */
1507 CXCursor_GNUNullExpr = 123,
1508
1509 /** C++'s static_cast<> expression.
1510 */
1511 CXCursor_CXXStaticCastExpr = 124,
1512
1513 /** C++'s dynamic_cast<> expression.
1514 */
1515 CXCursor_CXXDynamicCastExpr = 125,
1516
1517 /** C++'s reinterpret_cast<> expression.
1518 */
1519 CXCursor_CXXReinterpretCastExpr = 126,
1520
1521 /** C++'s const_cast<> expression.
1522 */
1523 CXCursor_CXXConstCastExpr = 127,
1524
1525 /** Represents an explicit C++ type conversion that uses "functional"
1526 * notion (C++ [expr.type.conv]).
1527 *
1528 * Example:
1529 * \code
1530 * x = int(0.5);
1531 * \endcode
1532 */
1533 CXCursor_CXXFunctionalCastExpr = 128,
1534
1535 /** A C++ typeid expression (C++ [expr.typeid]).
1536 */
1537 CXCursor_CXXTypeidExpr = 129,
1538
1539 /** [C++ 2.13.5] C++ Boolean Literal.
1540 */
1541 CXCursor_CXXBoolLiteralExpr = 130,
1542
1543 /** [C++0x 2.14.7] C++ Pointer Literal.
1544 */
1545 CXCursor_CXXNullPtrLiteralExpr = 131,
1546
1547 /** Represents the "this" expression in C++
1548 */
1549 CXCursor_CXXThisExpr = 132,
1550
1551 /** [C++ 15] C++ Throw Expression.
1552 *
1553 * This handles 'throw' and 'throw' assignment-expression. When
1554 * assignment-expression isn't present, Op will be null.
1555 */
1556 CXCursor_CXXThrowExpr = 133,
1557
1558 /** A new expression for memory allocation and constructor calls, e.g:
1559 * "new CXXNewExpr(foo)".
1560 */
1561 CXCursor_CXXNewExpr = 134,
1562
1563 /** A delete expression for memory deallocation and destructor calls,
1564 * e.g. "delete[] pArray".
1565 */
1566 CXCursor_CXXDeleteExpr = 135,
1567
1568 /** A unary expression. (noexcept, sizeof, or other traits)
1569 */
1570 CXCursor_UnaryExpr = 136,
1571
1572 /** An Objective-C string literal i.e. @"foo".
1573 */
1574 CXCursor_ObjCStringLiteral = 137,
1575
1576 /** An Objective-C \@encode expression.
1577 */
1578 CXCursor_ObjCEncodeExpr = 138,
1579
1580 /** An Objective-C \@selector expression.
1581 */
1582 CXCursor_ObjCSelectorExpr = 139,
1583
1584 /** An Objective-C \@protocol expression.
1585 */
1586 CXCursor_ObjCProtocolExpr = 140,
1587
1588 /** An Objective-C "bridged" cast expression, which casts between
1589 * Objective-C pointers and C pointers, transferring ownership in the process.
1590 *
1591 * \code
1592 * NSString *str = (__bridge_transfer NSString *)CFCreateString();
1593 * \endcode
1594 */
1595 CXCursor_ObjCBridgedCastExpr = 141,
1596
1597 /** Represents a C++0x pack expansion that produces a sequence of
1598 * expressions.
1599 *
1600 * A pack expansion expression contains a pattern (which itself is an
1601 * expression) followed by an ellipsis. For example:
1602 *
1603 * \code
1604 * template<typename F, typename ...Types>
1605 * void forward(F f, Types &&...args) {
1606 * f(static_cast<Types&&>(args)...);
1607 * }
1608 * \endcode
1609 */
1610 CXCursor_PackExpansionExpr = 142,
1611
1612 /** Represents an expression that computes the length of a parameter
1613 * pack.
1614 *
1615 * \code
1616 * template<typename ...Types>
1617 * struct count {
1618 * static const unsigned value = sizeof...(Types);
1619 * };
1620 * \endcode
1621 */
1622 CXCursor_SizeOfPackExpr = 143,
1623
1624 /* Represents a C++ lambda expression that produces a local function
1625 * object.
1626 *
1627 * \code
1628 * void abssort(float *x, unsigned N) {
1629 * std::sort(x, x + N,
1630 * [](float a, float b) {
1631 * return std::abs(a) < std::abs(b);
1632 * });
1633 * }
1634 * \endcode
1635 */
1636 CXCursor_LambdaExpr = 144,
1637
1638 /** Objective-c Boolean Literal.
1639 */
1640 CXCursor_ObjCBoolLiteralExpr = 145,
1641
1642 /** Represents the "self" expression in an Objective-C method.
1643 */
1644 CXCursor_ObjCSelfExpr = 146,
1645
1646 /** OpenMP 5.0 [2.1.5, Array Section].
1647 */
1648 CXCursor_OMPArraySectionExpr = 147,
1649
1650 /** Represents an @available(...) check.
1651 */
1652 CXCursor_ObjCAvailabilityCheckExpr = 148,
1653
1654 /**
1655 * Fixed point literal
1656 */
1657 CXCursor_FixedPointLiteral = 149,
1658
1659 /** OpenMP 5.0 [2.1.4, Array Shaping].
1660 */
1661 CXCursor_OMPArrayShapingExpr = 150,
1662
1663 /**
1664 * OpenMP 5.0 [2.1.6 Iterators]
1665 */
1666 CXCursor_OMPIteratorExpr = 151,
1667
1668 /** OpenCL's addrspace_cast<> expression.
1669 */
1670 CXCursor_CXXAddrspaceCastExpr = 152,
1671
1672 /**
1673 * Expression that references a C++20 concept.
1674 */
1675 CXCursor_ConceptSpecializationExpr = 153,
1676
1677 /**
1678 * Expression that references a C++20 requires expression.
1679 */
1680 CXCursor_RequiresExpr = 154,
1681
1682 /**
1683 * Expression that references a C++20 parenthesized list aggregate
1684 * initializer.
1685 */
1686 CXCursor_CXXParenListInitExpr = 155,
1687
1688 /**
1689 * Represents a C++26 pack indexing expression.
1690 */
1691 CXCursor_PackIndexingExpr = 156,
1692
1693 CXCursor_LastExpr = CXCursor_PackIndexingExpr,
1694
1695 /* Statements */
1696 CXCursor_FirstStmt = 200,
1697 /**
1698 * A statement whose specific kind is not exposed via this
1699 * interface.
1700 *
1701 * Unexposed statements have the same operations as any other kind of
1702 * statement; one can extract their location information, spelling,
1703 * children, etc. However, the specific kind of the statement is not
1704 * reported.
1705 */
1706 CXCursor_UnexposedStmt = 200,
1707
1708 /** A labelled statement in a function.
1709 *
1710 * This cursor kind is used to describe the "start_over:" label statement in
1711 * the following example:
1712 *
1713 * \code
1714 * start_over:
1715 * ++counter;
1716 * \endcode
1717 *
1718 */
1719 CXCursor_LabelStmt = 201,
1720
1721 /** A group of statements like { stmt stmt }.
1722 *
1723 * This cursor kind is used to describe compound statements, e.g. function
1724 * bodies.
1725 */
1726 CXCursor_CompoundStmt = 202,
1727
1728 /** A case statement.
1729 */
1730 CXCursor_CaseStmt = 203,
1731
1732 /** A default statement.
1733 */
1734 CXCursor_DefaultStmt = 204,
1735
1736 /** An if statement
1737 */
1738 CXCursor_IfStmt = 205,
1739
1740 /** A switch statement.
1741 */
1742 CXCursor_SwitchStmt = 206,
1743
1744 /** A while statement.
1745 */
1746 CXCursor_WhileStmt = 207,
1747
1748 /** A do statement.
1749 */
1750 CXCursor_DoStmt = 208,
1751
1752 /** A for statement.
1753 */
1754 CXCursor_ForStmt = 209,
1755
1756 /** A goto statement.
1757 */
1758 CXCursor_GotoStmt = 210,
1759
1760 /** An indirect goto statement.
1761 */
1762 CXCursor_IndirectGotoStmt = 211,
1763
1764 /** A continue statement.
1765 */
1766 CXCursor_ContinueStmt = 212,
1767
1768 /** A break statement.
1769 */
1770 CXCursor_BreakStmt = 213,
1771
1772 /** A return statement.
1773 */
1774 CXCursor_ReturnStmt = 214,
1775
1776 /** A GCC inline assembly statement extension.
1777 */
1778 CXCursor_GCCAsmStmt = 215,
1779 CXCursor_AsmStmt = CXCursor_GCCAsmStmt,
1780
1781 /** Objective-C's overall \@try-\@catch-\@finally statement.
1782 */
1783 CXCursor_ObjCAtTryStmt = 216,
1784
1785 /** Objective-C's \@catch statement.
1786 */
1787 CXCursor_ObjCAtCatchStmt = 217,
1788
1789 /** Objective-C's \@finally statement.
1790 */
1791 CXCursor_ObjCAtFinallyStmt = 218,
1792
1793 /** Objective-C's \@throw statement.
1794 */
1795 CXCursor_ObjCAtThrowStmt = 219,
1796
1797 /** Objective-C's \@synchronized statement.
1798 */
1799 CXCursor_ObjCAtSynchronizedStmt = 220,
1800
1801 /** Objective-C's autorelease pool statement.
1802 */
1803 CXCursor_ObjCAutoreleasePoolStmt = 221,
1804
1805 /** Objective-C's collection statement.
1806 */
1807 CXCursor_ObjCForCollectionStmt = 222,
1808
1809 /** C++'s catch statement.
1810 */
1811 CXCursor_CXXCatchStmt = 223,
1812
1813 /** C++'s try statement.
1814 */
1815 CXCursor_CXXTryStmt = 224,
1816
1817 /** C++'s for (* : *) statement.
1818 */
1819 CXCursor_CXXForRangeStmt = 225,
1820
1821 /** Windows Structured Exception Handling's try statement.
1822 */
1823 CXCursor_SEHTryStmt = 226,
1824
1825 /** Windows Structured Exception Handling's except statement.
1826 */
1827 CXCursor_SEHExceptStmt = 227,
1828
1829 /** Windows Structured Exception Handling's finally statement.
1830 */
1831 CXCursor_SEHFinallyStmt = 228,
1832
1833 /** A MS inline assembly statement extension.
1834 */
1835 CXCursor_MSAsmStmt = 229,
1836
1837 /** The null statement ";": C99 6.8.3p3.
1838 *
1839 * This cursor kind is used to describe the null statement.
1840 */
1841 CXCursor_NullStmt = 230,
1842
1843 /** Adaptor class for mixing declarations with statements and
1844 * expressions.
1845 */
1846 CXCursor_DeclStmt = 231,
1847
1848 /** OpenMP parallel directive.
1849 */
1850 CXCursor_OMPParallelDirective = 232,
1851
1852 /** OpenMP SIMD directive.
1853 */
1854 CXCursor_OMPSimdDirective = 233,
1855
1856 /** OpenMP for directive.
1857 */
1858 CXCursor_OMPForDirective = 234,
1859
1860 /** OpenMP sections directive.
1861 */
1862 CXCursor_OMPSectionsDirective = 235,
1863
1864 /** OpenMP section directive.
1865 */
1866 CXCursor_OMPSectionDirective = 236,
1867
1868 /** OpenMP single directive.
1869 */
1870 CXCursor_OMPSingleDirective = 237,
1871
1872 /** OpenMP parallel for directive.
1873 */
1874 CXCursor_OMPParallelForDirective = 238,
1875
1876 /** OpenMP parallel sections directive.
1877 */
1878 CXCursor_OMPParallelSectionsDirective = 239,
1879
1880 /** OpenMP task directive.
1881 */
1882 CXCursor_OMPTaskDirective = 240,
1883
1884 /** OpenMP master directive.
1885 */
1886 CXCursor_OMPMasterDirective = 241,
1887
1888 /** OpenMP critical directive.
1889 */
1890 CXCursor_OMPCriticalDirective = 242,
1891
1892 /** OpenMP taskyield directive.
1893 */
1894 CXCursor_OMPTaskyieldDirective = 243,
1895
1896 /** OpenMP barrier directive.
1897 */
1898 CXCursor_OMPBarrierDirective = 244,
1899
1900 /** OpenMP taskwait directive.
1901 */
1902 CXCursor_OMPTaskwaitDirective = 245,
1903
1904 /** OpenMP flush directive.
1905 */
1906 CXCursor_OMPFlushDirective = 246,
1907
1908 /** Windows Structured Exception Handling's leave statement.
1909 */
1910 CXCursor_SEHLeaveStmt = 247,
1911
1912 /** OpenMP ordered directive.
1913 */
1914 CXCursor_OMPOrderedDirective = 248,
1915
1916 /** OpenMP atomic directive.
1917 */
1918 CXCursor_OMPAtomicDirective = 249,
1919
1920 /** OpenMP for SIMD directive.
1921 */
1922 CXCursor_OMPForSimdDirective = 250,
1923
1924 /** OpenMP parallel for SIMD directive.
1925 */
1926 CXCursor_OMPParallelForSimdDirective = 251,
1927
1928 /** OpenMP target directive.
1929 */
1930 CXCursor_OMPTargetDirective = 252,
1931
1932 /** OpenMP teams directive.
1933 */
1934 CXCursor_OMPTeamsDirective = 253,
1935
1936 /** OpenMP taskgroup directive.
1937 */
1938 CXCursor_OMPTaskgroupDirective = 254,
1939
1940 /** OpenMP cancellation point directive.
1941 */
1942 CXCursor_OMPCancellationPointDirective = 255,
1943
1944 /** OpenMP cancel directive.
1945 */
1946 CXCursor_OMPCancelDirective = 256,
1947
1948 /** OpenMP target data directive.
1949 */
1950 CXCursor_OMPTargetDataDirective = 257,
1951
1952 /** OpenMP taskloop directive.
1953 */
1954 CXCursor_OMPTaskLoopDirective = 258,
1955
1956 /** OpenMP taskloop simd directive.
1957 */
1958 CXCursor_OMPTaskLoopSimdDirective = 259,
1959
1960 /** OpenMP distribute directive.
1961 */
1962 CXCursor_OMPDistributeDirective = 260,
1963
1964 /** OpenMP target enter data directive.
1965 */
1966 CXCursor_OMPTargetEnterDataDirective = 261,
1967
1968 /** OpenMP target exit data directive.
1969 */
1970 CXCursor_OMPTargetExitDataDirective = 262,
1971
1972 /** OpenMP target parallel directive.
1973 */
1974 CXCursor_OMPTargetParallelDirective = 263,
1975
1976 /** OpenMP target parallel for directive.
1977 */
1978 CXCursor_OMPTargetParallelForDirective = 264,
1979
1980 /** OpenMP target update directive.
1981 */
1982 CXCursor_OMPTargetUpdateDirective = 265,
1983
1984 /** OpenMP distribute parallel for directive.
1985 */
1986 CXCursor_OMPDistributeParallelForDirective = 266,
1987
1988 /** OpenMP distribute parallel for simd directive.
1989 */
1990 CXCursor_OMPDistributeParallelForSimdDirective = 267,
1991
1992 /** OpenMP distribute simd directive.
1993 */
1994 CXCursor_OMPDistributeSimdDirective = 268,
1995
1996 /** OpenMP target parallel for simd directive.
1997 */
1998 CXCursor_OMPTargetParallelForSimdDirective = 269,
1999
2000 /** OpenMP target simd directive.
2001 */
2002 CXCursor_OMPTargetSimdDirective = 270,
2003
2004 /** OpenMP teams distribute directive.
2005 */
2006 CXCursor_OMPTeamsDistributeDirective = 271,
2007
2008 /** OpenMP teams distribute simd directive.
2009 */
2010 CXCursor_OMPTeamsDistributeSimdDirective = 272,
2011
2012 /** OpenMP teams distribute parallel for simd directive.
2013 */
2014 CXCursor_OMPTeamsDistributeParallelForSimdDirective = 273,
2015
2016 /** OpenMP teams distribute parallel for directive.
2017 */
2018 CXCursor_OMPTeamsDistributeParallelForDirective = 274,
2019
2020 /** OpenMP target teams directive.
2021 */
2022 CXCursor_OMPTargetTeamsDirective = 275,
2023
2024 /** OpenMP target teams distribute directive.
2025 */
2026 CXCursor_OMPTargetTeamsDistributeDirective = 276,
2027
2028 /** OpenMP target teams distribute parallel for directive.
2029 */
2030 CXCursor_OMPTargetTeamsDistributeParallelForDirective = 277,
2031
2032 /** OpenMP target teams distribute parallel for simd directive.
2033 */
2034 CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective = 278,
2035
2036 /** OpenMP target teams distribute simd directive.
2037 */
2038 CXCursor_OMPTargetTeamsDistributeSimdDirective = 279,
2039
2040 /** C++2a std::bit_cast expression.
2041 */
2042 CXCursor_BuiltinBitCastExpr = 280,
2043
2044 /** OpenMP master taskloop directive.
2045 */
2046 CXCursor_OMPMasterTaskLoopDirective = 281,
2047
2048 /** OpenMP parallel master taskloop directive.
2049 */
2050 CXCursor_OMPParallelMasterTaskLoopDirective = 282,
2051
2052 /** OpenMP master taskloop simd directive.
2053 */
2054 CXCursor_OMPMasterTaskLoopSimdDirective = 283,
2055
2056 /** OpenMP parallel master taskloop simd directive.
2057 */
2058 CXCursor_OMPParallelMasterTaskLoopSimdDirective = 284,
2059
2060 /** OpenMP parallel master directive.
2061 */
2062 CXCursor_OMPParallelMasterDirective = 285,
2063
2064 /** OpenMP depobj directive.
2065 */
2066 CXCursor_OMPDepobjDirective = 286,
2067
2068 /** OpenMP scan directive.
2069 */
2070 CXCursor_OMPScanDirective = 287,
2071
2072 /** OpenMP tile directive.
2073 */
2074 CXCursor_OMPTileDirective = 288,
2075
2076 /** OpenMP canonical loop.
2077 */
2078 CXCursor_OMPCanonicalLoop = 289,
2079
2080 /** OpenMP interop directive.
2081 */
2082 CXCursor_OMPInteropDirective = 290,
2083
2084 /** OpenMP dispatch directive.
2085 */
2086 CXCursor_OMPDispatchDirective = 291,
2087
2088 /** OpenMP masked directive.
2089 */
2090 CXCursor_OMPMaskedDirective = 292,
2091
2092 /** OpenMP unroll directive.
2093 */
2094 CXCursor_OMPUnrollDirective = 293,
2095
2096 /** OpenMP metadirective directive.
2097 */
2098 CXCursor_OMPMetaDirective = 294,
2099
2100 /** OpenMP loop directive.
2101 */
2102 CXCursor_OMPGenericLoopDirective = 295,
2103
2104 /** OpenMP teams loop directive.
2105 */
2106 CXCursor_OMPTeamsGenericLoopDirective = 296,
2107
2108 /** OpenMP target teams loop directive.
2109 */
2110 CXCursor_OMPTargetTeamsGenericLoopDirective = 297,
2111
2112 /** OpenMP parallel loop directive.
2113 */
2114 CXCursor_OMPParallelGenericLoopDirective = 298,
2115
2116 /** OpenMP target parallel loop directive.
2117 */
2118 CXCursor_OMPTargetParallelGenericLoopDirective = 299,
2119
2120 /** OpenMP parallel masked directive.
2121 */
2122 CXCursor_OMPParallelMaskedDirective = 300,
2123
2124 /** OpenMP masked taskloop directive.
2125 */
2126 CXCursor_OMPMaskedTaskLoopDirective = 301,
2127
2128 /** OpenMP masked taskloop simd directive.
2129 */
2130 CXCursor_OMPMaskedTaskLoopSimdDirective = 302,
2131
2132 /** OpenMP parallel masked taskloop directive.
2133 */
2134 CXCursor_OMPParallelMaskedTaskLoopDirective = 303,
2135
2136 /** OpenMP parallel masked taskloop simd directive.
2137 */
2138 CXCursor_OMPParallelMaskedTaskLoopSimdDirective = 304,
2139
2140 /** OpenMP error directive.
2141 */
2142 CXCursor_OMPErrorDirective = 305,
2143
2144 /** OpenMP scope directive.
2145 */
2146 CXCursor_OMPScopeDirective = 306,
2147
2148 /** OpenACC Compute Construct.
2149 */
2150 CXCursor_OpenACCComputeConstruct = 320,
2151
2152 CXCursor_LastStmt = CXCursor_OpenACCComputeConstruct,
2153
2154 /**
2155 * Cursor that represents the translation unit itself.
2156 *
2157 * The translation unit cursor exists primarily to act as the root
2158 * cursor for traversing the contents of a translation unit.
2159 */
2160 CXCursor_TranslationUnit = 350,
2161
2162 /* Attributes */
2163 CXCursor_FirstAttr = 400,
2164 /**
2165 * An attribute whose specific kind is not exposed via this
2166 * interface.
2167 */
2168 CXCursor_UnexposedAttr = 400,
2169
2170 CXCursor_IBActionAttr = 401,
2171 CXCursor_IBOutletAttr = 402,
2172 CXCursor_IBOutletCollectionAttr = 403,
2173 CXCursor_CXXFinalAttr = 404,
2174 CXCursor_CXXOverrideAttr = 405,
2175 CXCursor_AnnotateAttr = 406,
2176 CXCursor_AsmLabelAttr = 407,
2177 CXCursor_PackedAttr = 408,
2178 CXCursor_PureAttr = 409,
2179 CXCursor_ConstAttr = 410,
2180 CXCursor_NoDuplicateAttr = 411,
2181 CXCursor_CUDAConstantAttr = 412,
2182 CXCursor_CUDADeviceAttr = 413,
2183 CXCursor_CUDAGlobalAttr = 414,
2184 CXCursor_CUDAHostAttr = 415,
2185 CXCursor_CUDASharedAttr = 416,
2186 CXCursor_VisibilityAttr = 417,
2187 CXCursor_DLLExport = 418,
2188 CXCursor_DLLImport = 419,
2189 CXCursor_NSReturnsRetained = 420,
2190 CXCursor_NSReturnsNotRetained = 421,
2191 CXCursor_NSReturnsAutoreleased = 422,
2192 CXCursor_NSConsumesSelf = 423,
2193 CXCursor_NSConsumed = 424,
2194 CXCursor_ObjCException = 425,
2195 CXCursor_ObjCNSObject = 426,
2196 CXCursor_ObjCIndependentClass = 427,
2197 CXCursor_ObjCPreciseLifetime = 428,
2198 CXCursor_ObjCReturnsInnerPointer = 429,
2199 CXCursor_ObjCRequiresSuper = 430,
2200 CXCursor_ObjCRootClass = 431,
2201 CXCursor_ObjCSubclassingRestricted = 432,
2202 CXCursor_ObjCExplicitProtocolImpl = 433,
2203 CXCursor_ObjCDesignatedInitializer = 434,
2204 CXCursor_ObjCRuntimeVisible = 435,
2205 CXCursor_ObjCBoxable = 436,
2206 CXCursor_FlagEnum = 437,
2207 CXCursor_ConvergentAttr = 438,
2208 CXCursor_WarnUnusedAttr = 439,
2209 CXCursor_WarnUnusedResultAttr = 440,
2210 CXCursor_AlignedAttr = 441,
2211 CXCursor_LastAttr = CXCursor_AlignedAttr,
2212
2213 /* Preprocessing */
2214 CXCursor_PreprocessingDirective = 500,
2215 CXCursor_MacroDefinition = 501,
2216 CXCursor_MacroExpansion = 502,
2217 CXCursor_MacroInstantiation = CXCursor_MacroExpansion,
2218 CXCursor_InclusionDirective = 503,
2219 CXCursor_FirstPreprocessing = CXCursor_PreprocessingDirective,
2220 CXCursor_LastPreprocessing = CXCursor_InclusionDirective,
2221
2222 /* Extra Declarations */
2223 /**
2224 * A module import declaration.
2225 */
2226 CXCursor_ModuleImportDecl = 600,
2227 CXCursor_TypeAliasTemplateDecl = 601,
2228 /**
2229 * A static_assert or _Static_assert node
2230 */
2231 CXCursor_StaticAssert = 602,
2232 /**
2233 * a friend declaration.
2234 */
2235 CXCursor_FriendDecl = 603,
2236 /**
2237 * a concept declaration.
2238 */
2239 CXCursor_ConceptDecl = 604,
2240
2241 CXCursor_FirstExtraDecl = CXCursor_ModuleImportDecl,
2242 CXCursor_LastExtraDecl = CXCursor_ConceptDecl,
2243
2244 /**
2245 * A code completion overload candidate.
2246 */
2247 CXCursor_OverloadCandidate = 700
2248};
2249
2250/**
2251 * A cursor representing some element in the abstract syntax tree for
2252 * a translation unit.
2253 *
2254 * The cursor abstraction unifies the different kinds of entities in a
2255 * program--declaration, statements, expressions, references to declarations,
2256 * etc.--under a single "cursor" abstraction with a common set of operations.
2257 * Common operation for a cursor include: getting the physical location in
2258 * a source file where the cursor points, getting the name associated with a
2259 * cursor, and retrieving cursors for any child nodes of a particular cursor.
2260 *
2261 * Cursors can be produced in two specific ways.
2262 * clang_getTranslationUnitCursor() produces a cursor for a translation unit,
2263 * from which one can use clang_visitChildren() to explore the rest of the
2264 * translation unit. clang_getCursor() maps from a physical source location
2265 * to the entity that resides at that location, allowing one to map from the
2266 * source code into the AST.
2267 */
2268typedef struct {
2269 enum CXCursorKind kind;
2270 int xdata;
2271 const void *data[3];
2272} CXCursor;
2273
2274/**
2275 * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations
2276 *
2277 * @{
2278 */
2279
2280/**
2281 * Retrieve the NULL cursor, which represents no entity.
2282 */
2283CINDEX_LINKAGE CXCursor clang_getNullCursor(void);
2284
2285/**
2286 * Retrieve the cursor that represents the given translation unit.
2287 *
2288 * The translation unit cursor can be used to start traversing the
2289 * various declarations within the given translation unit.
2290 */
2291CINDEX_LINKAGE CXCursor clang_getTranslationUnitCursor(CXTranslationUnit);
2292
2293/**
2294 * Determine whether two cursors are equivalent.
2295 */
2296CINDEX_LINKAGE unsigned clang_equalCursors(CXCursor, CXCursor);
2297
2298/**
2299 * Returns non-zero if \p cursor is null.
2300 */
2301CINDEX_LINKAGE int clang_Cursor_isNull(CXCursor cursor);
2302
2303/**
2304 * Compute a hash value for the given cursor.
2305 */
2306CINDEX_LINKAGE unsigned clang_hashCursor(CXCursor);
2307
2308/**
2309 * Retrieve the kind of the given cursor.
2310 */
2311CINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor);
2312
2313/**
2314 * Determine whether the given cursor kind represents a declaration.
2315 */
2316CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind);
2317
2318/**
2319 * Determine whether the given declaration is invalid.
2320 *
2321 * A declaration is invalid if it could not be parsed successfully.
2322 *
2323 * \returns non-zero if the cursor represents a declaration and it is
2324 * invalid, otherwise NULL.
2325 */
2326CINDEX_LINKAGE unsigned clang_isInvalidDeclaration(CXCursor);
2327
2328/**
2329 * Determine whether the given cursor kind represents a simple
2330 * reference.
2331 *
2332 * Note that other kinds of cursors (such as expressions) can also refer to
2333 * other cursors. Use clang_getCursorReferenced() to determine whether a
2334 * particular cursor refers to another entity.
2335 */
2336CINDEX_LINKAGE unsigned clang_isReference(enum CXCursorKind);
2337
2338/**
2339 * Determine whether the given cursor kind represents an expression.
2340 */
2341CINDEX_LINKAGE unsigned clang_isExpression(enum CXCursorKind);
2342
2343/**
2344 * Determine whether the given cursor kind represents a statement.
2345 */
2346CINDEX_LINKAGE unsigned clang_isStatement(enum CXCursorKind);
2347
2348/**
2349 * Determine whether the given cursor kind represents an attribute.
2350 */
2351CINDEX_LINKAGE unsigned clang_isAttribute(enum CXCursorKind);
2352
2353/**
2354 * Determine whether the given cursor has any attributes.
2355 */
2356CINDEX_LINKAGE unsigned clang_Cursor_hasAttrs(CXCursor C);
2357
2358/**
2359 * Determine whether the given cursor kind represents an invalid
2360 * cursor.
2361 */
2362CINDEX_LINKAGE unsigned clang_isInvalid(enum CXCursorKind);
2363
2364/**
2365 * Determine whether the given cursor kind represents a translation
2366 * unit.
2367 */
2368CINDEX_LINKAGE unsigned clang_isTranslationUnit(enum CXCursorKind);
2369
2370/***
2371 * Determine whether the given cursor represents a preprocessing
2372 * element, such as a preprocessor directive or macro instantiation.
2373 */
2374CINDEX_LINKAGE unsigned clang_isPreprocessing(enum CXCursorKind);
2375
2376/***
2377 * Determine whether the given cursor represents a currently
2378 * unexposed piece of the AST (e.g., CXCursor_UnexposedStmt).
2379 */
2380CINDEX_LINKAGE unsigned clang_isUnexposed(enum CXCursorKind);
2381
2382/**
2383 * Describe the linkage of the entity referred to by a cursor.
2384 */
2385enum CXLinkageKind {
2386 /** This value indicates that no linkage information is available
2387 * for a provided CXCursor. */
2388 CXLinkage_Invalid,
2389 /**
2390 * This is the linkage for variables, parameters, and so on that
2391 * have automatic storage. This covers normal (non-extern) local variables.
2392 */
2393 CXLinkage_NoLinkage,
2394 /** This is the linkage for static variables and static functions. */
2395 CXLinkage_Internal,
2396 /** This is the linkage for entities with external linkage that live
2397 * in C++ anonymous namespaces.*/
2398 CXLinkage_UniqueExternal,
2399 /** This is the linkage for entities with true, external linkage. */
2400 CXLinkage_External
2401};
2402
2403/**
2404 * Determine the linkage of the entity referred to by a given cursor.
2405 */
2406CINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor);
2407
2408enum CXVisibilityKind {
2409 /** This value indicates that no visibility information is available
2410 * for a provided CXCursor. */
2411 CXVisibility_Invalid,
2412
2413 /** Symbol not seen by the linker. */
2414 CXVisibility_Hidden,
2415 /** Symbol seen by the linker but resolves to a symbol inside this object. */
2416 CXVisibility_Protected,
2417 /** Symbol seen by the linker and acts like a normal symbol. */
2418 CXVisibility_Default
2419};
2420
2421/**
2422 * Describe the visibility of the entity referred to by a cursor.
2423 *
2424 * This returns the default visibility if not explicitly specified by
2425 * a visibility attribute. The default visibility may be changed by
2426 * commandline arguments.
2427 *
2428 * \param cursor The cursor to query.
2429 *
2430 * \returns The visibility of the cursor.
2431 */
2432CINDEX_LINKAGE enum CXVisibilityKind clang_getCursorVisibility(CXCursor cursor);
2433
2434/**
2435 * Determine the availability of the entity that this cursor refers to,
2436 * taking the current target platform into account.
2437 *
2438 * \param cursor The cursor to query.
2439 *
2440 * \returns The availability of the cursor.
2441 */
2442CINDEX_LINKAGE enum CXAvailabilityKind
2443clang_getCursorAvailability(CXCursor cursor);
2444
2445/**
2446 * Describes the availability of a given entity on a particular platform, e.g.,
2447 * a particular class might only be available on Mac OS 10.7 or newer.
2448 */
2449typedef struct CXPlatformAvailability {
2450 /**
2451 * A string that describes the platform for which this structure
2452 * provides availability information.
2453 *
2454 * Possible values are "ios" or "macos".
2455 */
2456 CXString Platform;
2457 /**
2458 * The version number in which this entity was introduced.
2459 */
2460 CXVersion Introduced;
2461 /**
2462 * The version number in which this entity was deprecated (but is
2463 * still available).
2464 */
2465 CXVersion Deprecated;
2466 /**
2467 * The version number in which this entity was obsoleted, and therefore
2468 * is no longer available.
2469 */
2470 CXVersion Obsoleted;
2471 /**
2472 * Whether the entity is unconditionally unavailable on this platform.
2473 */
2474 int Unavailable;
2475 /**
2476 * An optional message to provide to a user of this API, e.g., to
2477 * suggest replacement APIs.
2478 */
2479 CXString Message;
2480} CXPlatformAvailability;
2481
2482/**
2483 * Determine the availability of the entity that this cursor refers to
2484 * on any platforms for which availability information is known.
2485 *
2486 * \param cursor The cursor to query.
2487 *
2488 * \param always_deprecated If non-NULL, will be set to indicate whether the
2489 * entity is deprecated on all platforms.
2490 *
2491 * \param deprecated_message If non-NULL, will be set to the message text
2492 * provided along with the unconditional deprecation of this entity. The client
2493 * is responsible for deallocating this string.
2494 *
2495 * \param always_unavailable If non-NULL, will be set to indicate whether the
2496 * entity is unavailable on all platforms.
2497 *
2498 * \param unavailable_message If non-NULL, will be set to the message text
2499 * provided along with the unconditional unavailability of this entity. The
2500 * client is responsible for deallocating this string.
2501 *
2502 * \param availability If non-NULL, an array of CXPlatformAvailability instances
2503 * that will be populated with platform availability information, up to either
2504 * the number of platforms for which availability information is available (as
2505 * returned by this function) or \c availability_size, whichever is smaller.
2506 *
2507 * \param availability_size The number of elements available in the
2508 * \c availability array.
2509 *
2510 * \returns The number of platforms (N) for which availability information is
2511 * available (which is unrelated to \c availability_size).
2512 *
2513 * Note that the client is responsible for calling
2514 * \c clang_disposeCXPlatformAvailability to free each of the
2515 * platform-availability structures returned. There are
2516 * \c min(N, availability_size) such structures.
2517 */
2518CINDEX_LINKAGE int clang_getCursorPlatformAvailability(
2519 CXCursor cursor, int *always_deprecated, CXString *deprecated_message,
2520 int *always_unavailable, CXString *unavailable_message,
2521 CXPlatformAvailability *availability, int availability_size);
2522
2523/**
2524 * Free the memory associated with a \c CXPlatformAvailability structure.
2525 */
2526CINDEX_LINKAGE void
2527clang_disposeCXPlatformAvailability(CXPlatformAvailability *availability);
2528
2529/**
2530 * If cursor refers to a variable declaration and it has initializer returns
2531 * cursor referring to the initializer otherwise return null cursor.
2532 */
2533CINDEX_LINKAGE CXCursor clang_Cursor_getVarDeclInitializer(CXCursor cursor);
2534
2535/**
2536 * If cursor refers to a variable declaration that has global storage returns 1.
2537 * If cursor refers to a variable declaration that doesn't have global storage
2538 * returns 0. Otherwise returns -1.
2539 */
2540CINDEX_LINKAGE int clang_Cursor_hasVarDeclGlobalStorage(CXCursor cursor);
2541
2542/**
2543 * If cursor refers to a variable declaration that has external storage
2544 * returns 1. If cursor refers to a variable declaration that doesn't have
2545 * external storage returns 0. Otherwise returns -1.
2546 */
2547CINDEX_LINKAGE int clang_Cursor_hasVarDeclExternalStorage(CXCursor cursor);
2548
2549/**
2550 * Describe the "language" of the entity referred to by a cursor.
2551 */
2552enum CXLanguageKind {
2553 CXLanguage_Invalid = 0,
2554 CXLanguage_C,
2555 CXLanguage_ObjC,
2556 CXLanguage_CPlusPlus
2557};
2558
2559/**
2560 * Determine the "language" of the entity referred to by a given cursor.
2561 */
2562CINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor);
2563
2564/**
2565 * Describe the "thread-local storage (TLS) kind" of the declaration
2566 * referred to by a cursor.
2567 */
2568enum CXTLSKind { CXTLS_None = 0, CXTLS_Dynamic, CXTLS_Static };
2569
2570/**
2571 * Determine the "thread-local storage (TLS) kind" of the declaration
2572 * referred to by a cursor.
2573 */
2574CINDEX_LINKAGE enum CXTLSKind clang_getCursorTLSKind(CXCursor cursor);
2575
2576/**
2577 * Returns the translation unit that a cursor originated from.
2578 */
2579CINDEX_LINKAGE CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor);
2580
2581/**
2582 * A fast container representing a set of CXCursors.
2583 */
2584typedef struct CXCursorSetImpl *CXCursorSet;
2585
2586/**
2587 * Creates an empty CXCursorSet.
2588 */
2589CINDEX_LINKAGE CXCursorSet clang_createCXCursorSet(void);
2590
2591/**
2592 * Disposes a CXCursorSet and releases its associated memory.
2593 */
2594CINDEX_LINKAGE void clang_disposeCXCursorSet(CXCursorSet cset);
2595
2596/**
2597 * Queries a CXCursorSet to see if it contains a specific CXCursor.
2598 *
2599 * \returns non-zero if the set contains the specified cursor.
2600 */
2601CINDEX_LINKAGE unsigned clang_CXCursorSet_contains(CXCursorSet cset,
2602 CXCursor cursor);
2603
2604/**
2605 * Inserts a CXCursor into a CXCursorSet.
2606 *
2607 * \returns zero if the CXCursor was already in the set, and non-zero otherwise.
2608 */
2609CINDEX_LINKAGE unsigned clang_CXCursorSet_insert(CXCursorSet cset,
2610 CXCursor cursor);
2611
2612/**
2613 * Determine the semantic parent of the given cursor.
2614 *
2615 * The semantic parent of a cursor is the cursor that semantically contains
2616 * the given \p cursor. For many declarations, the lexical and semantic parents
2617 * are equivalent (the lexical parent is returned by
2618 * \c clang_getCursorLexicalParent()). They diverge when declarations or
2619 * definitions are provided out-of-line. For example:
2620 *
2621 * \code
2622 * class C {
2623 * void f();
2624 * };
2625 *
2626 * void C::f() { }
2627 * \endcode
2628 *
2629 * In the out-of-line definition of \c C::f, the semantic parent is
2630 * the class \c C, of which this function is a member. The lexical parent is
2631 * the place where the declaration actually occurs in the source code; in this
2632 * case, the definition occurs in the translation unit. In general, the
2633 * lexical parent for a given entity can change without affecting the semantics
2634 * of the program, and the lexical parent of different declarations of the
2635 * same entity may be different. Changing the semantic parent of a declaration,
2636 * on the other hand, can have a major impact on semantics, and redeclarations
2637 * of a particular entity should all have the same semantic context.
2638 *
2639 * In the example above, both declarations of \c C::f have \c C as their
2640 * semantic context, while the lexical context of the first \c C::f is \c C
2641 * and the lexical context of the second \c C::f is the translation unit.
2642 *
2643 * For global declarations, the semantic parent is the translation unit.
2644 */
2645CINDEX_LINKAGE CXCursor clang_getCursorSemanticParent(CXCursor cursor);
2646
2647/**
2648 * Determine the lexical parent of the given cursor.
2649 *
2650 * The lexical parent of a cursor is the cursor in which the given \p cursor
2651 * was actually written. For many declarations, the lexical and semantic parents
2652 * are equivalent (the semantic parent is returned by
2653 * \c clang_getCursorSemanticParent()). They diverge when declarations or
2654 * definitions are provided out-of-line. For example:
2655 *
2656 * \code
2657 * class C {
2658 * void f();
2659 * };
2660 *
2661 * void C::f() { }
2662 * \endcode
2663 *
2664 * In the out-of-line definition of \c C::f, the semantic parent is
2665 * the class \c C, of which this function is a member. The lexical parent is
2666 * the place where the declaration actually occurs in the source code; in this
2667 * case, the definition occurs in the translation unit. In general, the
2668 * lexical parent for a given entity can change without affecting the semantics
2669 * of the program, and the lexical parent of different declarations of the
2670 * same entity may be different. Changing the semantic parent of a declaration,
2671 * on the other hand, can have a major impact on semantics, and redeclarations
2672 * of a particular entity should all have the same semantic context.
2673 *
2674 * In the example above, both declarations of \c C::f have \c C as their
2675 * semantic context, while the lexical context of the first \c C::f is \c C
2676 * and the lexical context of the second \c C::f is the translation unit.
2677 *
2678 * For declarations written in the global scope, the lexical parent is
2679 * the translation unit.
2680 */
2681CINDEX_LINKAGE CXCursor clang_getCursorLexicalParent(CXCursor cursor);
2682
2683/**
2684 * Determine the set of methods that are overridden by the given
2685 * method.
2686 *
2687 * In both Objective-C and C++, a method (aka virtual member function,
2688 * in C++) can override a virtual method in a base class. For
2689 * Objective-C, a method is said to override any method in the class's
2690 * base class, its protocols, or its categories' protocols, that has the same
2691 * selector and is of the same kind (class or instance).
2692 * If no such method exists, the search continues to the class's superclass,
2693 * its protocols, and its categories, and so on. A method from an Objective-C
2694 * implementation is considered to override the same methods as its
2695 * corresponding method in the interface.
2696 *
2697 * For C++, a virtual member function overrides any virtual member
2698 * function with the same signature that occurs in its base
2699 * classes. With multiple inheritance, a virtual member function can
2700 * override several virtual member functions coming from different
2701 * base classes.
2702 *
2703 * In all cases, this function determines the immediate overridden
2704 * method, rather than all of the overridden methods. For example, if
2705 * a method is originally declared in a class A, then overridden in B
2706 * (which in inherits from A) and also in C (which inherited from B),
2707 * then the only overridden method returned from this function when
2708 * invoked on C's method will be B's method. The client may then
2709 * invoke this function again, given the previously-found overridden
2710 * methods, to map out the complete method-override set.
2711 *
2712 * \param cursor A cursor representing an Objective-C or C++
2713 * method. This routine will compute the set of methods that this
2714 * method overrides.
2715 *
2716 * \param overridden A pointer whose pointee will be replaced with a
2717 * pointer to an array of cursors, representing the set of overridden
2718 * methods. If there are no overridden methods, the pointee will be
2719 * set to NULL. The pointee must be freed via a call to
2720 * \c clang_disposeOverriddenCursors().
2721 *
2722 * \param num_overridden A pointer to the number of overridden
2723 * functions, will be set to the number of overridden functions in the
2724 * array pointed to by \p overridden.
2725 */
2726CINDEX_LINKAGE void clang_getOverriddenCursors(CXCursor cursor,
2727 CXCursor **overridden,
2728 unsigned *num_overridden);
2729
2730/**
2731 * Free the set of overridden cursors returned by \c
2732 * clang_getOverriddenCursors().
2733 */
2734CINDEX_LINKAGE void clang_disposeOverriddenCursors(CXCursor *overridden);
2735
2736/**
2737 * Retrieve the file that is included by the given inclusion directive
2738 * cursor.
2739 */
2740CINDEX_LINKAGE CXFile clang_getIncludedFile(CXCursor cursor);
2741
2742/**
2743 * @}
2744 */
2745
2746/**
2747 * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code
2748 *
2749 * Cursors represent a location within the Abstract Syntax Tree (AST). These
2750 * routines help map between cursors and the physical locations where the
2751 * described entities occur in the source code. The mapping is provided in
2752 * both directions, so one can map from source code to the AST and back.
2753 *
2754 * @{
2755 */
2756
2757/**
2758 * Map a source location to the cursor that describes the entity at that
2759 * location in the source code.
2760 *
2761 * clang_getCursor() maps an arbitrary source location within a translation
2762 * unit down to the most specific cursor that describes the entity at that
2763 * location. For example, given an expression \c x + y, invoking
2764 * clang_getCursor() with a source location pointing to "x" will return the
2765 * cursor for "x"; similarly for "y". If the cursor points anywhere between
2766 * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor()
2767 * will return a cursor referring to the "+" expression.
2768 *
2769 * \returns a cursor representing the entity at the given source location, or
2770 * a NULL cursor if no such entity can be found.
2771 */
2772CINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, CXSourceLocation);
2773
2774/**
2775 * Retrieve the physical location of the source constructor referenced
2776 * by the given cursor.
2777 *
2778 * The location of a declaration is typically the location of the name of that
2779 * declaration, where the name of that declaration would occur if it is
2780 * unnamed, or some keyword that introduces that particular declaration.
2781 * The location of a reference is where that reference occurs within the
2782 * source code.
2783 */
2784CINDEX_LINKAGE CXSourceLocation clang_getCursorLocation(CXCursor);
2785
2786/**
2787 * Retrieve the physical extent of the source construct referenced by
2788 * the given cursor.
2789 *
2790 * The extent of a cursor starts with the file/line/column pointing at the
2791 * first character within the source construct that the cursor refers to and
2792 * ends with the last character within that source construct. For a
2793 * declaration, the extent covers the declaration itself. For a reference,
2794 * the extent covers the location of the reference (e.g., where the referenced
2795 * entity was actually used).
2796 */
2797CINDEX_LINKAGE CXSourceRange clang_getCursorExtent(CXCursor);
2798
2799/**
2800 * @}
2801 */
2802
2803/**
2804 * \defgroup CINDEX_TYPES Type information for CXCursors
2805 *
2806 * @{
2807 */
2808
2809/**
2810 * Describes the kind of type
2811 */
2812enum CXTypeKind {
2813 /**
2814 * Represents an invalid type (e.g., where no type is available).
2815 */
2816 CXType_Invalid = 0,
2817
2818 /**
2819 * A type whose specific kind is not exposed via this
2820 * interface.
2821 */
2822 CXType_Unexposed = 1,
2823
2824 /* Builtin types */
2825 CXType_Void = 2,
2826 CXType_Bool = 3,
2827 CXType_Char_U = 4,
2828 CXType_UChar = 5,
2829 CXType_Char16 = 6,
2830 CXType_Char32 = 7,
2831 CXType_UShort = 8,
2832 CXType_UInt = 9,
2833 CXType_ULong = 10,
2834 CXType_ULongLong = 11,
2835 CXType_UInt128 = 12,
2836 CXType_Char_S = 13,
2837 CXType_SChar = 14,
2838 CXType_WChar = 15,
2839 CXType_Short = 16,
2840 CXType_Int = 17,
2841 CXType_Long = 18,
2842 CXType_LongLong = 19,
2843 CXType_Int128 = 20,
2844 CXType_Float = 21,
2845 CXType_Double = 22,
2846 CXType_LongDouble = 23,
2847 CXType_NullPtr = 24,
2848 CXType_Overload = 25,
2849 CXType_Dependent = 26,
2850 CXType_ObjCId = 27,
2851 CXType_ObjCClass = 28,
2852 CXType_ObjCSel = 29,
2853 CXType_Float128 = 30,
2854 CXType_Half = 31,
2855 CXType_Float16 = 32,
2856 CXType_ShortAccum = 33,
2857 CXType_Accum = 34,
2858 CXType_LongAccum = 35,
2859 CXType_UShortAccum = 36,
2860 CXType_UAccum = 37,
2861 CXType_ULongAccum = 38,
2862 CXType_BFloat16 = 39,
2863 CXType_Ibm128 = 40,
2864 CXType_FirstBuiltin = CXType_Void,
2865 CXType_LastBuiltin = CXType_Ibm128,
2866
2867 CXType_Complex = 100,
2868 CXType_Pointer = 101,
2869 CXType_BlockPointer = 102,
2870 CXType_LValueReference = 103,
2871 CXType_RValueReference = 104,
2872 CXType_Record = 105,
2873 CXType_Enum = 106,
2874 CXType_Typedef = 107,
2875 CXType_ObjCInterface = 108,
2876 CXType_ObjCObjectPointer = 109,
2877 CXType_FunctionNoProto = 110,
2878 CXType_FunctionProto = 111,
2879 CXType_ConstantArray = 112,
2880 CXType_Vector = 113,
2881 CXType_IncompleteArray = 114,
2882 CXType_VariableArray = 115,
2883 CXType_DependentSizedArray = 116,
2884 CXType_MemberPointer = 117,
2885 CXType_Auto = 118,
2886
2887 /**
2888 * Represents a type that was referred to using an elaborated type keyword.
2889 *
2890 * E.g., struct S, or via a qualified name, e.g., N::M::type, or both.
2891 */
2892 CXType_Elaborated = 119,
2893
2894 /* OpenCL PipeType. */
2895 CXType_Pipe = 120,
2896
2897 /* OpenCL builtin types. */
2898 CXType_OCLImage1dRO = 121,
2899 CXType_OCLImage1dArrayRO = 122,
2900 CXType_OCLImage1dBufferRO = 123,
2901 CXType_OCLImage2dRO = 124,
2902 CXType_OCLImage2dArrayRO = 125,
2903 CXType_OCLImage2dDepthRO = 126,
2904 CXType_OCLImage2dArrayDepthRO = 127,
2905 CXType_OCLImage2dMSAARO = 128,
2906 CXType_OCLImage2dArrayMSAARO = 129,
2907 CXType_OCLImage2dMSAADepthRO = 130,
2908 CXType_OCLImage2dArrayMSAADepthRO = 131,
2909 CXType_OCLImage3dRO = 132,
2910 CXType_OCLImage1dWO = 133,
2911 CXType_OCLImage1dArrayWO = 134,
2912 CXType_OCLImage1dBufferWO = 135,
2913 CXType_OCLImage2dWO = 136,
2914 CXType_OCLImage2dArrayWO = 137,
2915 CXType_OCLImage2dDepthWO = 138,
2916 CXType_OCLImage2dArrayDepthWO = 139,
2917 CXType_OCLImage2dMSAAWO = 140,
2918 CXType_OCLImage2dArrayMSAAWO = 141,
2919 CXType_OCLImage2dMSAADepthWO = 142,
2920 CXType_OCLImage2dArrayMSAADepthWO = 143,
2921 CXType_OCLImage3dWO = 144,
2922 CXType_OCLImage1dRW = 145,
2923 CXType_OCLImage1dArrayRW = 146,
2924 CXType_OCLImage1dBufferRW = 147,
2925 CXType_OCLImage2dRW = 148,
2926 CXType_OCLImage2dArrayRW = 149,
2927 CXType_OCLImage2dDepthRW = 150,
2928 CXType_OCLImage2dArrayDepthRW = 151,
2929 CXType_OCLImage2dMSAARW = 152,
2930 CXType_OCLImage2dArrayMSAARW = 153,
2931 CXType_OCLImage2dMSAADepthRW = 154,
2932 CXType_OCLImage2dArrayMSAADepthRW = 155,
2933 CXType_OCLImage3dRW = 156,
2934 CXType_OCLSampler = 157,
2935 CXType_OCLEvent = 158,
2936 CXType_OCLQueue = 159,
2937 CXType_OCLReserveID = 160,
2938
2939 CXType_ObjCObject = 161,
2940 CXType_ObjCTypeParam = 162,
2941 CXType_Attributed = 163,
2942
2943 CXType_OCLIntelSubgroupAVCMcePayload = 164,
2944 CXType_OCLIntelSubgroupAVCImePayload = 165,
2945 CXType_OCLIntelSubgroupAVCRefPayload = 166,
2946 CXType_OCLIntelSubgroupAVCSicPayload = 167,
2947 CXType_OCLIntelSubgroupAVCMceResult = 168,
2948 CXType_OCLIntelSubgroupAVCImeResult = 169,
2949 CXType_OCLIntelSubgroupAVCRefResult = 170,
2950 CXType_OCLIntelSubgroupAVCSicResult = 171,
2951 CXType_OCLIntelSubgroupAVCImeResultSingleReferenceStreamout = 172,
2952 CXType_OCLIntelSubgroupAVCImeResultDualReferenceStreamout = 173,
2953 CXType_OCLIntelSubgroupAVCImeSingleReferenceStreamin = 174,
2954 CXType_OCLIntelSubgroupAVCImeDualReferenceStreamin = 175,
2955
2956 /* Old aliases for AVC OpenCL extension types. */
2957 CXType_OCLIntelSubgroupAVCImeResultSingleRefStreamout = 172,
2958 CXType_OCLIntelSubgroupAVCImeResultDualRefStreamout = 173,
2959 CXType_OCLIntelSubgroupAVCImeSingleRefStreamin = 174,
2960 CXType_OCLIntelSubgroupAVCImeDualRefStreamin = 175,
2961
2962 CXType_ExtVector = 176,
2963 CXType_Atomic = 177,
2964 CXType_BTFTagAttributed = 178
2965};
2966
2967/**
2968 * Describes the calling convention of a function type
2969 */
2970enum CXCallingConv {
2971 CXCallingConv_Default = 0,
2972 CXCallingConv_C = 1,
2973 CXCallingConv_X86StdCall = 2,
2974 CXCallingConv_X86FastCall = 3,
2975 CXCallingConv_X86ThisCall = 4,
2976 CXCallingConv_X86Pascal = 5,
2977 CXCallingConv_AAPCS = 6,
2978 CXCallingConv_AAPCS_VFP = 7,
2979 CXCallingConv_X86RegCall = 8,
2980 CXCallingConv_IntelOclBicc = 9,
2981 CXCallingConv_Win64 = 10,
2982 /* Alias for compatibility with older versions of API. */
2983 CXCallingConv_X86_64Win64 = CXCallingConv_Win64,
2984 CXCallingConv_X86_64SysV = 11,
2985 CXCallingConv_X86VectorCall = 12,
2986 CXCallingConv_Swift = 13,
2987 CXCallingConv_PreserveMost = 14,
2988 CXCallingConv_PreserveAll = 15,
2989 CXCallingConv_AArch64VectorCall = 16,
2990 CXCallingConv_SwiftAsync = 17,
2991 CXCallingConv_AArch64SVEPCS = 18,
2992 CXCallingConv_M68kRTD = 19,
2993 CXCallingConv_PreserveNone = 20,
2994 CXCallingConv_RISCVVectorCall = 21,
2995
2996 CXCallingConv_Invalid = 100,
2997 CXCallingConv_Unexposed = 200
2998};
2999
3000/**
3001 * The type of an element in the abstract syntax tree.
3002 *
3003 */
3004typedef struct {
3005 enum CXTypeKind kind;
3006 void *data[2];
3007} CXType;
3008
3009/**
3010 * Retrieve the type of a CXCursor (if any).
3011 */
3012CINDEX_LINKAGE CXType clang_getCursorType(CXCursor C);
3013
3014/**
3015 * Pretty-print the underlying type using the rules of the
3016 * language of the translation unit from which it came.
3017 *
3018 * If the type is invalid, an empty string is returned.
3019 */
3020CINDEX_LINKAGE CXString clang_getTypeSpelling(CXType CT);
3021
3022/**
3023 * Retrieve the underlying type of a typedef declaration.
3024 *
3025 * If the cursor does not reference a typedef declaration, an invalid type is
3026 * returned.
3027 */
3028CINDEX_LINKAGE CXType clang_getTypedefDeclUnderlyingType(CXCursor C);
3029
3030/**
3031 * Retrieve the integer type of an enum declaration.
3032 *
3033 * If the cursor does not reference an enum declaration, an invalid type is
3034 * returned.
3035 */
3036CINDEX_LINKAGE CXType clang_getEnumDeclIntegerType(CXCursor C);
3037
3038/**
3039 * Retrieve the integer value of an enum constant declaration as a signed
3040 * long long.
3041 *
3042 * If the cursor does not reference an enum constant declaration, LLONG_MIN is
3043 * returned. Since this is also potentially a valid constant value, the kind of
3044 * the cursor must be verified before calling this function.
3045 */
3046CINDEX_LINKAGE long long clang_getEnumConstantDeclValue(CXCursor C);
3047
3048/**
3049 * Retrieve the integer value of an enum constant declaration as an unsigned
3050 * long long.
3051 *
3052 * If the cursor does not reference an enum constant declaration, ULLONG_MAX is
3053 * returned. Since this is also potentially a valid constant value, the kind of
3054 * the cursor must be verified before calling this function.
3055 */
3056CINDEX_LINKAGE unsigned long long
3057clang_getEnumConstantDeclUnsignedValue(CXCursor C);
3058
3059/**
3060 * Returns non-zero if the cursor specifies a Record member that is a bit-field.
3061 */
3062CINDEX_LINKAGE unsigned clang_Cursor_isBitField(CXCursor C);
3063
3064/**
3065 * Retrieve the bit width of a bit-field declaration as an integer.
3066 *
3067 * If the cursor does not reference a bit-field, or if the bit-field's width
3068 * expression cannot be evaluated, -1 is returned.
3069 *
3070 * For example:
3071 * \code
3072 * if (clang_Cursor_isBitField(Cursor)) {
3073 * int Width = clang_getFieldDeclBitWidth(Cursor);
3074 * if (Width != -1) {
3075 * // The bit-field width is not value-dependent.
3076 * }
3077 * }
3078 * \endcode
3079 */
3080CINDEX_LINKAGE int clang_getFieldDeclBitWidth(CXCursor C);
3081
3082/**
3083 * Retrieve the number of non-variadic arguments associated with a given
3084 * cursor.
3085 *
3086 * The number of arguments can be determined for calls as well as for
3087 * declarations of functions or methods. For other cursors -1 is returned.
3088 */
3089CINDEX_LINKAGE int clang_Cursor_getNumArguments(CXCursor C);
3090
3091/**
3092 * Retrieve the argument cursor of a function or method.
3093 *
3094 * The argument cursor can be determined for calls as well as for declarations
3095 * of functions or methods. For other cursors and for invalid indices, an
3096 * invalid cursor is returned.
3097 */
3098CINDEX_LINKAGE CXCursor clang_Cursor_getArgument(CXCursor C, unsigned i);
3099
3100/**
3101 * Describes the kind of a template argument.
3102 *
3103 * See the definition of llvm::clang::TemplateArgument::ArgKind for full
3104 * element descriptions.
3105 */
3106enum CXTemplateArgumentKind {
3107 CXTemplateArgumentKind_Null,
3108 CXTemplateArgumentKind_Type,
3109 CXTemplateArgumentKind_Declaration,
3110 CXTemplateArgumentKind_NullPtr,
3111 CXTemplateArgumentKind_Integral,
3112 CXTemplateArgumentKind_Template,
3113 CXTemplateArgumentKind_TemplateExpansion,
3114 CXTemplateArgumentKind_Expression,
3115 CXTemplateArgumentKind_Pack,
3116 /* Indicates an error case, preventing the kind from being deduced. */
3117 CXTemplateArgumentKind_Invalid
3118};
3119
3120/**
3121 * Returns the number of template args of a function, struct, or class decl
3122 * representing a template specialization.
3123 *
3124 * If the argument cursor cannot be converted into a template function
3125 * declaration, -1 is returned.
3126 *
3127 * For example, for the following declaration and specialization:
3128 * template <typename T, int kInt, bool kBool>
3129 * void foo() { ... }
3130 *
3131 * template <>
3132 * void foo<float, -7, true>();
3133 *
3134 * The value 3 would be returned from this call.
3135 */
3136CINDEX_LINKAGE int clang_Cursor_getNumTemplateArguments(CXCursor C);
3137
3138/**
3139 * Retrieve the kind of the I'th template argument of the CXCursor C.
3140 *
3141 * If the argument CXCursor does not represent a FunctionDecl, StructDecl, or
3142 * ClassTemplatePartialSpecialization, an invalid template argument kind is
3143 * returned.
3144 *
3145 * For example, for the following declaration and specialization:
3146 * template <typename T, int kInt, bool kBool>
3147 * void foo() { ... }
3148 *
3149 * template <>
3150 * void foo<float, -7, true>();
3151 *
3152 * For I = 0, 1, and 2, Type, Integral, and Integral will be returned,
3153 * respectively.
3154 */
3155CINDEX_LINKAGE enum CXTemplateArgumentKind
3156clang_Cursor_getTemplateArgumentKind(CXCursor C, unsigned I);
3157
3158/**
3159 * Retrieve a CXType representing the type of a TemplateArgument of a
3160 * function decl representing a template specialization.
3161 *
3162 * If the argument CXCursor does not represent a FunctionDecl, StructDecl,
3163 * ClassDecl or ClassTemplatePartialSpecialization whose I'th template argument
3164 * has a kind of CXTemplateArgKind_Integral, an invalid type is returned.
3165 *
3166 * For example, for the following declaration and specialization:
3167 * template <typename T, int kInt, bool kBool>
3168 * void foo() { ... }
3169 *
3170 * template <>
3171 * void foo<float, -7, true>();
3172 *
3173 * If called with I = 0, "float", will be returned.
3174 * Invalid types will be returned for I == 1 or 2.
3175 */
3176CINDEX_LINKAGE CXType clang_Cursor_getTemplateArgumentType(CXCursor C,
3177 unsigned I);
3178
3179/**
3180 * Retrieve the value of an Integral TemplateArgument (of a function
3181 * decl representing a template specialization) as a signed long long.
3182 *
3183 * It is undefined to call this function on a CXCursor that does not represent a
3184 * FunctionDecl, StructDecl, ClassDecl or ClassTemplatePartialSpecialization
3185 * whose I'th template argument is not an integral value.
3186 *
3187 * For example, for the following declaration and specialization:
3188 * template <typename T, int kInt, bool kBool>
3189 * void foo() { ... }
3190 *
3191 * template <>
3192 * void foo<float, -7, true>();
3193 *
3194 * If called with I = 1 or 2, -7 or true will be returned, respectively.
3195 * For I == 0, this function's behavior is undefined.
3196 */
3197CINDEX_LINKAGE long long clang_Cursor_getTemplateArgumentValue(CXCursor C,
3198 unsigned I);
3199
3200/**
3201 * Retrieve the value of an Integral TemplateArgument (of a function
3202 * decl representing a template specialization) as an unsigned long long.
3203 *
3204 * It is undefined to call this function on a CXCursor that does not represent a
3205 * FunctionDecl, StructDecl, ClassDecl or ClassTemplatePartialSpecialization or
3206 * whose I'th template argument is not an integral value.
3207 *
3208 * For example, for the following declaration and specialization:
3209 * template <typename T, int kInt, bool kBool>
3210 * void foo() { ... }
3211 *
3212 * template <>
3213 * void foo<float, 2147483649, true>();
3214 *
3215 * If called with I = 1 or 2, 2147483649 or true will be returned, respectively.
3216 * For I == 0, this function's behavior is undefined.
3217 */
3218CINDEX_LINKAGE unsigned long long
3219clang_Cursor_getTemplateArgumentUnsignedValue(CXCursor C, unsigned I);
3220
3221/**
3222 * Determine whether two CXTypes represent the same type.
3223 *
3224 * \returns non-zero if the CXTypes represent the same type and
3225 * zero otherwise.
3226 */
3227CINDEX_LINKAGE unsigned clang_equalTypes(CXType A, CXType B);
3228
3229/**
3230 * Return the canonical type for a CXType.
3231 *
3232 * Clang's type system explicitly models typedefs and all the ways
3233 * a specific type can be represented. The canonical type is the underlying
3234 * type with all the "sugar" removed. For example, if 'T' is a typedef
3235 * for 'int', the canonical type for 'T' would be 'int'.
3236 */
3237CINDEX_LINKAGE CXType clang_getCanonicalType(CXType T);
3238
3239/**
3240 * Determine whether a CXType has the "const" qualifier set,
3241 * without looking through typedefs that may have added "const" at a
3242 * different level.
3243 */
3244CINDEX_LINKAGE unsigned clang_isConstQualifiedType(CXType T);
3245
3246/**
3247 * Determine whether a CXCursor that is a macro, is
3248 * function like.
3249 */
3250CINDEX_LINKAGE unsigned clang_Cursor_isMacroFunctionLike(CXCursor C);
3251
3252/**
3253 * Determine whether a CXCursor that is a macro, is a
3254 * builtin one.
3255 */
3256CINDEX_LINKAGE unsigned clang_Cursor_isMacroBuiltin(CXCursor C);
3257
3258/**
3259 * Determine whether a CXCursor that is a function declaration, is an
3260 * inline declaration.
3261 */
3262CINDEX_LINKAGE unsigned clang_Cursor_isFunctionInlined(CXCursor C);
3263
3264/**
3265 * Determine whether a CXType has the "volatile" qualifier set,
3266 * without looking through typedefs that may have added "volatile" at
3267 * a different level.
3268 */
3269CINDEX_LINKAGE unsigned clang_isVolatileQualifiedType(CXType T);
3270
3271/**
3272 * Determine whether a CXType has the "restrict" qualifier set,
3273 * without looking through typedefs that may have added "restrict" at a
3274 * different level.
3275 */
3276CINDEX_LINKAGE unsigned clang_isRestrictQualifiedType(CXType T);
3277
3278/**
3279 * Returns the address space of the given type.
3280 */
3281CINDEX_LINKAGE unsigned clang_getAddressSpace(CXType T);
3282
3283/**
3284 * Returns the typedef name of the given type.
3285 */
3286CINDEX_LINKAGE CXString clang_getTypedefName(CXType CT);
3287
3288/**
3289 * For pointer types, returns the type of the pointee.
3290 */
3291CINDEX_LINKAGE CXType clang_getPointeeType(CXType T);
3292
3293/**
3294 * Retrieve the unqualified variant of the given type, removing as
3295 * little sugar as possible.
3296 *
3297 * For example, given the following series of typedefs:
3298 *
3299 * \code
3300 * typedef int Integer;
3301 * typedef const Integer CInteger;
3302 * typedef CInteger DifferenceType;
3303 * \endcode
3304 *
3305 * Executing \c clang_getUnqualifiedType() on a \c CXType that
3306 * represents \c DifferenceType, will desugar to a type representing
3307 * \c Integer, that has no qualifiers.
3308 *
3309 * And, executing \c clang_getUnqualifiedType() on the type of the
3310 * first argument of the following function declaration:
3311 *
3312 * \code
3313 * void foo(const int);
3314 * \endcode
3315 *
3316 * Will return a type representing \c int, removing the \c const
3317 * qualifier.
3318 *
3319 * Sugar over array types is not desugared.
3320 *
3321 * A type can be checked for qualifiers with \c
3322 * clang_isConstQualifiedType(), \c clang_isVolatileQualifiedType()
3323 * and \c clang_isRestrictQualifiedType().
3324 *
3325 * A type that resulted from a call to \c clang_getUnqualifiedType
3326 * will return \c false for all of the above calls.
3327 */
3328CINDEX_LINKAGE CXType clang_getUnqualifiedType(CXType CT);
3329
3330/**
3331 * For reference types (e.g., "const int&"), returns the type that the
3332 * reference refers to (e.g "const int").
3333 *
3334 * Otherwise, returns the type itself.
3335 *
3336 * A type that has kind \c CXType_LValueReference or
3337 * \c CXType_RValueReference is a reference type.
3338 */
3339CINDEX_LINKAGE CXType clang_getNonReferenceType(CXType CT);
3340
3341/**
3342 * Return the cursor for the declaration of the given type.
3343 */
3344CINDEX_LINKAGE CXCursor clang_getTypeDeclaration(CXType T);
3345
3346/**
3347 * Returns the Objective-C type encoding for the specified declaration.
3348 */
3349CINDEX_LINKAGE CXString clang_getDeclObjCTypeEncoding(CXCursor C);
3350
3351/**
3352 * Returns the Objective-C type encoding for the specified CXType.
3353 */
3354CINDEX_LINKAGE CXString clang_Type_getObjCEncoding(CXType type);
3355
3356/**
3357 * Retrieve the spelling of a given CXTypeKind.
3358 */
3359CINDEX_LINKAGE CXString clang_getTypeKindSpelling(enum CXTypeKind K);
3360
3361/**
3362 * Retrieve the calling convention associated with a function type.
3363 *
3364 * If a non-function type is passed in, CXCallingConv_Invalid is returned.
3365 */
3366CINDEX_LINKAGE enum CXCallingConv clang_getFunctionTypeCallingConv(CXType T);
3367
3368/**
3369 * Retrieve the return type associated with a function type.
3370 *
3371 * If a non-function type is passed in, an invalid type is returned.
3372 */
3373CINDEX_LINKAGE CXType clang_getResultType(CXType T);
3374
3375/**
3376 * Retrieve the exception specification type associated with a function type.
3377 * This is a value of type CXCursor_ExceptionSpecificationKind.
3378 *
3379 * If a non-function type is passed in, an error code of -1 is returned.
3380 */
3381CINDEX_LINKAGE int clang_getExceptionSpecificationType(CXType T);
3382
3383/**
3384 * Retrieve the number of non-variadic parameters associated with a
3385 * function type.
3386 *
3387 * If a non-function type is passed in, -1 is returned.
3388 */
3389CINDEX_LINKAGE int clang_getNumArgTypes(CXType T);
3390
3391/**
3392 * Retrieve the type of a parameter of a function type.
3393 *
3394 * If a non-function type is passed in or the function does not have enough
3395 * parameters, an invalid type is returned.
3396 */
3397CINDEX_LINKAGE CXType clang_getArgType(CXType T, unsigned i);
3398
3399/**
3400 * Retrieves the base type of the ObjCObjectType.
3401 *
3402 * If the type is not an ObjC object, an invalid type is returned.
3403 */
3404CINDEX_LINKAGE CXType clang_Type_getObjCObjectBaseType(CXType T);
3405
3406/**
3407 * Retrieve the number of protocol references associated with an ObjC object/id.
3408 *
3409 * If the type is not an ObjC object, 0 is returned.
3410 */
3411CINDEX_LINKAGE unsigned clang_Type_getNumObjCProtocolRefs(CXType T);
3412
3413/**
3414 * Retrieve the decl for a protocol reference for an ObjC object/id.
3415 *
3416 * If the type is not an ObjC object or there are not enough protocol
3417 * references, an invalid cursor is returned.
3418 */
3419CINDEX_LINKAGE CXCursor clang_Type_getObjCProtocolDecl(CXType T, unsigned i);
3420
3421/**
3422 * Retrieve the number of type arguments associated with an ObjC object.
3423 *
3424 * If the type is not an ObjC object, 0 is returned.
3425 */
3426CINDEX_LINKAGE unsigned clang_Type_getNumObjCTypeArgs(CXType T);
3427
3428/**
3429 * Retrieve a type argument associated with an ObjC object.
3430 *
3431 * If the type is not an ObjC or the index is not valid,
3432 * an invalid type is returned.
3433 */
3434CINDEX_LINKAGE CXType clang_Type_getObjCTypeArg(CXType T, unsigned i);
3435
3436/**
3437 * Return 1 if the CXType is a variadic function type, and 0 otherwise.
3438 */
3439CINDEX_LINKAGE unsigned clang_isFunctionTypeVariadic(CXType T);
3440
3441/**
3442 * Retrieve the return type associated with a given cursor.
3443 *
3444 * This only returns a valid type if the cursor refers to a function or method.
3445 */
3446CINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C);
3447
3448/**
3449 * Retrieve the exception specification type associated with a given cursor.
3450 * This is a value of type CXCursor_ExceptionSpecificationKind.
3451 *
3452 * This only returns a valid result if the cursor refers to a function or
3453 * method.
3454 */
3455CINDEX_LINKAGE int clang_getCursorExceptionSpecificationType(CXCursor C);
3456
3457/**
3458 * Return 1 if the CXType is a POD (plain old data) type, and 0
3459 * otherwise.
3460 */
3461CINDEX_LINKAGE unsigned clang_isPODType(CXType T);
3462
3463/**
3464 * Return the element type of an array, complex, or vector type.
3465 *
3466 * If a type is passed in that is not an array, complex, or vector type,
3467 * an invalid type is returned.
3468 */
3469CINDEX_LINKAGE CXType clang_getElementType(CXType T);
3470
3471/**
3472 * Return the number of elements of an array or vector type.
3473 *
3474 * If a type is passed in that is not an array or vector type,
3475 * -1 is returned.
3476 */
3477CINDEX_LINKAGE long long clang_getNumElements(CXType T);
3478
3479/**
3480 * Return the element type of an array type.
3481 *
3482 * If a non-array type is passed in, an invalid type is returned.
3483 */
3484CINDEX_LINKAGE CXType clang_getArrayElementType(CXType T);
3485
3486/**
3487 * Return the array size of a constant array.
3488 *
3489 * If a non-array type is passed in, -1 is returned.
3490 */
3491CINDEX_LINKAGE long long clang_getArraySize(CXType T);
3492
3493/**
3494 * Retrieve the type named by the qualified-id.
3495 *
3496 * If a non-elaborated type is passed in, an invalid type is returned.
3497 */
3498CINDEX_LINKAGE CXType clang_Type_getNamedType(CXType T);
3499
3500/**
3501 * Determine if a typedef is 'transparent' tag.
3502 *
3503 * A typedef is considered 'transparent' if it shares a name and spelling
3504 * location with its underlying tag type, as is the case with the NS_ENUM macro.
3505 *
3506 * \returns non-zero if transparent and zero otherwise.
3507 */
3508CINDEX_LINKAGE unsigned clang_Type_isTransparentTagTypedef(CXType T);
3509
3510enum CXTypeNullabilityKind {
3511 /**
3512 * Values of this type can never be null.
3513 */
3514 CXTypeNullability_NonNull = 0,
3515 /**
3516 * Values of this type can be null.
3517 */
3518 CXTypeNullability_Nullable = 1,
3519 /**
3520 * Whether values of this type can be null is (explicitly)
3521 * unspecified. This captures a (fairly rare) case where we
3522 * can't conclude anything about the nullability of the type even
3523 * though it has been considered.
3524 */
3525 CXTypeNullability_Unspecified = 2,
3526 /**
3527 * Nullability is not applicable to this type.
3528 */
3529 CXTypeNullability_Invalid = 3,
3530
3531 /**
3532 * Generally behaves like Nullable, except when used in a block parameter that
3533 * was imported into a swift async method. There, swift will assume that the
3534 * parameter can get null even if no error occurred. _Nullable parameters are
3535 * assumed to only get null on error.
3536 */
3537 CXTypeNullability_NullableResult = 4
3538};
3539
3540/**
3541 * Retrieve the nullability kind of a pointer type.
3542 */
3543CINDEX_LINKAGE enum CXTypeNullabilityKind clang_Type_getNullability(CXType T);
3544
3545/**
3546 * List the possible error codes for \c clang_Type_getSizeOf,
3547 * \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf and
3548 * \c clang_Cursor_getOffsetOf.
3549 *
3550 * A value of this enumeration type can be returned if the target type is not
3551 * a valid argument to sizeof, alignof or offsetof.
3552 */
3553enum CXTypeLayoutError {
3554 /**
3555 * Type is of kind CXType_Invalid.
3556 */
3557 CXTypeLayoutError_Invalid = -1,
3558 /**
3559 * The type is an incomplete Type.
3560 */
3561 CXTypeLayoutError_Incomplete = -2,
3562 /**
3563 * The type is a dependent Type.
3564 */
3565 CXTypeLayoutError_Dependent = -3,
3566 /**
3567 * The type is not a constant size type.
3568 */
3569 CXTypeLayoutError_NotConstantSize = -4,
3570 /**
3571 * The Field name is not valid for this record.
3572 */
3573 CXTypeLayoutError_InvalidFieldName = -5,
3574 /**
3575 * The type is undeduced.
3576 */
3577 CXTypeLayoutError_Undeduced = -6
3578};
3579
3580/**
3581 * Return the alignment of a type in bytes as per C++[expr.alignof]
3582 * standard.
3583 *
3584 * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
3585 * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
3586 * is returned.
3587 * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
3588 * returned.
3589 * If the type declaration is not a constant size type,
3590 * CXTypeLayoutError_NotConstantSize is returned.
3591 */
3592CINDEX_LINKAGE long long clang_Type_getAlignOf(CXType T);
3593
3594/**
3595 * Return the class type of an member pointer type.
3596 *
3597 * If a non-member-pointer type is passed in, an invalid type is returned.
3598 */
3599CINDEX_LINKAGE CXType clang_Type_getClassType(CXType T);
3600
3601/**
3602 * Return the size of a type in bytes as per C++[expr.sizeof] standard.
3603 *
3604 * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
3605 * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
3606 * is returned.
3607 * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
3608 * returned.
3609 */
3610CINDEX_LINKAGE long long clang_Type_getSizeOf(CXType T);
3611
3612/**
3613 * Return the offset of a field named S in a record of type T in bits
3614 * as it would be returned by __offsetof__ as per C++11[18.2p4]
3615 *
3616 * If the cursor is not a record field declaration, CXTypeLayoutError_Invalid
3617 * is returned.
3618 * If the field's type declaration is an incomplete type,
3619 * CXTypeLayoutError_Incomplete is returned.
3620 * If the field's type declaration is a dependent type,
3621 * CXTypeLayoutError_Dependent is returned.
3622 * If the field's name S is not found,
3623 * CXTypeLayoutError_InvalidFieldName is returned.
3624 */
3625CINDEX_LINKAGE long long clang_Type_getOffsetOf(CXType T, const char *S);
3626
3627/**
3628 * Return the type that was modified by this attributed type.
3629 *
3630 * If the type is not an attributed type, an invalid type is returned.
3631 */
3632CINDEX_LINKAGE CXType clang_Type_getModifiedType(CXType T);
3633
3634/**
3635 * Gets the type contained by this atomic type.
3636 *
3637 * If a non-atomic type is passed in, an invalid type is returned.
3638 */
3639CINDEX_LINKAGE CXType clang_Type_getValueType(CXType CT);
3640
3641/**
3642 * Return the offset of the field represented by the Cursor.
3643 *
3644 * If the cursor is not a field declaration, -1 is returned.
3645 * If the cursor semantic parent is not a record field declaration,
3646 * CXTypeLayoutError_Invalid is returned.
3647 * If the field's type declaration is an incomplete type,
3648 * CXTypeLayoutError_Incomplete is returned.
3649 * If the field's type declaration is a dependent type,
3650 * CXTypeLayoutError_Dependent is returned.
3651 * If the field's name S is not found,
3652 * CXTypeLayoutError_InvalidFieldName is returned.
3653 */
3654CINDEX_LINKAGE long long clang_Cursor_getOffsetOfField(CXCursor C);
3655
3656/**
3657 * Determine whether the given cursor represents an anonymous
3658 * tag or namespace
3659 */
3660CINDEX_LINKAGE unsigned clang_Cursor_isAnonymous(CXCursor C);
3661
3662/**
3663 * Determine whether the given cursor represents an anonymous record
3664 * declaration.
3665 */
3666CINDEX_LINKAGE unsigned clang_Cursor_isAnonymousRecordDecl(CXCursor C);
3667
3668/**
3669 * Determine whether the given cursor represents an inline namespace
3670 * declaration.
3671 */
3672CINDEX_LINKAGE unsigned clang_Cursor_isInlineNamespace(CXCursor C);
3673
3674enum CXRefQualifierKind {
3675 /** No ref-qualifier was provided. */
3676 CXRefQualifier_None = 0,
3677 /** An lvalue ref-qualifier was provided (\c &). */
3678 CXRefQualifier_LValue,
3679 /** An rvalue ref-qualifier was provided (\c &&). */
3680 CXRefQualifier_RValue
3681};
3682
3683/**
3684 * Returns the number of template arguments for given template
3685 * specialization, or -1 if type \c T is not a template specialization.
3686 */
3687CINDEX_LINKAGE int clang_Type_getNumTemplateArguments(CXType T);
3688
3689/**
3690 * Returns the type template argument of a template class specialization
3691 * at given index.
3692 *
3693 * This function only returns template type arguments and does not handle
3694 * template template arguments or variadic packs.
3695 */
3696CINDEX_LINKAGE CXType clang_Type_getTemplateArgumentAsType(CXType T,
3697 unsigned i);
3698
3699/**
3700 * Retrieve the ref-qualifier kind of a function or method.
3701 *
3702 * The ref-qualifier is returned for C++ functions or methods. For other types
3703 * or non-C++ declarations, CXRefQualifier_None is returned.
3704 */
3705CINDEX_LINKAGE enum CXRefQualifierKind clang_Type_getCXXRefQualifier(CXType T);
3706
3707/**
3708 * Returns 1 if the base class specified by the cursor with kind
3709 * CX_CXXBaseSpecifier is virtual.
3710 */
3711CINDEX_LINKAGE unsigned clang_isVirtualBase(CXCursor);
3712
3713/**
3714 * Represents the C++ access control level to a base class for a
3715 * cursor with kind CX_CXXBaseSpecifier.
3716 */
3717enum CX_CXXAccessSpecifier {
3718 CX_CXXInvalidAccessSpecifier,
3719 CX_CXXPublic,
3720 CX_CXXProtected,
3721 CX_CXXPrivate
3722};
3723
3724/**
3725 * Returns the access control level for the referenced object.
3726 *
3727 * If the cursor refers to a C++ declaration, its access control level within
3728 * its parent scope is returned. Otherwise, if the cursor refers to a base
3729 * specifier or access specifier, the specifier itself is returned.
3730 */
3731CINDEX_LINKAGE enum CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor);
3732
3733/**
3734 * Represents the storage classes as declared in the source. CX_SC_Invalid
3735 * was added for the case that the passed cursor in not a declaration.
3736 */
3737enum CX_StorageClass {
3738 CX_SC_Invalid,
3739 CX_SC_None,
3740 CX_SC_Extern,
3741 CX_SC_Static,
3742 CX_SC_PrivateExtern,
3743 CX_SC_OpenCLWorkGroupLocal,
3744 CX_SC_Auto,
3745 CX_SC_Register
3746};
3747
3748/**
3749 * Returns the storage class for a function or variable declaration.
3750 *
3751 * If the passed in Cursor is not a function or variable declaration,
3752 * CX_SC_Invalid is returned else the storage class.
3753 */
3754CINDEX_LINKAGE enum CX_StorageClass clang_Cursor_getStorageClass(CXCursor);
3755
3756/**
3757 * Determine the number of overloaded declarations referenced by a
3758 * \c CXCursor_OverloadedDeclRef cursor.
3759 *
3760 * \param cursor The cursor whose overloaded declarations are being queried.
3761 *
3762 * \returns The number of overloaded declarations referenced by \c cursor. If it
3763 * is not a \c CXCursor_OverloadedDeclRef cursor, returns 0.
3764 */
3765CINDEX_LINKAGE unsigned clang_getNumOverloadedDecls(CXCursor cursor);
3766
3767/**
3768 * Retrieve a cursor for one of the overloaded declarations referenced
3769 * by a \c CXCursor_OverloadedDeclRef cursor.
3770 *
3771 * \param cursor The cursor whose overloaded declarations are being queried.
3772 *
3773 * \param index The zero-based index into the set of overloaded declarations in
3774 * the cursor.
3775 *
3776 * \returns A cursor representing the declaration referenced by the given
3777 * \c cursor at the specified \c index. If the cursor does not have an
3778 * associated set of overloaded declarations, or if the index is out of bounds,
3779 * returns \c clang_getNullCursor();
3780 */
3781CINDEX_LINKAGE CXCursor clang_getOverloadedDecl(CXCursor cursor,
3782 unsigned index);
3783
3784/**
3785 * @}
3786 */
3787
3788/**
3789 * \defgroup CINDEX_ATTRIBUTES Information for attributes
3790 *
3791 * @{
3792 */
3793
3794/**
3795 * For cursors representing an iboutletcollection attribute,
3796 * this function returns the collection element type.
3797 *
3798 */
3799CINDEX_LINKAGE CXType clang_getIBOutletCollectionType(CXCursor);
3800
3801/**
3802 * @}
3803 */
3804
3805/**
3806 * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors
3807 *
3808 * These routines provide the ability to traverse the abstract syntax tree
3809 * using cursors.
3810 *
3811 * @{
3812 */
3813
3814/**
3815 * Describes how the traversal of the children of a particular
3816 * cursor should proceed after visiting a particular child cursor.
3817 *
3818 * A value of this enumeration type should be returned by each
3819 * \c CXCursorVisitor to indicate how clang_visitChildren() proceed.
3820 */
3821enum CXChildVisitResult {
3822 /**
3823 * Terminates the cursor traversal.
3824 */
3825 CXChildVisit_Break,
3826 /**
3827 * Continues the cursor traversal with the next sibling of
3828 * the cursor just visited, without visiting its children.
3829 */
3830 CXChildVisit_Continue,
3831 /**
3832 * Recursively traverse the children of this cursor, using
3833 * the same visitor and client data.
3834 */
3835 CXChildVisit_Recurse
3836};
3837
3838/**
3839 * Visitor invoked for each cursor found by a traversal.
3840 *
3841 * This visitor function will be invoked for each cursor found by
3842 * clang_visitCursorChildren(). Its first argument is the cursor being
3843 * visited, its second argument is the parent visitor for that cursor,
3844 * and its third argument is the client data provided to
3845 * clang_visitCursorChildren().
3846 *
3847 * The visitor should return one of the \c CXChildVisitResult values
3848 * to direct clang_visitCursorChildren().
3849 */
3850typedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor,
3851 CXCursor parent,
3852 CXClientData client_data);
3853
3854/**
3855 * Visit the children of a particular cursor.
3856 *
3857 * This function visits all the direct children of the given cursor,
3858 * invoking the given \p visitor function with the cursors of each
3859 * visited child. The traversal may be recursive, if the visitor returns
3860 * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if
3861 * the visitor returns \c CXChildVisit_Break.
3862 *
3863 * \param parent the cursor whose child may be visited. All kinds of
3864 * cursors can be visited, including invalid cursors (which, by
3865 * definition, have no children).
3866 *
3867 * \param visitor the visitor function that will be invoked for each
3868 * child of \p parent.
3869 *
3870 * \param client_data pointer data supplied by the client, which will
3871 * be passed to the visitor each time it is invoked.
3872 *
3873 * \returns a non-zero value if the traversal was terminated
3874 * prematurely by the visitor returning \c CXChildVisit_Break.
3875 */
3876CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent,
3877 CXCursorVisitor visitor,
3878 CXClientData client_data);
3879/**
3880 * Visitor invoked for each cursor found by a traversal.
3881 *
3882 * This visitor block will be invoked for each cursor found by
3883 * clang_visitChildrenWithBlock(). Its first argument is the cursor being
3884 * visited, its second argument is the parent visitor for that cursor.
3885 *
3886 * The visitor should return one of the \c CXChildVisitResult values
3887 * to direct clang_visitChildrenWithBlock().
3888 */
3889#if __has_feature(blocks)
3890typedef enum CXChildVisitResult (^CXCursorVisitorBlock)(CXCursor cursor,
3891 CXCursor parent);
3892#else
3893typedef struct _CXChildVisitResult *CXCursorVisitorBlock;
3894#endif
3895
3896/**
3897 * Visits the children of a cursor using the specified block. Behaves
3898 * identically to clang_visitChildren() in all other respects.
3899 */
3900CINDEX_LINKAGE unsigned
3901clang_visitChildrenWithBlock(CXCursor parent, CXCursorVisitorBlock block);
3902
3903/**
3904 * @}
3905 */
3906
3907/**
3908 * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST
3909 *
3910 * These routines provide the ability to determine references within and
3911 * across translation units, by providing the names of the entities referenced
3912 * by cursors, follow reference cursors to the declarations they reference,
3913 * and associate declarations with their definitions.
3914 *
3915 * @{
3916 */
3917
3918/**
3919 * Retrieve a Unified Symbol Resolution (USR) for the entity referenced
3920 * by the given cursor.
3921 *
3922 * A Unified Symbol Resolution (USR) is a string that identifies a particular
3923 * entity (function, class, variable, etc.) within a program. USRs can be
3924 * compared across translation units to determine, e.g., when references in
3925 * one translation refer to an entity defined in another translation unit.
3926 */
3927CINDEX_LINKAGE CXString clang_getCursorUSR(CXCursor);
3928
3929/**
3930 * Construct a USR for a specified Objective-C class.
3931 */
3932CINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name);
3933
3934/**
3935 * Construct a USR for a specified Objective-C category.
3936 */
3937CINDEX_LINKAGE CXString clang_constructUSR_ObjCCategory(
3938 const char *class_name, const char *category_name);
3939
3940/**
3941 * Construct a USR for a specified Objective-C protocol.
3942 */
3943CINDEX_LINKAGE CXString
3944clang_constructUSR_ObjCProtocol(const char *protocol_name);
3945
3946/**
3947 * Construct a USR for a specified Objective-C instance variable and
3948 * the USR for its containing class.
3949 */
3950CINDEX_LINKAGE CXString clang_constructUSR_ObjCIvar(const char *name,
3951 CXString classUSR);
3952
3953/**
3954 * Construct a USR for a specified Objective-C method and
3955 * the USR for its containing class.
3956 */
3957CINDEX_LINKAGE CXString clang_constructUSR_ObjCMethod(const char *name,
3958 unsigned isInstanceMethod,
3959 CXString classUSR);
3960
3961/**
3962 * Construct a USR for a specified Objective-C property and the USR
3963 * for its containing class.
3964 */
3965CINDEX_LINKAGE CXString clang_constructUSR_ObjCProperty(const char *property,
3966 CXString classUSR);
3967
3968/**
3969 * Retrieve a name for the entity referenced by this cursor.
3970 */
3971CINDEX_LINKAGE CXString clang_getCursorSpelling(CXCursor);
3972
3973/**
3974 * Retrieve a range for a piece that forms the cursors spelling name.
3975 * Most of the times there is only one range for the complete spelling but for
3976 * Objective-C methods and Objective-C message expressions, there are multiple
3977 * pieces for each selector identifier.
3978 *
3979 * \param pieceIndex the index of the spelling name piece. If this is greater
3980 * than the actual number of pieces, it will return a NULL (invalid) range.
3981 *
3982 * \param options Reserved.
3983 */
3984CINDEX_LINKAGE CXSourceRange clang_Cursor_getSpellingNameRange(
3985 CXCursor, unsigned pieceIndex, unsigned options);
3986
3987/**
3988 * Opaque pointer representing a policy that controls pretty printing
3989 * for \c clang_getCursorPrettyPrinted.
3990 */
3991typedef void *CXPrintingPolicy;
3992
3993/**
3994 * Properties for the printing policy.
3995 *
3996 * See \c clang::PrintingPolicy for more information.
3997 */
3998enum CXPrintingPolicyProperty {
3999 CXPrintingPolicy_Indentation,
4000 CXPrintingPolicy_SuppressSpecifiers,
4001 CXPrintingPolicy_SuppressTagKeyword,
4002 CXPrintingPolicy_IncludeTagDefinition,
4003 CXPrintingPolicy_SuppressScope,
4004 CXPrintingPolicy_SuppressUnwrittenScope,
4005 CXPrintingPolicy_SuppressInitializers,
4006 CXPrintingPolicy_ConstantArraySizeAsWritten,
4007 CXPrintingPolicy_AnonymousTagLocations,
4008 CXPrintingPolicy_SuppressStrongLifetime,
4009 CXPrintingPolicy_SuppressLifetimeQualifiers,
4010 CXPrintingPolicy_SuppressTemplateArgsInCXXConstructors,
4011 CXPrintingPolicy_Bool,
4012 CXPrintingPolicy_Restrict,
4013 CXPrintingPolicy_Alignof,
4014 CXPrintingPolicy_UnderscoreAlignof,
4015 CXPrintingPolicy_UseVoidForZeroParams,
4016 CXPrintingPolicy_TerseOutput,
4017 CXPrintingPolicy_PolishForDeclaration,
4018 CXPrintingPolicy_Half,
4019 CXPrintingPolicy_MSWChar,
4020 CXPrintingPolicy_IncludeNewlines,
4021 CXPrintingPolicy_MSVCFormatting,
4022 CXPrintingPolicy_ConstantsAsWritten,
4023 CXPrintingPolicy_SuppressImplicitBase,
4024 CXPrintingPolicy_FullyQualifiedName,
4025
4026 CXPrintingPolicy_LastProperty = CXPrintingPolicy_FullyQualifiedName
4027};
4028
4029/**
4030 * Get a property value for the given printing policy.
4031 */
4032CINDEX_LINKAGE unsigned
4033clang_PrintingPolicy_getProperty(CXPrintingPolicy Policy,
4034 enum CXPrintingPolicyProperty Property);
4035
4036/**
4037 * Set a property value for the given printing policy.
4038 */
4039CINDEX_LINKAGE void
4040clang_PrintingPolicy_setProperty(CXPrintingPolicy Policy,
4041 enum CXPrintingPolicyProperty Property,
4042 unsigned Value);
4043
4044/**
4045 * Retrieve the default policy for the cursor.
4046 *
4047 * The policy should be released after use with \c
4048 * clang_PrintingPolicy_dispose.
4049 */
4050CINDEX_LINKAGE CXPrintingPolicy clang_getCursorPrintingPolicy(CXCursor);
4051
4052/**
4053 * Release a printing policy.
4054 */
4055CINDEX_LINKAGE void clang_PrintingPolicy_dispose(CXPrintingPolicy Policy);
4056
4057/**
4058 * Pretty print declarations.
4059 *
4060 * \param Cursor The cursor representing a declaration.
4061 *
4062 * \param Policy The policy to control the entities being printed. If
4063 * NULL, a default policy is used.
4064 *
4065 * \returns The pretty printed declaration or the empty string for
4066 * other cursors.
4067 */
4068CINDEX_LINKAGE CXString clang_getCursorPrettyPrinted(CXCursor Cursor,
4069 CXPrintingPolicy Policy);
4070
4071/**
4072 * Retrieve the display name for the entity referenced by this cursor.
4073 *
4074 * The display name contains extra information that helps identify the cursor,
4075 * such as the parameters of a function or template or the arguments of a
4076 * class template specialization.
4077 */
4078CINDEX_LINKAGE CXString clang_getCursorDisplayName(CXCursor);
4079
4080/** For a cursor that is a reference, retrieve a cursor representing the
4081 * entity that it references.
4082 *
4083 * Reference cursors refer to other entities in the AST. For example, an
4084 * Objective-C superclass reference cursor refers to an Objective-C class.
4085 * This function produces the cursor for the Objective-C class from the
4086 * cursor for the superclass reference. If the input cursor is a declaration or
4087 * definition, it returns that declaration or definition unchanged.
4088 * Otherwise, returns the NULL cursor.
4089 */
4090CINDEX_LINKAGE CXCursor clang_getCursorReferenced(CXCursor);
4091
4092/**
4093 * For a cursor that is either a reference to or a declaration
4094 * of some entity, retrieve a cursor that describes the definition of
4095 * that entity.
4096 *
4097 * Some entities can be declared multiple times within a translation
4098 * unit, but only one of those declarations can also be a
4099 * definition. For example, given:
4100 *
4101 * \code
4102 * int f(int, int);
4103 * int g(int x, int y) { return f(x, y); }
4104 * int f(int a, int b) { return a + b; }
4105 * int f(int, int);
4106 * \endcode
4107 *
4108 * there are three declarations of the function "f", but only the
4109 * second one is a definition. The clang_getCursorDefinition()
4110 * function will take any cursor pointing to a declaration of "f"
4111 * (the first or fourth lines of the example) or a cursor referenced
4112 * that uses "f" (the call to "f' inside "g") and will return a
4113 * declaration cursor pointing to the definition (the second "f"
4114 * declaration).
4115 *
4116 * If given a cursor for which there is no corresponding definition,
4117 * e.g., because there is no definition of that entity within this
4118 * translation unit, returns a NULL cursor.
4119 */
4120CINDEX_LINKAGE CXCursor clang_getCursorDefinition(CXCursor);
4121
4122/**
4123 * Determine whether the declaration pointed to by this cursor
4124 * is also a definition of that entity.
4125 */
4126CINDEX_LINKAGE unsigned clang_isCursorDefinition(CXCursor);
4127
4128/**
4129 * Retrieve the canonical cursor corresponding to the given cursor.
4130 *
4131 * In the C family of languages, many kinds of entities can be declared several
4132 * times within a single translation unit. For example, a structure type can
4133 * be forward-declared (possibly multiple times) and later defined:
4134 *
4135 * \code
4136 * struct X;
4137 * struct X;
4138 * struct X {
4139 * int member;
4140 * };
4141 * \endcode
4142 *
4143 * The declarations and the definition of \c X are represented by three
4144 * different cursors, all of which are declarations of the same underlying
4145 * entity. One of these cursor is considered the "canonical" cursor, which
4146 * is effectively the representative for the underlying entity. One can
4147 * determine if two cursors are declarations of the same underlying entity by
4148 * comparing their canonical cursors.
4149 *
4150 * \returns The canonical cursor for the entity referred to by the given cursor.
4151 */
4152CINDEX_LINKAGE CXCursor clang_getCanonicalCursor(CXCursor);
4153
4154/**
4155 * If the cursor points to a selector identifier in an Objective-C
4156 * method or message expression, this returns the selector index.
4157 *
4158 * After getting a cursor with #clang_getCursor, this can be called to
4159 * determine if the location points to a selector identifier.
4160 *
4161 * \returns The selector index if the cursor is an Objective-C method or message
4162 * expression and the cursor is pointing to a selector identifier, or -1
4163 * otherwise.
4164 */
4165CINDEX_LINKAGE int clang_Cursor_getObjCSelectorIndex(CXCursor);
4166
4167/**
4168 * Given a cursor pointing to a C++ method call or an Objective-C
4169 * message, returns non-zero if the method/message is "dynamic", meaning:
4170 *
4171 * For a C++ method: the call is virtual.
4172 * For an Objective-C message: the receiver is an object instance, not 'super'
4173 * or a specific class.
4174 *
4175 * If the method/message is "static" or the cursor does not point to a
4176 * method/message, it will return zero.
4177 */
4178CINDEX_LINKAGE int clang_Cursor_isDynamicCall(CXCursor C);
4179
4180/**
4181 * Given a cursor pointing to an Objective-C message or property
4182 * reference, or C++ method call, returns the CXType of the receiver.
4183 */
4184CINDEX_LINKAGE CXType clang_Cursor_getReceiverType(CXCursor C);
4185
4186/**
4187 * Property attributes for a \c CXCursor_ObjCPropertyDecl.
4188 */
4189typedef enum {
4190 CXObjCPropertyAttr_noattr = 0x00,
4191 CXObjCPropertyAttr_readonly = 0x01,
4192 CXObjCPropertyAttr_getter = 0x02,
4193 CXObjCPropertyAttr_assign = 0x04,
4194 CXObjCPropertyAttr_readwrite = 0x08,
4195 CXObjCPropertyAttr_retain = 0x10,
4196 CXObjCPropertyAttr_copy = 0x20,
4197 CXObjCPropertyAttr_nonatomic = 0x40,
4198 CXObjCPropertyAttr_setter = 0x80,
4199 CXObjCPropertyAttr_atomic = 0x100,
4200 CXObjCPropertyAttr_weak = 0x200,
4201 CXObjCPropertyAttr_strong = 0x400,
4202 CXObjCPropertyAttr_unsafe_unretained = 0x800,
4203 CXObjCPropertyAttr_class = 0x1000
4204} CXObjCPropertyAttrKind;
4205
4206/**
4207 * Given a cursor that represents a property declaration, return the
4208 * associated property attributes. The bits are formed from
4209 * \c CXObjCPropertyAttrKind.
4210 *
4211 * \param reserved Reserved for future use, pass 0.
4212 */
4213CINDEX_LINKAGE unsigned
4214clang_Cursor_getObjCPropertyAttributes(CXCursor C, unsigned reserved);
4215
4216/**
4217 * Given a cursor that represents a property declaration, return the
4218 * name of the method that implements the getter.
4219 */
4220CINDEX_LINKAGE CXString clang_Cursor_getObjCPropertyGetterName(CXCursor C);
4221
4222/**
4223 * Given a cursor that represents a property declaration, return the
4224 * name of the method that implements the setter, if any.
4225 */
4226CINDEX_LINKAGE CXString clang_Cursor_getObjCPropertySetterName(CXCursor C);
4227
4228/**
4229 * 'Qualifiers' written next to the return and parameter types in
4230 * Objective-C method declarations.
4231 */
4232typedef enum {
4233 CXObjCDeclQualifier_None = 0x0,
4234 CXObjCDeclQualifier_In = 0x1,
4235 CXObjCDeclQualifier_Inout = 0x2,
4236 CXObjCDeclQualifier_Out = 0x4,
4237 CXObjCDeclQualifier_Bycopy = 0x8,
4238 CXObjCDeclQualifier_Byref = 0x10,
4239 CXObjCDeclQualifier_Oneway = 0x20
4240} CXObjCDeclQualifierKind;
4241
4242/**
4243 * Given a cursor that represents an Objective-C method or parameter
4244 * declaration, return the associated Objective-C qualifiers for the return
4245 * type or the parameter respectively. The bits are formed from
4246 * CXObjCDeclQualifierKind.
4247 */
4248CINDEX_LINKAGE unsigned clang_Cursor_getObjCDeclQualifiers(CXCursor C);
4249
4250/**
4251 * Given a cursor that represents an Objective-C method or property
4252 * declaration, return non-zero if the declaration was affected by "\@optional".
4253 * Returns zero if the cursor is not such a declaration or it is "\@required".
4254 */
4255CINDEX_LINKAGE unsigned clang_Cursor_isObjCOptional(CXCursor C);
4256
4257/**
4258 * Returns non-zero if the given cursor is a variadic function or method.
4259 */
4260CINDEX_LINKAGE unsigned clang_Cursor_isVariadic(CXCursor C);
4261
4262/**
4263 * Returns non-zero if the given cursor points to a symbol marked with
4264 * external_source_symbol attribute.
4265 *
4266 * \param language If non-NULL, and the attribute is present, will be set to
4267 * the 'language' string from the attribute.
4268 *
4269 * \param definedIn If non-NULL, and the attribute is present, will be set to
4270 * the 'definedIn' string from the attribute.
4271 *
4272 * \param isGenerated If non-NULL, and the attribute is present, will be set to
4273 * non-zero if the 'generated_declaration' is set in the attribute.
4274 */
4275CINDEX_LINKAGE unsigned clang_Cursor_isExternalSymbol(CXCursor C,
4276 CXString *language,
4277 CXString *definedIn,
4278 unsigned *isGenerated);
4279
4280/**
4281 * Given a cursor that represents a declaration, return the associated
4282 * comment's source range. The range may include multiple consecutive comments
4283 * with whitespace in between.
4284 */
4285CINDEX_LINKAGE CXSourceRange clang_Cursor_getCommentRange(CXCursor C);
4286
4287/**
4288 * Given a cursor that represents a declaration, return the associated
4289 * comment text, including comment markers.
4290 */
4291CINDEX_LINKAGE CXString clang_Cursor_getRawCommentText(CXCursor C);
4292
4293/**
4294 * Given a cursor that represents a documentable entity (e.g.,
4295 * declaration), return the associated \paragraph; otherwise return the
4296 * first paragraph.
4297 */
4298CINDEX_LINKAGE CXString clang_Cursor_getBriefCommentText(CXCursor C);
4299
4300/**
4301 * @}
4302 */
4303
4304/** \defgroup CINDEX_MANGLE Name Mangling API Functions
4305 *
4306 * @{
4307 */
4308
4309/**
4310 * Retrieve the CXString representing the mangled name of the cursor.
4311 */
4312CINDEX_LINKAGE CXString clang_Cursor_getMangling(CXCursor);
4313
4314/**
4315 * Retrieve the CXStrings representing the mangled symbols of the C++
4316 * constructor or destructor at the cursor.
4317 */
4318CINDEX_LINKAGE CXStringSet *clang_Cursor_getCXXManglings(CXCursor);
4319
4320/**
4321 * Retrieve the CXStrings representing the mangled symbols of the ObjC
4322 * class interface or implementation at the cursor.
4323 */
4324CINDEX_LINKAGE CXStringSet *clang_Cursor_getObjCManglings(CXCursor);
4325
4326/**
4327 * @}
4328 */
4329
4330/**
4331 * \defgroup CINDEX_MODULE Module introspection
4332 *
4333 * The functions in this group provide access to information about modules.
4334 *
4335 * @{
4336 */
4337
4338typedef void *CXModule;
4339
4340/**
4341 * Given a CXCursor_ModuleImportDecl cursor, return the associated module.
4342 */
4343CINDEX_LINKAGE CXModule clang_Cursor_getModule(CXCursor C);
4344
4345/**
4346 * Given a CXFile header file, return the module that contains it, if one
4347 * exists.
4348 */
4349CINDEX_LINKAGE CXModule clang_getModuleForFile(CXTranslationUnit, CXFile);
4350
4351/**
4352 * \param Module a module object.
4353 *
4354 * \returns the module file where the provided module object came from.
4355 */
4356CINDEX_LINKAGE CXFile clang_Module_getASTFile(CXModule Module);
4357
4358/**
4359 * \param Module a module object.
4360 *
4361 * \returns the parent of a sub-module or NULL if the given module is top-level,
4362 * e.g. for 'std.vector' it will return the 'std' module.
4363 */
4364CINDEX_LINKAGE CXModule clang_Module_getParent(CXModule Module);
4365
4366/**
4367 * \param Module a module object.
4368 *
4369 * \returns the name of the module, e.g. for the 'std.vector' sub-module it
4370 * will return "vector".
4371 */
4372CINDEX_LINKAGE CXString clang_Module_getName(CXModule Module);
4373
4374/**
4375 * \param Module a module object.
4376 *
4377 * \returns the full name of the module, e.g. "std.vector".
4378 */
4379CINDEX_LINKAGE CXString clang_Module_getFullName(CXModule Module);
4380
4381/**
4382 * \param Module a module object.
4383 *
4384 * \returns non-zero if the module is a system one.
4385 */
4386CINDEX_LINKAGE int clang_Module_isSystem(CXModule Module);
4387
4388/**
4389 * \param Module a module object.
4390 *
4391 * \returns the number of top level headers associated with this module.
4392 */
4393CINDEX_LINKAGE unsigned clang_Module_getNumTopLevelHeaders(CXTranslationUnit,
4394 CXModule Module);
4395
4396/**
4397 * \param Module a module object.
4398 *
4399 * \param Index top level header index (zero-based).
4400 *
4401 * \returns the specified top level header associated with the module.
4402 */
4403CINDEX_LINKAGE
4404CXFile clang_Module_getTopLevelHeader(CXTranslationUnit, CXModule Module,
4405 unsigned Index);
4406
4407/**
4408 * @}
4409 */
4410
4411/**
4412 * \defgroup CINDEX_CPP C++ AST introspection
4413 *
4414 * The routines in this group provide access information in the ASTs specific
4415 * to C++ language features.
4416 *
4417 * @{
4418 */
4419
4420/**
4421 * Determine if a C++ constructor is a converting constructor.
4422 */
4423CINDEX_LINKAGE unsigned
4424clang_CXXConstructor_isConvertingConstructor(CXCursor C);
4425
4426/**
4427 * Determine if a C++ constructor is a copy constructor.
4428 */
4429CINDEX_LINKAGE unsigned clang_CXXConstructor_isCopyConstructor(CXCursor C);
4430
4431/**
4432 * Determine if a C++ constructor is the default constructor.
4433 */
4434CINDEX_LINKAGE unsigned clang_CXXConstructor_isDefaultConstructor(CXCursor C);
4435
4436/**
4437 * Determine if a C++ constructor is a move constructor.
4438 */
4439CINDEX_LINKAGE unsigned clang_CXXConstructor_isMoveConstructor(CXCursor C);
4440
4441/**
4442 * Determine if a C++ field is declared 'mutable'.
4443 */
4444CINDEX_LINKAGE unsigned clang_CXXField_isMutable(CXCursor C);
4445
4446/**
4447 * Determine if a C++ method is declared '= default'.
4448 */
4449CINDEX_LINKAGE unsigned clang_CXXMethod_isDefaulted(CXCursor C);
4450
4451/**
4452 * Determine if a C++ method is declared '= delete'.
4453 */
4454CINDEX_LINKAGE unsigned clang_CXXMethod_isDeleted(CXCursor C);
4455
4456/**
4457 * Determine if a C++ member function or member function template is
4458 * pure virtual.
4459 */
4460CINDEX_LINKAGE unsigned clang_CXXMethod_isPureVirtual(CXCursor C);
4461
4462/**
4463 * Determine if a C++ member function or member function template is
4464 * declared 'static'.
4465 */
4466CINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C);
4467
4468/**
4469 * Determine if a C++ member function or member function template is
4470 * explicitly declared 'virtual' or if it overrides a virtual method from
4471 * one of the base classes.
4472 */
4473CINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual(CXCursor C);
4474
4475/**
4476 * Determine if a C++ member function is a copy-assignment operator,
4477 * returning 1 if such is the case and 0 otherwise.
4478 *
4479 * > A copy-assignment operator `X::operator=` is a non-static,
4480 * > non-template member function of _class_ `X` with exactly one
4481 * > parameter of type `X`, `X&`, `const X&`, `volatile X&` or `const
4482 * > volatile X&`.
4483 *
4484 * That is, for example, the `operator=` in:
4485 *
4486 * class Foo {
4487 * bool operator=(const volatile Foo&);
4488 * };
4489 *
4490 * Is a copy-assignment operator, while the `operator=` in:
4491 *
4492 * class Bar {
4493 * bool operator=(const int&);
4494 * };
4495 *
4496 * Is not.
4497 */
4498CINDEX_LINKAGE unsigned clang_CXXMethod_isCopyAssignmentOperator(CXCursor C);
4499
4500/**
4501 * Determine if a C++ member function is a move-assignment operator,
4502 * returning 1 if such is the case and 0 otherwise.
4503 *
4504 * > A move-assignment operator `X::operator=` is a non-static,
4505 * > non-template member function of _class_ `X` with exactly one
4506 * > parameter of type `X&&`, `const X&&`, `volatile X&&` or `const
4507 * > volatile X&&`.
4508 *
4509 * That is, for example, the `operator=` in:
4510 *
4511 * class Foo {
4512 * bool operator=(const volatile Foo&&);
4513 * };
4514 *
4515 * Is a move-assignment operator, while the `operator=` in:
4516 *
4517 * class Bar {
4518 * bool operator=(const int&&);
4519 * };
4520 *
4521 * Is not.
4522 */
4523CINDEX_LINKAGE unsigned clang_CXXMethod_isMoveAssignmentOperator(CXCursor C);
4524
4525/**
4526 * Determines if a C++ constructor or conversion function was declared
4527 * explicit, returning 1 if such is the case and 0 otherwise.
4528 *
4529 * Constructors or conversion functions are declared explicit through
4530 * the use of the explicit specifier.
4531 *
4532 * For example, the following constructor and conversion function are
4533 * not explicit as they lack the explicit specifier:
4534 *
4535 * class Foo {
4536 * Foo();
4537 * operator int();
4538 * };
4539 *
4540 * While the following constructor and conversion function are
4541 * explicit as they are declared with the explicit specifier.
4542 *
4543 * class Foo {
4544 * explicit Foo();
4545 * explicit operator int();
4546 * };
4547 *
4548 * This function will return 0 when given a cursor pointing to one of
4549 * the former declarations and it will return 1 for a cursor pointing
4550 * to the latter declarations.
4551 *
4552 * The explicit specifier allows the user to specify a
4553 * conditional compile-time expression whose value decides
4554 * whether the marked element is explicit or not.
4555 *
4556 * For example:
4557 *
4558 * constexpr bool foo(int i) { return i % 2 == 0; }
4559 *
4560 * class Foo {
4561 * explicit(foo(1)) Foo();
4562 * explicit(foo(2)) operator int();
4563 * }
4564 *
4565 * This function will return 0 for the constructor and 1 for
4566 * the conversion function.
4567 */
4568CINDEX_LINKAGE unsigned clang_CXXMethod_isExplicit(CXCursor C);
4569
4570/**
4571 * Determine if a C++ record is abstract, i.e. whether a class or struct
4572 * has a pure virtual member function.
4573 */
4574CINDEX_LINKAGE unsigned clang_CXXRecord_isAbstract(CXCursor C);
4575
4576/**
4577 * Determine if an enum declaration refers to a scoped enum.
4578 */
4579CINDEX_LINKAGE unsigned clang_EnumDecl_isScoped(CXCursor C);
4580
4581/**
4582 * Determine if a C++ member function or member function template is
4583 * declared 'const'.
4584 */
4585CINDEX_LINKAGE unsigned clang_CXXMethod_isConst(CXCursor C);
4586
4587/**
4588 * Given a cursor that represents a template, determine
4589 * the cursor kind of the specializations would be generated by instantiating
4590 * the template.
4591 *
4592 * This routine can be used to determine what flavor of function template,
4593 * class template, or class template partial specialization is stored in the
4594 * cursor. For example, it can describe whether a class template cursor is
4595 * declared with "struct", "class" or "union".
4596 *
4597 * \param C The cursor to query. This cursor should represent a template
4598 * declaration.
4599 *
4600 * \returns The cursor kind of the specializations that would be generated
4601 * by instantiating the template \p C. If \p C is not a template, returns
4602 * \c CXCursor_NoDeclFound.
4603 */
4604CINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind(CXCursor C);
4605
4606/**
4607 * Given a cursor that may represent a specialization or instantiation
4608 * of a template, retrieve the cursor that represents the template that it
4609 * specializes or from which it was instantiated.
4610 *
4611 * This routine determines the template involved both for explicit
4612 * specializations of templates and for implicit instantiations of the template,
4613 * both of which are referred to as "specializations". For a class template
4614 * specialization (e.g., \c std::vector<bool>), this routine will return
4615 * either the primary template (\c std::vector) or, if the specialization was
4616 * instantiated from a class template partial specialization, the class template
4617 * partial specialization. For a class template partial specialization and a
4618 * function template specialization (including instantiations), this
4619 * this routine will return the specialized template.
4620 *
4621 * For members of a class template (e.g., member functions, member classes, or
4622 * static data members), returns the specialized or instantiated member.
4623 * Although not strictly "templates" in the C++ language, members of class
4624 * templates have the same notions of specializations and instantiations that
4625 * templates do, so this routine treats them similarly.
4626 *
4627 * \param C A cursor that may be a specialization of a template or a member
4628 * of a template.
4629 *
4630 * \returns If the given cursor is a specialization or instantiation of a
4631 * template or a member thereof, the template or member that it specializes or
4632 * from which it was instantiated. Otherwise, returns a NULL cursor.
4633 */
4634CINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate(CXCursor C);
4635
4636/**
4637 * Given a cursor that references something else, return the source range
4638 * covering that reference.
4639 *
4640 * \param C A cursor pointing to a member reference, a declaration reference, or
4641 * an operator call.
4642 * \param NameFlags A bitset with three independent flags:
4643 * CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and
4644 * CXNameRange_WantSinglePiece.
4645 * \param PieceIndex For contiguous names or when passing the flag
4646 * CXNameRange_WantSinglePiece, only one piece with index 0 is
4647 * available. When the CXNameRange_WantSinglePiece flag is not passed for a
4648 * non-contiguous names, this index can be used to retrieve the individual
4649 * pieces of the name. See also CXNameRange_WantSinglePiece.
4650 *
4651 * \returns The piece of the name pointed to by the given cursor. If there is no
4652 * name, or if the PieceIndex is out-of-range, a null-cursor will be returned.
4653 */
4654CINDEX_LINKAGE CXSourceRange clang_getCursorReferenceNameRange(
4655 CXCursor C, unsigned NameFlags, unsigned PieceIndex);
4656
4657enum CXNameRefFlags {
4658 /**
4659 * Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the
4660 * range.
4661 */
4662 CXNameRange_WantQualifier = 0x1,
4663
4664 /**
4665 * Include the explicit template arguments, e.g. \<int> in x.f<int>,
4666 * in the range.
4667 */
4668 CXNameRange_WantTemplateArgs = 0x2,
4669
4670 /**
4671 * If the name is non-contiguous, return the full spanning range.
4672 *
4673 * Non-contiguous names occur in Objective-C when a selector with two or more
4674 * parameters is used, or in C++ when using an operator:
4675 * \code
4676 * [object doSomething:here withValue:there]; // Objective-C
4677 * return some_vector[1]; // C++
4678 * \endcode
4679 */
4680 CXNameRange_WantSinglePiece = 0x4
4681};
4682
4683/**
4684 * @}
4685 */
4686
4687/**
4688 * \defgroup CINDEX_LEX Token extraction and manipulation
4689 *
4690 * The routines in this group provide access to the tokens within a
4691 * translation unit, along with a semantic mapping of those tokens to
4692 * their corresponding cursors.
4693 *
4694 * @{
4695 */
4696
4697/**
4698 * Describes a kind of token.
4699 */
4700typedef enum CXTokenKind {
4701 /**
4702 * A token that contains some kind of punctuation.
4703 */
4704 CXToken_Punctuation,
4705
4706 /**
4707 * A language keyword.
4708 */
4709 CXToken_Keyword,
4710
4711 /**
4712 * An identifier (that is not a keyword).
4713 */
4714 CXToken_Identifier,
4715
4716 /**
4717 * A numeric, string, or character literal.
4718 */
4719 CXToken_Literal,
4720
4721 /**
4722 * A comment.
4723 */
4724 CXToken_Comment
4725} CXTokenKind;
4726
4727/**
4728 * Describes a single preprocessing token.
4729 */
4730typedef struct {
4731 unsigned int_data[4];
4732 void *ptr_data;
4733} CXToken;
4734
4735/**
4736 * Get the raw lexical token starting with the given location.
4737 *
4738 * \param TU the translation unit whose text is being tokenized.
4739 *
4740 * \param Location the source location with which the token starts.
4741 *
4742 * \returns The token starting with the given location or NULL if no such token
4743 * exist. The returned pointer must be freed with clang_disposeTokens before the
4744 * translation unit is destroyed.
4745 */
4746CINDEX_LINKAGE CXToken *clang_getToken(CXTranslationUnit TU,
4747 CXSourceLocation Location);
4748
4749/**
4750 * Determine the kind of the given token.
4751 */
4752CINDEX_LINKAGE CXTokenKind clang_getTokenKind(CXToken);
4753
4754/**
4755 * Determine the spelling of the given token.
4756 *
4757 * The spelling of a token is the textual representation of that token, e.g.,
4758 * the text of an identifier or keyword.
4759 */
4760CINDEX_LINKAGE CXString clang_getTokenSpelling(CXTranslationUnit, CXToken);
4761
4762/**
4763 * Retrieve the source location of the given token.
4764 */
4765CINDEX_LINKAGE CXSourceLocation clang_getTokenLocation(CXTranslationUnit,
4766 CXToken);
4767
4768/**
4769 * Retrieve a source range that covers the given token.
4770 */
4771CINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken);
4772
4773/**
4774 * Tokenize the source code described by the given range into raw
4775 * lexical tokens.
4776 *
4777 * \param TU the translation unit whose text is being tokenized.
4778 *
4779 * \param Range the source range in which text should be tokenized. All of the
4780 * tokens produced by tokenization will fall within this source range,
4781 *
4782 * \param Tokens this pointer will be set to point to the array of tokens
4783 * that occur within the given source range. The returned pointer must be
4784 * freed with clang_disposeTokens() before the translation unit is destroyed.
4785 *
4786 * \param NumTokens will be set to the number of tokens in the \c *Tokens
4787 * array.
4788 *
4789 */
4790CINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
4791 CXToken **Tokens, unsigned *NumTokens);
4792
4793/**
4794 * Annotate the given set of tokens by providing cursors for each token
4795 * that can be mapped to a specific entity within the abstract syntax tree.
4796 *
4797 * This token-annotation routine is equivalent to invoking
4798 * clang_getCursor() for the source locations of each of the
4799 * tokens. The cursors provided are filtered, so that only those
4800 * cursors that have a direct correspondence to the token are
4801 * accepted. For example, given a function call \c f(x),
4802 * clang_getCursor() would provide the following cursors:
4803 *
4804 * * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'.
4805 * * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'.
4806 * * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'.
4807 *
4808 * Only the first and last of these cursors will occur within the
4809 * annotate, since the tokens "f" and "x' directly refer to a function
4810 * and a variable, respectively, but the parentheses are just a small
4811 * part of the full syntax of the function call expression, which is
4812 * not provided as an annotation.
4813 *
4814 * \param TU the translation unit that owns the given tokens.
4815 *
4816 * \param Tokens the set of tokens to annotate.
4817 *
4818 * \param NumTokens the number of tokens in \p Tokens.
4819 *
4820 * \param Cursors an array of \p NumTokens cursors, whose contents will be
4821 * replaced with the cursors corresponding to each token.
4822 */
4823CINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU, CXToken *Tokens,
4824 unsigned NumTokens, CXCursor *Cursors);
4825
4826/**
4827 * Free the given set of tokens.
4828 */
4829CINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU, CXToken *Tokens,
4830 unsigned NumTokens);
4831
4832/**
4833 * @}
4834 */
4835
4836/**
4837 * \defgroup CINDEX_DEBUG Debugging facilities
4838 *
4839 * These routines are used for testing and debugging, only, and should not
4840 * be relied upon.
4841 *
4842 * @{
4843 */
4844
4845/* for debug/testing */
4846CINDEX_LINKAGE CXString clang_getCursorKindSpelling(enum CXCursorKind Kind);
4847CINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(
4848 CXCursor, const char **startBuf, const char **endBuf, unsigned *startLine,
4849 unsigned *startColumn, unsigned *endLine, unsigned *endColumn);
4850CINDEX_LINKAGE void clang_enableStackTraces(void);
4851CINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void *), void *user_data,
4852 unsigned stack_size);
4853
4854/**
4855 * @}
4856 */
4857
4858/**
4859 * \defgroup CINDEX_CODE_COMPLET Code completion
4860 *
4861 * Code completion involves taking an (incomplete) source file, along with
4862 * knowledge of where the user is actively editing that file, and suggesting
4863 * syntactically- and semantically-valid constructs that the user might want to
4864 * use at that particular point in the source code. These data structures and
4865 * routines provide support for code completion.
4866 *
4867 * @{
4868 */
4869
4870/**
4871 * A semantic string that describes a code-completion result.
4872 *
4873 * A semantic string that describes the formatting of a code-completion
4874 * result as a single "template" of text that should be inserted into the
4875 * source buffer when a particular code-completion result is selected.
4876 * Each semantic string is made up of some number of "chunks", each of which
4877 * contains some text along with a description of what that text means, e.g.,
4878 * the name of the entity being referenced, whether the text chunk is part of
4879 * the template, or whether it is a "placeholder" that the user should replace
4880 * with actual code,of a specific kind. See \c CXCompletionChunkKind for a
4881 * description of the different kinds of chunks.
4882 */
4883typedef void *CXCompletionString;
4884
4885/**
4886 * A single result of code completion.
4887 */
4888typedef struct {
4889 /**
4890 * The kind of entity that this completion refers to.
4891 *
4892 * The cursor kind will be a macro, keyword, or a declaration (one of the
4893 * *Decl cursor kinds), describing the entity that the completion is
4894 * referring to.
4895 *
4896 * \todo In the future, we would like to provide a full cursor, to allow
4897 * the client to extract additional information from declaration.
4898 */
4899 enum CXCursorKind CursorKind;
4900
4901 /**
4902 * The code-completion string that describes how to insert this
4903 * code-completion result into the editing buffer.
4904 */
4905 CXCompletionString CompletionString;
4906} CXCompletionResult;
4907
4908/**
4909 * Describes a single piece of text within a code-completion string.
4910 *
4911 * Each "chunk" within a code-completion string (\c CXCompletionString) is
4912 * either a piece of text with a specific "kind" that describes how that text
4913 * should be interpreted by the client or is another completion string.
4914 */
4915enum CXCompletionChunkKind {
4916 /**
4917 * A code-completion string that describes "optional" text that
4918 * could be a part of the template (but is not required).
4919 *
4920 * The Optional chunk is the only kind of chunk that has a code-completion
4921 * string for its representation, which is accessible via
4922 * \c clang_getCompletionChunkCompletionString(). The code-completion string
4923 * describes an additional part of the template that is completely optional.
4924 * For example, optional chunks can be used to describe the placeholders for
4925 * arguments that match up with defaulted function parameters, e.g. given:
4926 *
4927 * \code
4928 * void f(int x, float y = 3.14, double z = 2.71828);
4929 * \endcode
4930 *
4931 * The code-completion string for this function would contain:
4932 * - a TypedText chunk for "f".
4933 * - a LeftParen chunk for "(".
4934 * - a Placeholder chunk for "int x"
4935 * - an Optional chunk containing the remaining defaulted arguments, e.g.,
4936 * - a Comma chunk for ","
4937 * - a Placeholder chunk for "float y"
4938 * - an Optional chunk containing the last defaulted argument:
4939 * - a Comma chunk for ","
4940 * - a Placeholder chunk for "double z"
4941 * - a RightParen chunk for ")"
4942 *
4943 * There are many ways to handle Optional chunks. Two simple approaches are:
4944 * - Completely ignore optional chunks, in which case the template for the
4945 * function "f" would only include the first parameter ("int x").
4946 * - Fully expand all optional chunks, in which case the template for the
4947 * function "f" would have all of the parameters.
4948 */
4949 CXCompletionChunk_Optional,
4950 /**
4951 * Text that a user would be expected to type to get this
4952 * code-completion result.
4953 *
4954 * There will be exactly one "typed text" chunk in a semantic string, which
4955 * will typically provide the spelling of a keyword or the name of a
4956 * declaration that could be used at the current code point. Clients are
4957 * expected to filter the code-completion results based on the text in this
4958 * chunk.
4959 */
4960 CXCompletionChunk_TypedText,
4961 /**
4962 * Text that should be inserted as part of a code-completion result.
4963 *
4964 * A "text" chunk represents text that is part of the template to be
4965 * inserted into user code should this particular code-completion result
4966 * be selected.
4967 */
4968 CXCompletionChunk_Text,
4969 /**
4970 * Placeholder text that should be replaced by the user.
4971 *
4972 * A "placeholder" chunk marks a place where the user should insert text
4973 * into the code-completion template. For example, placeholders might mark
4974 * the function parameters for a function declaration, to indicate that the
4975 * user should provide arguments for each of those parameters. The actual
4976 * text in a placeholder is a suggestion for the text to display before
4977 * the user replaces the placeholder with real code.
4978 */
4979 CXCompletionChunk_Placeholder,
4980 /**
4981 * Informative text that should be displayed but never inserted as
4982 * part of the template.
4983 *
4984 * An "informative" chunk contains annotations that can be displayed to
4985 * help the user decide whether a particular code-completion result is the
4986 * right option, but which is not part of the actual template to be inserted
4987 * by code completion.
4988 */
4989 CXCompletionChunk_Informative,
4990 /**
4991 * Text that describes the current parameter when code-completion is
4992 * referring to function call, message send, or template specialization.
4993 *
4994 * A "current parameter" chunk occurs when code-completion is providing
4995 * information about a parameter corresponding to the argument at the
4996 * code-completion point. For example, given a function
4997 *
4998 * \code
4999 * int add(int x, int y);
5000 * \endcode
5001 *
5002 * and the source code \c add(, where the code-completion point is after the
5003 * "(", the code-completion string will contain a "current parameter" chunk
5004 * for "int x", indicating that the current argument will initialize that
5005 * parameter. After typing further, to \c add(17, (where the code-completion
5006 * point is after the ","), the code-completion string will contain a
5007 * "current parameter" chunk to "int y".
5008 */
5009 CXCompletionChunk_CurrentParameter,
5010 /**
5011 * A left parenthesis ('('), used to initiate a function call or
5012 * signal the beginning of a function parameter list.
5013 */
5014 CXCompletionChunk_LeftParen,
5015 /**
5016 * A right parenthesis (')'), used to finish a function call or
5017 * signal the end of a function parameter list.
5018 */
5019 CXCompletionChunk_RightParen,
5020 /**
5021 * A left bracket ('[').
5022 */
5023 CXCompletionChunk_LeftBracket,
5024 /**
5025 * A right bracket (']').
5026 */
5027 CXCompletionChunk_RightBracket,
5028 /**
5029 * A left brace ('{').
5030 */
5031 CXCompletionChunk_LeftBrace,
5032 /**
5033 * A right brace ('}').
5034 */
5035 CXCompletionChunk_RightBrace,
5036 /**
5037 * A left angle bracket ('<').
5038 */
5039 CXCompletionChunk_LeftAngle,
5040 /**
5041 * A right angle bracket ('>').
5042 */
5043 CXCompletionChunk_RightAngle,
5044 /**
5045 * A comma separator (',').
5046 */
5047 CXCompletionChunk_Comma,
5048 /**
5049 * Text that specifies the result type of a given result.
5050 *
5051 * This special kind of informative chunk is not meant to be inserted into
5052 * the text buffer. Rather, it is meant to illustrate the type that an
5053 * expression using the given completion string would have.
5054 */
5055 CXCompletionChunk_ResultType,
5056 /**
5057 * A colon (':').
5058 */
5059 CXCompletionChunk_Colon,
5060 /**
5061 * A semicolon (';').
5062 */
5063 CXCompletionChunk_SemiColon,
5064 /**
5065 * An '=' sign.
5066 */
5067 CXCompletionChunk_Equal,
5068 /**
5069 * Horizontal space (' ').
5070 */
5071 CXCompletionChunk_HorizontalSpace,
5072 /**
5073 * Vertical space ('\\n'), after which it is generally a good idea to
5074 * perform indentation.
5075 */
5076 CXCompletionChunk_VerticalSpace
5077};
5078
5079/**
5080 * Determine the kind of a particular chunk within a completion string.
5081 *
5082 * \param completion_string the completion string to query.
5083 *
5084 * \param chunk_number the 0-based index of the chunk in the completion string.
5085 *
5086 * \returns the kind of the chunk at the index \c chunk_number.
5087 */
5088CINDEX_LINKAGE enum CXCompletionChunkKind
5089clang_getCompletionChunkKind(CXCompletionString completion_string,
5090 unsigned chunk_number);
5091
5092/**
5093 * Retrieve the text associated with a particular chunk within a
5094 * completion string.
5095 *
5096 * \param completion_string the completion string to query.
5097 *
5098 * \param chunk_number the 0-based index of the chunk in the completion string.
5099 *
5100 * \returns the text associated with the chunk at index \c chunk_number.
5101 */
5102CINDEX_LINKAGE CXString clang_getCompletionChunkText(
5103 CXCompletionString completion_string, unsigned chunk_number);
5104
5105/**
5106 * Retrieve the completion string associated with a particular chunk
5107 * within a completion string.
5108 *
5109 * \param completion_string the completion string to query.
5110 *
5111 * \param chunk_number the 0-based index of the chunk in the completion string.
5112 *
5113 * \returns the completion string associated with the chunk at index
5114 * \c chunk_number.
5115 */
5116CINDEX_LINKAGE CXCompletionString clang_getCompletionChunkCompletionString(
5117 CXCompletionString completion_string, unsigned chunk_number);
5118
5119/**
5120 * Retrieve the number of chunks in the given code-completion string.
5121 */
5122CINDEX_LINKAGE unsigned
5123clang_getNumCompletionChunks(CXCompletionString completion_string);
5124
5125/**
5126 * Determine the priority of this code completion.
5127 *
5128 * The priority of a code completion indicates how likely it is that this
5129 * particular completion is the completion that the user will select. The
5130 * priority is selected by various internal heuristics.
5131 *
5132 * \param completion_string The completion string to query.
5133 *
5134 * \returns The priority of this completion string. Smaller values indicate
5135 * higher-priority (more likely) completions.
5136 */
5137CINDEX_LINKAGE unsigned
5138clang_getCompletionPriority(CXCompletionString completion_string);
5139
5140/**
5141 * Determine the availability of the entity that this code-completion
5142 * string refers to.
5143 *
5144 * \param completion_string The completion string to query.
5145 *
5146 * \returns The availability of the completion string.
5147 */
5148CINDEX_LINKAGE enum CXAvailabilityKind
5149clang_getCompletionAvailability(CXCompletionString completion_string);
5150
5151/**
5152 * Retrieve the number of annotations associated with the given
5153 * completion string.
5154 *
5155 * \param completion_string the completion string to query.
5156 *
5157 * \returns the number of annotations associated with the given completion
5158 * string.
5159 */
5160CINDEX_LINKAGE unsigned
5161clang_getCompletionNumAnnotations(CXCompletionString completion_string);
5162
5163/**
5164 * Retrieve the annotation associated with the given completion string.
5165 *
5166 * \param completion_string the completion string to query.
5167 *
5168 * \param annotation_number the 0-based index of the annotation of the
5169 * completion string.
5170 *
5171 * \returns annotation string associated with the completion at index
5172 * \c annotation_number, or a NULL string if that annotation is not available.
5173 */
5174CINDEX_LINKAGE CXString clang_getCompletionAnnotation(
5175 CXCompletionString completion_string, unsigned annotation_number);
5176
5177/**
5178 * Retrieve the parent context of the given completion string.
5179 *
5180 * The parent context of a completion string is the semantic parent of
5181 * the declaration (if any) that the code completion represents. For example,
5182 * a code completion for an Objective-C method would have the method's class
5183 * or protocol as its context.
5184 *
5185 * \param completion_string The code completion string whose parent is
5186 * being queried.
5187 *
5188 * \param kind DEPRECATED: always set to CXCursor_NotImplemented if non-NULL.
5189 *
5190 * \returns The name of the completion parent, e.g., "NSObject" if
5191 * the completion string represents a method in the NSObject class.
5192 */
5193CINDEX_LINKAGE CXString clang_getCompletionParent(
5194 CXCompletionString completion_string, enum CXCursorKind *kind);
5195
5196/**
5197 * Retrieve the brief documentation comment attached to the declaration
5198 * that corresponds to the given completion string.
5199 */
5200CINDEX_LINKAGE CXString
5201clang_getCompletionBriefComment(CXCompletionString completion_string);
5202
5203/**
5204 * Retrieve a completion string for an arbitrary declaration or macro
5205 * definition cursor.
5206 *
5207 * \param cursor The cursor to query.
5208 *
5209 * \returns A non-context-sensitive completion string for declaration and macro
5210 * definition cursors, or NULL for other kinds of cursors.
5211 */
5212CINDEX_LINKAGE CXCompletionString
5213clang_getCursorCompletionString(CXCursor cursor);
5214
5215/**
5216 * Contains the results of code-completion.
5217 *
5218 * This data structure contains the results of code completion, as
5219 * produced by \c clang_codeCompleteAt(). Its contents must be freed by
5220 * \c clang_disposeCodeCompleteResults.
5221 */
5222typedef struct {
5223 /**
5224 * The code-completion results.
5225 */
5226 CXCompletionResult *Results;
5227
5228 /**
5229 * The number of code-completion results stored in the
5230 * \c Results array.
5231 */
5232 unsigned NumResults;
5233} CXCodeCompleteResults;
5234
5235/**
5236 * Retrieve the number of fix-its for the given completion index.
5237 *
5238 * Calling this makes sense only if CXCodeComplete_IncludeCompletionsWithFixIts
5239 * option was set.
5240 *
5241 * \param results The structure keeping all completion results
5242 *
5243 * \param completion_index The index of the completion
5244 *
5245 * \return The number of fix-its which must be applied before the completion at
5246 * completion_index can be applied
5247 */
5248CINDEX_LINKAGE unsigned
5249clang_getCompletionNumFixIts(CXCodeCompleteResults *results,
5250 unsigned completion_index);
5251
5252/**
5253 * Fix-its that *must* be applied before inserting the text for the
5254 * corresponding completion.
5255 *
5256 * By default, clang_codeCompleteAt() only returns completions with empty
5257 * fix-its. Extra completions with non-empty fix-its should be explicitly
5258 * requested by setting CXCodeComplete_IncludeCompletionsWithFixIts.
5259 *
5260 * For the clients to be able to compute position of the cursor after applying
5261 * fix-its, the following conditions are guaranteed to hold for
5262 * replacement_range of the stored fix-its:
5263 * - Ranges in the fix-its are guaranteed to never contain the completion
5264 * point (or identifier under completion point, if any) inside them, except
5265 * at the start or at the end of the range.
5266 * - If a fix-it range starts or ends with completion point (or starts or
5267 * ends after the identifier under completion point), it will contain at
5268 * least one character. It allows to unambiguously recompute completion
5269 * point after applying the fix-it.
5270 *
5271 * The intuition is that provided fix-its change code around the identifier we
5272 * complete, but are not allowed to touch the identifier itself or the
5273 * completion point. One example of completions with corrections are the ones
5274 * replacing '.' with '->' and vice versa:
5275 *
5276 * std::unique_ptr<std::vector<int>> vec_ptr;
5277 * In 'vec_ptr.^', one of the completions is 'push_back', it requires
5278 * replacing '.' with '->'.
5279 * In 'vec_ptr->^', one of the completions is 'release', it requires
5280 * replacing '->' with '.'.
5281 *
5282 * \param results The structure keeping all completion results
5283 *
5284 * \param completion_index The index of the completion
5285 *
5286 * \param fixit_index The index of the fix-it for the completion at
5287 * completion_index
5288 *
5289 * \param replacement_range The fix-it range that must be replaced before the
5290 * completion at completion_index can be applied
5291 *
5292 * \returns The fix-it string that must replace the code at replacement_range
5293 * before the completion at completion_index can be applied
5294 */
5295CINDEX_LINKAGE CXString clang_getCompletionFixIt(
5296 CXCodeCompleteResults *results, unsigned completion_index,
5297 unsigned fixit_index, CXSourceRange *replacement_range);
5298
5299/**
5300 * Flags that can be passed to \c clang_codeCompleteAt() to
5301 * modify its behavior.
5302 *
5303 * The enumerators in this enumeration can be bitwise-OR'd together to
5304 * provide multiple options to \c clang_codeCompleteAt().
5305 */
5306enum CXCodeComplete_Flags {
5307 /**
5308 * Whether to include macros within the set of code
5309 * completions returned.
5310 */
5311 CXCodeComplete_IncludeMacros = 0x01,
5312
5313 /**
5314 * Whether to include code patterns for language constructs
5315 * within the set of code completions, e.g., for loops.
5316 */
5317 CXCodeComplete_IncludeCodePatterns = 0x02,
5318
5319 /**
5320 * Whether to include brief documentation within the set of code
5321 * completions returned.
5322 */
5323 CXCodeComplete_IncludeBriefComments = 0x04,
5324
5325 /**
5326 * Whether to speed up completion by omitting top- or namespace-level entities
5327 * defined in the preamble. There's no guarantee any particular entity is
5328 * omitted. This may be useful if the headers are indexed externally.
5329 */
5330 CXCodeComplete_SkipPreamble = 0x08,
5331
5332 /**
5333 * Whether to include completions with small
5334 * fix-its, e.g. change '.' to '->' on member access, etc.
5335 */
5336 CXCodeComplete_IncludeCompletionsWithFixIts = 0x10
5337};
5338
5339/**
5340 * Bits that represent the context under which completion is occurring.
5341 *
5342 * The enumerators in this enumeration may be bitwise-OR'd together if multiple
5343 * contexts are occurring simultaneously.
5344 */
5345enum CXCompletionContext {
5346 /**
5347 * The context for completions is unexposed, as only Clang results
5348 * should be included. (This is equivalent to having no context bits set.)
5349 */
5350 CXCompletionContext_Unexposed = 0,
5351
5352 /**
5353 * Completions for any possible type should be included in the results.
5354 */
5355 CXCompletionContext_AnyType = 1 << 0,
5356
5357 /**
5358 * Completions for any possible value (variables, function calls, etc.)
5359 * should be included in the results.
5360 */
5361 CXCompletionContext_AnyValue = 1 << 1,
5362 /**
5363 * Completions for values that resolve to an Objective-C object should
5364 * be included in the results.
5365 */
5366 CXCompletionContext_ObjCObjectValue = 1 << 2,
5367 /**
5368 * Completions for values that resolve to an Objective-C selector
5369 * should be included in the results.
5370 */
5371 CXCompletionContext_ObjCSelectorValue = 1 << 3,
5372 /**
5373 * Completions for values that resolve to a C++ class type should be
5374 * included in the results.
5375 */
5376 CXCompletionContext_CXXClassTypeValue = 1 << 4,
5377
5378 /**
5379 * Completions for fields of the member being accessed using the dot
5380 * operator should be included in the results.
5381 */
5382 CXCompletionContext_DotMemberAccess = 1 << 5,
5383 /**
5384 * Completions for fields of the member being accessed using the arrow
5385 * operator should be included in the results.
5386 */
5387 CXCompletionContext_ArrowMemberAccess = 1 << 6,
5388 /**
5389 * Completions for properties of the Objective-C object being accessed
5390 * using the dot operator should be included in the results.
5391 */
5392 CXCompletionContext_ObjCPropertyAccess = 1 << 7,
5393
5394 /**
5395 * Completions for enum tags should be included in the results.
5396 */
5397 CXCompletionContext_EnumTag = 1 << 8,
5398 /**
5399 * Completions for union tags should be included in the results.
5400 */
5401 CXCompletionContext_UnionTag = 1 << 9,
5402 /**
5403 * Completions for struct tags should be included in the results.
5404 */
5405 CXCompletionContext_StructTag = 1 << 10,
5406
5407 /**
5408 * Completions for C++ class names should be included in the results.
5409 */
5410 CXCompletionContext_ClassTag = 1 << 11,
5411 /**
5412 * Completions for C++ namespaces and namespace aliases should be
5413 * included in the results.
5414 */
5415 CXCompletionContext_Namespace = 1 << 12,
5416 /**
5417 * Completions for C++ nested name specifiers should be included in
5418 * the results.
5419 */
5420 CXCompletionContext_NestedNameSpecifier = 1 << 13,
5421
5422 /**
5423 * Completions for Objective-C interfaces (classes) should be included
5424 * in the results.
5425 */
5426 CXCompletionContext_ObjCInterface = 1 << 14,
5427 /**
5428 * Completions for Objective-C protocols should be included in
5429 * the results.
5430 */
5431 CXCompletionContext_ObjCProtocol = 1 << 15,
5432 /**
5433 * Completions for Objective-C categories should be included in
5434 * the results.
5435 */
5436 CXCompletionContext_ObjCCategory = 1 << 16,
5437 /**
5438 * Completions for Objective-C instance messages should be included
5439 * in the results.
5440 */
5441 CXCompletionContext_ObjCInstanceMessage = 1 << 17,
5442 /**
5443 * Completions for Objective-C class messages should be included in
5444 * the results.
5445 */
5446 CXCompletionContext_ObjCClassMessage = 1 << 18,
5447 /**
5448 * Completions for Objective-C selector names should be included in
5449 * the results.
5450 */
5451 CXCompletionContext_ObjCSelectorName = 1 << 19,
5452
5453 /**
5454 * Completions for preprocessor macro names should be included in
5455 * the results.
5456 */
5457 CXCompletionContext_MacroName = 1 << 20,
5458
5459 /**
5460 * Natural language completions should be included in the results.
5461 */
5462 CXCompletionContext_NaturalLanguage = 1 << 21,
5463
5464 /**
5465 * #include file completions should be included in the results.
5466 */
5467 CXCompletionContext_IncludedFile = 1 << 22,
5468
5469 /**
5470 * The current context is unknown, so set all contexts.
5471 */
5472 CXCompletionContext_Unknown = ((1 << 23) - 1)
5473};
5474
5475/**
5476 * Returns a default set of code-completion options that can be
5477 * passed to\c clang_codeCompleteAt().
5478 */
5479CINDEX_LINKAGE unsigned clang_defaultCodeCompleteOptions(void);
5480
5481/**
5482 * Perform code completion at a given location in a translation unit.
5483 *
5484 * This function performs code completion at a particular file, line, and
5485 * column within source code, providing results that suggest potential
5486 * code snippets based on the context of the completion. The basic model
5487 * for code completion is that Clang will parse a complete source file,
5488 * performing syntax checking up to the location where code-completion has
5489 * been requested. At that point, a special code-completion token is passed
5490 * to the parser, which recognizes this token and determines, based on the
5491 * current location in the C/Objective-C/C++ grammar and the state of
5492 * semantic analysis, what completions to provide. These completions are
5493 * returned via a new \c CXCodeCompleteResults structure.
5494 *
5495 * Code completion itself is meant to be triggered by the client when the
5496 * user types punctuation characters or whitespace, at which point the
5497 * code-completion location will coincide with the cursor. For example, if \c p
5498 * is a pointer, code-completion might be triggered after the "-" and then
5499 * after the ">" in \c p->. When the code-completion location is after the ">",
5500 * the completion results will provide, e.g., the members of the struct that
5501 * "p" points to. The client is responsible for placing the cursor at the
5502 * beginning of the token currently being typed, then filtering the results
5503 * based on the contents of the token. For example, when code-completing for
5504 * the expression \c p->get, the client should provide the location just after
5505 * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the
5506 * client can filter the results based on the current token text ("get"), only
5507 * showing those results that start with "get". The intent of this interface
5508 * is to separate the relatively high-latency acquisition of code-completion
5509 * results from the filtering of results on a per-character basis, which must
5510 * have a lower latency.
5511 *
5512 * \param TU The translation unit in which code-completion should
5513 * occur. The source files for this translation unit need not be
5514 * completely up-to-date (and the contents of those source files may
5515 * be overridden via \p unsaved_files). Cursors referring into the
5516 * translation unit may be invalidated by this invocation.
5517 *
5518 * \param complete_filename The name of the source file where code
5519 * completion should be performed. This filename may be any file
5520 * included in the translation unit.
5521 *
5522 * \param complete_line The line at which code-completion should occur.
5523 *
5524 * \param complete_column The column at which code-completion should occur.
5525 * Note that the column should point just after the syntactic construct that
5526 * initiated code completion, and not in the middle of a lexical token.
5527 *
5528 * \param unsaved_files the Files that have not yet been saved to disk
5529 * but may be required for parsing or code completion, including the
5530 * contents of those files. The contents and name of these files (as
5531 * specified by CXUnsavedFile) are copied when necessary, so the
5532 * client only needs to guarantee their validity until the call to
5533 * this function returns.
5534 *
5535 * \param num_unsaved_files The number of unsaved file entries in \p
5536 * unsaved_files.
5537 *
5538 * \param options Extra options that control the behavior of code
5539 * completion, expressed as a bitwise OR of the enumerators of the
5540 * CXCodeComplete_Flags enumeration. The
5541 * \c clang_defaultCodeCompleteOptions() function returns a default set
5542 * of code-completion options.
5543 *
5544 * \returns If successful, a new \c CXCodeCompleteResults structure
5545 * containing code-completion results, which should eventually be
5546 * freed with \c clang_disposeCodeCompleteResults(). If code
5547 * completion fails, returns NULL.
5548 */
5549CINDEX_LINKAGE
5550CXCodeCompleteResults *
5551clang_codeCompleteAt(CXTranslationUnit TU, const char *complete_filename,
5552 unsigned complete_line, unsigned complete_column,
5553 struct CXUnsavedFile *unsaved_files,
5554 unsigned num_unsaved_files, unsigned options);
5555
5556/**
5557 * Sort the code-completion results in case-insensitive alphabetical
5558 * order.
5559 *
5560 * \param Results The set of results to sort.
5561 * \param NumResults The number of results in \p Results.
5562 */
5563CINDEX_LINKAGE
5564void clang_sortCodeCompletionResults(CXCompletionResult *Results,
5565 unsigned NumResults);
5566
5567/**
5568 * Free the given set of code-completion results.
5569 */
5570CINDEX_LINKAGE
5571void clang_disposeCodeCompleteResults(CXCodeCompleteResults *Results);
5572
5573/**
5574 * Determine the number of diagnostics produced prior to the
5575 * location where code completion was performed.
5576 */
5577CINDEX_LINKAGE
5578unsigned clang_codeCompleteGetNumDiagnostics(CXCodeCompleteResults *Results);
5579
5580/**
5581 * Retrieve a diagnostic associated with the given code completion.
5582 *
5583 * \param Results the code completion results to query.
5584 * \param Index the zero-based diagnostic number to retrieve.
5585 *
5586 * \returns the requested diagnostic. This diagnostic must be freed
5587 * via a call to \c clang_disposeDiagnostic().
5588 */
5589CINDEX_LINKAGE
5590CXDiagnostic clang_codeCompleteGetDiagnostic(CXCodeCompleteResults *Results,
5591 unsigned Index);
5592
5593/**
5594 * Determines what completions are appropriate for the context
5595 * the given code completion.
5596 *
5597 * \param Results the code completion results to query
5598 *
5599 * \returns the kinds of completions that are appropriate for use
5600 * along with the given code completion results.
5601 */
5602CINDEX_LINKAGE
5603unsigned long long
5604clang_codeCompleteGetContexts(CXCodeCompleteResults *Results);
5605
5606/**
5607 * Returns the cursor kind for the container for the current code
5608 * completion context. The container is only guaranteed to be set for
5609 * contexts where a container exists (i.e. member accesses or Objective-C
5610 * message sends); if there is not a container, this function will return
5611 * CXCursor_InvalidCode.
5612 *
5613 * \param Results the code completion results to query
5614 *
5615 * \param IsIncomplete on return, this value will be false if Clang has complete
5616 * information about the container. If Clang does not have complete
5617 * information, this value will be true.
5618 *
5619 * \returns the container kind, or CXCursor_InvalidCode if there is not a
5620 * container
5621 */
5622CINDEX_LINKAGE
5623enum CXCursorKind
5624clang_codeCompleteGetContainerKind(CXCodeCompleteResults *Results,
5625 unsigned *IsIncomplete);
5626
5627/**
5628 * Returns the USR for the container for the current code completion
5629 * context. If there is not a container for the current context, this
5630 * function will return the empty string.
5631 *
5632 * \param Results the code completion results to query
5633 *
5634 * \returns the USR for the container
5635 */
5636CINDEX_LINKAGE
5637CXString clang_codeCompleteGetContainerUSR(CXCodeCompleteResults *Results);
5638
5639/**
5640 * Returns the currently-entered selector for an Objective-C message
5641 * send, formatted like "initWithFoo:bar:". Only guaranteed to return a
5642 * non-empty string for CXCompletionContext_ObjCInstanceMessage and
5643 * CXCompletionContext_ObjCClassMessage.
5644 *
5645 * \param Results the code completion results to query
5646 *
5647 * \returns the selector (or partial selector) that has been entered thus far
5648 * for an Objective-C message send.
5649 */
5650CINDEX_LINKAGE
5651CXString clang_codeCompleteGetObjCSelector(CXCodeCompleteResults *Results);
5652
5653/**
5654 * @}
5655 */
5656
5657/**
5658 * \defgroup CINDEX_MISC Miscellaneous utility functions
5659 *
5660 * @{
5661 */
5662
5663/**
5664 * Return a version string, suitable for showing to a user, but not
5665 * intended to be parsed (the format is not guaranteed to be stable).
5666 */
5667CINDEX_LINKAGE CXString clang_getClangVersion(void);
5668
5669/**
5670 * Enable/disable crash recovery.
5671 *
5672 * \param isEnabled Flag to indicate if crash recovery is enabled. A non-zero
5673 * value enables crash recovery, while 0 disables it.
5674 */
5675CINDEX_LINKAGE void clang_toggleCrashRecovery(unsigned isEnabled);
5676
5677/**
5678 * Visitor invoked for each file in a translation unit
5679 * (used with clang_getInclusions()).
5680 *
5681 * This visitor function will be invoked by clang_getInclusions() for each
5682 * file included (either at the top-level or by \#include directives) within
5683 * a translation unit. The first argument is the file being included, and
5684 * the second and third arguments provide the inclusion stack. The
5685 * array is sorted in order of immediate inclusion. For example,
5686 * the first element refers to the location that included 'included_file'.
5687 */
5688typedef void (*CXInclusionVisitor)(CXFile included_file,
5689 CXSourceLocation *inclusion_stack,
5690 unsigned include_len,
5691 CXClientData client_data);
5692
5693/**
5694 * Visit the set of preprocessor inclusions in a translation unit.
5695 * The visitor function is called with the provided data for every included
5696 * file. This does not include headers included by the PCH file (unless one
5697 * is inspecting the inclusions in the PCH file itself).
5698 */
5699CINDEX_LINKAGE void clang_getInclusions(CXTranslationUnit tu,
5700 CXInclusionVisitor visitor,
5701 CXClientData client_data);
5702
5703typedef enum {
5704 CXEval_Int = 1,
5705 CXEval_Float = 2,
5706 CXEval_ObjCStrLiteral = 3,
5707 CXEval_StrLiteral = 4,
5708 CXEval_CFStr = 5,
5709 CXEval_Other = 6,
5710
5711 CXEval_UnExposed = 0
5712
5713} CXEvalResultKind;
5714
5715/**
5716 * Evaluation result of a cursor
5717 */
5718typedef void *CXEvalResult;
5719
5720/**
5721 * If cursor is a statement declaration tries to evaluate the
5722 * statement and if its variable, tries to evaluate its initializer,
5723 * into its corresponding type.
5724 * If it's an expression, tries to evaluate the expression.
5725 */
5726CINDEX_LINKAGE CXEvalResult clang_Cursor_Evaluate(CXCursor C);
5727
5728/**
5729 * Returns the kind of the evaluated result.
5730 */
5731CINDEX_LINKAGE CXEvalResultKind clang_EvalResult_getKind(CXEvalResult E);
5732
5733/**
5734 * Returns the evaluation result as integer if the
5735 * kind is Int.
5736 */
5737CINDEX_LINKAGE int clang_EvalResult_getAsInt(CXEvalResult E);
5738
5739/**
5740 * Returns the evaluation result as a long long integer if the
5741 * kind is Int. This prevents overflows that may happen if the result is
5742 * returned with clang_EvalResult_getAsInt.
5743 */
5744CINDEX_LINKAGE long long clang_EvalResult_getAsLongLong(CXEvalResult E);
5745
5746/**
5747 * Returns a non-zero value if the kind is Int and the evaluation
5748 * result resulted in an unsigned integer.
5749 */
5750CINDEX_LINKAGE unsigned clang_EvalResult_isUnsignedInt(CXEvalResult E);
5751
5752/**
5753 * Returns the evaluation result as an unsigned integer if
5754 * the kind is Int and clang_EvalResult_isUnsignedInt is non-zero.
5755 */
5756CINDEX_LINKAGE unsigned long long
5757clang_EvalResult_getAsUnsigned(CXEvalResult E);
5758
5759/**
5760 * Returns the evaluation result as double if the
5761 * kind is double.
5762 */
5763CINDEX_LINKAGE double clang_EvalResult_getAsDouble(CXEvalResult E);
5764
5765/**
5766 * Returns the evaluation result as a constant string if the
5767 * kind is other than Int or float. User must not free this pointer,
5768 * instead call clang_EvalResult_dispose on the CXEvalResult returned
5769 * by clang_Cursor_Evaluate.
5770 */
5771CINDEX_LINKAGE const char *clang_EvalResult_getAsStr(CXEvalResult E);
5772
5773/**
5774 * Disposes the created Eval memory.
5775 */
5776CINDEX_LINKAGE void clang_EvalResult_dispose(CXEvalResult E);
5777/**
5778 * @}
5779 */
5780
5781/** \defgroup CINDEX_REMAPPING Remapping functions
5782 *
5783 * @{
5784 */
5785
5786/**
5787 * A remapping of original source files and their translated files.
5788 */
5789typedef void *CXRemapping;
5790
5791/**
5792 * Retrieve a remapping.
5793 *
5794 * \param path the path that contains metadata about remappings.
5795 *
5796 * \returns the requested remapping. This remapping must be freed
5797 * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
5798 */
5799CINDEX_LINKAGE CXRemapping clang_getRemappings(const char *path);
5800
5801/**
5802 * Retrieve a remapping.
5803 *
5804 * \param filePaths pointer to an array of file paths containing remapping info.
5805 *
5806 * \param numFiles number of file paths.
5807 *
5808 * \returns the requested remapping. This remapping must be freed
5809 * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
5810 */
5811CINDEX_LINKAGE
5812CXRemapping clang_getRemappingsFromFileList(const char **filePaths,
5813 unsigned numFiles);
5814
5815/**
5816 * Determine the number of remappings.
5817 */
5818CINDEX_LINKAGE unsigned clang_remap_getNumFiles(CXRemapping);
5819
5820/**
5821 * Get the original and the associated filename from the remapping.
5822 *
5823 * \param original If non-NULL, will be set to the original filename.
5824 *
5825 * \param transformed If non-NULL, will be set to the filename that the original
5826 * is associated with.
5827 */
5828CINDEX_LINKAGE void clang_remap_getFilenames(CXRemapping, unsigned index,
5829 CXString *original,
5830 CXString *transformed);
5831
5832/**
5833 * Dispose the remapping.
5834 */
5835CINDEX_LINKAGE void clang_remap_dispose(CXRemapping);
5836
5837/**
5838 * @}
5839 */
5840
5841/** \defgroup CINDEX_HIGH Higher level API functions
5842 *
5843 * @{
5844 */
5845
5846enum CXVisitorResult { CXVisit_Break, CXVisit_Continue };
5847
5848typedef struct CXCursorAndRangeVisitor {
5849 void *context;
5850 enum CXVisitorResult (*visit)(void *context, CXCursor, CXSourceRange);
5851} CXCursorAndRangeVisitor;
5852
5853typedef enum {
5854 /**
5855 * Function returned successfully.
5856 */
5857 CXResult_Success = 0,
5858 /**
5859 * One of the parameters was invalid for the function.
5860 */
5861 CXResult_Invalid = 1,
5862 /**
5863 * The function was terminated by a callback (e.g. it returned
5864 * CXVisit_Break)
5865 */
5866 CXResult_VisitBreak = 2
5867
5868} CXResult;
5869
5870/**
5871 * Find references of a declaration in a specific file.
5872 *
5873 * \param cursor pointing to a declaration or a reference of one.
5874 *
5875 * \param file to search for references.
5876 *
5877 * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
5878 * each reference found.
5879 * The CXSourceRange will point inside the file; if the reference is inside
5880 * a macro (and not a macro argument) the CXSourceRange will be invalid.
5881 *
5882 * \returns one of the CXResult enumerators.
5883 */
5884CINDEX_LINKAGE CXResult clang_findReferencesInFile(
5885 CXCursor cursor, CXFile file, CXCursorAndRangeVisitor visitor);
5886
5887/**
5888 * Find #import/#include directives in a specific file.
5889 *
5890 * \param TU translation unit containing the file to query.
5891 *
5892 * \param file to search for #import/#include directives.
5893 *
5894 * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
5895 * each directive found.
5896 *
5897 * \returns one of the CXResult enumerators.
5898 */
5899CINDEX_LINKAGE CXResult clang_findIncludesInFile(
5900 CXTranslationUnit TU, CXFile file, CXCursorAndRangeVisitor visitor);
5901
5902#if __has_feature(blocks)
5903typedef enum CXVisitorResult (^CXCursorAndRangeVisitorBlock)(CXCursor,
5904 CXSourceRange);
5905#else
5906typedef struct _CXCursorAndRangeVisitorBlock *CXCursorAndRangeVisitorBlock;
5907#endif
5908
5909CINDEX_LINKAGE
5910CXResult clang_findReferencesInFileWithBlock(CXCursor, CXFile,
5911 CXCursorAndRangeVisitorBlock);
5912
5913CINDEX_LINKAGE
5914CXResult clang_findIncludesInFileWithBlock(CXTranslationUnit, CXFile,
5915 CXCursorAndRangeVisitorBlock);
5916
5917/**
5918 * The client's data object that is associated with a CXFile.
5919 */
5920typedef void *CXIdxClientFile;
5921
5922/**
5923 * The client's data object that is associated with a semantic entity.
5924 */
5925typedef void *CXIdxClientEntity;
5926
5927/**
5928 * The client's data object that is associated with a semantic container
5929 * of entities.
5930 */
5931typedef void *CXIdxClientContainer;
5932
5933/**
5934 * The client's data object that is associated with an AST file (PCH
5935 * or module).
5936 */
5937typedef void *CXIdxClientASTFile;
5938
5939/**
5940 * Source location passed to index callbacks.
5941 */
5942typedef struct {
5943 void *ptr_data[2];
5944 unsigned int_data;
5945} CXIdxLoc;
5946
5947/**
5948 * Data for ppIncludedFile callback.
5949 */
5950typedef struct {
5951 /**
5952 * Location of '#' in the \#include/\#import directive.
5953 */
5954 CXIdxLoc hashLoc;
5955 /**
5956 * Filename as written in the \#include/\#import directive.
5957 */
5958 const char *filename;
5959 /**
5960 * The actual file that the \#include/\#import directive resolved to.
5961 */
5962 CXFile file;
5963 int isImport;
5964 int isAngled;
5965 /**
5966 * Non-zero if the directive was automatically turned into a module
5967 * import.
5968 */
5969 int isModuleImport;
5970} CXIdxIncludedFileInfo;
5971
5972/**
5973 * Data for IndexerCallbacks#importedASTFile.
5974 */
5975typedef struct {
5976 /**
5977 * Top level AST file containing the imported PCH, module or submodule.
5978 */
5979 CXFile file;
5980 /**
5981 * The imported module or NULL if the AST file is a PCH.
5982 */
5983 CXModule module;
5984 /**
5985 * Location where the file is imported. Applicable only for modules.
5986 */
5987 CXIdxLoc loc;
5988 /**
5989 * Non-zero if an inclusion directive was automatically turned into
5990 * a module import. Applicable only for modules.
5991 */
5992 int isImplicit;
5993
5994} CXIdxImportedASTFileInfo;
5995
5996typedef enum {
5997 CXIdxEntity_Unexposed = 0,
5998 CXIdxEntity_Typedef = 1,
5999 CXIdxEntity_Function = 2,
6000 CXIdxEntity_Variable = 3,
6001 CXIdxEntity_Field = 4,
6002 CXIdxEntity_EnumConstant = 5,
6003
6004 CXIdxEntity_ObjCClass = 6,
6005 CXIdxEntity_ObjCProtocol = 7,
6006 CXIdxEntity_ObjCCategory = 8,
6007
6008 CXIdxEntity_ObjCInstanceMethod = 9,
6009 CXIdxEntity_ObjCClassMethod = 10,
6010 CXIdxEntity_ObjCProperty = 11,
6011 CXIdxEntity_ObjCIvar = 12,
6012
6013 CXIdxEntity_Enum = 13,
6014 CXIdxEntity_Struct = 14,
6015 CXIdxEntity_Union = 15,
6016
6017 CXIdxEntity_CXXClass = 16,
6018 CXIdxEntity_CXXNamespace = 17,
6019 CXIdxEntity_CXXNamespaceAlias = 18,
6020 CXIdxEntity_CXXStaticVariable = 19,
6021 CXIdxEntity_CXXStaticMethod = 20,
6022 CXIdxEntity_CXXInstanceMethod = 21,
6023 CXIdxEntity_CXXConstructor = 22,
6024 CXIdxEntity_CXXDestructor = 23,
6025 CXIdxEntity_CXXConversionFunction = 24,
6026 CXIdxEntity_CXXTypeAlias = 25,
6027 CXIdxEntity_CXXInterface = 26,
6028 CXIdxEntity_CXXConcept = 27
6029
6030} CXIdxEntityKind;
6031
6032typedef enum {
6033 CXIdxEntityLang_None = 0,
6034 CXIdxEntityLang_C = 1,
6035 CXIdxEntityLang_ObjC = 2,
6036 CXIdxEntityLang_CXX = 3,
6037 CXIdxEntityLang_Swift = 4
6038} CXIdxEntityLanguage;
6039
6040/**
6041 * Extra C++ template information for an entity. This can apply to:
6042 * CXIdxEntity_Function
6043 * CXIdxEntity_CXXClass
6044 * CXIdxEntity_CXXStaticMethod
6045 * CXIdxEntity_CXXInstanceMethod
6046 * CXIdxEntity_CXXConstructor
6047 * CXIdxEntity_CXXConversionFunction
6048 * CXIdxEntity_CXXTypeAlias
6049 */
6050typedef enum {
6051 CXIdxEntity_NonTemplate = 0,
6052 CXIdxEntity_Template = 1,
6053 CXIdxEntity_TemplatePartialSpecialization = 2,
6054 CXIdxEntity_TemplateSpecialization = 3
6055} CXIdxEntityCXXTemplateKind;
6056
6057typedef enum {
6058 CXIdxAttr_Unexposed = 0,
6059 CXIdxAttr_IBAction = 1,
6060 CXIdxAttr_IBOutlet = 2,
6061 CXIdxAttr_IBOutletCollection = 3
6062} CXIdxAttrKind;
6063
6064typedef struct {
6065 CXIdxAttrKind kind;
6066 CXCursor cursor;
6067 CXIdxLoc loc;
6068} CXIdxAttrInfo;
6069
6070typedef struct {
6071 CXIdxEntityKind kind;
6072 CXIdxEntityCXXTemplateKind templateKind;
6073 CXIdxEntityLanguage lang;
6074 const char *name;
6075 const char *USR;
6076 CXCursor cursor;
6077 const CXIdxAttrInfo *const *attributes;
6078 unsigned numAttributes;
6079} CXIdxEntityInfo;
6080
6081typedef struct {
6082 CXCursor cursor;
6083} CXIdxContainerInfo;
6084
6085typedef struct {
6086 const CXIdxAttrInfo *attrInfo;
6087 const CXIdxEntityInfo *objcClass;
6088 CXCursor classCursor;
6089 CXIdxLoc classLoc;
6090} CXIdxIBOutletCollectionAttrInfo;
6091
6092typedef enum { CXIdxDeclFlag_Skipped = 0x1 } CXIdxDeclInfoFlags;
6093
6094typedef struct {
6095 const CXIdxEntityInfo *entityInfo;
6096 CXCursor cursor;
6097 CXIdxLoc loc;
6098 const CXIdxContainerInfo *semanticContainer;
6099 /**
6100 * Generally same as #semanticContainer but can be different in
6101 * cases like out-of-line C++ member functions.
6102 */
6103 const CXIdxContainerInfo *lexicalContainer;
6104 int isRedeclaration;
6105 int isDefinition;
6106 int isContainer;
6107 const CXIdxContainerInfo *declAsContainer;
6108 /**
6109 * Whether the declaration exists in code or was created implicitly
6110 * by the compiler, e.g. implicit Objective-C methods for properties.
6111 */
6112 int isImplicit;
6113 const CXIdxAttrInfo *const *attributes;
6114 unsigned numAttributes;
6115
6116 unsigned flags;
6117
6118} CXIdxDeclInfo;
6119
6120typedef enum {
6121 CXIdxObjCContainer_ForwardRef = 0,
6122 CXIdxObjCContainer_Interface = 1,
6123 CXIdxObjCContainer_Implementation = 2
6124} CXIdxObjCContainerKind;
6125
6126typedef struct {
6127 const CXIdxDeclInfo *declInfo;
6128 CXIdxObjCContainerKind kind;
6129} CXIdxObjCContainerDeclInfo;
6130
6131typedef struct {
6132 const CXIdxEntityInfo *base;
6133 CXCursor cursor;
6134 CXIdxLoc loc;
6135} CXIdxBaseClassInfo;
6136
6137typedef struct {
6138 const CXIdxEntityInfo *protocol;
6139 CXCursor cursor;
6140 CXIdxLoc loc;
6141} CXIdxObjCProtocolRefInfo;
6142
6143typedef struct {
6144 const CXIdxObjCProtocolRefInfo *const *protocols;
6145 unsigned numProtocols;
6146} CXIdxObjCProtocolRefListInfo;
6147
6148typedef struct {
6149 const CXIdxObjCContainerDeclInfo *containerInfo;
6150 const CXIdxBaseClassInfo *superInfo;
6151 const CXIdxObjCProtocolRefListInfo *protocols;
6152} CXIdxObjCInterfaceDeclInfo;
6153
6154typedef struct {
6155 const CXIdxObjCContainerDeclInfo *containerInfo;
6156 const CXIdxEntityInfo *objcClass;
6157 CXCursor classCursor;
6158 CXIdxLoc classLoc;
6159 const CXIdxObjCProtocolRefListInfo *protocols;
6160} CXIdxObjCCategoryDeclInfo;
6161
6162typedef struct {
6163 const CXIdxDeclInfo *declInfo;
6164 const CXIdxEntityInfo *getter;
6165 const CXIdxEntityInfo *setter;
6166} CXIdxObjCPropertyDeclInfo;
6167
6168typedef struct {
6169 const CXIdxDeclInfo *declInfo;
6170 const CXIdxBaseClassInfo *const *bases;
6171 unsigned numBases;
6172} CXIdxCXXClassDeclInfo;
6173
6174/**
6175 * Data for IndexerCallbacks#indexEntityReference.
6176 *
6177 * This may be deprecated in a future version as this duplicates
6178 * the \c CXSymbolRole_Implicit bit in \c CXSymbolRole.
6179 */
6180typedef enum {
6181 /**
6182 * The entity is referenced directly in user's code.
6183 */
6184 CXIdxEntityRef_Direct = 1,
6185 /**
6186 * An implicit reference, e.g. a reference of an Objective-C method
6187 * via the dot syntax.
6188 */
6189 CXIdxEntityRef_Implicit = 2
6190} CXIdxEntityRefKind;
6191
6192/**
6193 * Roles that are attributed to symbol occurrences.
6194 *
6195 * Internal: this currently mirrors low 9 bits of clang::index::SymbolRole with
6196 * higher bits zeroed. These high bits may be exposed in the future.
6197 */
6198typedef enum {
6199 CXSymbolRole_None = 0,
6200 CXSymbolRole_Declaration = 1 << 0,
6201 CXSymbolRole_Definition = 1 << 1,
6202 CXSymbolRole_Reference = 1 << 2,
6203 CXSymbolRole_Read = 1 << 3,
6204 CXSymbolRole_Write = 1 << 4,
6205 CXSymbolRole_Call = 1 << 5,
6206 CXSymbolRole_Dynamic = 1 << 6,
6207 CXSymbolRole_AddressOf = 1 << 7,
6208 CXSymbolRole_Implicit = 1 << 8
6209} CXSymbolRole;
6210
6211/**
6212 * Data for IndexerCallbacks#indexEntityReference.
6213 */
6214typedef struct {
6215 CXIdxEntityRefKind kind;
6216 /**
6217 * Reference cursor.
6218 */
6219 CXCursor cursor;
6220 CXIdxLoc loc;
6221 /**
6222 * The entity that gets referenced.
6223 */
6224 const CXIdxEntityInfo *referencedEntity;
6225 /**
6226 * Immediate "parent" of the reference. For example:
6227 *
6228 * \code
6229 * Foo *var;
6230 * \endcode
6231 *
6232 * The parent of reference of type 'Foo' is the variable 'var'.
6233 * For references inside statement bodies of functions/methods,
6234 * the parentEntity will be the function/method.
6235 */
6236 const CXIdxEntityInfo *parentEntity;
6237 /**
6238 * Lexical container context of the reference.
6239 */
6240 const CXIdxContainerInfo *container;
6241 /**
6242 * Sets of symbol roles of the reference.
6243 */
6244 CXSymbolRole role;
6245} CXIdxEntityRefInfo;
6246
6247/**
6248 * A group of callbacks used by #clang_indexSourceFile and
6249 * #clang_indexTranslationUnit.
6250 */
6251typedef struct {
6252 /**
6253 * Called periodically to check whether indexing should be aborted.
6254 * Should return 0 to continue, and non-zero to abort.
6255 */
6256 int (*abortQuery)(CXClientData client_data, void *reserved);
6257
6258 /**
6259 * Called at the end of indexing; passes the complete diagnostic set.
6260 */
6261 void (*diagnostic)(CXClientData client_data, CXDiagnosticSet, void *reserved);
6262
6263 CXIdxClientFile (*enteredMainFile)(CXClientData client_data, CXFile mainFile,
6264 void *reserved);
6265
6266 /**
6267 * Called when a file gets \#included/\#imported.
6268 */
6269 CXIdxClientFile (*ppIncludedFile)(CXClientData client_data,
6270 const CXIdxIncludedFileInfo *);
6271
6272 /**
6273 * Called when a AST file (PCH or module) gets imported.
6274 *
6275 * AST files will not get indexed (there will not be callbacks to index all
6276 * the entities in an AST file). The recommended action is that, if the AST
6277 * file is not already indexed, to initiate a new indexing job specific to
6278 * the AST file.
6279 */
6280 CXIdxClientASTFile (*importedASTFile)(CXClientData client_data,
6281 const CXIdxImportedASTFileInfo *);
6282
6283 /**
6284 * Called at the beginning of indexing a translation unit.
6285 */
6286 CXIdxClientContainer (*startedTranslationUnit)(CXClientData client_data,
6287 void *reserved);
6288
6289 void (*indexDeclaration)(CXClientData client_data, const CXIdxDeclInfo *);
6290
6291 /**
6292 * Called to index a reference of an entity.
6293 */
6294 void (*indexEntityReference)(CXClientData client_data,
6295 const CXIdxEntityRefInfo *);
6296
6297} IndexerCallbacks;
6298
6299CINDEX_LINKAGE int clang_index_isEntityObjCContainerKind(CXIdxEntityKind);
6300CINDEX_LINKAGE const CXIdxObjCContainerDeclInfo *
6301clang_index_getObjCContainerDeclInfo(const CXIdxDeclInfo *);
6302
6303CINDEX_LINKAGE const CXIdxObjCInterfaceDeclInfo *
6304clang_index_getObjCInterfaceDeclInfo(const CXIdxDeclInfo *);
6305
6306CINDEX_LINKAGE
6307const CXIdxObjCCategoryDeclInfo *
6308clang_index_getObjCCategoryDeclInfo(const CXIdxDeclInfo *);
6309
6310CINDEX_LINKAGE const CXIdxObjCProtocolRefListInfo *
6311clang_index_getObjCProtocolRefListInfo(const CXIdxDeclInfo *);
6312
6313CINDEX_LINKAGE const CXIdxObjCPropertyDeclInfo *
6314clang_index_getObjCPropertyDeclInfo(const CXIdxDeclInfo *);
6315
6316CINDEX_LINKAGE const CXIdxIBOutletCollectionAttrInfo *
6317clang_index_getIBOutletCollectionAttrInfo(const CXIdxAttrInfo *);
6318
6319CINDEX_LINKAGE const CXIdxCXXClassDeclInfo *
6320clang_index_getCXXClassDeclInfo(const CXIdxDeclInfo *);
6321
6322/**
6323 * For retrieving a custom CXIdxClientContainer attached to a
6324 * container.
6325 */
6326CINDEX_LINKAGE CXIdxClientContainer
6327clang_index_getClientContainer(const CXIdxContainerInfo *);
6328
6329/**
6330 * For setting a custom CXIdxClientContainer attached to a
6331 * container.
6332 */
6333CINDEX_LINKAGE void clang_index_setClientContainer(const CXIdxContainerInfo *,
6334 CXIdxClientContainer);
6335
6336/**
6337 * For retrieving a custom CXIdxClientEntity attached to an entity.
6338 */
6339CINDEX_LINKAGE CXIdxClientEntity
6340clang_index_getClientEntity(const CXIdxEntityInfo *);
6341
6342/**
6343 * For setting a custom CXIdxClientEntity attached to an entity.
6344 */
6345CINDEX_LINKAGE void clang_index_setClientEntity(const CXIdxEntityInfo *,
6346 CXIdxClientEntity);
6347
6348/**
6349 * An indexing action/session, to be applied to one or multiple
6350 * translation units.
6351 */
6352typedef void *CXIndexAction;
6353
6354/**
6355 * An indexing action/session, to be applied to one or multiple
6356 * translation units.
6357 *
6358 * \param CIdx The index object with which the index action will be associated.
6359 */
6360CINDEX_LINKAGE CXIndexAction clang_IndexAction_create(CXIndex CIdx);
6361
6362/**
6363 * Destroy the given index action.
6364 *
6365 * The index action must not be destroyed until all of the translation units
6366 * created within that index action have been destroyed.
6367 */
6368CINDEX_LINKAGE void clang_IndexAction_dispose(CXIndexAction);
6369
6370typedef enum {
6371 /**
6372 * Used to indicate that no special indexing options are needed.
6373 */
6374 CXIndexOpt_None = 0x0,
6375
6376 /**
6377 * Used to indicate that IndexerCallbacks#indexEntityReference should
6378 * be invoked for only one reference of an entity per source file that does
6379 * not also include a declaration/definition of the entity.
6380 */
6381 CXIndexOpt_SuppressRedundantRefs = 0x1,
6382
6383 /**
6384 * Function-local symbols should be indexed. If this is not set
6385 * function-local symbols will be ignored.
6386 */
6387 CXIndexOpt_IndexFunctionLocalSymbols = 0x2,
6388
6389 /**
6390 * Implicit function/class template instantiations should be indexed.
6391 * If this is not set, implicit instantiations will be ignored.
6392 */
6393 CXIndexOpt_IndexImplicitTemplateInstantiations = 0x4,
6394
6395 /**
6396 * Suppress all compiler warnings when parsing for indexing.
6397 */
6398 CXIndexOpt_SuppressWarnings = 0x8,
6399
6400 /**
6401 * Skip a function/method body that was already parsed during an
6402 * indexing session associated with a \c CXIndexAction object.
6403 * Bodies in system headers are always skipped.
6404 */
6405 CXIndexOpt_SkipParsedBodiesInSession = 0x10
6406
6407} CXIndexOptFlags;
6408
6409/**
6410 * Index the given source file and the translation unit corresponding
6411 * to that file via callbacks implemented through #IndexerCallbacks.
6412 *
6413 * \param client_data pointer data supplied by the client, which will
6414 * be passed to the invoked callbacks.
6415 *
6416 * \param index_callbacks Pointer to indexing callbacks that the client
6417 * implements.
6418 *
6419 * \param index_callbacks_size Size of #IndexerCallbacks structure that gets
6420 * passed in index_callbacks.
6421 *
6422 * \param index_options A bitmask of options that affects how indexing is
6423 * performed. This should be a bitwise OR of the CXIndexOpt_XXX flags.
6424 *
6425 * \param[out] out_TU pointer to store a \c CXTranslationUnit that can be
6426 * reused after indexing is finished. Set to \c NULL if you do not require it.
6427 *
6428 * \returns 0 on success or if there were errors from which the compiler could
6429 * recover. If there is a failure from which there is no recovery, returns
6430 * a non-zero \c CXErrorCode.
6431 *
6432 * The rest of the parameters are the same as #clang_parseTranslationUnit.
6433 */
6434CINDEX_LINKAGE int clang_indexSourceFile(
6435 CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks,
6436 unsigned index_callbacks_size, unsigned index_options,
6437 const char *source_filename, const char *const *command_line_args,
6438 int num_command_line_args, struct CXUnsavedFile *unsaved_files,
6439 unsigned num_unsaved_files, CXTranslationUnit *out_TU, unsigned TU_options);
6440
6441/**
6442 * Same as clang_indexSourceFile but requires a full command line
6443 * for \c command_line_args including argv[0]. This is useful if the standard
6444 * library paths are relative to the binary.
6445 */
6446CINDEX_LINKAGE int clang_indexSourceFileFullArgv(
6447 CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks,
6448 unsigned index_callbacks_size, unsigned index_options,
6449 const char *source_filename, const char *const *command_line_args,
6450 int num_command_line_args, struct CXUnsavedFile *unsaved_files,
6451 unsigned num_unsaved_files, CXTranslationUnit *out_TU, unsigned TU_options);
6452
6453/**
6454 * Index the given translation unit via callbacks implemented through
6455 * #IndexerCallbacks.
6456 *
6457 * The order of callback invocations is not guaranteed to be the same as
6458 * when indexing a source file. The high level order will be:
6459 *
6460 * -Preprocessor callbacks invocations
6461 * -Declaration/reference callbacks invocations
6462 * -Diagnostic callback invocations
6463 *
6464 * The parameters are the same as #clang_indexSourceFile.
6465 *
6466 * \returns If there is a failure from which there is no recovery, returns
6467 * non-zero, otherwise returns 0.
6468 */
6469CINDEX_LINKAGE int clang_indexTranslationUnit(
6470 CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks,
6471 unsigned index_callbacks_size, unsigned index_options, CXTranslationUnit);
6472
6473/**
6474 * Retrieve the CXIdxFile, file, line, column, and offset represented by
6475 * the given CXIdxLoc.
6476 *
6477 * If the location refers into a macro expansion, retrieves the
6478 * location of the macro expansion and if it refers into a macro argument
6479 * retrieves the location of the argument.
6480 */
6481CINDEX_LINKAGE void clang_indexLoc_getFileLocation(CXIdxLoc loc,
6482 CXIdxClientFile *indexFile,
6483 CXFile *file, unsigned *line,
6484 unsigned *column,
6485 unsigned *offset);
6486
6487/**
6488 * Retrieve the CXSourceLocation represented by the given CXIdxLoc.
6489 */
6490CINDEX_LINKAGE
6491CXSourceLocation clang_indexLoc_getCXSourceLocation(CXIdxLoc loc);
6492
6493/**
6494 * Visitor invoked for each field found by a traversal.
6495 *
6496 * This visitor function will be invoked for each field found by
6497 * \c clang_Type_visitFields. Its first argument is the cursor being
6498 * visited, its second argument is the client data provided to
6499 * \c clang_Type_visitFields.
6500 *
6501 * The visitor should return one of the \c CXVisitorResult values
6502 * to direct \c clang_Type_visitFields.
6503 */
6504typedef enum CXVisitorResult (*CXFieldVisitor)(CXCursor C,
6505 CXClientData client_data);
6506
6507/**
6508 * Visit the fields of a particular type.
6509 *
6510 * This function visits all the direct fields of the given cursor,
6511 * invoking the given \p visitor function with the cursors of each
6512 * visited field. The traversal may be ended prematurely, if
6513 * the visitor returns \c CXFieldVisit_Break.
6514 *
6515 * \param T the record type whose field may be visited.
6516 *
6517 * \param visitor the visitor function that will be invoked for each
6518 * field of \p T.
6519 *
6520 * \param client_data pointer data supplied by the client, which will
6521 * be passed to the visitor each time it is invoked.
6522 *
6523 * \returns a non-zero value if the traversal was terminated
6524 * prematurely by the visitor returning \c CXFieldVisit_Break.
6525 */
6526CINDEX_LINKAGE unsigned clang_Type_visitFields(CXType T, CXFieldVisitor visitor,
6527 CXClientData client_data);
6528
6529/**
6530 * Describes the kind of binary operators.
6531 */
6532enum CXBinaryOperatorKind {
6533 /** This value describes cursors which are not binary operators. */
6534 CXBinaryOperator_Invalid,
6535 /** C++ Pointer - to - member operator. */
6536 CXBinaryOperator_PtrMemD,
6537 /** C++ Pointer - to - member operator. */
6538 CXBinaryOperator_PtrMemI,
6539 /** Multiplication operator. */
6540 CXBinaryOperator_Mul,
6541 /** Division operator. */
6542 CXBinaryOperator_Div,
6543 /** Remainder operator. */
6544 CXBinaryOperator_Rem,
6545 /** Addition operator. */
6546 CXBinaryOperator_Add,
6547 /** Subtraction operator. */
6548 CXBinaryOperator_Sub,
6549 /** Bitwise shift left operator. */
6550 CXBinaryOperator_Shl,
6551 /** Bitwise shift right operator. */
6552 CXBinaryOperator_Shr,
6553 /** C++ three-way comparison (spaceship) operator. */
6554 CXBinaryOperator_Cmp,
6555 /** Less than operator. */
6556 CXBinaryOperator_LT,
6557 /** Greater than operator. */
6558 CXBinaryOperator_GT,
6559 /** Less or equal operator. */
6560 CXBinaryOperator_LE,
6561 /** Greater or equal operator. */
6562 CXBinaryOperator_GE,
6563 /** Equal operator. */
6564 CXBinaryOperator_EQ,
6565 /** Not equal operator. */
6566 CXBinaryOperator_NE,
6567 /** Bitwise AND operator. */
6568 CXBinaryOperator_And,
6569 /** Bitwise XOR operator. */
6570 CXBinaryOperator_Xor,
6571 /** Bitwise OR operator. */
6572 CXBinaryOperator_Or,
6573 /** Logical AND operator. */
6574 CXBinaryOperator_LAnd,
6575 /** Logical OR operator. */
6576 CXBinaryOperator_LOr,
6577 /** Assignment operator. */
6578 CXBinaryOperator_Assign,
6579 /** Multiplication assignment operator. */
6580 CXBinaryOperator_MulAssign,
6581 /** Division assignment operator. */
6582 CXBinaryOperator_DivAssign,
6583 /** Remainder assignment operator. */
6584 CXBinaryOperator_RemAssign,
6585 /** Addition assignment operator. */
6586 CXBinaryOperator_AddAssign,
6587 /** Subtraction assignment operator. */
6588 CXBinaryOperator_SubAssign,
6589 /** Bitwise shift left assignment operator. */
6590 CXBinaryOperator_ShlAssign,
6591 /** Bitwise shift right assignment operator. */
6592 CXBinaryOperator_ShrAssign,
6593 /** Bitwise AND assignment operator. */
6594 CXBinaryOperator_AndAssign,
6595 /** Bitwise XOR assignment operator. */
6596 CXBinaryOperator_XorAssign,
6597 /** Bitwise OR assignment operator. */
6598 CXBinaryOperator_OrAssign,
6599 /** Comma operator. */
6600 CXBinaryOperator_Comma
6601};
6602
6603/**
6604 * Retrieve the spelling of a given CXBinaryOperatorKind.
6605 */
6606CINDEX_LINKAGE CXString
6607clang_getBinaryOperatorKindSpelling(enum CXBinaryOperatorKind kind);
6608
6609/**
6610 * Retrieve the binary operator kind of this cursor.
6611 *
6612 * If this cursor is not a binary operator then returns Invalid.
6613 */
6614CINDEX_LINKAGE enum CXBinaryOperatorKind
6615clang_getCursorBinaryOperatorKind(CXCursor cursor);
6616
6617/**
6618 * Describes the kind of unary operators.
6619 */
6620enum CXUnaryOperatorKind {
6621 /** This value describes cursors which are not unary operators. */
6622 CXUnaryOperator_Invalid,
6623 /** Postfix increment operator. */
6624 CXUnaryOperator_PostInc,
6625 /** Postfix decrement operator. */
6626 CXUnaryOperator_PostDec,
6627 /** Prefix increment operator. */
6628 CXUnaryOperator_PreInc,
6629 /** Prefix decrement operator. */
6630 CXUnaryOperator_PreDec,
6631 /** Address of operator. */
6632 CXUnaryOperator_AddrOf,
6633 /** Dereference operator. */
6634 CXUnaryOperator_Deref,
6635 /** Plus operator. */
6636 CXUnaryOperator_Plus,
6637 /** Minus operator. */
6638 CXUnaryOperator_Minus,
6639 /** Not operator. */
6640 CXUnaryOperator_Not,
6641 /** LNot operator. */
6642 CXUnaryOperator_LNot,
6643 /** "__real expr" operator. */
6644 CXUnaryOperator_Real,
6645 /** "__imag expr" operator. */
6646 CXUnaryOperator_Imag,
6647 /** __extension__ marker operator. */
6648 CXUnaryOperator_Extension,
6649 /** C++ co_await operator. */
6650 CXUnaryOperator_Coawait
6651};
6652
6653/**
6654 * Retrieve the spelling of a given CXUnaryOperatorKind.
6655 */
6656CINDEX_LINKAGE CXString
6657clang_getUnaryOperatorKindSpelling(enum CXUnaryOperatorKind kind);
6658
6659/**
6660 * Retrieve the unary operator kind of this cursor.
6661 *
6662 * If this cursor is not a unary operator then returns Invalid.
6663 */
6664CINDEX_LINKAGE enum CXUnaryOperatorKind
6665clang_getCursorUnaryOperatorKind(CXCursor cursor);
6666
6667/**
6668 * @}
6669 */
6670
6671/**
6672 * @}
6673 */
6674
6675LLVM_CLANG_C_EXTERN_C_END
6676
6677#endif
6678

source code of clang/include/clang-c/Index.h